summaryrefslogtreecommitdiff
path: root/io-module/mts_eeprom.h
blob: 2a86ebd31a434c6720c6daa74526b2c651577aaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef __MTS_EEPROM_H
#define __MTS_EEPROM_H

#if !__KERNEL__
#include <stdint.h>

#ifndef BIT
#define BIT(nr)			(1UL << (nr))
#endif
#endif

/* on-board EEPROM
 * eeprom_layout_version == 0        capa_cellular is ignored
 * eeprom_layout_version >= 1        capa_cellular is used for has_radio
 */
struct mts_id_eeprom_layout {
	char vendor_id[32];
	char product_id[32];
	char device_id[32];
	char hw_version[32];
	uint8_t mac_addr[6];
	char imei[32];
	uint8_t capa[32];
	uint8_t mac_bluetooth[6];
	uint8_t mac_wifi[6];
	uint8_t uuid[16];
	uint8_t lora_eui[8];
	char lora_product_id[32];
	char lora_hw_version[32];
#ifdef MTRE
	char oem_string1[32];
	char oem_string2[32];
	uint16_t eeprom_layout_version;
	uint8_t reserved[148];
#else
	uint16_t eeprom_layout_version;
	uint8_t reserved[212];
#endif
};

/* accessory card EEPROM */
struct mts_ap_eeprom_layout {
	char vendor_id[32];
	char product_id[32];
	char device_id[32];
	char hw_version[32];
	uint8_t mac_addr[6];
	uint8_t eui[8];
	uint8_t reserved[370];
};

#define DEVICE_CAPA_INDEX(c)			(((c) & 0xFF) >> 3)
#define DEVICE_CAPA_MASK(c)			BIT((c) & 0x07)

#define DEVICE_CAPA(capa_buf, c)		((capa_buf)[DEVICE_CAPA_INDEX(c)] & DEVICE_CAPA_MASK(c))

#define DEVICE_CAPA_SET(capa_buf, c) \
do { \
	(capa_buf)[DEVICE_CAPA_INDEX(c)] |= DEVICE_CAPA_MASK(c); \
}while (0)

#define DEVICE_CAPA_CLEAR(capa_buf, c) \
do { \
	(capa_buf)[DEVICE_CAPA_INDEX(c)] &= ~DEVICE_CAPA_MASK(c); \
} while (0)

#define DEVICE_CAPA_VALUE(index, bit)		((((index) & 0x1F) << 3) | ((bit) & 0x07))

#define CAPA_GPS				DEVICE_CAPA_VALUE(0, 7)
#define CAPA_DIN				DEVICE_CAPA_VALUE(0, 6)
#define CAPA_DOUT				DEVICE_CAPA_VALUE(0, 5)
#define CAPA_ADC				DEVICE_CAPA_VALUE(0, 4)

#define CAPA_BLUETOOTH				DEVICE_CAPA_VALUE(1, 7)
/* Used for rs9113 detection in Conduit 0.1 and others */
#define CAPA_WIFI				DEVICE_CAPA_VALUE(1, 6)
#define CAPA_LORA				DEVICE_CAPA_VALUE(1, 3)  // on-board lora
#define CAPA_BATTERY				DEVICE_CAPA_VALUE(1, 4)  // 1st battery type
#define CAPA_SUPERCAP				DEVICE_CAPA_VALUE(1, 5)
#define CAPA_CELLULAR				DEVICE_CAPA_VALUE(1,2)  // Only valid if eeprom_layout_version > 0
#endif /* __MTS_EEPROM_H */