1
2
3
4
5
6
7
8 #ifndef _ADP5588_H
9 #define _ADP5588_H
10
11 #define DEV_ID 0x00
12 #define CFG 0x01
13 #define INT_STAT 0x02
14 #define KEY_LCK_EC_STAT 0x03
15 #define Key_EVENTA 0x04
16 #define Key_EVENTB 0x05
17 #define Key_EVENTC 0x06
18 #define Key_EVENTD 0x07
19 #define Key_EVENTE 0x08
20 #define Key_EVENTF 0x09
21 #define Key_EVENTG 0x0A
22 #define Key_EVENTH 0x0B
23 #define Key_EVENTI 0x0C
24 #define Key_EVENTJ 0x0D
25 #define KP_LCK_TMR 0x0E
26 #define UNLOCK1 0x0F
27 #define UNLOCK2 0x10
28 #define GPIO_INT_STAT1 0x11
29 #define GPIO_INT_STAT2 0x12
30 #define GPIO_INT_STAT3 0x13
31 #define GPIO_DAT_STAT1 0x14
32 #define GPIO_DAT_STAT2 0x15
33 #define GPIO_DAT_STAT3 0x16
34 #define GPIO_DAT_OUT1 0x17
35 #define GPIO_DAT_OUT2 0x18
36 #define GPIO_DAT_OUT3 0x19
37 #define GPIO_INT_EN1 0x1A
38 #define GPIO_INT_EN2 0x1B
39 #define GPIO_INT_EN3 0x1C
40 #define KP_GPIO1 0x1D
41 #define KP_GPIO2 0x1E
42 #define KP_GPIO3 0x1F
43 #define GPI_EM1 0x20
44 #define GPI_EM2 0x21
45 #define GPI_EM3 0x22
46 #define GPIO_DIR1 0x23
47 #define GPIO_DIR2 0x24
48 #define GPIO_DIR3 0x25
49 #define GPIO_INT_LVL1 0x26
50 #define GPIO_INT_LVL2 0x27
51 #define GPIO_INT_LVL3 0x28
52 #define Debounce_DIS1 0x29
53 #define Debounce_DIS2 0x2A
54 #define Debounce_DIS3 0x2B
55 #define GPIO_PULL1 0x2C
56 #define GPIO_PULL2 0x2D
57 #define GPIO_PULL3 0x2E
58 #define CMP_CFG_STAT 0x30
59 #define CMP_CONFG_SENS1 0x31
60 #define CMP_CONFG_SENS2 0x32
61 #define CMP1_LVL2_TRIP 0x33
62 #define CMP1_LVL2_HYS 0x34
63 #define CMP1_LVL3_TRIP 0x35
64 #define CMP1_LVL3_HYS 0x36
65 #define CMP2_LVL2_TRIP 0x37
66 #define CMP2_LVL2_HYS 0x38
67 #define CMP2_LVL3_TRIP 0x39
68 #define CMP2_LVL3_HYS 0x3A
69 #define CMP1_ADC_DAT_R1 0x3B
70 #define CMP1_ADC_DAT_R2 0x3C
71 #define CMP2_ADC_DAT_R1 0x3D
72 #define CMP2_ADC_DAT_R2 0x3E
73
74 #define ADP5588_DEVICE_ID_MASK 0xF
75
76
77 #define ADP5588_AUTO_INC (1 << 7)
78 #define ADP5588_GPIEM_CFG (1 << 6)
79 #define ADP5588_OVR_FLOW_M (1 << 5)
80 #define ADP5588_INT_CFG (1 << 4)
81 #define ADP5588_OVR_FLOW_IEN (1 << 3)
82 #define ADP5588_K_LCK_IM (1 << 2)
83 #define ADP5588_GPI_IEN (1 << 1)
84 #define ADP5588_KE_IEN (1 << 0)
85
86
87 #define ADP5588_CMP2_INT (1 << 5)
88 #define ADP5588_CMP1_INT (1 << 4)
89 #define ADP5588_OVR_FLOW_INT (1 << 3)
90 #define ADP5588_K_LCK_INT (1 << 2)
91 #define ADP5588_GPI_INT (1 << 1)
92 #define ADP5588_KE_INT (1 << 0)
93
94
95 #define ADP5588_K_LCK_EN (1 << 6)
96 #define ADP5588_LCK21 0x30
97 #define ADP5588_KEC 0xF
98
99 #define ADP5588_MAXGPIO 18
100 #define ADP5588_BANK(offs) ((offs) >> 3)
101 #define ADP5588_BIT(offs) (1u << ((offs) & 0x7))
102
103
104
105 #define ADP5588_KEYMAPSIZE 80
106
107 #define GPI_PIN_ROW0 97
108 #define GPI_PIN_ROW1 98
109 #define GPI_PIN_ROW2 99
110 #define GPI_PIN_ROW3 100
111 #define GPI_PIN_ROW4 101
112 #define GPI_PIN_ROW5 102
113 #define GPI_PIN_ROW6 103
114 #define GPI_PIN_ROW7 104
115 #define GPI_PIN_COL0 105
116 #define GPI_PIN_COL1 106
117 #define GPI_PIN_COL2 107
118 #define GPI_PIN_COL3 108
119 #define GPI_PIN_COL4 109
120 #define GPI_PIN_COL5 110
121 #define GPI_PIN_COL6 111
122 #define GPI_PIN_COL7 112
123 #define GPI_PIN_COL8 113
124 #define GPI_PIN_COL9 114
125
126 #define GPI_PIN_ROW_BASE GPI_PIN_ROW0
127 #define GPI_PIN_ROW_END GPI_PIN_ROW7
128 #define GPI_PIN_COL_BASE GPI_PIN_COL0
129 #define GPI_PIN_COL_END GPI_PIN_COL9
130
131 #define GPI_PIN_BASE GPI_PIN_ROW_BASE
132 #define GPI_PIN_END GPI_PIN_COL_END
133
134 #define ADP5588_GPIMAPSIZE_MAX (GPI_PIN_END - GPI_PIN_BASE + 1)
135
136 struct adp5588_gpi_map {
137 unsigned short pin;
138 unsigned short sw_evt;
139 };
140
141 struct adp5588_kpad_platform_data {
142 int rows;
143 int cols;
144 const unsigned short *keymap;
145 unsigned short keymapsize;
146 unsigned repeat:1;
147 unsigned en_keylock:1;
148 unsigned short unlock_key1;
149 unsigned short unlock_key2;
150 const struct adp5588_gpi_map *gpimap;
151 unsigned short gpimapsize;
152 const struct adp5588_gpio_platform_data *gpio_data;
153 };
154
155 struct i2c_client;
156
157 struct adp5588_gpio_platform_data {
158 int gpio_start;
159 const char *const *names;
160 unsigned irq_base;
161 unsigned pullup_dis_mask;
162 int (*setup)(struct i2c_client *client,
163 unsigned gpio, unsigned ngpio,
164 void *context);
165 int (*teardown)(struct i2c_client *client,
166 unsigned gpio, unsigned ngpio,
167 void *context);
168 void *context;
169 };
170
171 #endif