aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-ep93xx/include/mach/ep93xx_keypad.h14
-rw-r--r--drivers/input/keyboard/ep93xx_keypad.c40
2 files changed, 22 insertions, 32 deletions
diff --git a/arch/arm/mach-ep93xx/include/mach/ep93xx_keypad.h b/arch/arm/mach-ep93xx/include/mach/ep93xx_keypad.h
index 62d17421e48c..1e2f4e97f428 100644
--- a/arch/arm/mach-ep93xx/include/mach/ep93xx_keypad.h
+++ b/arch/arm/mach-ep93xx/include/mach/ep93xx_keypad.h
@@ -5,6 +5,8 @@
5#ifndef __ASM_ARCH_EP93XX_KEYPAD_H 5#ifndef __ASM_ARCH_EP93XX_KEYPAD_H
6#define __ASM_ARCH_EP93XX_KEYPAD_H 6#define __ASM_ARCH_EP93XX_KEYPAD_H
7 7
8struct matrix_keymap_data;
9
8/* flags for the ep93xx_keypad driver */ 10/* flags for the ep93xx_keypad driver */
9#define EP93XX_KEYPAD_DISABLE_3_KEY (1<<0) /* disable 3-key reset */ 11#define EP93XX_KEYPAD_DISABLE_3_KEY (1<<0) /* disable 3-key reset */
10#define EP93XX_KEYPAD_DIAG_MODE (1<<1) /* diagnostic mode */ 12#define EP93XX_KEYPAD_DIAG_MODE (1<<1) /* diagnostic mode */
@@ -15,15 +17,13 @@
15 17
16/** 18/**
17 * struct ep93xx_keypad_platform_data - platform specific device structure 19 * struct ep93xx_keypad_platform_data - platform specific device structure
18 * @matrix_key_map: array of keycodes defining the keypad matrix 20 * @keymap_data: pointer to &matrix_keymap_data
19 * @matrix_key_map_size: ARRAY_SIZE(matrix_key_map) 21 * @debounce: debounce start count; terminal count is 0xff
20 * @debounce: debounce start count; terminal count is 0xff 22 * @prescale: row/column counter pre-scaler load value
21 * @prescale: row/column counter pre-scaler load value 23 * @flags: see above
22 * @flags: see above
23 */ 24 */
24struct ep93xx_keypad_platform_data { 25struct ep93xx_keypad_platform_data {
25 unsigned int *matrix_key_map; 26 struct matrix_keymap_data *keymap_data;
26 int matrix_key_map_size;
27 unsigned int debounce; 27 unsigned int debounce;
28 unsigned int prescale; 28 unsigned int prescale;
29 unsigned int flags; 29 unsigned int flags;
diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
index e45740429f7e..bd25a3af1664 100644
--- a/drivers/input/keyboard/ep93xx_keypad.c
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -69,7 +69,7 @@ struct ep93xx_keypad {
69 69
70 void __iomem *mmio_base; 70 void __iomem *mmio_base;
71 71
72 unsigned int matrix_keycodes[EP93XX_MATRIX_SIZE]; 72 unsigned short keycodes[EP93XX_MATRIX_SIZE];
73 73
74 int key1; 74 int key1;
75 int key2; 75 int key2;
@@ -79,24 +79,6 @@ struct ep93xx_keypad {
79 bool enabled; 79 bool enabled;
80}; 80};
81 81
82static void ep93xx_keypad_build_keycode(struct ep93xx_keypad *keypad)
83{
84 struct ep93xx_keypad_platform_data *pdata = keypad->pdata;
85 struct input_dev *input_dev = keypad->input_dev;
86 unsigned int *key;
87 int i;
88
89 key = &pdata->matrix_key_map[0];
90 for (i = 0; i < pdata->matrix_key_map_size; i++, key++) {
91 int row = KEY_ROW(*key);
92 int col = KEY_COL(*key);
93 int code = KEY_VAL(*key);
94
95 keypad->matrix_keycodes[(row << 3) + col] = code;
96 __set_bit(code, input_dev->keybit);
97 }
98}
99
100static irqreturn_t ep93xx_keypad_irq_handler(int irq, void *dev_id) 82static irqreturn_t ep93xx_keypad_irq_handler(int irq, void *dev_id)
101{ 83{
102 struct ep93xx_keypad *keypad = dev_id; 84 struct ep93xx_keypad *keypad = dev_id;
@@ -107,10 +89,10 @@ static irqreturn_t ep93xx_keypad_irq_handler(int irq, void *dev_id)
107 status = __raw_readl(keypad->mmio_base + KEY_REG); 89 status = __raw_readl(keypad->mmio_base + KEY_REG);
108 90
109 keycode = (status & KEY_REG_KEY1_MASK) >> KEY_REG_KEY1_SHIFT; 91 keycode = (status & KEY_REG_KEY1_MASK) >> KEY_REG_KEY1_SHIFT;
110 key1 = keypad->matrix_keycodes[keycode]; 92 key1 = keypad->keycodes[keycode];
111 93
112 keycode = (status & KEY_REG_KEY2_MASK) >> KEY_REG_KEY2_SHIFT; 94 keycode = (status & KEY_REG_KEY2_MASK) >> KEY_REG_KEY2_SHIFT;
113 key2 = keypad->matrix_keycodes[keycode]; 95 key2 = keypad->keycodes[keycode];
114 96
115 if (status & KEY_REG_2KEYS) { 97 if (status & KEY_REG_2KEYS) {
116 if (keypad->key1 && key1 != keypad->key1 && key2 != keypad->key1) 98 if (keypad->key1 && key1 != keypad->key1 && key2 != keypad->key1)
@@ -256,6 +238,7 @@ static int ep93xx_keypad_resume(struct platform_device *pdev)
256static int __devinit ep93xx_keypad_probe(struct platform_device *pdev) 238static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
257{ 239{
258 struct ep93xx_keypad *keypad; 240 struct ep93xx_keypad *keypad;
241 const struct matrix_keymap_data *keymap_data;
259 struct input_dev *input_dev; 242 struct input_dev *input_dev;
260 struct resource *res; 243 struct resource *res;
261 int err; 244 int err;
@@ -270,6 +253,12 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
270 goto failed_free; 253 goto failed_free;
271 } 254 }
272 255
256 keymap_data = keypad->pdata->keymap_data;
257 if (!keymap_data) {
258 err = -EINVAL;
259 goto failed_free;
260 }
261
273 keypad->irq = platform_get_irq(pdev, 0); 262 keypad->irq = platform_get_irq(pdev, 0);
274 if (!keypad->irq) { 263 if (!keypad->irq) {
275 err = -ENXIO; 264 err = -ENXIO;
@@ -317,9 +306,9 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
317 input_dev->open = ep93xx_keypad_open; 306 input_dev->open = ep93xx_keypad_open;
318 input_dev->close = ep93xx_keypad_close; 307 input_dev->close = ep93xx_keypad_close;
319 input_dev->dev.parent = &pdev->dev; 308 input_dev->dev.parent = &pdev->dev;
320 input_dev->keycode = keypad->matrix_keycodes; 309 input_dev->keycode = keypad->keycodes;
321 input_dev->keycodesize = sizeof(keypad->matrix_keycodes[0]); 310 input_dev->keycodesize = sizeof(keypad->keycodes[0]);
322 input_dev->keycodemax = ARRAY_SIZE(keypad->matrix_keycodes); 311 input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
323 312
324 input_set_drvdata(input_dev, keypad); 313 input_set_drvdata(input_dev, keypad);
325 314
@@ -327,7 +316,8 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
327 if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT) 316 if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT)
328 input_dev->evbit[0] |= BIT_MASK(EV_REP); 317 input_dev->evbit[0] |= BIT_MASK(EV_REP);
329 318
330 ep93xx_keypad_build_keycode(keypad); 319 matrix_keypad_build_keymap(keymap_data, 3,
320 input_dev->keycode, input_dev->keybit);
331 platform_set_drvdata(pdev, keypad); 321 platform_set_drvdata(pdev, keypad);
332 322
333 err = request_irq(keypad->irq, ep93xx_keypad_irq_handler, 323 err = request_irq(keypad->irq, ep93xx_keypad_irq_handler,