18 #include <linux/input.h>
19 #include <linux/slab.h>
21 #include <linux/module.h>
26 #define SKE_KPMLT (0x1 << 6)
27 #define SKE_KPCN (0x7 << 3)
28 #define SKE_KPASEN (0x1 << 2)
29 #define SKE_KPASON (0x1 << 7)
32 #define SKE_KPIMA (0x1 << 2)
35 #define SKE_KPICS (0x1 << 3)
36 #define SKE_KPICA (0x1 << 2)
39 #define SKE_KPRISA (0x1 << 2)
41 #define SKE_KEYPAD_ROW_SHIFT 3
42 #define SKE_KPD_NUM_ROWS 8
43 #define SKE_KPD_NUM_COLS 8
51 #define SKE_NUM_ASRX_REGISTERS (4)
52 #define KEY_PRESSED_DELAY 10
112 value = value & 0xff;
113 value |= ((keypad->
board->debounce_ms * 32000)/32768) << 8;
124 value = (keypad->
board->kcol - 1) << 3;
152 status &= ~(1 <<
pos);
159 input_report_key(input, keypad->
keymap[
code], key_pressed);
162 }
while (num_of_rows);
165 static void ske_keypad_read_data(
struct ske_keypad *keypad)
184 status = ske_asr & 0xff;
187 ske_keypad_report(keypad, status, col);
189 status = (ske_asr & 0xff00) >> 8;
192 ske_keypad_report(keypad, status, col);
200 int timeout = keypad->
board->debounce_ms;
210 ske_keypad_read_data(keypad);
226 struct input_dev *
input;
232 dev_err(&pdev->
dev,
"invalid keypad platform data\n");
238 dev_err(&pdev->
dev,
"failed to get keypad irq\n");
244 dev_err(&pdev->
dev,
"missing platform resources\n");
249 input = input_allocate_device();
250 if (!keypad || !input) {
251 dev_err(&pdev->
dev,
"failed to allocate keypad memory\n");
257 keypad->
board = plat;
262 dev_err(&pdev->
dev,
"failed to request I/O memory\n");
269 dev_err(&pdev->
dev,
"failed to remap I/O memory\n");
271 goto err_free_mem_region;
275 if (IS_ERR(keypad->
clk)) {
277 error = PTR_ERR(keypad->
clk);
282 input->name =
"ux500-ske-keypad";
283 input->dev.parent = &pdev->
dev;
289 dev_err(&pdev->
dev,
"Failed to build keymap\n");
300 if (keypad->
board->init)
301 keypad->
board->init();
303 error = ske_keypad_chip_init(keypad);
305 dev_err(&pdev->
dev,
"unable to init keypad hardware\n");
306 goto err_clk_disable;
312 dev_err(&pdev->
dev,
"allocate irq %d failed\n", keypad->
irq);
313 goto err_clk_disable;
316 error = input_register_device(input);
319 "unable to register input device: %d\n", error);
326 platform_set_drvdata(pdev, keypad);
340 input_free_device(input);
347 struct ske_keypad *keypad = platform_get_drvdata(pdev);
352 input_unregister_device(keypad->
input);
357 if (keypad->
board->exit)
358 keypad->
board->exit();
367 #ifdef CONFIG_PM_SLEEP
368 static int ske_keypad_suspend(
struct device *
dev)
371 struct ske_keypad *keypad = platform_get_drvdata(pdev);
374 if (device_may_wakeup(dev))
375 enable_irq_wake(irq);
382 static int ske_keypad_resume(
struct device *dev)
385 struct ske_keypad *keypad = platform_get_drvdata(pdev);
388 if (device_may_wakeup(dev))
389 disable_irq_wake(irq);
398 ske_keypad_suspend, ske_keypad_resume);
402 .name =
"nmk-ske-keypad",
404 .pm = &ske_keypad_dev_pm_ops,
409 static int __init ske_keypad_init(
void)
415 static void __exit ske_keypad_exit(
void)