diff options
Diffstat (limited to 'drivers/input/keyboard/pxa27x_keypad.c')
-rw-r--r-- | drivers/input/keyboard/pxa27x_keypad.c | 219 |
1 files changed, 115 insertions, 104 deletions
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c index 0d2fc64a5e1c..79cd3e9fdf2e 100644 --- a/drivers/input/keyboard/pxa27x_keypad.c +++ b/drivers/input/keyboard/pxa27x_keypad.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * | 8 | * |
9 | * Based on a previous implementations by Kevin O'Connor | 9 | * Based on a previous implementations by Kevin O'Connor |
10 | * <kevin_at_koconnor.net> and Alex Osborne <bobofdoom@gmail.com> and | 10 | * <kevin_at_koconnor.net> and Alex Osborne <bobofdoom@gmail.com> and |
11 | * on some suggestions by Nicolas Pitre <nico@cam.org>. | 11 | * on some suggestions by Nicolas Pitre <nico@fluxnic.net>. |
12 | * | 12 | * |
13 | * This program is free software; you can redistribute it and/or modify | 13 | * This program is free software; you can redistribute it and/or modify |
14 | * it under the terms of the GNU General Public License version 2 as | 14 | * it under the terms of the GNU General Public License version 2 as |
@@ -25,13 +25,13 @@ | |||
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> |
31 | 32 | ||
32 | #include <mach/hardware.h> | 33 | #include <mach/hardware.h> |
33 | #include <mach/pxa27x_keypad.h> | 34 | #include <mach/pxa27x_keypad.h> |
34 | |||
35 | /* | 35 | /* |
36 | * Keypad Controller registers | 36 | * Keypad Controller registers |
37 | */ | 37 | */ |
@@ -95,7 +95,8 @@ | |||
95 | #define keypad_readl(off) __raw_readl(keypad->mmio_base + (off)) | 95 | #define keypad_readl(off) __raw_readl(keypad->mmio_base + (off)) |
96 | #define keypad_writel(off, v) __raw_writel((v), keypad->mmio_base + (off)) | 96 | #define keypad_writel(off, v) __raw_writel((v), keypad->mmio_base + (off)) |
97 | 97 | ||
98 | #define MAX_MATRIX_KEY_NUM (8 * 8) | 98 | #define MAX_MATRIX_KEY_NUM (MAX_MATRIX_KEY_ROWS * MAX_MATRIX_KEY_COLS) |
99 | #define MAX_KEYPAD_KEYS (MAX_MATRIX_KEY_NUM + MAX_DIRECT_KEY_NUM) | ||
99 | 100 | ||
100 | struct pxa27x_keypad { | 101 | struct pxa27x_keypad { |
101 | struct pxa27x_keypad_platform_data *pdata; | 102 | struct pxa27x_keypad_platform_data *pdata; |
@@ -106,73 +107,82 @@ struct pxa27x_keypad { | |||
106 | 107 | ||
107 | int irq; | 108 | int irq; |
108 | 109 | ||
109 | /* matrix key code map */ | 110 | unsigned short keycodes[MAX_KEYPAD_KEYS]; |
110 | unsigned int matrix_keycodes[MAX_MATRIX_KEY_NUM]; | 111 | int rotary_rel_code[2]; |
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]; |
114 | uint32_t direct_key_state; | 115 | uint32_t direct_key_state; |
115 | 116 | ||
116 | unsigned int direct_key_mask; | 117 | unsigned int direct_key_mask; |
117 | |||
118 | int rotary_rel_code[2]; | ||
119 | int rotary_up_key[2]; | ||
120 | int rotary_down_key[2]; | ||
121 | }; | 118 | }; |
122 | 119 | ||
123 | static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad) | 120 | static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad) |
124 | { | 121 | { |
125 | struct pxa27x_keypad_platform_data *pdata = keypad->pdata; | 122 | struct pxa27x_keypad_platform_data *pdata = keypad->pdata; |
126 | struct input_dev *input_dev = keypad->input_dev; | 123 | struct input_dev *input_dev = keypad->input_dev; |
127 | unsigned int *key; | 124 | unsigned short keycode; |
128 | int i; | 125 | int i; |
129 | 126 | ||
130 | key = &pdata->matrix_key_map[0]; | 127 | for (i = 0; i < pdata->matrix_key_map_size; i++) { |
131 | for (i = 0; i < pdata->matrix_key_map_size; i++, key++) { | 128 | unsigned int key = pdata->matrix_key_map[i]; |
132 | int row = ((*key) >> 28) & 0xf; | 129 | unsigned int row = KEY_ROW(key); |
133 | int col = ((*key) >> 24) & 0xf; | 130 | unsigned int col = KEY_COL(key); |
134 | int code = (*key) & 0xffffff; | 131 | unsigned int scancode = MATRIX_SCAN_CODE(row, col, |
132 | MATRIX_ROW_SHIFT); | ||
135 | 133 | ||
136 | keypad->matrix_keycodes[(row << 3) + col] = code; | 134 | keycode = KEY_VAL(key); |
137 | set_bit(code, input_dev->keybit); | 135 | keypad->keycodes[scancode] = keycode; |
136 | __set_bit(keycode, input_dev->keybit); | ||
138 | } | 137 | } |
139 | 138 | ||
140 | for (i = 0; i < pdata->direct_key_num; i++) | 139 | for (i = 0; i < pdata->direct_key_num; i++) { |
141 | set_bit(pdata->direct_key_map[i], input_dev->keybit); | 140 | keycode = pdata->direct_key_map[i]; |
142 | 141 | keypad->keycodes[MAX_MATRIX_KEY_NUM + i] = keycode; | |
143 | keypad->rotary_up_key[0] = pdata->rotary0_up_key; | 142 | __set_bit(keycode, input_dev->keybit); |
144 | keypad->rotary_up_key[1] = pdata->rotary1_up_key; | 143 | } |
145 | keypad->rotary_down_key[0] = pdata->rotary0_down_key; | ||
146 | keypad->rotary_down_key[1] = pdata->rotary1_down_key; | ||
147 | keypad->rotary_rel_code[0] = pdata->rotary0_rel_code; | ||
148 | keypad->rotary_rel_code[1] = pdata->rotary1_rel_code; | ||
149 | 144 | ||
150 | if (pdata->enable_rotary0) { | 145 | if (pdata->enable_rotary0) { |
151 | if (pdata->rotary0_up_key && pdata->rotary0_down_key) { | 146 | if (pdata->rotary0_up_key && pdata->rotary0_down_key) { |
152 | set_bit(pdata->rotary0_up_key, input_dev->keybit); | 147 | keycode = pdata->rotary0_up_key; |
153 | set_bit(pdata->rotary0_down_key, input_dev->keybit); | 148 | keypad->keycodes[MAX_MATRIX_KEY_NUM + 0] = keycode; |
154 | } else | 149 | __set_bit(keycode, input_dev->keybit); |
155 | set_bit(pdata->rotary0_rel_code, input_dev->relbit); | 150 | |
151 | keycode = pdata->rotary0_down_key; | ||
152 | keypad->keycodes[MAX_MATRIX_KEY_NUM + 1] = keycode; | ||
153 | __set_bit(keycode, input_dev->keybit); | ||
154 | |||
155 | keypad->rotary_rel_code[0] = -1; | ||
156 | } else { | ||
157 | keypad->rotary_rel_code[0] = pdata->rotary0_rel_code; | ||
158 | __set_bit(pdata->rotary0_rel_code, input_dev->relbit); | ||
159 | } | ||
156 | } | 160 | } |
157 | 161 | ||
158 | if (pdata->enable_rotary1) { | 162 | if (pdata->enable_rotary1) { |
159 | if (pdata->rotary1_up_key && pdata->rotary1_down_key) { | 163 | if (pdata->rotary1_up_key && pdata->rotary1_down_key) { |
160 | set_bit(pdata->rotary1_up_key, input_dev->keybit); | 164 | keycode = pdata->rotary1_up_key; |
161 | set_bit(pdata->rotary1_down_key, input_dev->keybit); | 165 | keypad->keycodes[MAX_MATRIX_KEY_NUM + 2] = keycode; |
162 | } else | 166 | __set_bit(keycode, input_dev->keybit); |
163 | set_bit(pdata->rotary1_rel_code, input_dev->relbit); | 167 | |
168 | keycode = pdata->rotary1_down_key; | ||
169 | keypad->keycodes[MAX_MATRIX_KEY_NUM + 3] = keycode; | ||
170 | __set_bit(keycode, input_dev->keybit); | ||
171 | |||
172 | keypad->rotary_rel_code[1] = -1; | ||
173 | } else { | ||
174 | keypad->rotary_rel_code[1] = pdata->rotary1_rel_code; | ||
175 | __set_bit(pdata->rotary1_rel_code, input_dev->relbit); | ||
176 | } | ||
164 | } | 177 | } |
165 | } | ||
166 | 178 | ||
167 | static inline unsigned int lookup_matrix_keycode( | 179 | __clear_bit(KEY_RESERVED, input_dev->keybit); |
168 | struct pxa27x_keypad *keypad, int row, int col) | ||
169 | { | ||
170 | return keypad->matrix_keycodes[(row << 3) + col]; | ||
171 | } | 180 | } |
172 | 181 | ||
173 | static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad) | 182 | static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad) |
174 | { | 183 | { |
175 | struct pxa27x_keypad_platform_data *pdata = keypad->pdata; | 184 | struct pxa27x_keypad_platform_data *pdata = keypad->pdata; |
185 | struct input_dev *input_dev = keypad->input_dev; | ||
176 | int row, col, num_keys_pressed = 0; | 186 | int row, col, num_keys_pressed = 0; |
177 | uint32_t new_state[MAX_MATRIX_KEY_COLS]; | 187 | uint32_t new_state[MAX_MATRIX_KEY_COLS]; |
178 | uint32_t kpas = keypad_readl(KPAS); | 188 | uint32_t kpas = keypad_readl(KPAS); |
@@ -215,6 +225,7 @@ static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad) | |||
215 | scan: | 225 | scan: |
216 | for (col = 0; col < pdata->matrix_key_cols; col++) { | 226 | for (col = 0; col < pdata->matrix_key_cols; col++) { |
217 | uint32_t bits_changed; | 227 | uint32_t bits_changed; |
228 | int code; | ||
218 | 229 | ||
219 | bits_changed = keypad->matrix_key_state[col] ^ new_state[col]; | 230 | bits_changed = keypad->matrix_key_state[col] ^ new_state[col]; |
220 | if (bits_changed == 0) | 231 | if (bits_changed == 0) |
@@ -224,12 +235,13 @@ scan: | |||
224 | if ((bits_changed & (1 << row)) == 0) | 235 | if ((bits_changed & (1 << row)) == 0) |
225 | continue; | 236 | continue; |
226 | 237 | ||
227 | input_report_key(keypad->input_dev, | 238 | code = MATRIX_SCAN_CODE(row, col, MATRIX_ROW_SHIFT); |
228 | lookup_matrix_keycode(keypad, row, col), | 239 | input_event(input_dev, EV_MSC, MSC_SCAN, code); |
229 | new_state[col] & (1 << row)); | 240 | input_report_key(input_dev, keypad->keycodes[code], |
241 | new_state[col] & (1 << row)); | ||
230 | } | 242 | } |
231 | } | 243 | } |
232 | input_sync(keypad->input_dev); | 244 | input_sync(input_dev); |
233 | memcpy(keypad->matrix_key_state, new_state, sizeof(new_state)); | 245 | memcpy(keypad->matrix_key_state, new_state, sizeof(new_state)); |
234 | } | 246 | } |
235 | 247 | ||
@@ -252,13 +264,15 @@ static void report_rotary_event(struct pxa27x_keypad *keypad, int r, int delta) | |||
252 | if (delta == 0) | 264 | if (delta == 0) |
253 | return; | 265 | return; |
254 | 266 | ||
255 | if (keypad->rotary_up_key[r] && keypad->rotary_down_key[r]) { | 267 | if (keypad->rotary_rel_code[r] == -1) { |
256 | int keycode = (delta > 0) ? keypad->rotary_up_key[r] : | 268 | int code = MAX_MATRIX_KEY_NUM + 2 * r + (delta > 0 ? 0 : 1); |
257 | keypad->rotary_down_key[r]; | 269 | unsigned char keycode = keypad->keycodes[code]; |
258 | 270 | ||
259 | /* simulate a press-n-release */ | 271 | /* simulate a press-n-release */ |
272 | input_event(dev, EV_MSC, MSC_SCAN, code); | ||
260 | input_report_key(dev, keycode, 1); | 273 | input_report_key(dev, keycode, 1); |
261 | input_sync(dev); | 274 | input_sync(dev); |
275 | input_event(dev, EV_MSC, MSC_SCAN, code); | ||
262 | input_report_key(dev, keycode, 0); | 276 | input_report_key(dev, keycode, 0); |
263 | input_sync(dev); | 277 | input_sync(dev); |
264 | } else { | 278 | } else { |
@@ -286,6 +300,7 @@ static void pxa27x_keypad_scan_rotary(struct pxa27x_keypad *keypad) | |||
286 | static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad) | 300 | static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad) |
287 | { | 301 | { |
288 | struct pxa27x_keypad_platform_data *pdata = keypad->pdata; | 302 | struct pxa27x_keypad_platform_data *pdata = keypad->pdata; |
303 | struct input_dev *input_dev = keypad->input_dev; | ||
289 | unsigned int new_state; | 304 | unsigned int new_state; |
290 | uint32_t kpdk, bits_changed; | 305 | uint32_t kpdk, bits_changed; |
291 | int i; | 306 | int i; |
@@ -295,9 +310,6 @@ static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad) | |||
295 | if (pdata->enable_rotary0 || pdata->enable_rotary1) | 310 | if (pdata->enable_rotary0 || pdata->enable_rotary1) |
296 | pxa27x_keypad_scan_rotary(keypad); | 311 | pxa27x_keypad_scan_rotary(keypad); |
297 | 312 | ||
298 | if (pdata->direct_key_map == NULL) | ||
299 | return; | ||
300 | |||
301 | new_state = KPDK_DK(kpdk) & keypad->direct_key_mask; | 313 | new_state = KPDK_DK(kpdk) & keypad->direct_key_mask; |
302 | bits_changed = keypad->direct_key_state ^ new_state; | 314 | bits_changed = keypad->direct_key_state ^ new_state; |
303 | 315 | ||
@@ -305,12 +317,15 @@ static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad) | |||
305 | return; | 317 | return; |
306 | 318 | ||
307 | for (i = 0; i < pdata->direct_key_num; i++) { | 319 | for (i = 0; i < pdata->direct_key_num; i++) { |
308 | if (bits_changed & (1 << i)) | 320 | if (bits_changed & (1 << i)) { |
309 | input_report_key(keypad->input_dev, | 321 | int code = MAX_MATRIX_KEY_NUM + i; |
310 | pdata->direct_key_map[i], | 322 | |
311 | (new_state & (1 << i))); | 323 | input_event(input_dev, EV_MSC, MSC_SCAN, code); |
324 | input_report_key(input_dev, keypad->keycodes[code], | ||
325 | new_state & (1 << i)); | ||
326 | } | ||
312 | } | 327 | } |
313 | input_sync(keypad->input_dev); | 328 | input_sync(input_dev); |
314 | keypad->direct_key_state = new_state; | 329 | keypad->direct_key_state = new_state; |
315 | } | 330 | } |
316 | 331 | ||
@@ -388,8 +403,9 @@ static void pxa27x_keypad_close(struct input_dev *dev) | |||
388 | } | 403 | } |
389 | 404 | ||
390 | #ifdef CONFIG_PM | 405 | #ifdef CONFIG_PM |
391 | static int pxa27x_keypad_suspend(struct platform_device *pdev, pm_message_t state) | 406 | static int pxa27x_keypad_suspend(struct device *dev) |
392 | { | 407 | { |
408 | struct platform_device *pdev = to_platform_device(dev); | ||
393 | struct pxa27x_keypad *keypad = platform_get_drvdata(pdev); | 409 | struct pxa27x_keypad *keypad = platform_get_drvdata(pdev); |
394 | 410 | ||
395 | clk_disable(keypad->clk); | 411 | clk_disable(keypad->clk); |
@@ -400,8 +416,9 @@ static int pxa27x_keypad_suspend(struct platform_device *pdev, pm_message_t stat | |||
400 | return 0; | 416 | return 0; |
401 | } | 417 | } |
402 | 418 | ||
403 | static int pxa27x_keypad_resume(struct platform_device *pdev) | 419 | static int pxa27x_keypad_resume(struct device *dev) |
404 | { | 420 | { |
421 | struct platform_device *pdev = to_platform_device(dev); | ||
405 | struct pxa27x_keypad *keypad = platform_get_drvdata(pdev); | 422 | struct pxa27x_keypad *keypad = platform_get_drvdata(pdev); |
406 | struct input_dev *input_dev = keypad->input_dev; | 423 | struct input_dev *input_dev = keypad->input_dev; |
407 | 424 | ||
@@ -420,55 +437,58 @@ static int pxa27x_keypad_resume(struct platform_device *pdev) | |||
420 | 437 | ||
421 | return 0; | 438 | return 0; |
422 | } | 439 | } |
423 | #else | ||
424 | #define pxa27x_keypad_suspend NULL | ||
425 | #define pxa27x_keypad_resume NULL | ||
426 | #endif | ||
427 | 440 | ||
428 | #define res_size(res) ((res)->end - (res)->start + 1) | 441 | static const struct dev_pm_ops pxa27x_keypad_pm_ops = { |
442 | .suspend = pxa27x_keypad_suspend, | ||
443 | .resume = pxa27x_keypad_resume, | ||
444 | }; | ||
445 | #endif | ||
429 | 446 | ||
430 | static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) | 447 | static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) |
431 | { | 448 | { |
449 | struct pxa27x_keypad_platform_data *pdata = pdev->dev.platform_data; | ||
432 | struct pxa27x_keypad *keypad; | 450 | struct pxa27x_keypad *keypad; |
433 | struct input_dev *input_dev; | 451 | struct input_dev *input_dev; |
434 | struct resource *res; | 452 | struct resource *res; |
435 | int irq, error; | 453 | int irq, error; |
436 | 454 | ||
437 | keypad = kzalloc(sizeof(struct pxa27x_keypad), GFP_KERNEL); | 455 | if (pdata == NULL) { |
438 | if (keypad == NULL) { | ||
439 | dev_err(&pdev->dev, "failed to allocate driver data\n"); | ||
440 | return -ENOMEM; | ||
441 | } | ||
442 | |||
443 | keypad->pdata = pdev->dev.platform_data; | ||
444 | if (keypad->pdata == NULL) { | ||
445 | dev_err(&pdev->dev, "no platform data defined\n"); | 456 | dev_err(&pdev->dev, "no platform data defined\n"); |
446 | error = -EINVAL; | 457 | return -EINVAL; |
447 | goto failed_free; | ||
448 | } | 458 | } |
449 | 459 | ||
450 | irq = platform_get_irq(pdev, 0); | 460 | irq = platform_get_irq(pdev, 0); |
451 | if (irq < 0) { | 461 | if (irq < 0) { |
452 | dev_err(&pdev->dev, "failed to get keypad irq\n"); | 462 | dev_err(&pdev->dev, "failed to get keypad irq\n"); |
453 | error = -ENXIO; | 463 | return -ENXIO; |
454 | goto failed_free; | ||
455 | } | 464 | } |
456 | 465 | ||
457 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 466 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
458 | if (res == NULL) { | 467 | if (res == NULL) { |
459 | dev_err(&pdev->dev, "failed to get I/O memory\n"); | 468 | dev_err(&pdev->dev, "failed to get I/O memory\n"); |
460 | error = -ENXIO; | 469 | return -ENXIO; |
470 | } | ||
471 | |||
472 | keypad = kzalloc(sizeof(struct pxa27x_keypad), GFP_KERNEL); | ||
473 | input_dev = input_allocate_device(); | ||
474 | if (!keypad || !input_dev) { | ||
475 | dev_err(&pdev->dev, "failed to allocate memory\n"); | ||
476 | error = -ENOMEM; | ||
461 | goto failed_free; | 477 | goto failed_free; |
462 | } | 478 | } |
463 | 479 | ||
464 | res = request_mem_region(res->start, res_size(res), pdev->name); | 480 | keypad->pdata = pdata; |
481 | keypad->input_dev = input_dev; | ||
482 | keypad->irq = irq; | ||
483 | |||
484 | res = request_mem_region(res->start, resource_size(res), pdev->name); | ||
465 | if (res == NULL) { | 485 | if (res == NULL) { |
466 | dev_err(&pdev->dev, "failed to request I/O memory\n"); | 486 | dev_err(&pdev->dev, "failed to request I/O memory\n"); |
467 | error = -EBUSY; | 487 | error = -EBUSY; |
468 | goto failed_free; | 488 | goto failed_free; |
469 | } | 489 | } |
470 | 490 | ||
471 | keypad->mmio_base = ioremap(res->start, res_size(res)); | 491 | keypad->mmio_base = ioremap(res->start, resource_size(res)); |
472 | if (keypad->mmio_base == NULL) { | 492 | if (keypad->mmio_base == NULL) { |
473 | dev_err(&pdev->dev, "failed to remap I/O memory\n"); | 493 | dev_err(&pdev->dev, "failed to remap I/O memory\n"); |
474 | error = -ENXIO; | 494 | error = -ENXIO; |
@@ -482,43 +502,35 @@ static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) | |||
482 | goto failed_free_io; | 502 | goto failed_free_io; |
483 | } | 503 | } |
484 | 504 | ||
485 | /* Create and register the input driver. */ | ||
486 | input_dev = input_allocate_device(); | ||
487 | if (!input_dev) { | ||
488 | dev_err(&pdev->dev, "failed to allocate input device\n"); | ||
489 | error = -ENOMEM; | ||
490 | goto failed_put_clk; | ||
491 | } | ||
492 | |||
493 | input_dev->name = pdev->name; | 505 | input_dev->name = pdev->name; |
494 | input_dev->id.bustype = BUS_HOST; | 506 | input_dev->id.bustype = BUS_HOST; |
495 | input_dev->open = pxa27x_keypad_open; | 507 | input_dev->open = pxa27x_keypad_open; |
496 | input_dev->close = pxa27x_keypad_close; | 508 | input_dev->close = pxa27x_keypad_close; |
497 | input_dev->dev.parent = &pdev->dev; | 509 | input_dev->dev.parent = &pdev->dev; |
498 | 510 | ||
499 | keypad->input_dev = input_dev; | 511 | input_dev->keycode = keypad->keycodes; |
512 | input_dev->keycodesize = sizeof(keypad->keycodes[0]); | ||
513 | input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes); | ||
514 | |||
500 | input_set_drvdata(input_dev, keypad); | 515 | input_set_drvdata(input_dev, keypad); |
501 | 516 | ||
502 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); | 517 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
503 | if ((keypad->pdata->enable_rotary0 && | 518 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); |
504 | keypad->pdata->rotary0_rel_code) || | ||
505 | (keypad->pdata->enable_rotary1 && | ||
506 | keypad->pdata->rotary1_rel_code)) { | ||
507 | input_dev->evbit[0] |= BIT_MASK(EV_REL); | ||
508 | } | ||
509 | 519 | ||
510 | pxa27x_keypad_build_keycode(keypad); | 520 | pxa27x_keypad_build_keycode(keypad); |
511 | platform_set_drvdata(pdev, keypad); | 521 | |
522 | if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) || | ||
523 | (pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) { | ||
524 | input_dev->evbit[0] |= BIT_MASK(EV_REL); | ||
525 | } | ||
512 | 526 | ||
513 | error = request_irq(irq, pxa27x_keypad_irq_handler, IRQF_DISABLED, | 527 | error = request_irq(irq, pxa27x_keypad_irq_handler, IRQF_DISABLED, |
514 | pdev->name, keypad); | 528 | pdev->name, keypad); |
515 | if (error) { | 529 | if (error) { |
516 | dev_err(&pdev->dev, "failed to request IRQ\n"); | 530 | dev_err(&pdev->dev, "failed to request IRQ\n"); |
517 | goto failed_free_dev; | 531 | goto failed_put_clk; |
518 | } | 532 | } |
519 | 533 | ||
520 | keypad->irq = irq; | ||
521 | |||
522 | /* Register the input device */ | 534 | /* Register the input device */ |
523 | error = input_register_device(input_dev); | 535 | error = input_register_device(input_dev); |
524 | if (error) { | 536 | if (error) { |
@@ -526,22 +538,21 @@ static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) | |||
526 | goto failed_free_irq; | 538 | goto failed_free_irq; |
527 | } | 539 | } |
528 | 540 | ||
541 | platform_set_drvdata(pdev, keypad); | ||
529 | device_init_wakeup(&pdev->dev, 1); | 542 | device_init_wakeup(&pdev->dev, 1); |
530 | 543 | ||
531 | return 0; | 544 | return 0; |
532 | 545 | ||
533 | failed_free_irq: | 546 | failed_free_irq: |
534 | free_irq(irq, pdev); | 547 | free_irq(irq, pdev); |
535 | platform_set_drvdata(pdev, NULL); | ||
536 | failed_free_dev: | ||
537 | input_free_device(input_dev); | ||
538 | failed_put_clk: | 548 | failed_put_clk: |
539 | clk_put(keypad->clk); | 549 | clk_put(keypad->clk); |
540 | failed_free_io: | 550 | failed_free_io: |
541 | iounmap(keypad->mmio_base); | 551 | iounmap(keypad->mmio_base); |
542 | failed_free_mem: | 552 | failed_free_mem: |
543 | release_mem_region(res->start, res_size(res)); | 553 | release_mem_region(res->start, resource_size(res)); |
544 | failed_free: | 554 | failed_free: |
555 | input_free_device(input_dev); | ||
545 | kfree(keypad); | 556 | kfree(keypad); |
546 | return error; | 557 | return error; |
547 | } | 558 | } |
@@ -552,8 +563,6 @@ static int __devexit pxa27x_keypad_remove(struct platform_device *pdev) | |||
552 | struct resource *res; | 563 | struct resource *res; |
553 | 564 | ||
554 | free_irq(keypad->irq, pdev); | 565 | free_irq(keypad->irq, pdev); |
555 | |||
556 | clk_disable(keypad->clk); | ||
557 | clk_put(keypad->clk); | 566 | clk_put(keypad->clk); |
558 | 567 | ||
559 | input_unregister_device(keypad->input_dev); | 568 | input_unregister_device(keypad->input_dev); |
@@ -562,10 +571,11 @@ static int __devexit pxa27x_keypad_remove(struct platform_device *pdev) | |||
562 | iounmap(keypad->mmio_base); | 571 | iounmap(keypad->mmio_base); |
563 | 572 | ||
564 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 573 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
565 | release_mem_region(res->start, res_size(res)); | 574 | release_mem_region(res->start, resource_size(res)); |
566 | 575 | ||
567 | platform_set_drvdata(pdev, NULL); | 576 | platform_set_drvdata(pdev, NULL); |
568 | kfree(keypad); | 577 | kfree(keypad); |
578 | |||
569 | return 0; | 579 | return 0; |
570 | } | 580 | } |
571 | 581 | ||
@@ -575,11 +585,12 @@ MODULE_ALIAS("platform:pxa27x-keypad"); | |||
575 | static struct platform_driver pxa27x_keypad_driver = { | 585 | static struct platform_driver pxa27x_keypad_driver = { |
576 | .probe = pxa27x_keypad_probe, | 586 | .probe = pxa27x_keypad_probe, |
577 | .remove = __devexit_p(pxa27x_keypad_remove), | 587 | .remove = __devexit_p(pxa27x_keypad_remove), |
578 | .suspend = pxa27x_keypad_suspend, | ||
579 | .resume = pxa27x_keypad_resume, | ||
580 | .driver = { | 588 | .driver = { |
581 | .name = "pxa27x-keypad", | 589 | .name = "pxa27x-keypad", |
582 | .owner = THIS_MODULE, | 590 | .owner = THIS_MODULE, |
591 | #ifdef CONFIG_PM | ||
592 | .pm = &pxa27x_keypad_pm_ops, | ||
593 | #endif | ||
583 | }, | 594 | }, |
584 | }; | 595 | }; |
585 | 596 | ||