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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
#ifndef __MTS_IO_H
#define __MTS_IO_H
#if !__KERNEL__
#include <stdint.h>
#ifndef BIT
#define BIT(nr) (1UL << (nr))
#endif
#endif
#define MTS_ATTR_MODE_RW S_IWUSR | S_IRUGO
#define MTS_ATTR_MODE_RO S_IRUGO
#define DEVICE_ATTR_MTS(_dev_name, _name, _show, _store) \
struct device_attribute _dev_name = { \
.attr = { .name = _name, .mode = MTS_ATTR_MODE_RW }, \
.show = _show, \
.store = _store, \
}
#define DEVICE_ATTR_RO_MTS(_dev_name, _name, _show) \
struct device_attribute _dev_name = { \
.attr = { .name = _name, .mode = MTS_ATTR_MODE_RO }, \
.show = _show, \
}
#define VENDOR_ID_MULTITECH "Multi-Tech Systems"
#define PRODUCT_ID_MTCDP_E1_DK "MTCDP-E1-DK"
#define PRODUCT_ID_MT100EOCG "MT100EOCG"
#define PRODUCT_ID_MTR2 "MTR2"
#define PRODUCT_ID_MTR "MTR"
#define PRODUCT_ID_MTOCGD3 "MTOCGD3"
#define PRODUCT_ID_MTOCGD "MTOCGD"
#define HW_VERSION_MTCBA2_2_0 "MTCBA2-2.0"
#define HW_VERSION_MTCDP_0_0 "MTCDP-0.0"
#define HW_VERSION_MTCDP_1_0 "MTCDP-1.0"
#define HW_VERSION_MT100EOCG_0_0 "MT100EOCG-0.0"
#define HW_VERSION_MTR2_0_0 "MTR2-0.0"
#define HW_VERSION_MTR_0_0 "MTR-0.0"
#define HW_VERSION_MTR_0_1 "MTR-0.1"
#define HW_VERSION_MTOCGD3_0_0 "MTOCGD3-0.0"
#define HW_VERSION_MTOCGD_0_0 "MTOCGD-0.0"
enum {
MTCDP_E1_DK_0_0,
MTCDP_E1_DK_1_0,
MT100EOCG_0_0,
MTR2_0_0,
MTR_0_0,
MTR_0_1,
MTOCGD3_0_0,
MTOCGD_0_0,
};
#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)
#define CAPA_WIFI DEVICE_CAPA_VALUE(1, 6)
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 reserved[302];
};
// GPIO pin types:input, output, open drain (1 = high Z, 0 = output low)
enum {
GPIO_DIR_INPUT,
GPIO_DIR_OUTPUT,
GPIO_DIR_OD,
};
struct gpio_pin {
char name[32];
char attr_name[32];
unsigned pin;
int direction;
int output_value;
int use_pullup;
int active_low;
};
enum {
LED_OFF,
LED_ON,
LED_FLASHING,
};
#endif /* ~__MTS_IO_H */
|