aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-pxa/include/mach/pxa27x_keypad.h3
-rw-r--r--drivers/input/keyboard/pxa27x_keypad.c43
2 files changed, 21 insertions, 25 deletions
diff --git a/arch/arm/mach-pxa/include/mach/pxa27x_keypad.h b/arch/arm/mach-pxa/include/mach/pxa27x_keypad.h
index d5a48a96dea7..63e8965ad85d 100644
--- a/arch/arm/mach-pxa/include/mach/pxa27x_keypad.h
+++ b/arch/arm/mach-pxa/include/mach/pxa27x_keypad.h
@@ -2,6 +2,7 @@
2#define __ASM_ARCH_PXA27x_KEYPAD_H 2#define __ASM_ARCH_PXA27x_KEYPAD_H
3 3
4#include <linux/input.h> 4#include <linux/input.h>
5#include <linux/input/matrix_keypad.h>
5 6
6#define MAX_MATRIX_KEY_ROWS (8) 7#define MAX_MATRIX_KEY_ROWS (8)
7#define MAX_MATRIX_KEY_COLS (8) 8#define MAX_MATRIX_KEY_COLS (8)
@@ -51,8 +52,6 @@ struct pxa27x_keypad_platform_data {
51 unsigned int debounce_interval; 52 unsigned int debounce_interval;
52}; 53};
53 54
54#define KEY(row, col, val) (((row) << 28) | ((col) << 24) | (val))
55
56extern void pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info); 55extern void pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info);
57 56
58#endif /* __ASM_ARCH_PXA27x_KEYPAD_H */ 57#endif /* __ASM_ARCH_PXA27x_KEYPAD_H */
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index 0d2fc64a5e1c..094323819398 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -25,6 +25,7 @@
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/clk.h> 26#include <linux/clk.h>
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/input/matrix_keypad.h>
28 29
29#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
30#include <asm/mach/map.h> 31#include <asm/mach/map.h>
@@ -107,7 +108,7 @@ struct pxa27x_keypad {
107 int irq; 108 int irq;
108 109
109 /* matrix key code map */ 110 /* matrix key code map */
110 unsigned int matrix_keycodes[MAX_MATRIX_KEY_NUM]; 111 unsigned short matrix_keycodes[MAX_MATRIX_KEY_NUM];
111 112
112 /* state row bits of each column scan */ 113 /* state row bits of each column scan */
113 uint32_t matrix_key_state[MAX_MATRIX_KEY_COLS]; 114 uint32_t matrix_key_state[MAX_MATRIX_KEY_COLS];
@@ -124,21 +125,21 @@ static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
124{ 125{
125 struct pxa27x_keypad_platform_data *pdata = keypad->pdata; 126 struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
126 struct input_dev *input_dev = keypad->input_dev; 127 struct input_dev *input_dev = keypad->input_dev;
127 unsigned int *key;
128 int i; 128 int i;
129 129
130 key = &pdata->matrix_key_map[0]; 130 for (i = 0; i < pdata->matrix_key_map_size; i++) {
131 for (i = 0; i < pdata->matrix_key_map_size; i++, key++) { 131 unsigned int key = pdata->matrix_key_map[i];
132 int row = ((*key) >> 28) & 0xf; 132 unsigned int row = KEY_ROW(key);
133 int col = ((*key) >> 24) & 0xf; 133 unsigned int col = KEY_COL(key);
134 int code = (*key) & 0xffffff; 134 unsigned short code = KEY_VAL(key);
135 135
136 keypad->matrix_keycodes[(row << 3) + col] = code; 136 keypad->matrix_keycodes[(row << 3) + col] = code;
137 set_bit(code, input_dev->keybit); 137 __set_bit(code, input_dev->keybit);
138 } 138 }
139 __clear_bit(KEY_RESERVED, input_dev->keybit);
139 140
140 for (i = 0; i < pdata->direct_key_num; i++) 141 for (i = 0; i < pdata->direct_key_num; i++)
141 set_bit(pdata->direct_key_map[i], input_dev->keybit); 142 __set_bit(pdata->direct_key_map[i], input_dev->keybit);
142 143
143 keypad->rotary_up_key[0] = pdata->rotary0_up_key; 144 keypad->rotary_up_key[0] = pdata->rotary0_up_key;
144 keypad->rotary_up_key[1] = pdata->rotary1_up_key; 145 keypad->rotary_up_key[1] = pdata->rotary1_up_key;
@@ -149,18 +150,18 @@ static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
149 150
150 if (pdata->enable_rotary0) { 151 if (pdata->enable_rotary0) {
151 if (pdata->rotary0_up_key && pdata->rotary0_down_key) { 152 if (pdata->rotary0_up_key && pdata->rotary0_down_key) {
152 set_bit(pdata->rotary0_up_key, input_dev->keybit); 153 __set_bit(pdata->rotary0_up_key, input_dev->keybit);
153 set_bit(pdata->rotary0_down_key, input_dev->keybit); 154 __set_bit(pdata->rotary0_down_key, input_dev->keybit);
154 } else 155 } else
155 set_bit(pdata->rotary0_rel_code, input_dev->relbit); 156 __set_bit(pdata->rotary0_rel_code, input_dev->relbit);
156 } 157 }
157 158
158 if (pdata->enable_rotary1) { 159 if (pdata->enable_rotary1) {
159 if (pdata->rotary1_up_key && pdata->rotary1_down_key) { 160 if (pdata->rotary1_up_key && pdata->rotary1_down_key) {
160 set_bit(pdata->rotary1_up_key, input_dev->keybit); 161 __set_bit(pdata->rotary1_up_key, input_dev->keybit);
161 set_bit(pdata->rotary1_down_key, input_dev->keybit); 162 __set_bit(pdata->rotary1_down_key, input_dev->keybit);
162 } else 163 } else
163 set_bit(pdata->rotary1_rel_code, input_dev->relbit); 164 __set_bit(pdata->rotary1_rel_code, input_dev->relbit);
164 } 165 }
165} 166}
166 167
@@ -425,8 +426,6 @@ static int pxa27x_keypad_resume(struct platform_device *pdev)
425#define pxa27x_keypad_resume NULL 426#define pxa27x_keypad_resume NULL
426#endif 427#endif
427 428
428#define res_size(res) ((res)->end - (res)->start + 1)
429
430static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) 429static int __devinit pxa27x_keypad_probe(struct platform_device *pdev)
431{ 430{
432 struct pxa27x_keypad *keypad; 431 struct pxa27x_keypad *keypad;
@@ -461,14 +460,14 @@ static int __devinit pxa27x_keypad_probe(struct platform_device *pdev)
461 goto failed_free; 460 goto failed_free;
462 } 461 }
463 462
464 res = request_mem_region(res->start, res_size(res), pdev->name); 463 res = request_mem_region(res->start, resource_size(res), pdev->name);
465 if (res == NULL) { 464 if (res == NULL) {
466 dev_err(&pdev->dev, "failed to request I/O memory\n"); 465 dev_err(&pdev->dev, "failed to request I/O memory\n");
467 error = -EBUSY; 466 error = -EBUSY;
468 goto failed_free; 467 goto failed_free;
469 } 468 }
470 469
471 keypad->mmio_base = ioremap(res->start, res_size(res)); 470 keypad->mmio_base = ioremap(res->start, resource_size(res));
472 if (keypad->mmio_base == NULL) { 471 if (keypad->mmio_base == NULL) {
473 dev_err(&pdev->dev, "failed to remap I/O memory\n"); 472 dev_err(&pdev->dev, "failed to remap I/O memory\n");
474 error = -ENXIO; 473 error = -ENXIO;
@@ -540,7 +539,7 @@ failed_put_clk:
540failed_free_io: 539failed_free_io:
541 iounmap(keypad->mmio_base); 540 iounmap(keypad->mmio_base);
542failed_free_mem: 541failed_free_mem:
543 release_mem_region(res->start, res_size(res)); 542 release_mem_region(res->start, resource_size(res));
544failed_free: 543failed_free:
545 kfree(keypad); 544 kfree(keypad);
546 return error; 545 return error;
@@ -552,8 +551,6 @@ static int __devexit pxa27x_keypad_remove(struct platform_device *pdev)
552 struct resource *res; 551 struct resource *res;
553 552
554 free_irq(keypad->irq, pdev); 553 free_irq(keypad->irq, pdev);
555
556 clk_disable(keypad->clk);
557 clk_put(keypad->clk); 554 clk_put(keypad->clk);
558 555
559 input_unregister_device(keypad->input_dev); 556 input_unregister_device(keypad->input_dev);
@@ -562,7 +559,7 @@ static int __devexit pxa27x_keypad_remove(struct platform_device *pdev)
562 iounmap(keypad->mmio_base); 559 iounmap(keypad->mmio_base);
563 560
564 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 561 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
565 release_mem_region(res->start, res_size(res)); 562 release_mem_region(res->start, resource_size(res));
566 563
567 platform_set_drvdata(pdev, NULL); 564 platform_set_drvdata(pdev, NULL);
568 kfree(keypad); 565 kfree(keypad);