2 * Analog Devices ADP5589/ADP5585 I/O Expander and QWERTY Keypad Controller
4 * Copyright 2010-2011 Analog Devices Inc.
6 * Licensed under the GPL-2.
13 * ADP5589 specific GPI and Keymap defines
16 #define ADP5589_KEYMAPSIZE 88
18 #define ADP5589_GPI_PIN_ROW0 97
19 #define ADP5589_GPI_PIN_ROW1 98
20 #define ADP5589_GPI_PIN_ROW2 99
21 #define ADP5589_GPI_PIN_ROW3 100
22 #define ADP5589_GPI_PIN_ROW4 101
23 #define ADP5589_GPI_PIN_ROW5 102
24 #define ADP5589_GPI_PIN_ROW6 103
25 #define ADP5589_GPI_PIN_ROW7 104
26 #define ADP5589_GPI_PIN_COL0 105
27 #define ADP5589_GPI_PIN_COL1 106
28 #define ADP5589_GPI_PIN_COL2 107
29 #define ADP5589_GPI_PIN_COL3 108
30 #define ADP5589_GPI_PIN_COL4 109
31 #define ADP5589_GPI_PIN_COL5 110
32 #define ADP5589_GPI_PIN_COL6 111
33 #define ADP5589_GPI_PIN_COL7 112
34 #define ADP5589_GPI_PIN_COL8 113
35 #define ADP5589_GPI_PIN_COL9 114
36 #define ADP5589_GPI_PIN_COL10 115
37 #define GPI_LOGIC1 116
38 #define GPI_LOGIC2 117
40 #define ADP5589_GPI_PIN_ROW_BASE ADP5589_GPI_PIN_ROW0
41 #define ADP5589_GPI_PIN_ROW_END ADP5589_GPI_PIN_ROW7
42 #define ADP5589_GPI_PIN_COL_BASE ADP5589_GPI_PIN_COL0
43 #define ADP5589_GPI_PIN_COL_END ADP5589_GPI_PIN_COL10
45 #define ADP5589_GPI_PIN_BASE ADP5589_GPI_PIN_ROW_BASE
46 #define ADP5589_GPI_PIN_END ADP5589_GPI_PIN_COL_END
48 #define ADP5589_GPIMAPSIZE_MAX (ADP5589_GPI_PIN_END - ADP5589_GPI_PIN_BASE + 1)
51 * ADP5585 specific GPI and Keymap defines
54 #define ADP5585_KEYMAPSIZE 30
56 #define ADP5585_GPI_PIN_ROW0 37
57 #define ADP5585_GPI_PIN_ROW1 38
58 #define ADP5585_GPI_PIN_ROW2 39
59 #define ADP5585_GPI_PIN_ROW3 40
60 #define ADP5585_GPI_PIN_ROW4 41
61 #define ADP5585_GPI_PIN_ROW5 42
62 #define ADP5585_GPI_PIN_COL0 43
63 #define ADP5585_GPI_PIN_COL1 44
64 #define ADP5585_GPI_PIN_COL2 45
65 #define ADP5585_GPI_PIN_COL3 46
66 #define ADP5585_GPI_PIN_COL4 47
69 #define ADP5585_GPI_PIN_ROW_BASE ADP5585_GPI_PIN_ROW0
70 #define ADP5585_GPI_PIN_ROW_END ADP5585_GPI_PIN_ROW5
71 #define ADP5585_GPI_PIN_COL_BASE ADP5585_GPI_PIN_COL0
72 #define ADP5585_GPI_PIN_COL_END ADP5585_GPI_PIN_COL4
74 #define ADP5585_GPI_PIN_BASE ADP5585_GPI_PIN_ROW_BASE
75 #define ADP5585_GPI_PIN_END ADP5585_GPI_PIN_COL_END
77 #define ADP5585_GPIMAPSIZE_MAX (ADP5585_GPI_PIN_END - ADP5585_GPI_PIN_BASE + 1)
79 struct adp5589_gpi_map
{
81 unsigned short sw_evt
;
85 #define ADP5589_SCAN_CYCLE_10ms 0
86 #define ADP5589_SCAN_CYCLE_20ms 1
87 #define ADP5589_SCAN_CYCLE_30ms 2
88 #define ADP5589_SCAN_CYCLE_40ms 3
91 #define RESET_PULSE_WIDTH_500us 0
92 #define RESET_PULSE_WIDTH_1ms 1
93 #define RESET_PULSE_WIDTH_2ms 2
94 #define RESET_PULSE_WIDTH_10ms 3
96 #define RESET_TRIG_TIME_0ms (0 << 2)
97 #define RESET_TRIG_TIME_1000ms (1 << 2)
98 #define RESET_TRIG_TIME_1500ms (2 << 2)
99 #define RESET_TRIG_TIME_2000ms (3 << 2)
100 #define RESET_TRIG_TIME_2500ms (4 << 2)
101 #define RESET_TRIG_TIME_3000ms (5 << 2)
102 #define RESET_TRIG_TIME_3500ms (6 << 2)
103 #define RESET_TRIG_TIME_4000ms (7 << 2)
105 #define RESET_PASSTHRU_EN (1 << 5)
106 #define RESET1_POL_HIGH (1 << 6)
107 #define RESET1_POL_LOW (0 << 6)
108 #define RESET2_POL_HIGH (1 << 7)
109 #define RESET2_POL_LOW (0 << 7)
111 /* ADP5589 Mask Bits:
112 * C C C C C C C C C C C | R R R R R R R R
113 * 1 9 8 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0
115 * ---------------- BIT ------------------
116 * 1 1 1 1 1 1 1 1 1 0 0 | 0 0 0 0 0 0 0 0
117 * 8 7 6 5 4 3 2 1 0 9 8 | 7 6 5 4 3 2 1 0
120 #define ADP_ROW(x) (1 << (x))
121 #define ADP_COL(x) (1 << (x + 8))
122 #define ADP5589_ROW_MASK 0xFF
123 #define ADP5589_COL_MASK 0xFF
124 #define ADP5589_COL_SHIFT 8
125 #define ADP5589_MAX_ROW_NUM 7
126 #define ADP5589_MAX_COL_NUM 10
128 /* ADP5585 Mask Bits:
129 * C C C C C | R R R R R R
130 * 4 3 2 1 0 | 5 4 3 2 1 0
132 * ---- BIT -- -----------
133 * 1 0 0 0 0 | 0 0 0 0 0 0
134 * 0 9 8 7 6 | 5 4 3 2 1 0
137 #define ADP5585_ROW_MASK 0x3F
138 #define ADP5585_COL_MASK 0x1F
139 #define ADP5585_ROW_SHIFT 0
140 #define ADP5585_COL_SHIFT 6
141 #define ADP5585_MAX_ROW_NUM 5
142 #define ADP5585_MAX_COL_NUM 4
144 #define ADP5585_ROW(x) (1 << ((x) & ADP5585_ROW_MASK))
145 #define ADP5585_COL(x) (1 << (((x) & ADP5585_COL_MASK) + ADP5585_COL_SHIFT))
147 /* Put one of these structures in i2c_board_info platform_data */
149 struct adp5589_kpad_platform_data
{
150 unsigned keypad_en_mask
; /* Keypad (Rows/Columns) enable mask */
151 const unsigned short *keymap
; /* Pointer to keymap */
152 unsigned short keymapsize
; /* Keymap size */
153 bool repeat
; /* Enable key repeat */
154 bool en_keylock
; /* Enable key lock feature (ADP5589 only)*/
155 unsigned char unlock_key1
; /* Unlock Key 1 (ADP5589 only) */
156 unsigned char unlock_key2
; /* Unlock Key 2 (ADP5589 only) */
157 unsigned char unlock_timer
; /* Time in seconds [0..7] between the two unlock keys 0=disable (ADP5589 only) */
158 unsigned char scan_cycle_time
; /* Time between consecutive scan cycles */
159 unsigned char reset_cfg
; /* Reset config */
160 unsigned short reset1_key_1
; /* Reset Key 1 */
161 unsigned short reset1_key_2
; /* Reset Key 2 */
162 unsigned short reset1_key_3
; /* Reset Key 3 */
163 unsigned short reset2_key_1
; /* Reset Key 1 */
164 unsigned short reset2_key_2
; /* Reset Key 2 */
165 unsigned debounce_dis_mask
; /* Disable debounce mask */
166 unsigned pull_dis_mask
; /* Disable all pull resistors mask */
167 unsigned pullup_en_100k
; /* Pull-Up 100k Enable Mask */
168 unsigned pullup_en_300k
; /* Pull-Up 300k Enable Mask */
169 unsigned pulldown_en_300k
; /* Pull-Down 300k Enable Mask */
170 const struct adp5589_gpi_map
*gpimap
;
171 unsigned short gpimapsize
;
172 const struct adp5589_gpio_platform_data
*gpio_data
;
175 struct i2c_client
; /* forward declaration */
177 struct adp5589_gpio_platform_data
{
178 int gpio_start
; /* GPIO Chip base # */
179 int (*setup
)(struct i2c_client
*client
,
180 int gpio
, unsigned ngpio
,
182 int (*teardown
)(struct i2c_client
*client
,
183 int gpio
, unsigned ngpio
,