aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/input
diff options
context:
space:
mode:
authorMichael Hennerich <michael.hennerich@analog.com>2011-10-19 00:12:39 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-10-19 00:26:55 -0400
commit3f48e7354358519e5b93f7f755ec270b3f8eafa0 (patch)
tree3fd938a5bec641942439c719be5a1056c3b5730d /include/linux/input
parent81e8f2bc82cd591a749c0cc5694f57676db749ae (diff)
Input: adp5589-keys - add support for the ADP5585 derivatives
The ADP5585 family keypad decoder and IO expander is similar to the ADP5589, however it features less IO pins, and lacks hardware assisted key-lock functionality. Unfortunately the register addresses are different, as well as the event codes and bit organization within the port related registers. Move ADP5589 Register defines from the header file into the main source file. Add new defines while making sure we don't break existing platform_data. Add register address translation, and turn device specific defines into variables. Introduce some helper functions and disable functions that doesn't exist on the added devices. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'include/linux/input')
-rw-r--r--include/linux/input/adp5589.h157
1 files changed, 66 insertions, 91 deletions
diff --git a/include/linux/input/adp5589.h b/include/linux/input/adp5589.h
index ef792ecfaabf..1a05eee15e67 100644
--- a/include/linux/input/adp5589.h
+++ b/include/linux/input/adp5589.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Analog Devices ADP5589 I/O Expander and QWERTY Keypad Controller 2 * Analog Devices ADP5589/ADP5585 I/O Expander and QWERTY Keypad Controller
3 * 3 *
4 * Copyright 2010-2011 Analog Devices Inc. 4 * Copyright 2010-2011 Analog Devices Inc.
5 * 5 *
@@ -9,89 +9,9 @@
9#ifndef _ADP5589_H 9#ifndef _ADP5589_H
10#define _ADP5589_H 10#define _ADP5589_H
11 11
12#define ADP5589_ID 0x00 12/*
13#define ADP5589_INT_STATUS 0x01 13 * ADP5589 specific GPI and Keymap defines
14#define ADP5589_STATUS 0x02 14 */
15#define ADP5589_FIFO_1 0x03
16#define ADP5589_FIFO_2 0x04
17#define ADP5589_FIFO_3 0x05
18#define ADP5589_FIFO_4 0x06
19#define ADP5589_FIFO_5 0x07
20#define ADP5589_FIFO_6 0x08
21#define ADP5589_FIFO_7 0x09
22#define ADP5589_FIFO_8 0x0A
23#define ADP5589_FIFO_9 0x0B
24#define ADP5589_FIFO_10 0x0C
25#define ADP5589_FIFO_11 0x0D
26#define ADP5589_FIFO_12 0x0E
27#define ADP5589_FIFO_13 0x0F
28#define ADP5589_FIFO_14 0x10
29#define ADP5589_FIFO_15 0x11
30#define ADP5589_FIFO_16 0x12
31#define ADP5589_GPI_INT_STAT_A 0x13
32#define ADP5589_GPI_INT_STAT_B 0x14
33#define ADP5589_GPI_INT_STAT_C 0x15
34#define ADP5589_GPI_STATUS_A 0x16
35#define ADP5589_GPI_STATUS_B 0x17
36#define ADP5589_GPI_STATUS_C 0x18
37#define ADP5589_RPULL_CONFIG_A 0x19
38#define ADP5589_RPULL_CONFIG_B 0x1A
39#define ADP5589_RPULL_CONFIG_C 0x1B
40#define ADP5589_RPULL_CONFIG_D 0x1C
41#define ADP5589_RPULL_CONFIG_E 0x1D
42#define ADP5589_GPI_INT_LEVEL_A 0x1E
43#define ADP5589_GPI_INT_LEVEL_B 0x1F
44#define ADP5589_GPI_INT_LEVEL_C 0x20
45#define ADP5589_GPI_EVENT_EN_A 0x21
46#define ADP5589_GPI_EVENT_EN_B 0x22
47#define ADP5589_GPI_EVENT_EN_C 0x23
48#define ADP5589_GPI_INTERRUPT_EN_A 0x24
49#define ADP5589_GPI_INTERRUPT_EN_B 0x25
50#define ADP5589_GPI_INTERRUPT_EN_C 0x26
51#define ADP5589_DEBOUNCE_DIS_A 0x27
52#define ADP5589_DEBOUNCE_DIS_B 0x28
53#define ADP5589_DEBOUNCE_DIS_C 0x29
54#define ADP5589_GPO_DATA_OUT_A 0x2A
55#define ADP5589_GPO_DATA_OUT_B 0x2B
56#define ADP5589_GPO_DATA_OUT_C 0x2C
57#define ADP5589_GPO_OUT_MODE_A 0x2D
58#define ADP5589_GPO_OUT_MODE_B 0x2E
59#define ADP5589_GPO_OUT_MODE_C 0x2F
60#define ADP5589_GPIO_DIRECTION_A 0x30
61#define ADP5589_GPIO_DIRECTION_B 0x31
62#define ADP5589_GPIO_DIRECTION_C 0x32
63#define ADP5589_UNLOCK1 0x33
64#define ADP5589_UNLOCK2 0x34
65#define ADP5589_EXT_LOCK_EVENT 0x35
66#define ADP5589_UNLOCK_TIMERS 0x36
67#define ADP5589_LOCK_CFG 0x37
68#define ADP5589_RESET1_EVENT_A 0x38
69#define ADP5589_RESET1_EVENT_B 0x39
70#define ADP5589_RESET1_EVENT_C 0x3A
71#define ADP5589_RESET2_EVENT_A 0x3B
72#define ADP5589_RESET2_EVENT_B 0x3C
73#define ADP5589_RESET_CFG 0x3D
74#define ADP5589_PWM_OFFT_LOW 0x3E
75#define ADP5589_PWM_OFFT_HIGH 0x3F
76#define ADP5589_PWM_ONT_LOW 0x40
77#define ADP5589_PWM_ONT_HIGH 0x41
78#define ADP5589_PWM_CFG 0x42
79#define ADP5589_CLOCK_DIV_CFG 0x43
80#define ADP5589_LOGIC_1_CFG 0x44
81#define ADP5589_LOGIC_2_CFG 0x45
82#define ADP5589_LOGIC_FF_CFG 0x46
83#define ADP5589_LOGIC_INT_EVENT_EN 0x47
84#define ADP5589_POLL_PTIME_CFG 0x48
85#define ADP5589_PIN_CONFIG_A 0x49
86#define ADP5589_PIN_CONFIG_B 0x4A
87#define ADP5589_PIN_CONFIG_C 0x4B
88#define ADP5589_PIN_CONFIG_D 0x4C
89#define ADP5589_GENERAL_CFG 0x4D
90#define ADP5589_INT_EN 0x4E
91
92#define ADP5589_DEVICE_ID_MASK 0xF
93
94/* Put one of these structures in i2c_board_info platform_data */
95 15
96#define ADP5589_KEYMAPSIZE 88 16#define ADP5589_KEYMAPSIZE 88
97 17
@@ -127,6 +47,35 @@
127 47
128#define ADP5589_GPIMAPSIZE_MAX (ADP5589_GPI_PIN_END - ADP5589_GPI_PIN_BASE + 1) 48#define ADP5589_GPIMAPSIZE_MAX (ADP5589_GPI_PIN_END - ADP5589_GPI_PIN_BASE + 1)
129 49
50/*
51 * ADP5585 specific GPI and Keymap defines
52 */
53
54#define ADP5585_KEYMAPSIZE 30
55
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
67#define GPI_LOGIC 48
68
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
73
74#define ADP5585_GPI_PIN_BASE ADP5585_GPI_PIN_ROW_BASE
75#define ADP5585_GPI_PIN_END ADP5585_GPI_PIN_COL_END
76
77#define ADP5585_GPIMAPSIZE_MAX (ADP5585_GPI_PIN_END - ADP5585_GPI_PIN_BASE + 1)
78
130struct adp5589_gpi_map { 79struct adp5589_gpi_map {
131 unsigned short pin; 80 unsigned short pin;
132 unsigned short sw_evt; 81 unsigned short sw_evt;
@@ -159,7 +108,7 @@ struct adp5589_gpi_map {
159#define RESET2_POL_HIGH (1 << 7) 108#define RESET2_POL_HIGH (1 << 7)
160#define RESET2_POL_LOW (0 << 7) 109#define RESET2_POL_LOW (0 << 7)
161 110
162/* Mask Bits: 111/* ADP5589 Mask Bits:
163 * C C C C C C C C C C C | R R R R R R R R 112 * C C C C C C C C C C C | R R R R R R R R
164 * 1 9 8 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 113 * 1 9 8 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0
165 * 0 114 * 0
@@ -168,18 +117,44 @@ struct adp5589_gpi_map {
168 * 8 7 6 5 4 3 2 1 0 9 8 | 7 6 5 4 3 2 1 0 117 * 8 7 6 5 4 3 2 1 0 9 8 | 7 6 5 4 3 2 1 0
169 */ 118 */
170 119
171#define ADP_ROW(x) (1 << (x)) 120#define ADP_ROW(x) (1 << (x))
172#define ADP_COL(x) (1 << (x + 8)) 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
127
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
131 *
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
135 */
136
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
143
144#define ADP5585_ROW(x) (1 << ((x) & ADP5585_ROW_MASK))
145#define ADP5585_COL(x) (1 << (((x) & ADP5585_COL_MASK) + ADP5585_COL_SHIFT))
146
147/* Put one of these structures in i2c_board_info platform_data */
173 148
174struct adp5589_kpad_platform_data { 149struct adp5589_kpad_platform_data {
175 unsigned keypad_en_mask; /* Keypad (Rows/Columns) enable mask */ 150 unsigned keypad_en_mask; /* Keypad (Rows/Columns) enable mask */
176 const unsigned short *keymap; /* Pointer to keymap */ 151 const unsigned short *keymap; /* Pointer to keymap */
177 unsigned short keymapsize; /* Keymap size */ 152 unsigned short keymapsize; /* Keymap size */
178 bool repeat; /* Enable key repeat */ 153 bool repeat; /* Enable key repeat */
179 bool en_keylock; /* Enable key lock feature */ 154 bool en_keylock; /* Enable key lock feature (ADP5589 only)*/
180 unsigned char unlock_key1; /* Unlock Key 1 */ 155 unsigned char unlock_key1; /* Unlock Key 1 (ADP5589 only) */
181 unsigned char unlock_key2; /* Unlock Key 2 */ 156 unsigned char unlock_key2; /* Unlock Key 2 (ADP5589 only) */
182 unsigned char unlock_timer; /* Time in seconds [0..7] between the two unlock keys 0=disable */ 157 unsigned char unlock_timer; /* Time in seconds [0..7] between the two unlock keys 0=disable (ADP5589 only) */
183 unsigned char scan_cycle_time; /* Time between consecutive scan cycles */ 158 unsigned char scan_cycle_time; /* Time between consecutive scan cycles */
184 unsigned char reset_cfg; /* Reset config */ 159 unsigned char reset_cfg; /* Reset config */
185 unsigned short reset1_key_1; /* Reset Key 1 */ 160 unsigned short reset1_key_1; /* Reset Key 1 */