aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r--drivers/input/keyboard/Kconfig32
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/adp5588-keys.c1
-rw-r--r--drivers/input/keyboard/atkbd.c2
-rw-r--r--drivers/input/keyboard/ep93xx_keypad.c44
-rw-r--r--drivers/input/keyboard/hil_kbd.c13
-rw-r--r--drivers/input/keyboard/imx_keypad.c17
-rw-r--r--drivers/input/keyboard/lkkbd.c17
-rw-r--r--drivers/input/keyboard/lm8333.c235
-rw-r--r--drivers/input/keyboard/matrix_keypad.c99
-rw-r--r--drivers/input/keyboard/newtonkbd.c13
-rw-r--r--drivers/input/keyboard/nomadik-ske-keypad.c20
-rw-r--r--drivers/input/keyboard/omap-keypad.c20
-rw-r--r--drivers/input/keyboard/omap4-keypad.c133
-rw-r--r--drivers/input/keyboard/pmic8xxx-keypad.c20
-rw-r--r--drivers/input/keyboard/samsung-keypad.c20
-rw-r--r--drivers/input/keyboard/spear-keyboard.c92
-rw-r--r--drivers/input/keyboard/stmpe-keypad.c16
-rw-r--r--drivers/input/keyboard/stowaway.c13
-rw-r--r--drivers/input/keyboard/sunkbd.c17
-rw-r--r--drivers/input/keyboard/tc3589x-keypad.c41
-rw-r--r--drivers/input/keyboard/tca8418_keypad.c15
-rw-r--r--drivers/input/keyboard/tegra-kbc.c68
-rw-r--r--drivers/input/keyboard/tnetv107x-keypad.c21
-rw-r--r--drivers/input/keyboard/twl4030_keypad.c25
-rw-r--r--drivers/input/keyboard/w90p910_keypad.c27
-rw-r--r--drivers/input/keyboard/xtkbd.c13
27 files changed, 667 insertions, 368 deletions
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index f354813a13e8..c0e11ecc646f 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -166,6 +166,7 @@ config KEYBOARD_LKKBD
166config KEYBOARD_EP93XX 166config KEYBOARD_EP93XX
167 tristate "EP93xx Matrix Keypad support" 167 tristate "EP93xx Matrix Keypad support"
168 depends on ARCH_EP93XX 168 depends on ARCH_EP93XX
169 select INPUT_MATRIXKMAP
169 help 170 help
170 Say Y here to enable the matrix keypad on the Cirrus EP93XX. 171 Say Y here to enable the matrix keypad on the Cirrus EP93XX.
171 172
@@ -224,6 +225,7 @@ config KEYBOARD_TCA6416
224config KEYBOARD_TCA8418 225config KEYBOARD_TCA8418
225 tristate "TCA8418 Keypad Support" 226 tristate "TCA8418 Keypad Support"
226 depends on I2C 227 depends on I2C
228 select INPUT_MATRIXKMAP
227 help 229 help
228 This driver implements basic keypad functionality 230 This driver implements basic keypad functionality
229 for keys connected through TCA8418 keypad decoder. 231 for keys connected through TCA8418 keypad decoder.
@@ -240,6 +242,7 @@ config KEYBOARD_TCA8418
240config KEYBOARD_MATRIX 242config KEYBOARD_MATRIX
241 tristate "GPIO driven matrix keypad support" 243 tristate "GPIO driven matrix keypad support"
242 depends on GENERIC_GPIO 244 depends on GENERIC_GPIO
245 select INPUT_MATRIXKMAP
243 help 246 help
244 Enable support for GPIO driven matrix keypad. 247 Enable support for GPIO driven matrix keypad.
245 248
@@ -309,6 +312,17 @@ config KEYBOARD_LM8323
309 To compile this driver as a module, choose M here: the 312 To compile this driver as a module, choose M here: the
310 module will be called lm8323. 313 module will be called lm8323.
311 314
315config KEYBOARD_LM8333
316 tristate "LM8333 keypad chip"
317 depends on I2C
318 select INPUT_MATRIXKMAP
319 help
320 If you say yes here you get support for the National Semiconductor
321 LM8333 keypad controller.
322
323 To compile this driver as a module, choose M here: the
324 module will be called lm8333.
325
312config KEYBOARD_LOCOMO 326config KEYBOARD_LOCOMO
313 tristate "LoCoMo Keyboard Support" 327 tristate "LoCoMo Keyboard Support"
314 depends on SHARP_LOCOMO 328 depends on SHARP_LOCOMO
@@ -366,6 +380,7 @@ config KEYBOARD_MPR121
366config KEYBOARD_IMX 380config KEYBOARD_IMX
367 tristate "IMX keypad support" 381 tristate "IMX keypad support"
368 depends on ARCH_MXC 382 depends on ARCH_MXC
383 select INPUT_MATRIXKMAP
369 help 384 help
370 Enable support for IMX keypad port. 385 Enable support for IMX keypad port.
371 386
@@ -384,6 +399,7 @@ config KEYBOARD_NEWTON
384config KEYBOARD_NOMADIK 399config KEYBOARD_NOMADIK
385 tristate "ST-Ericsson Nomadik SKE keyboard" 400 tristate "ST-Ericsson Nomadik SKE keyboard"
386 depends on PLAT_NOMADIK 401 depends on PLAT_NOMADIK
402 select INPUT_MATRIXKMAP
387 help 403 help
388 Say Y here if you want to use a keypad provided on the SKE controller 404 Say Y here if you want to use a keypad provided on the SKE controller
389 used on the Ux500 and Nomadik platforms 405 used on the Ux500 and Nomadik platforms
@@ -394,7 +410,7 @@ config KEYBOARD_NOMADIK
394config KEYBOARD_TEGRA 410config KEYBOARD_TEGRA
395 tristate "NVIDIA Tegra internal matrix keyboard controller support" 411 tristate "NVIDIA Tegra internal matrix keyboard controller support"
396 depends on ARCH_TEGRA 412 depends on ARCH_TEGRA
397 select INPUT_OF_MATRIX_KEYMAP if USE_OF 413 select INPUT_MATRIXKMAP
398 help 414 help
399 Say Y here if you want to use a matrix keyboard connected directly 415 Say Y here if you want to use a matrix keyboard connected directly
400 to the internal keyboard controller on Tegra SoCs. 416 to the internal keyboard controller on Tegra SoCs.
@@ -432,6 +448,7 @@ config KEYBOARD_PXA930_ROTARY
432config KEYBOARD_PMIC8XXX 448config KEYBOARD_PMIC8XXX
433 tristate "Qualcomm PMIC8XXX keypad support" 449 tristate "Qualcomm PMIC8XXX keypad support"
434 depends on MFD_PM8XXX 450 depends on MFD_PM8XXX
451 select INPUT_MATRIXKMAP
435 help 452 help
436 Say Y here if you want to enable the driver for the PMIC8XXX 453 Say Y here if you want to enable the driver for the PMIC8XXX
437 keypad provided as a reference design from Qualcomm. This is intended 454 keypad provided as a reference design from Qualcomm. This is intended
@@ -443,6 +460,7 @@ config KEYBOARD_PMIC8XXX
443config KEYBOARD_SAMSUNG 460config KEYBOARD_SAMSUNG
444 tristate "Samsung keypad support" 461 tristate "Samsung keypad support"
445 depends on HAVE_CLK 462 depends on HAVE_CLK
463 select INPUT_MATRIXKMAP
446 help 464 help
447 Say Y here if you want to use the keypad on your Samsung mobile 465 Say Y here if you want to use the keypad on your Samsung mobile
448 device. 466 device.
@@ -485,6 +503,7 @@ config KEYBOARD_SH_KEYSC
485config KEYBOARD_STMPE 503config KEYBOARD_STMPE
486 tristate "STMPE keypad support" 504 tristate "STMPE keypad support"
487 depends on MFD_STMPE 505 depends on MFD_STMPE
506 select INPUT_MATRIXKMAP
488 help 507 help
489 Say Y here if you want to use the keypad controller on STMPE I/O 508 Say Y here if you want to use the keypad controller on STMPE I/O
490 expanders. 509 expanders.
@@ -505,6 +524,7 @@ config KEYBOARD_DAVINCI
505config KEYBOARD_OMAP 524config KEYBOARD_OMAP
506 tristate "TI OMAP keypad support" 525 tristate "TI OMAP keypad support"
507 depends on (ARCH_OMAP1 || ARCH_OMAP2) 526 depends on (ARCH_OMAP1 || ARCH_OMAP2)
527 select INPUT_MATRIXKMAP
508 help 528 help
509 Say Y here if you want to use the OMAP keypad. 529 Say Y here if you want to use the OMAP keypad.
510 530
@@ -512,9 +532,10 @@ config KEYBOARD_OMAP
512 module will be called omap-keypad. 532 module will be called omap-keypad.
513 533
514config KEYBOARD_OMAP4 534config KEYBOARD_OMAP4
515 tristate "TI OMAP4 keypad support" 535 tristate "TI OMAP4+ keypad support"
536 select INPUT_MATRIXKMAP
516 help 537 help
517 Say Y here if you want to use the OMAP4 keypad. 538 Say Y here if you want to use the OMAP4+ keypad.
518 539
519 To compile this driver as a module, choose M here: the 540 To compile this driver as a module, choose M here: the
520 module will be called omap4-keypad. 541 module will be called omap4-keypad.
@@ -522,6 +543,7 @@ config KEYBOARD_OMAP4
522config KEYBOARD_SPEAR 543config KEYBOARD_SPEAR
523 tristate "ST SPEAR keyboard support" 544 tristate "ST SPEAR keyboard support"
524 depends on PLAT_SPEAR 545 depends on PLAT_SPEAR
546 select INPUT_MATRIXKMAP
525 help 547 help
526 Say Y here if you want to use the SPEAR keyboard. 548 Say Y here if you want to use the SPEAR keyboard.
527 549
@@ -531,6 +553,7 @@ config KEYBOARD_SPEAR
531config KEYBOARD_TC3589X 553config KEYBOARD_TC3589X
532 tristate "TC3589X Keypad support" 554 tristate "TC3589X Keypad support"
533 depends on MFD_TC3589X 555 depends on MFD_TC3589X
556 select INPUT_MATRIXKMAP
534 help 557 help
535 Say Y here if you want to use the keypad controller on 558 Say Y here if you want to use the keypad controller on
536 TC35892/3 I/O expander. 559 TC35892/3 I/O expander.
@@ -541,6 +564,7 @@ config KEYBOARD_TC3589X
541config KEYBOARD_TNETV107X 564config KEYBOARD_TNETV107X
542 tristate "TI TNETV107X keypad support" 565 tristate "TI TNETV107X keypad support"
543 depends on ARCH_DAVINCI_TNETV107X 566 depends on ARCH_DAVINCI_TNETV107X
567 select INPUT_MATRIXKMAP
544 help 568 help
545 Say Y here if you want to use the TNETV107X keypad. 569 Say Y here if you want to use the TNETV107X keypad.
546 570
@@ -550,6 +574,7 @@ config KEYBOARD_TNETV107X
550config KEYBOARD_TWL4030 574config KEYBOARD_TWL4030
551 tristate "TI TWL4030/TWL5030/TPS659x0 keypad support" 575 tristate "TI TWL4030/TWL5030/TPS659x0 keypad support"
552 depends on TWL4030_CORE 576 depends on TWL4030_CORE
577 select INPUT_MATRIXKMAP
553 help 578 help
554 Say Y here if your board use the keypad controller on 579 Say Y here if your board use the keypad controller on
555 TWL4030 family chips. It's safe to say enable this 580 TWL4030 family chips. It's safe to say enable this
@@ -573,6 +598,7 @@ config KEYBOARD_XTKBD
573config KEYBOARD_W90P910 598config KEYBOARD_W90P910
574 tristate "W90P910 Matrix Keypad support" 599 tristate "W90P910 Matrix Keypad support"
575 depends on ARCH_W90X900 600 depends on ARCH_W90X900
601 select INPUT_MATRIXKMAP
576 help 602 help
577 Say Y here to enable the matrix keypad on evaluation board 603 Say Y here to enable the matrix keypad on evaluation board
578 based on W90P910. 604 based on W90P910.
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index df7061f12918..b03b02456a82 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o
24obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o 24obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o
25obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o 25obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o
26obj-$(CONFIG_KEYBOARD_LM8323) += lm8323.o 26obj-$(CONFIG_KEYBOARD_LM8323) += lm8323.o
27obj-$(CONFIG_KEYBOARD_LM8333) += lm8333.o
27obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o 28obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o
28obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o 29obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o
29obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o 30obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o
diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
index 39ebffac207e..b083bf10f139 100644
--- a/drivers/input/keyboard/adp5588-keys.c
+++ b/drivers/input/keyboard/adp5588-keys.c
@@ -197,6 +197,7 @@ static int __devinit adp5588_gpio_add(struct adp5588_kpad *kpad)
197 kpad->gc.base = gpio_data->gpio_start; 197 kpad->gc.base = gpio_data->gpio_start;
198 kpad->gc.label = kpad->client->name; 198 kpad->gc.label = kpad->client->name;
199 kpad->gc.owner = THIS_MODULE; 199 kpad->gc.owner = THIS_MODULE;
200 kpad->gc.names = gpio_data->names;
200 201
201 mutex_init(&kpad->gpio_lock); 202 mutex_init(&kpad->gpio_lock);
202 203
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index e05a2e7073c6..add5ffd9fe26 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -433,7 +433,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
433 if (printk_ratelimit()) 433 if (printk_ratelimit())
434 dev_warn(&serio->dev, 434 dev_warn(&serio->dev,
435 "Spurious %s on %s. " 435 "Spurious %s on %s. "
436 "Some program might be trying access hardware directly.\n", 436 "Some program might be trying to access hardware directly.\n",
437 data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys); 437 data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys);
438 goto out; 438 goto out;
439 case ATKBD_RET_ERR: 439 case ATKBD_RET_ERR:
diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
index 0ba69f3fcb52..c46fc8185469 100644
--- a/drivers/input/keyboard/ep93xx_keypad.c
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -182,16 +182,10 @@ static void ep93xx_keypad_close(struct input_dev *pdev)
182} 182}
183 183
184 184
185#ifdef CONFIG_PM 185#ifdef CONFIG_PM_SLEEP
186/* 186static int ep93xx_keypad_suspend(struct device *dev)
187 * NOTE: I don't know if this is correct, or will work on the ep93xx.
188 *
189 * None of the existing ep93xx drivers have power management support.
190 * But, this is basically what the pxa27x_keypad driver does.
191 */
192static int ep93xx_keypad_suspend(struct platform_device *pdev,
193 pm_message_t state)
194{ 187{
188 struct platform_device *pdev = to_platform_device(dev);
195 struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); 189 struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
196 struct input_dev *input_dev = keypad->input_dev; 190 struct input_dev *input_dev = keypad->input_dev;
197 191
@@ -210,8 +204,9 @@ static int ep93xx_keypad_suspend(struct platform_device *pdev,
210 return 0; 204 return 0;
211} 205}
212 206
213static int ep93xx_keypad_resume(struct platform_device *pdev) 207static int ep93xx_keypad_resume(struct device *dev)
214{ 208{
209 struct platform_device *pdev = to_platform_device(dev);
215 struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); 210 struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
216 struct input_dev *input_dev = keypad->input_dev; 211 struct input_dev *input_dev = keypad->input_dev;
217 212
@@ -232,10 +227,10 @@ static int ep93xx_keypad_resume(struct platform_device *pdev)
232 227
233 return 0; 228 return 0;
234} 229}
235#else /* !CONFIG_PM */ 230#endif
236#define ep93xx_keypad_suspend NULL 231
237#define ep93xx_keypad_resume NULL 232static SIMPLE_DEV_PM_OPS(ep93xx_keypad_pm_ops,
238#endif /* !CONFIG_PM */ 233 ep93xx_keypad_suspend, ep93xx_keypad_resume);
239 234
240static int __devinit ep93xx_keypad_probe(struct platform_device *pdev) 235static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
241{ 236{
@@ -308,19 +303,16 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
308 input_dev->open = ep93xx_keypad_open; 303 input_dev->open = ep93xx_keypad_open;
309 input_dev->close = ep93xx_keypad_close; 304 input_dev->close = ep93xx_keypad_close;
310 input_dev->dev.parent = &pdev->dev; 305 input_dev->dev.parent = &pdev->dev;
311 input_dev->keycode = keypad->keycodes;
312 input_dev->keycodesize = sizeof(keypad->keycodes[0]);
313 input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
314 306
315 input_set_drvdata(input_dev, keypad); 307 err = matrix_keypad_build_keymap(keymap_data, NULL,
308 EP93XX_MATRIX_ROWS, EP93XX_MATRIX_COLS,
309 keypad->keycodes, input_dev);
310 if (err)
311 goto failed_free_dev;
316 312
317 input_dev->evbit[0] = BIT_MASK(EV_KEY);
318 if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT) 313 if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT)
319 input_dev->evbit[0] |= BIT_MASK(EV_REP); 314 __set_bit(EV_REP, input_dev->evbit);
320 315 input_set_drvdata(input_dev, keypad);
321 matrix_keypad_build_keymap(keymap_data, 3,
322 input_dev->keycode, input_dev->keybit);
323 platform_set_drvdata(pdev, keypad);
324 316
325 err = request_irq(keypad->irq, ep93xx_keypad_irq_handler, 317 err = request_irq(keypad->irq, ep93xx_keypad_irq_handler,
326 0, pdev->name, keypad); 318 0, pdev->name, keypad);
@@ -331,6 +323,7 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
331 if (err) 323 if (err)
332 goto failed_free_irq; 324 goto failed_free_irq;
333 325
326 platform_set_drvdata(pdev, keypad);
334 device_init_wakeup(&pdev->dev, 1); 327 device_init_wakeup(&pdev->dev, 1);
335 328
336 return 0; 329 return 0;
@@ -384,11 +377,10 @@ static struct platform_driver ep93xx_keypad_driver = {
384 .driver = { 377 .driver = {
385 .name = "ep93xx-keypad", 378 .name = "ep93xx-keypad",
386 .owner = THIS_MODULE, 379 .owner = THIS_MODULE,
380 .pm = &ep93xx_keypad_pm_ops,
387 }, 381 },
388 .probe = ep93xx_keypad_probe, 382 .probe = ep93xx_keypad_probe,
389 .remove = __devexit_p(ep93xx_keypad_remove), 383 .remove = __devexit_p(ep93xx_keypad_remove),
390 .suspend = ep93xx_keypad_suspend,
391 .resume = ep93xx_keypad_resume,
392}; 384};
393module_platform_driver(ep93xx_keypad_driver); 385module_platform_driver(ep93xx_keypad_driver);
394 386
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c
index fed31e0947a1..589e3c258f3f 100644
--- a/drivers/input/keyboard/hil_kbd.c
+++ b/drivers/input/keyboard/hil_kbd.c
@@ -583,15 +583,4 @@ static struct serio_driver hil_serio_drv = {
583 .interrupt = hil_dev_interrupt 583 .interrupt = hil_dev_interrupt
584}; 584};
585 585
586static int __init hil_dev_init(void) 586module_serio_driver(hil_serio_drv);
587{
588 return serio_register_driver(&hil_serio_drv);
589}
590
591static void __exit hil_dev_exit(void)
592{
593 serio_unregister_driver(&hil_serio_drv);
594}
595
596module_init(hil_dev_init);
597module_exit(hil_dev_exit);
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index fb87b3bcadb9..6ee7421e2321 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -481,7 +481,7 @@ static int __devinit imx_keypad_probe(struct platform_device *pdev)
481 } 481 }
482 482
483 if (keypad->rows_en_mask > ((1 << MAX_MATRIX_KEY_ROWS) - 1) || 483 if (keypad->rows_en_mask > ((1 << MAX_MATRIX_KEY_ROWS) - 1) ||
484 keypad->cols_en_mask > ((1 << MAX_MATRIX_KEY_COLS) - 1)) { 484 keypad->cols_en_mask > ((1 << MAX_MATRIX_KEY_COLS) - 1)) {
485 dev_err(&pdev->dev, 485 dev_err(&pdev->dev,
486 "invalid key data (too many rows or colums)\n"); 486 "invalid key data (too many rows or colums)\n");
487 error = -EINVAL; 487 error = -EINVAL;
@@ -496,14 +496,17 @@ static int __devinit imx_keypad_probe(struct platform_device *pdev)
496 input_dev->dev.parent = &pdev->dev; 496 input_dev->dev.parent = &pdev->dev;
497 input_dev->open = imx_keypad_open; 497 input_dev->open = imx_keypad_open;
498 input_dev->close = imx_keypad_close; 498 input_dev->close = imx_keypad_close;
499 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
500 input_dev->keycode = keypad->keycodes;
501 input_dev->keycodesize = sizeof(keypad->keycodes[0]);
502 input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
503 499
504 matrix_keypad_build_keymap(keymap_data, MATRIX_ROW_SHIFT, 500 error = matrix_keypad_build_keymap(keymap_data, NULL,
505 keypad->keycodes, input_dev->keybit); 501 MAX_MATRIX_KEY_ROWS,
502 MAX_MATRIX_KEY_COLS,
503 keypad->keycodes, input_dev);
504 if (error) {
505 dev_err(&pdev->dev, "failed to build keymap\n");
506 goto failed_clock_put;
507 }
506 508
509 __set_bit(EV_REP, input_dev->evbit);
507 input_set_capability(input_dev, EV_MSC, MSC_SCAN); 510 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
508 input_set_drvdata(input_dev, keypad); 511 input_set_drvdata(input_dev, keypad);
509 512
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index fa9bb6d235e2..fc0a63c2f278 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -731,19 +731,4 @@ static struct serio_driver lkkbd_drv = {
731 .interrupt = lkkbd_interrupt, 731 .interrupt = lkkbd_interrupt,
732}; 732};
733 733
734/* 734module_serio_driver(lkkbd_drv);
735 * The functions for insering/removing us as a module.
736 */
737static int __init lkkbd_init(void)
738{
739 return serio_register_driver(&lkkbd_drv);
740}
741
742static void __exit lkkbd_exit(void)
743{
744 serio_unregister_driver(&lkkbd_drv);
745}
746
747module_init(lkkbd_init);
748module_exit(lkkbd_exit);
749
diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard/lm8333.c
new file mode 100644
index 000000000000..ca168a6679de
--- /dev/null
+++ b/drivers/input/keyboard/lm8333.c
@@ -0,0 +1,235 @@
1/*
2 * LM8333 keypad driver
3 * Copyright (C) 2012 Wolfram Sang, Pengutronix <w.sang@pengutronix.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License.
8 */
9
10#include <linux/module.h>
11#include <linux/slab.h>
12#include <linux/irq.h>
13#include <linux/i2c.h>
14#include <linux/interrupt.h>
15#include <linux/input/matrix_keypad.h>
16#include <linux/input/lm8333.h>
17
18#define LM8333_FIFO_READ 0x20
19#define LM8333_DEBOUNCE 0x22
20#define LM8333_READ_INT 0xD0
21#define LM8333_ACTIVE 0xE4
22#define LM8333_READ_ERROR 0xF0
23
24#define LM8333_KEYPAD_IRQ (1 << 0)
25#define LM8333_ERROR_IRQ (1 << 3)
26
27#define LM8333_ERROR_KEYOVR 0x04
28#define LM8333_ERROR_FIFOOVR 0x40
29
30#define LM8333_FIFO_TRANSFER_SIZE 16
31
32#define LM8333_NUM_ROWS 8
33#define LM8333_NUM_COLS 16
34#define LM8333_ROW_SHIFT 4
35
36struct lm8333 {
37 struct i2c_client *client;
38 struct input_dev *input;
39 unsigned short keycodes[LM8333_NUM_ROWS << LM8333_ROW_SHIFT];
40};
41
42/* The accessors try twice because the first access may be needed for wakeup */
43#define LM8333_READ_RETRIES 2
44
45int lm8333_read8(struct lm8333 *lm8333, u8 cmd)
46{
47 int retries = 0, ret;
48
49 do {
50 ret = i2c_smbus_read_byte_data(lm8333->client, cmd);
51 } while (ret < 0 && retries++ < LM8333_READ_RETRIES);
52
53 return ret;
54}
55
56int lm8333_write8(struct lm8333 *lm8333, u8 cmd, u8 val)
57{
58 int retries = 0, ret;
59
60 do {
61 ret = i2c_smbus_write_byte_data(lm8333->client, cmd, val);
62 } while (ret < 0 && retries++ < LM8333_READ_RETRIES);
63
64 return ret;
65}
66
67int lm8333_read_block(struct lm8333 *lm8333, u8 cmd, u8 len, u8 *buf)
68{
69 int retries = 0, ret;
70
71 do {
72 ret = i2c_smbus_read_i2c_block_data(lm8333->client,
73 cmd, len, buf);
74 } while (ret < 0 && retries++ < LM8333_READ_RETRIES);
75
76 return ret;
77}
78
79static void lm8333_key_handler(struct lm8333 *lm8333)
80{
81 struct input_dev *input = lm8333->input;
82 u8 keys[LM8333_FIFO_TRANSFER_SIZE];
83 u8 code, pressed;
84 int i, ret;
85
86 ret = lm8333_read_block(lm8333, LM8333_FIFO_READ,
87 LM8333_FIFO_TRANSFER_SIZE, keys);
88 if (ret != LM8333_FIFO_TRANSFER_SIZE) {
89 dev_err(&lm8333->client->dev,
90 "Error %d while reading FIFO\n", ret);
91 return;
92 }
93
94 for (i = 0; keys[i] && i < LM8333_FIFO_TRANSFER_SIZE; i++) {
95 pressed = keys[i] & 0x80;
96 code = keys[i] & 0x7f;
97
98 input_event(input, EV_MSC, MSC_SCAN, code);
99 input_report_key(input, lm8333->keycodes[code], pressed);
100 }
101
102 input_sync(input);
103}
104
105static irqreturn_t lm8333_irq_thread(int irq, void *data)
106{
107 struct lm8333 *lm8333 = data;
108 u8 status = lm8333_read8(lm8333, LM8333_READ_INT);
109
110 if (!status)
111 return IRQ_NONE;
112
113 if (status & LM8333_ERROR_IRQ) {
114 u8 err = lm8333_read8(lm8333, LM8333_READ_ERROR);
115
116 if (err & (LM8333_ERROR_KEYOVR | LM8333_ERROR_FIFOOVR)) {
117 u8 dummy[LM8333_FIFO_TRANSFER_SIZE];
118
119 lm8333_read_block(lm8333, LM8333_FIFO_READ,
120 LM8333_FIFO_TRANSFER_SIZE, dummy);
121 }
122 dev_err(&lm8333->client->dev, "Got error %02x\n", err);
123 }
124
125 if (status & LM8333_KEYPAD_IRQ)
126 lm8333_key_handler(lm8333);
127
128 return IRQ_HANDLED;
129}
130
131static int __devinit lm8333_probe(struct i2c_client *client,
132 const struct i2c_device_id *id)
133{
134 const struct lm8333_platform_data *pdata = client->dev.platform_data;
135 struct lm8333 *lm8333;
136 struct input_dev *input;
137 int err, active_time;
138
139 if (!pdata)
140 return -EINVAL;
141
142 active_time = pdata->active_time ?: 500;
143 if (active_time / 3 <= pdata->debounce_time / 3) {
144 dev_err(&client->dev, "Active time not big enough!\n");
145 return -EINVAL;
146 }
147
148 lm8333 = kzalloc(sizeof(*lm8333), GFP_KERNEL);
149 input = input_allocate_device();
150 if (!lm8333 || !input) {
151 err = -ENOMEM;
152 goto free_mem;
153 }
154
155 lm8333->client = client;
156 lm8333->input = input;
157
158 input->name = client->name;
159 input->dev.parent = &client->dev;
160 input->id.bustype = BUS_I2C;
161
162 input_set_capability(input, EV_MSC, MSC_SCAN);
163
164 err = matrix_keypad_build_keymap(pdata->matrix_data, NULL,
165 LM8333_NUM_ROWS, LM8333_NUM_COLS,
166 lm8333->keycodes, input);
167 if (err)
168 goto free_mem;
169
170 if (pdata->debounce_time) {
171 err = lm8333_write8(lm8333, LM8333_DEBOUNCE,
172 pdata->debounce_time / 3);
173 if (err)
174 dev_warn(&client->dev, "Unable to set debounce time\n");
175 }
176
177 if (pdata->active_time) {
178 err = lm8333_write8(lm8333, LM8333_ACTIVE,
179 pdata->active_time / 3);
180 if (err)
181 dev_warn(&client->dev, "Unable to set active time\n");
182 }
183
184 err = request_threaded_irq(client->irq, NULL, lm8333_irq_thread,
185 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
186 "lm8333", lm8333);
187 if (err)
188 goto free_mem;
189
190 err = input_register_device(input);
191 if (err)
192 goto free_irq;
193
194 i2c_set_clientdata(client, lm8333);
195 return 0;
196
197 free_irq:
198 free_irq(client->irq, lm8333);
199 free_mem:
200 input_free_device(input);
201 kfree(lm8333);
202 return err;
203}
204
205static int __devexit lm8333_remove(struct i2c_client *client)
206{
207 struct lm8333 *lm8333 = i2c_get_clientdata(client);
208
209 free_irq(client->irq, lm8333);
210 input_unregister_device(lm8333->input);
211 kfree(lm8333);
212
213 return 0;
214}
215
216static const struct i2c_device_id lm8333_id[] = {
217 { "lm8333", 0 },
218 { }
219};
220MODULE_DEVICE_TABLE(i2c, lm8333_id);
221
222static struct i2c_driver lm8333_driver = {
223 .driver = {
224 .name = "lm8333",
225 .owner = THIS_MODULE,
226 },
227 .probe = lm8333_probe,
228 .remove = __devexit_p(lm8333_remove),
229 .id_table = lm8333_id,
230};
231module_i2c_driver(lm8333_driver);
232
233MODULE_AUTHOR("Wolfram Sang <w.sang@pengutronix.de>");
234MODULE_DESCRIPTION("LM8333 keyboard driver");
235MODULE_LICENSE("GPL v2");
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index 9b223d73de32..18b72372028a 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -27,7 +27,6 @@
27struct matrix_keypad { 27struct matrix_keypad {
28 const struct matrix_keypad_platform_data *pdata; 28 const struct matrix_keypad_platform_data *pdata;
29 struct input_dev *input_dev; 29 struct input_dev *input_dev;
30 unsigned short *keycodes;
31 unsigned int row_shift; 30 unsigned int row_shift;
32 31
33 DECLARE_BITMAP(disabled_gpios, MATRIX_MAX_ROWS); 32 DECLARE_BITMAP(disabled_gpios, MATRIX_MAX_ROWS);
@@ -38,6 +37,8 @@ struct matrix_keypad {
38 bool scan_pending; 37 bool scan_pending;
39 bool stopped; 38 bool stopped;
40 bool gpio_all_disabled; 39 bool gpio_all_disabled;
40
41 unsigned short keycodes[];
41}; 42};
42 43
43/* 44/*
@@ -224,7 +225,7 @@ static void matrix_keypad_stop(struct input_dev *dev)
224 disable_row_irqs(keypad); 225 disable_row_irqs(keypad);
225} 226}
226 227
227#ifdef CONFIG_PM 228#ifdef CONFIG_PM_SLEEP
228static void matrix_keypad_enable_wakeup(struct matrix_keypad *keypad) 229static void matrix_keypad_enable_wakeup(struct matrix_keypad *keypad)
229{ 230{
230 const struct matrix_keypad_platform_data *pdata = keypad->pdata; 231 const struct matrix_keypad_platform_data *pdata = keypad->pdata;
@@ -293,16 +294,16 @@ static int matrix_keypad_resume(struct device *dev)
293 294
294 return 0; 295 return 0;
295} 296}
296
297static const SIMPLE_DEV_PM_OPS(matrix_keypad_pm_ops,
298 matrix_keypad_suspend, matrix_keypad_resume);
299#endif 297#endif
300 298
301static int __devinit init_matrix_gpio(struct platform_device *pdev, 299static SIMPLE_DEV_PM_OPS(matrix_keypad_pm_ops,
302 struct matrix_keypad *keypad) 300 matrix_keypad_suspend, matrix_keypad_resume);
301
302static int __devinit matrix_keypad_init_gpio(struct platform_device *pdev,
303 struct matrix_keypad *keypad)
303{ 304{
304 const struct matrix_keypad_platform_data *pdata = keypad->pdata; 305 const struct matrix_keypad_platform_data *pdata = keypad->pdata;
305 int i, err = -EINVAL; 306 int i, err;
306 307
307 /* initialized strobe lines as outputs, activated */ 308 /* initialized strobe lines as outputs, activated */
308 for (i = 0; i < pdata->num_col_gpios; i++) { 309 for (i = 0; i < pdata->num_col_gpios; i++) {
@@ -348,8 +349,7 @@ static int __devinit init_matrix_gpio(struct platform_device *pdev,
348 "matrix-keypad", keypad); 349 "matrix-keypad", keypad);
349 if (err) { 350 if (err) {
350 dev_err(&pdev->dev, 351 dev_err(&pdev->dev,
351 "Unable to acquire interrupt " 352 "Unable to acquire interrupt for GPIO line %i\n",
352 "for GPIO line %i\n",
353 pdata->row_gpios[i]); 353 pdata->row_gpios[i]);
354 goto err_free_irqs; 354 goto err_free_irqs;
355 } 355 }
@@ -375,14 +375,33 @@ err_free_cols:
375 return err; 375 return err;
376} 376}
377 377
378static void matrix_keypad_free_gpio(struct matrix_keypad *keypad)
379{
380 const struct matrix_keypad_platform_data *pdata = keypad->pdata;
381 int i;
382
383 if (pdata->clustered_irq > 0) {
384 free_irq(pdata->clustered_irq, keypad);
385 } else {
386 for (i = 0; i < pdata->num_row_gpios; i++)
387 free_irq(gpio_to_irq(pdata->row_gpios[i]), keypad);
388 }
389
390 for (i = 0; i < pdata->num_row_gpios; i++)
391 gpio_free(pdata->row_gpios[i]);
392
393 for (i = 0; i < pdata->num_col_gpios; i++)
394 gpio_free(pdata->col_gpios[i]);
395}
396
378static int __devinit matrix_keypad_probe(struct platform_device *pdev) 397static int __devinit matrix_keypad_probe(struct platform_device *pdev)
379{ 398{
380 const struct matrix_keypad_platform_data *pdata; 399 const struct matrix_keypad_platform_data *pdata;
381 const struct matrix_keymap_data *keymap_data; 400 const struct matrix_keymap_data *keymap_data;
382 struct matrix_keypad *keypad; 401 struct matrix_keypad *keypad;
383 struct input_dev *input_dev; 402 struct input_dev *input_dev;
384 unsigned short *keycodes;
385 unsigned int row_shift; 403 unsigned int row_shift;
404 size_t keymap_size;
386 int err; 405 int err;
387 406
388 pdata = pdev->dev.platform_data; 407 pdata = pdev->dev.platform_data;
@@ -398,20 +417,18 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
398 } 417 }
399 418
400 row_shift = get_count_order(pdata->num_col_gpios); 419 row_shift = get_count_order(pdata->num_col_gpios);
401 420 keymap_size = (pdata->num_row_gpios << row_shift) *
402 keypad = kzalloc(sizeof(struct matrix_keypad), GFP_KERNEL); 421 sizeof(keypad->keycodes[0]);
403 keycodes = kzalloc((pdata->num_row_gpios << row_shift) * 422 keypad = kzalloc(sizeof(struct matrix_keypad) + keymap_size,
404 sizeof(*keycodes), 423 GFP_KERNEL);
405 GFP_KERNEL);
406 input_dev = input_allocate_device(); 424 input_dev = input_allocate_device();
407 if (!keypad || !keycodes || !input_dev) { 425 if (!keypad || !input_dev) {
408 err = -ENOMEM; 426 err = -ENOMEM;
409 goto err_free_mem; 427 goto err_free_mem;
410 } 428 }
411 429
412 keypad->input_dev = input_dev; 430 keypad->input_dev = input_dev;
413 keypad->pdata = pdata; 431 keypad->pdata = pdata;
414 keypad->keycodes = keycodes;
415 keypad->row_shift = row_shift; 432 keypad->row_shift = row_shift;
416 keypad->stopped = true; 433 keypad->stopped = true;
417 INIT_DELAYED_WORK(&keypad->work, matrix_keypad_scan); 434 INIT_DELAYED_WORK(&keypad->work, matrix_keypad_scan);
@@ -420,38 +437,38 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
420 input_dev->name = pdev->name; 437 input_dev->name = pdev->name;
421 input_dev->id.bustype = BUS_HOST; 438 input_dev->id.bustype = BUS_HOST;
422 input_dev->dev.parent = &pdev->dev; 439 input_dev->dev.parent = &pdev->dev;
423 input_dev->evbit[0] = BIT_MASK(EV_KEY);
424 if (!pdata->no_autorepeat)
425 input_dev->evbit[0] |= BIT_MASK(EV_REP);
426 input_dev->open = matrix_keypad_start; 440 input_dev->open = matrix_keypad_start;
427 input_dev->close = matrix_keypad_stop; 441 input_dev->close = matrix_keypad_stop;
428 442
429 input_dev->keycode = keycodes; 443 err = matrix_keypad_build_keymap(keymap_data, NULL,
430 input_dev->keycodesize = sizeof(*keycodes); 444 pdata->num_row_gpios,
431 input_dev->keycodemax = pdata->num_row_gpios << row_shift; 445 pdata->num_col_gpios,
432 446 keypad->keycodes, input_dev);
433 matrix_keypad_build_keymap(keymap_data, row_shift, 447 if (err)
434 input_dev->keycode, input_dev->keybit); 448 goto err_free_mem;
435 449
450 if (!pdata->no_autorepeat)
451 __set_bit(EV_REP, input_dev->evbit);
436 input_set_capability(input_dev, EV_MSC, MSC_SCAN); 452 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
437 input_set_drvdata(input_dev, keypad); 453 input_set_drvdata(input_dev, keypad);
438 454
439 err = init_matrix_gpio(pdev, keypad); 455 err = matrix_keypad_init_gpio(pdev, keypad);
440 if (err) 456 if (err)
441 goto err_free_mem; 457 goto err_free_mem;
442 458
443 err = input_register_device(keypad->input_dev); 459 err = input_register_device(keypad->input_dev);
444 if (err) 460 if (err)
445 goto err_free_mem; 461 goto err_free_gpio;
446 462
447 device_init_wakeup(&pdev->dev, pdata->wakeup); 463 device_init_wakeup(&pdev->dev, pdata->wakeup);
448 platform_set_drvdata(pdev, keypad); 464 platform_set_drvdata(pdev, keypad);
449 465
450 return 0; 466 return 0;
451 467
468err_free_gpio:
469 matrix_keypad_free_gpio(keypad);
452err_free_mem: 470err_free_mem:
453 input_free_device(input_dev); 471 input_free_device(input_dev);
454 kfree(keycodes);
455 kfree(keypad); 472 kfree(keypad);
456 return err; 473 return err;
457} 474}
@@ -459,29 +476,15 @@ err_free_mem:
459static int __devexit matrix_keypad_remove(struct platform_device *pdev) 476static int __devexit matrix_keypad_remove(struct platform_device *pdev)
460{ 477{
461 struct matrix_keypad *keypad = platform_get_drvdata(pdev); 478 struct matrix_keypad *keypad = platform_get_drvdata(pdev);
462 const struct matrix_keypad_platform_data *pdata = keypad->pdata;
463 int i;
464 479
465 device_init_wakeup(&pdev->dev, 0); 480 device_init_wakeup(&pdev->dev, 0);
466 481
467 if (pdata->clustered_irq > 0) { 482 matrix_keypad_free_gpio(keypad);
468 free_irq(pdata->clustered_irq, keypad);
469 } else {
470 for (i = 0; i < pdata->num_row_gpios; i++)
471 free_irq(gpio_to_irq(pdata->row_gpios[i]), keypad);
472 }
473
474 for (i = 0; i < pdata->num_row_gpios; i++)
475 gpio_free(pdata->row_gpios[i]);
476
477 for (i = 0; i < pdata->num_col_gpios; i++)
478 gpio_free(pdata->col_gpios[i]);
479
480 input_unregister_device(keypad->input_dev); 483 input_unregister_device(keypad->input_dev);
481 platform_set_drvdata(pdev, NULL);
482 kfree(keypad->keycodes);
483 kfree(keypad); 484 kfree(keypad);
484 485
486 platform_set_drvdata(pdev, NULL);
487
485 return 0; 488 return 0;
486} 489}
487 490
@@ -491,9 +494,7 @@ static struct platform_driver matrix_keypad_driver = {
491 .driver = { 494 .driver = {
492 .name = "matrix-keypad", 495 .name = "matrix-keypad",
493 .owner = THIS_MODULE, 496 .owner = THIS_MODULE,
494#ifdef CONFIG_PM
495 .pm = &matrix_keypad_pm_ops, 497 .pm = &matrix_keypad_pm_ops,
496#endif
497 }, 498 },
498}; 499};
499module_platform_driver(matrix_keypad_driver); 500module_platform_driver(matrix_keypad_driver);
diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c
index 48d1cab0aa1c..f971898ad591 100644
--- a/drivers/input/keyboard/newtonkbd.c
+++ b/drivers/input/keyboard/newtonkbd.c
@@ -166,15 +166,4 @@ static struct serio_driver nkbd_drv = {
166 .disconnect = nkbd_disconnect, 166 .disconnect = nkbd_disconnect,
167}; 167};
168 168
169static int __init nkbd_init(void) 169module_serio_driver(nkbd_drv);
170{
171 return serio_register_driver(&nkbd_drv);
172}
173
174static void __exit nkbd_exit(void)
175{
176 serio_unregister_driver(&nkbd_drv);
177}
178
179module_init(nkbd_init);
180module_exit(nkbd_exit);
diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c
index 101e245944e7..4ea4341a68c5 100644
--- a/drivers/input/keyboard/nomadik-ske-keypad.c
+++ b/drivers/input/keyboard/nomadik-ske-keypad.c
@@ -39,7 +39,8 @@
39#define SKE_KPRISA (0x1 << 2) 39#define SKE_KPRISA (0x1 << 2)
40 40
41#define SKE_KEYPAD_ROW_SHIFT 3 41#define SKE_KEYPAD_ROW_SHIFT 3
42#define SKE_KPD_KEYMAP_SIZE (8 * 8) 42#define SKE_KPD_NUM_ROWS 8
43#define SKE_KPD_NUM_COLS 8
43 44
44/* keypad auto scan registers */ 45/* keypad auto scan registers */
45#define SKE_ASR0 0x20 46#define SKE_ASR0 0x20
@@ -63,7 +64,7 @@ struct ske_keypad {
63 void __iomem *reg_base; 64 void __iomem *reg_base;
64 struct input_dev *input; 65 struct input_dev *input;
65 const struct ske_keypad_platform_data *board; 66 const struct ske_keypad_platform_data *board;
66 unsigned short keymap[SKE_KPD_KEYMAP_SIZE]; 67 unsigned short keymap[SKE_KPD_NUM_ROWS * SKE_KPD_NUM_COLS];
67 struct clk *clk; 68 struct clk *clk;
68 spinlock_t ske_keypad_lock; 69 spinlock_t ske_keypad_lock;
69}; 70};
@@ -261,19 +262,18 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
261 input->name = "ux500-ske-keypad"; 262 input->name = "ux500-ske-keypad";
262 input->dev.parent = &pdev->dev; 263 input->dev.parent = &pdev->dev;
263 264
264 input->keycode = keypad->keymap; 265 error = matrix_keypad_build_keymap(plat->keymap_data, NULL,
265 input->keycodesize = sizeof(keypad->keymap[0]); 266 SKE_KPD_NUM_ROWS, SKE_KPD_NUM_COLS,
266 input->keycodemax = ARRAY_SIZE(keypad->keymap); 267 keypad->keymap, input);
268 if (error) {
269 dev_err(&pdev->dev, "Failed to build keymap\n");
270 goto err_iounmap;
271 }
267 272
268 input_set_capability(input, EV_MSC, MSC_SCAN); 273 input_set_capability(input, EV_MSC, MSC_SCAN);
269
270 __set_bit(EV_KEY, input->evbit);
271 if (!plat->no_autorepeat) 274 if (!plat->no_autorepeat)
272 __set_bit(EV_REP, input->evbit); 275 __set_bit(EV_REP, input->evbit);
273 276
274 matrix_keypad_build_keymap(plat->keymap_data, SKE_KEYPAD_ROW_SHIFT,
275 input->keycode, input->keybit);
276
277 clk_enable(keypad->clk); 277 clk_enable(keypad->clk);
278 278
279 /* go through board initialization helpers */ 279 /* go through board initialization helpers */
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
index 6b630d9d3dff..a0222db4dc86 100644
--- a/drivers/input/keyboard/omap-keypad.c
+++ b/drivers/input/keyboard/omap-keypad.c
@@ -61,6 +61,7 @@ struct omap_kp {
61 unsigned int cols; 61 unsigned int cols;
62 unsigned long delay; 62 unsigned long delay;
63 unsigned int debounce; 63 unsigned int debounce;
64 unsigned short keymap[];
64}; 65};
65 66
66static DECLARE_TASKLET_DISABLED(kp_tasklet, omap_kp_tasklet, 0); 67static DECLARE_TASKLET_DISABLED(kp_tasklet, omap_kp_tasklet, 0);
@@ -316,13 +317,6 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
316 if (!cpu_is_omap24xx()) 317 if (!cpu_is_omap24xx())
317 omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); 318 omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
318 319
319 input_dev->keycode = &omap_kp[1];
320 input_dev->keycodesize = sizeof(unsigned short);
321 input_dev->keycodemax = keycodemax;
322
323 if (pdata->rep)
324 __set_bit(EV_REP, input_dev->evbit);
325
326 if (pdata->delay) 320 if (pdata->delay)
327 omap_kp->delay = pdata->delay; 321 omap_kp->delay = pdata->delay;
328 322
@@ -371,9 +365,6 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
371 goto err2; 365 goto err2;
372 366
373 /* setup input device */ 367 /* setup input device */
374 __set_bit(EV_KEY, input_dev->evbit);
375 matrix_keypad_build_keymap(pdata->keymap_data, row_shift,
376 input_dev->keycode, input_dev->keybit);
377 input_dev->name = "omap-keypad"; 368 input_dev->name = "omap-keypad";
378 input_dev->phys = "omap-keypad/input0"; 369 input_dev->phys = "omap-keypad/input0";
379 input_dev->dev.parent = &pdev->dev; 370 input_dev->dev.parent = &pdev->dev;
@@ -383,6 +374,15 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
383 input_dev->id.product = 0x0001; 374 input_dev->id.product = 0x0001;
384 input_dev->id.version = 0x0100; 375 input_dev->id.version = 0x0100;
385 376
377 if (pdata->rep)
378 __set_bit(EV_REP, input_dev->evbit);
379
380 ret = matrix_keypad_build_keymap(pdata->keymap_data, NULL,
381 pdata->rows, pdata->cols,
382 omap_kp->keymap, input_dev);
383 if (ret < 0)
384 goto err3;
385
386 ret = input_register_device(omap_kp->input); 386 ret = input_register_device(omap_kp->input);
387 if (ret < 0) { 387 if (ret < 0) {
388 printk(KERN_ERR "Unable to register omap-keypad input device\n"); 388 printk(KERN_ERR "Unable to register omap-keypad input device\n");
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index e809ac095a38..aed5f6999ce2 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -68,19 +68,52 @@
68 68
69#define OMAP4_MASK_IRQSTATUSDISABLE 0xFFFF 69#define OMAP4_MASK_IRQSTATUSDISABLE 0xFFFF
70 70
71enum {
72 KBD_REVISION_OMAP4 = 0,
73 KBD_REVISION_OMAP5,
74};
75
71struct omap4_keypad { 76struct omap4_keypad {
72 struct input_dev *input; 77 struct input_dev *input;
73 78
74 void __iomem *base; 79 void __iomem *base;
75 int irq; 80 unsigned int irq;
76 81
77 unsigned int rows; 82 unsigned int rows;
78 unsigned int cols; 83 unsigned int cols;
84 u32 reg_offset;
85 u32 irqreg_offset;
79 unsigned int row_shift; 86 unsigned int row_shift;
80 unsigned char key_state[8]; 87 unsigned char key_state[8];
81 unsigned short keymap[]; 88 unsigned short keymap[];
82}; 89};
83 90
91static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset)
92{
93 return __raw_readl(keypad_data->base +
94 keypad_data->reg_offset + offset);
95}
96
97static void kbd_writel(struct omap4_keypad *keypad_data, u32 offset, u32 value)
98{
99 __raw_writel(value,
100 keypad_data->base + keypad_data->reg_offset + offset);
101}
102
103static int kbd_read_irqreg(struct omap4_keypad *keypad_data, u32 offset)
104{
105 return __raw_readl(keypad_data->base +
106 keypad_data->irqreg_offset + offset);
107}
108
109static void kbd_write_irqreg(struct omap4_keypad *keypad_data,
110 u32 offset, u32 value)
111{
112 __raw_writel(value,
113 keypad_data->base + keypad_data->irqreg_offset + offset);
114}
115
116
84/* Interrupt handler */ 117/* Interrupt handler */
85static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) 118static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id)
86{ 119{
@@ -91,12 +124,11 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id)
91 u32 *new_state = (u32 *) key_state; 124 u32 *new_state = (u32 *) key_state;
92 125
93 /* Disable interrupts */ 126 /* Disable interrupts */
94 __raw_writel(OMAP4_VAL_IRQDISABLE, 127 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
95 keypad_data->base + OMAP4_KBD_IRQENABLE); 128 OMAP4_VAL_IRQDISABLE);
96 129
97 *new_state = __raw_readl(keypad_data->base + OMAP4_KBD_FULLCODE31_0); 130 *new_state = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0);
98 *(new_state + 1) = __raw_readl(keypad_data->base 131 *(new_state + 1) = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32);
99 + OMAP4_KBD_FULLCODE63_32);
100 132
101 for (row = 0; row < keypad_data->rows; row++) { 133 for (row = 0; row < keypad_data->rows; row++) {
102 changed = key_state[row] ^ keypad_data->key_state[row]; 134 changed = key_state[row] ^ keypad_data->key_state[row];
@@ -121,12 +153,13 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id)
121 sizeof(keypad_data->key_state)); 153 sizeof(keypad_data->key_state));
122 154
123 /* clear pending interrupts */ 155 /* clear pending interrupts */
124 __raw_writel(__raw_readl(keypad_data->base + OMAP4_KBD_IRQSTATUS), 156 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
125 keypad_data->base + OMAP4_KBD_IRQSTATUS); 157 kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS));
126 158
127 /* enable interrupts */ 159 /* enable interrupts */
128 __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY, 160 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
129 keypad_data->base + OMAP4_KBD_IRQENABLE); 161 OMAP4_DEF_IRQENABLE_EVENTEN |
162 OMAP4_DEF_IRQENABLE_LONGKEY);
130 163
131 return IRQ_HANDLED; 164 return IRQ_HANDLED;
132} 165}
@@ -139,16 +172,17 @@ static int omap4_keypad_open(struct input_dev *input)
139 172
140 disable_irq(keypad_data->irq); 173 disable_irq(keypad_data->irq);
141 174
142 __raw_writel(OMAP4_VAL_FUNCTIONALCFG, 175 kbd_writel(keypad_data, OMAP4_KBD_CTRL,
143 keypad_data->base + OMAP4_KBD_CTRL); 176 OMAP4_VAL_FUNCTIONALCFG);
144 __raw_writel(OMAP4_VAL_DEBOUNCINGTIME, 177 kbd_writel(keypad_data, OMAP4_KBD_DEBOUNCINGTIME,
145 keypad_data->base + OMAP4_KBD_DEBOUNCINGTIME); 178 OMAP4_VAL_DEBOUNCINGTIME);
146 __raw_writel(OMAP4_VAL_IRQDISABLE, 179 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
147 keypad_data->base + OMAP4_KBD_IRQSTATUS); 180 OMAP4_VAL_IRQDISABLE);
148 __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY, 181 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
149 keypad_data->base + OMAP4_KBD_IRQENABLE); 182 OMAP4_DEF_IRQENABLE_EVENTEN |
150 __raw_writel(OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA, 183 OMAP4_DEF_IRQENABLE_LONGKEY);
151 keypad_data->base + OMAP4_KBD_WAKEUPENABLE); 184 kbd_writel(keypad_data, OMAP4_KBD_WAKEUPENABLE,
185 OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA);
152 186
153 enable_irq(keypad_data->irq); 187 enable_irq(keypad_data->irq);
154 188
@@ -162,12 +196,12 @@ static void omap4_keypad_close(struct input_dev *input)
162 disable_irq(keypad_data->irq); 196 disable_irq(keypad_data->irq);
163 197
164 /* Disable interrupts */ 198 /* Disable interrupts */
165 __raw_writel(OMAP4_VAL_IRQDISABLE, 199 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
166 keypad_data->base + OMAP4_KBD_IRQENABLE); 200 OMAP4_VAL_IRQDISABLE);
167 201
168 /* clear pending interrupts */ 202 /* clear pending interrupts */
169 __raw_writel(__raw_readl(keypad_data->base + OMAP4_KBD_IRQSTATUS), 203 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
170 keypad_data->base + OMAP4_KBD_IRQSTATUS); 204 kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS));
171 205
172 enable_irq(keypad_data->irq); 206 enable_irq(keypad_data->irq);
173 207
@@ -182,6 +216,7 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev)
182 struct resource *res; 216 struct resource *res;
183 resource_size_t size; 217 resource_size_t size;
184 unsigned int row_shift, max_keys; 218 unsigned int row_shift, max_keys;
219 int rev;
185 int irq; 220 int irq;
186 int error; 221 int error;
187 222
@@ -241,11 +276,40 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev)
241 keypad_data->rows = pdata->rows; 276 keypad_data->rows = pdata->rows;
242 keypad_data->cols = pdata->cols; 277 keypad_data->cols = pdata->cols;
243 278
279 /*
280 * Enable clocks for the keypad module so that we can read
281 * revision register.
282 */
283 pm_runtime_enable(&pdev->dev);
284 error = pm_runtime_get_sync(&pdev->dev);
285 if (error) {
286 dev_err(&pdev->dev, "pm_runtime_get_sync() failed\n");
287 goto err_unmap;
288 }
289 rev = __raw_readl(keypad_data->base + OMAP4_KBD_REVISION);
290 rev &= 0x03 << 30;
291 rev >>= 30;
292 switch (rev) {
293 case KBD_REVISION_OMAP4:
294 keypad_data->reg_offset = 0x00;
295 keypad_data->irqreg_offset = 0x00;
296 break;
297 case KBD_REVISION_OMAP5:
298 keypad_data->reg_offset = 0x10;
299 keypad_data->irqreg_offset = 0x0c;
300 break;
301 default:
302 dev_err(&pdev->dev,
303 "Keypad reports unsupported revision %d", rev);
304 error = -EINVAL;
305 goto err_pm_put_sync;
306 }
307
244 /* input device allocation */ 308 /* input device allocation */
245 keypad_data->input = input_dev = input_allocate_device(); 309 keypad_data->input = input_dev = input_allocate_device();
246 if (!input_dev) { 310 if (!input_dev) {
247 error = -ENOMEM; 311 error = -ENOMEM;
248 goto err_unmap; 312 goto err_pm_put_sync;
249 } 313 }
250 314
251 input_dev->name = pdev->name; 315 input_dev->name = pdev->name;
@@ -258,20 +322,19 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev)
258 input_dev->open = omap4_keypad_open; 322 input_dev->open = omap4_keypad_open;
259 input_dev->close = omap4_keypad_close; 323 input_dev->close = omap4_keypad_close;
260 324
261 input_dev->keycode = keypad_data->keymap; 325 error = matrix_keypad_build_keymap(pdata->keymap_data, NULL,
262 input_dev->keycodesize = sizeof(keypad_data->keymap[0]); 326 pdata->rows, pdata->cols,
263 input_dev->keycodemax = max_keys; 327 keypad_data->keymap, input_dev);
328 if (error) {
329 dev_err(&pdev->dev, "failed to build keymap\n");
330 goto err_free_input;
331 }
264 332
265 __set_bit(EV_KEY, input_dev->evbit);
266 __set_bit(EV_REP, input_dev->evbit); 333 __set_bit(EV_REP, input_dev->evbit);
267
268 input_set_capability(input_dev, EV_MSC, MSC_SCAN); 334 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
269 335
270 input_set_drvdata(input_dev, keypad_data); 336 input_set_drvdata(input_dev, keypad_data);
271 337
272 matrix_keypad_build_keymap(pdata->keymap_data, row_shift,
273 input_dev->keycode, input_dev->keybit);
274
275 error = request_irq(keypad_data->irq, omap4_keypad_interrupt, 338 error = request_irq(keypad_data->irq, omap4_keypad_interrupt,
276 IRQF_TRIGGER_RISING, 339 IRQF_TRIGGER_RISING,
277 "omap4-keypad", keypad_data); 340 "omap4-keypad", keypad_data);
@@ -280,7 +343,7 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev)
280 goto err_free_input; 343 goto err_free_input;
281 } 344 }
282 345
283 pm_runtime_enable(&pdev->dev); 346 pm_runtime_put_sync(&pdev->dev);
284 347
285 error = input_register_device(keypad_data->input); 348 error = input_register_device(keypad_data->input);
286 if (error < 0) { 349 if (error < 0) {
@@ -296,6 +359,8 @@ err_pm_disable:
296 free_irq(keypad_data->irq, keypad_data); 359 free_irq(keypad_data->irq, keypad_data);
297err_free_input: 360err_free_input:
298 input_free_device(input_dev); 361 input_free_device(input_dev);
362err_pm_put_sync:
363 pm_runtime_put_sync(&pdev->dev);
299err_unmap: 364err_unmap:
300 iounmap(keypad_data->base); 365 iounmap(keypad_data->base);
301err_release_mem: 366err_release_mem:
diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c b/drivers/input/keyboard/pmic8xxx-keypad.c
index 01a1c9f8a383..52c34657d301 100644
--- a/drivers/input/keyboard/pmic8xxx-keypad.c
+++ b/drivers/input/keyboard/pmic8xxx-keypad.c
@@ -626,21 +626,21 @@ static int __devinit pmic8xxx_kp_probe(struct platform_device *pdev)
626 kp->input->id.product = 0x0001; 626 kp->input->id.product = 0x0001;
627 kp->input->id.vendor = 0x0001; 627 kp->input->id.vendor = 0x0001;
628 628
629 kp->input->evbit[0] = BIT_MASK(EV_KEY);
630
631 if (pdata->rep)
632 __set_bit(EV_REP, kp->input->evbit);
633
634 kp->input->keycode = kp->keycodes;
635 kp->input->keycodemax = PM8XXX_MATRIX_MAX_SIZE;
636 kp->input->keycodesize = sizeof(kp->keycodes);
637 kp->input->open = pmic8xxx_kp_open; 629 kp->input->open = pmic8xxx_kp_open;
638 kp->input->close = pmic8xxx_kp_close; 630 kp->input->close = pmic8xxx_kp_close;
639 631
640 matrix_keypad_build_keymap(keymap_data, PM8XXX_ROW_SHIFT, 632 rc = matrix_keypad_build_keymap(keymap_data, NULL,
641 kp->input->keycode, kp->input->keybit); 633 PM8XXX_MAX_ROWS, PM8XXX_MAX_COLS,
634 kp->keycodes, kp->input);
635 if (rc) {
636 dev_err(&pdev->dev, "failed to build keymap\n");
637 goto err_get_irq;
638 }
642 639
640 if (pdata->rep)
641 __set_bit(EV_REP, kp->input->evbit);
643 input_set_capability(kp->input, EV_MSC, MSC_SCAN); 642 input_set_capability(kp->input, EV_MSC, MSC_SCAN);
643
644 input_set_drvdata(kp->input, kp); 644 input_set_drvdata(kp->input, kp);
645 645
646 /* initialize keypad state */ 646 /* initialize keypad state */
diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index 2391ae884fee..a061ba603a29 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -454,23 +454,23 @@ static int __devinit samsung_keypad_probe(struct platform_device *pdev)
454 input_dev->name = pdev->name; 454 input_dev->name = pdev->name;
455 input_dev->id.bustype = BUS_HOST; 455 input_dev->id.bustype = BUS_HOST;
456 input_dev->dev.parent = &pdev->dev; 456 input_dev->dev.parent = &pdev->dev;
457 input_set_drvdata(input_dev, keypad);
458 457
459 input_dev->open = samsung_keypad_open; 458 input_dev->open = samsung_keypad_open;
460 input_dev->close = samsung_keypad_close; 459 input_dev->close = samsung_keypad_close;
461 460
462 input_dev->evbit[0] = BIT_MASK(EV_KEY); 461 error = matrix_keypad_build_keymap(keymap_data, NULL,
463 if (!pdata->no_autorepeat) 462 pdata->rows, pdata->cols,
464 input_dev->evbit[0] |= BIT_MASK(EV_REP); 463 keypad->keycodes, input_dev);
464 if (error) {
465 dev_err(&pdev->dev, "failed to build keymap\n");
466 goto err_put_clk;
467 }
465 468
466 input_set_capability(input_dev, EV_MSC, MSC_SCAN); 469 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
470 if (!pdata->no_autorepeat)
471 __set_bit(EV_REP, input_dev->evbit);
467 472
468 input_dev->keycode = keypad->keycodes; 473 input_set_drvdata(input_dev, keypad);
469 input_dev->keycodesize = sizeof(keypad->keycodes[0]);
470 input_dev->keycodemax = pdata->rows << row_shift;
471
472 matrix_keypad_build_keymap(keymap_data, row_shift,
473 input_dev->keycode, input_dev->keybit);
474 474
475 keypad->irq = platform_get_irq(pdev, 0); 475 keypad->irq = platform_get_irq(pdev, 0);
476 if (keypad->irq < 0) { 476 if (keypad->irq < 0) {
diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
index 3b6b528f02fd..6f287f7e1538 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -19,6 +19,7 @@
19#include <linux/irq.h> 19#include <linux/irq.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/of.h>
22#include <linux/platform_device.h> 23#include <linux/platform_device.h>
23#include <linux/pm_wakeup.h> 24#include <linux/pm_wakeup.h>
24#include <linux/slab.h> 25#include <linux/slab.h>
@@ -49,7 +50,9 @@
49#define KEY_VALUE 0x00FFFFFF 50#define KEY_VALUE 0x00FFFFFF
50#define ROW_MASK 0xF0 51#define ROW_MASK 0xF0
51#define COLUMN_MASK 0x0F 52#define COLUMN_MASK 0x0F
52#define ROW_SHIFT 4 53#define NUM_ROWS 16
54#define NUM_COLS 16
55
53#define KEY_MATRIX_SHIFT 6 56#define KEY_MATRIX_SHIFT 6
54 57
55struct spear_kbd { 58struct spear_kbd {
@@ -60,7 +63,8 @@ struct spear_kbd {
60 unsigned int irq; 63 unsigned int irq;
61 unsigned int mode; 64 unsigned int mode;
62 unsigned short last_key; 65 unsigned short last_key;
63 unsigned short keycodes[256]; 66 unsigned short keycodes[NUM_ROWS * NUM_COLS];
67 bool rep;
64}; 68};
65 69
66static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id) 70static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id)
@@ -136,27 +140,49 @@ static void spear_kbd_close(struct input_dev *dev)
136 kbd->last_key = KEY_RESERVED; 140 kbd->last_key = KEY_RESERVED;
137} 141}
138 142
139static int __devinit spear_kbd_probe(struct platform_device *pdev) 143#ifdef CONFIG_OF
144static int __devinit spear_kbd_parse_dt(struct platform_device *pdev,
145 struct spear_kbd *kbd)
140{ 146{
141 const struct kbd_platform_data *pdata = pdev->dev.platform_data; 147 struct device_node *np = pdev->dev.of_node;
142 const struct matrix_keymap_data *keymap;
143 struct spear_kbd *kbd;
144 struct input_dev *input_dev;
145 struct resource *res;
146 int irq;
147 int error; 148 int error;
149 u32 val;
148 150
149 if (!pdata) { 151 if (!np) {
150 dev_err(&pdev->dev, "Invalid platform data\n"); 152 dev_err(&pdev->dev, "Missing DT data\n");
151 return -EINVAL; 153 return -EINVAL;
152 } 154 }
153 155
154 keymap = pdata->keymap; 156 if (of_property_read_bool(np, "autorepeat"))
155 if (!keymap) { 157 kbd->rep = true;
156 dev_err(&pdev->dev, "no keymap defined\n"); 158
157 return -EINVAL; 159 error = of_property_read_u32(np, "st,mode", &val);
160 if (error) {
161 dev_err(&pdev->dev, "DT: Invalid or missing mode\n");
162 return error;
158 } 163 }
159 164
165 kbd->mode = val;
166 return 0;
167}
168#else
169static inline int spear_kbd_parse_dt(struct platform_device *pdev,
170 struct spear_kbd *kbd)
171{
172 return -ENOSYS;
173}
174#endif
175
176static int __devinit spear_kbd_probe(struct platform_device *pdev)
177{
178 struct kbd_platform_data *pdata = dev_get_platdata(&pdev->dev);
179 const struct matrix_keymap_data *keymap = pdata ? pdata->keymap : NULL;
180 struct spear_kbd *kbd;
181 struct input_dev *input_dev;
182 struct resource *res;
183 int irq;
184 int error;
185
160 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 186 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
161 if (!res) { 187 if (!res) {
162 dev_err(&pdev->dev, "no keyboard resource defined\n"); 188 dev_err(&pdev->dev, "no keyboard resource defined\n");
@@ -179,7 +205,15 @@ static int __devinit spear_kbd_probe(struct platform_device *pdev)
179 205
180 kbd->input = input_dev; 206 kbd->input = input_dev;
181 kbd->irq = irq; 207 kbd->irq = irq;
182 kbd->mode = pdata->mode; 208
209 if (!pdata) {
210 error = spear_kbd_parse_dt(pdev, kbd);
211 if (error)
212 goto err_free_mem;
213 } else {
214 kbd->mode = pdata->mode;
215 kbd->rep = pdata->rep;
216 }
183 217
184 kbd->res = request_mem_region(res->start, resource_size(res), 218 kbd->res = request_mem_region(res->start, resource_size(res),
185 pdev->name); 219 pdev->name);
@@ -212,18 +246,17 @@ static int __devinit spear_kbd_probe(struct platform_device *pdev)
212 input_dev->open = spear_kbd_open; 246 input_dev->open = spear_kbd_open;
213 input_dev->close = spear_kbd_close; 247 input_dev->close = spear_kbd_close;
214 248
215 __set_bit(EV_KEY, input_dev->evbit); 249 error = matrix_keypad_build_keymap(keymap, NULL, NUM_ROWS, NUM_COLS,
216 if (pdata->rep) 250 kbd->keycodes, input_dev);
251 if (error) {
252 dev_err(&pdev->dev, "Failed to build keymap\n");
253 goto err_put_clk;
254 }
255
256 if (kbd->rep)
217 __set_bit(EV_REP, input_dev->evbit); 257 __set_bit(EV_REP, input_dev->evbit);
218 input_set_capability(input_dev, EV_MSC, MSC_SCAN); 258 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
219 259
220 input_dev->keycode = kbd->keycodes;
221 input_dev->keycodesize = sizeof(kbd->keycodes[0]);
222 input_dev->keycodemax = ARRAY_SIZE(kbd->keycodes);
223
224 matrix_keypad_build_keymap(keymap, ROW_SHIFT,
225 input_dev->keycode, input_dev->keybit);
226
227 input_set_drvdata(input_dev, kbd); 260 input_set_drvdata(input_dev, kbd);
228 261
229 error = request_irq(irq, spear_kbd_interrupt, 0, "keyboard", kbd); 262 error = request_irq(irq, spear_kbd_interrupt, 0, "keyboard", kbd);
@@ -317,6 +350,14 @@ static int spear_kbd_resume(struct device *dev)
317 350
318static SIMPLE_DEV_PM_OPS(spear_kbd_pm_ops, spear_kbd_suspend, spear_kbd_resume); 351static SIMPLE_DEV_PM_OPS(spear_kbd_pm_ops, spear_kbd_suspend, spear_kbd_resume);
319 352
353#ifdef CONFIG_OF
354static const struct of_device_id spear_kbd_id_table[] = {
355 { .compatible = "st,spear300-kbd" },
356 {}
357};
358MODULE_DEVICE_TABLE(of, spear_kbd_id_table);
359#endif
360
320static struct platform_driver spear_kbd_driver = { 361static struct platform_driver spear_kbd_driver = {
321 .probe = spear_kbd_probe, 362 .probe = spear_kbd_probe,
322 .remove = __devexit_p(spear_kbd_remove), 363 .remove = __devexit_p(spear_kbd_remove),
@@ -324,6 +365,7 @@ static struct platform_driver spear_kbd_driver = {
324 .name = "keyboard", 365 .name = "keyboard",
325 .owner = THIS_MODULE, 366 .owner = THIS_MODULE,
326 .pm = &spear_kbd_pm_ops, 367 .pm = &spear_kbd_pm_ops,
368 .of_match_table = of_match_ptr(spear_kbd_id_table),
327 }, 369 },
328}; 370};
329module_platform_driver(spear_kbd_driver); 371module_platform_driver(spear_kbd_driver);
diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
index 9397cf9c625c..470a8778dec1 100644
--- a/drivers/input/keyboard/stmpe-keypad.c
+++ b/drivers/input/keyboard/stmpe-keypad.c
@@ -289,19 +289,17 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
289 input->id.bustype = BUS_I2C; 289 input->id.bustype = BUS_I2C;
290 input->dev.parent = &pdev->dev; 290 input->dev.parent = &pdev->dev;
291 291
292 input_set_capability(input, EV_MSC, MSC_SCAN); 292 ret = matrix_keypad_build_keymap(plat->keymap_data, NULL,
293 STMPE_KEYPAD_MAX_ROWS,
294 STMPE_KEYPAD_MAX_COLS,
295 keypad->keymap, input);
296 if (ret)
297 goto out_freeinput;
293 298
294 __set_bit(EV_KEY, input->evbit); 299 input_set_capability(input, EV_MSC, MSC_SCAN);
295 if (!plat->no_autorepeat) 300 if (!plat->no_autorepeat)
296 __set_bit(EV_REP, input->evbit); 301 __set_bit(EV_REP, input->evbit);
297 302
298 input->keycode = keypad->keymap;
299 input->keycodesize = sizeof(keypad->keymap[0]);
300 input->keycodemax = ARRAY_SIZE(keypad->keymap);
301
302 matrix_keypad_build_keymap(plat->keymap_data, STMPE_KEYPAD_ROW_SHIFT,
303 input->keycode, input->keybit);
304
305 for (i = 0; i < plat->keymap_data->keymap_size; i++) { 303 for (i = 0; i < plat->keymap_data->keymap_size; i++) {
306 unsigned int key = plat->keymap_data->keymap[i]; 304 unsigned int key = plat->keymap_data->keymap[i];
307 305
diff --git a/drivers/input/keyboard/stowaway.c b/drivers/input/keyboard/stowaway.c
index 7437219370b1..cc612c5d5427 100644
--- a/drivers/input/keyboard/stowaway.c
+++ b/drivers/input/keyboard/stowaway.c
@@ -170,15 +170,4 @@ static struct serio_driver skbd_drv = {
170 .disconnect = skbd_disconnect, 170 .disconnect = skbd_disconnect,
171}; 171};
172 172
173static int __init skbd_init(void) 173module_serio_driver(skbd_drv);
174{
175 return serio_register_driver(&skbd_drv);
176}
177
178static void __exit skbd_exit(void)
179{
180 serio_unregister_driver(&skbd_drv);
181}
182
183module_init(skbd_init);
184module_exit(skbd_exit);
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
index a99a04b03ee4..5f836b1638c1 100644
--- a/drivers/input/keyboard/sunkbd.c
+++ b/drivers/input/keyboard/sunkbd.c
@@ -369,19 +369,4 @@ static struct serio_driver sunkbd_drv = {
369 .disconnect = sunkbd_disconnect, 369 .disconnect = sunkbd_disconnect,
370}; 370};
371 371
372/* 372module_serio_driver(sunkbd_drv);
373 * The functions for insering/removing us as a module.
374 */
375
376static int __init sunkbd_init(void)
377{
378 return serio_register_driver(&sunkbd_drv);
379}
380
381static void __exit sunkbd_exit(void)
382{
383 serio_unregister_driver(&sunkbd_drv);
384}
385
386module_init(sunkbd_init);
387module_exit(sunkbd_exit);
diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c
index 2dee3e4e7c6f..7d498e698508 100644
--- a/drivers/input/keyboard/tc3589x-keypad.c
+++ b/drivers/input/keyboard/tc3589x-keypad.c
@@ -78,7 +78,7 @@
78 * @input: pointer to input device object 78 * @input: pointer to input device object
79 * @board: keypad platform device 79 * @board: keypad platform device
80 * @krow: number of rows 80 * @krow: number of rows
81 * @kcol: number of coloumns 81 * @kcol: number of columns
82 * @keymap: matrix scan code table for keycodes 82 * @keymap: matrix scan code table for keycodes
83 * @keypad_stopped: holds keypad status 83 * @keypad_stopped: holds keypad status
84 */ 84 */
@@ -96,21 +96,15 @@ static int tc3589x_keypad_init_key_hardware(struct tc_keypad *keypad)
96{ 96{
97 int ret; 97 int ret;
98 struct tc3589x *tc3589x = keypad->tc3589x; 98 struct tc3589x *tc3589x = keypad->tc3589x;
99 u8 settle_time = keypad->board->settle_time; 99 const struct tc3589x_keypad_platform_data *board = keypad->board;
100 u8 dbounce_period = keypad->board->debounce_period; 100
101 u8 rows = keypad->board->krow & 0xf; /* mask out the nibble */ 101 /* validate platform configuration */
102 u8 column = keypad->board->kcol & 0xf; /* mask out the nibble */ 102 if (board->kcol > TC3589x_MAX_KPCOL || board->krow > TC3589x_MAX_KPROW)
103
104 /* validate platform configurations */
105 if (keypad->board->kcol > TC3589x_MAX_KPCOL ||
106 keypad->board->krow > TC3589x_MAX_KPROW ||
107 keypad->board->debounce_period > TC3589x_MAX_DEBOUNCE_SETTLE ||
108 keypad->board->settle_time > TC3589x_MAX_DEBOUNCE_SETTLE)
109 return -EINVAL; 103 return -EINVAL;
110 104
111 /* configure KBDSIZE 4 LSbits for cols and 4 MSbits for rows */ 105 /* configure KBDSIZE 4 LSbits for cols and 4 MSbits for rows */
112 ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSIZE, 106 ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSIZE,
113 (rows << KP_ROW_SHIFT) | column); 107 (board->krow << KP_ROW_SHIFT) | board->kcol);
114 if (ret < 0) 108 if (ret < 0)
115 return ret; 109 return ret;
116 110
@@ -124,12 +118,14 @@ static int tc3589x_keypad_init_key_hardware(struct tc_keypad *keypad)
124 return ret; 118 return ret;
125 119
126 /* Configure settle time */ 120 /* Configure settle time */
127 ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSETTLE_REG, settle_time); 121 ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSETTLE_REG,
122 board->settle_time);
128 if (ret < 0) 123 if (ret < 0)
129 return ret; 124 return ret;
130 125
131 /* Configure debounce time */ 126 /* Configure debounce time */
132 ret = tc3589x_reg_write(tc3589x, TC3589x_KBDBOUNCE, dbounce_period); 127 ret = tc3589x_reg_write(tc3589x, TC3589x_KBDBOUNCE,
128 board->debounce_period);
133 if (ret < 0) 129 if (ret < 0)
134 return ret; 130 return ret;
135 131
@@ -337,23 +333,22 @@ static int __devinit tc3589x_keypad_probe(struct platform_device *pdev)
337 input->name = pdev->name; 333 input->name = pdev->name;
338 input->dev.parent = &pdev->dev; 334 input->dev.parent = &pdev->dev;
339 335
340 input->keycode = keypad->keymap;
341 input->keycodesize = sizeof(keypad->keymap[0]);
342 input->keycodemax = ARRAY_SIZE(keypad->keymap);
343
344 input->open = tc3589x_keypad_open; 336 input->open = tc3589x_keypad_open;
345 input->close = tc3589x_keypad_close; 337 input->close = tc3589x_keypad_close;
346 338
347 input_set_drvdata(input, keypad); 339 error = matrix_keypad_build_keymap(plat->keymap_data, NULL,
340 TC3589x_MAX_KPROW, TC3589x_MAX_KPCOL,
341 keypad->keymap, input);
342 if (error) {
343 dev_err(&pdev->dev, "Failed to build keymap\n");
344 goto err_free_mem;
345 }
348 346
349 input_set_capability(input, EV_MSC, MSC_SCAN); 347 input_set_capability(input, EV_MSC, MSC_SCAN);
350
351 __set_bit(EV_KEY, input->evbit);
352 if (!plat->no_autorepeat) 348 if (!plat->no_autorepeat)
353 __set_bit(EV_REP, input->evbit); 349 __set_bit(EV_REP, input->evbit);
354 350
355 matrix_keypad_build_keymap(plat->keymap_data, 0x3, 351 input_set_drvdata(input, keypad);
356 input->keycode, input->keybit);
357 352
358 error = request_threaded_irq(irq, NULL, 353 error = request_threaded_irq(irq, NULL,
359 tc3589x_keypad_irq, plat->irqtype, 354 tc3589x_keypad_irq, plat->irqtype,
diff --git a/drivers/input/keyboard/tca8418_keypad.c b/drivers/input/keyboard/tca8418_keypad.c
index 958ec107bfbc..5f87b28b3192 100644
--- a/drivers/input/keyboard/tca8418_keypad.c
+++ b/drivers/input/keyboard/tca8418_keypad.c
@@ -342,21 +342,20 @@ static int __devinit tca8418_keypad_probe(struct i2c_client *client,
342 input->id.product = 0x001; 342 input->id.product = 0x001;
343 input->id.version = 0x0001; 343 input->id.version = 0x0001;
344 344
345 input->keycode = keypad_data->keymap; 345 error = matrix_keypad_build_keymap(pdata->keymap_data, NULL,
346 input->keycodesize = sizeof(keypad_data->keymap[0]); 346 pdata->rows, pdata->cols,
347 input->keycodemax = max_keys; 347 keypad_data->keymap, input);
348 if (error) {
349 dev_dbg(&client->dev, "Failed to build keymap\n");
350 goto fail2;
351 }
348 352
349 __set_bit(EV_KEY, input->evbit);
350 if (pdata->rep) 353 if (pdata->rep)
351 __set_bit(EV_REP, input->evbit); 354 __set_bit(EV_REP, input->evbit);
352
353 input_set_capability(input, EV_MSC, MSC_SCAN); 355 input_set_capability(input, EV_MSC, MSC_SCAN);
354 356
355 input_set_drvdata(input, keypad_data); 357 input_set_drvdata(input, keypad_data);
356 358
357 matrix_keypad_build_keymap(pdata->keymap_data, row_shift,
358 input->keycode, input->keybit);
359
360 if (pdata->irq_is_gpio) 359 if (pdata->irq_is_gpio)
361 client->irq = gpio_to_irq(client->irq); 360 client->irq = gpio_to_irq(client->irq);
362 361
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
index fe4ac95ca6c8..4ffe64d53107 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -619,8 +619,8 @@ tegra_kbc_check_pin_cfg(const struct tegra_kbc_platform_data *pdata,
619} 619}
620 620
621#ifdef CONFIG_OF 621#ifdef CONFIG_OF
622static struct tegra_kbc_platform_data * __devinit 622static struct tegra_kbc_platform_data * __devinit tegra_kbc_dt_parse_pdata(
623tegra_kbc_dt_parse_pdata(struct platform_device *pdev) 623 struct platform_device *pdev)
624{ 624{
625 struct tegra_kbc_platform_data *pdata; 625 struct tegra_kbc_platform_data *pdata;
626 struct device_node *np = pdev->dev.of_node; 626 struct device_node *np = pdev->dev.of_node;
@@ -660,10 +660,6 @@ tegra_kbc_dt_parse_pdata(struct platform_device *pdev)
660 pdata->pin_cfg[KBC_MAX_ROW + i].type = PIN_CFG_COL; 660 pdata->pin_cfg[KBC_MAX_ROW + i].type = PIN_CFG_COL;
661 } 661 }
662 662
663 pdata->keymap_data = matrix_keyboard_of_fill_keymap(np, "linux,keymap");
664
665 /* FIXME: Add handling of linux,fn-keymap here */
666
667 return pdata; 663 return pdata;
668} 664}
669#else 665#else
@@ -674,10 +670,36 @@ static inline struct tegra_kbc_platform_data *tegra_kbc_dt_parse_pdata(
674} 670}
675#endif 671#endif
676 672
673static int __devinit tegra_kbd_setup_keymap(struct tegra_kbc *kbc)
674{
675 const struct tegra_kbc_platform_data *pdata = kbc->pdata;
676 const struct matrix_keymap_data *keymap_data = pdata->keymap_data;
677 unsigned int keymap_rows = KBC_MAX_KEY;
678 int retval;
679
680 if (keymap_data && pdata->use_fn_map)
681 keymap_rows *= 2;
682
683 retval = matrix_keypad_build_keymap(keymap_data, NULL,
684 keymap_rows, KBC_MAX_COL,
685 kbc->keycode, kbc->idev);
686 if (retval == -ENOSYS || retval == -ENOENT) {
687 /*
688 * If there is no OF support in kernel or keymap
689 * property is missing, use default keymap.
690 */
691 retval = matrix_keypad_build_keymap(
692 &tegra_kbc_default_keymap_data, NULL,
693 keymap_rows, KBC_MAX_COL,
694 kbc->keycode, kbc->idev);
695 }
696
697 return retval;
698}
699
677static int __devinit tegra_kbc_probe(struct platform_device *pdev) 700static int __devinit tegra_kbc_probe(struct platform_device *pdev)
678{ 701{
679 const struct tegra_kbc_platform_data *pdata = pdev->dev.platform_data; 702 const struct tegra_kbc_platform_data *pdata = pdev->dev.platform_data;
680 const struct matrix_keymap_data *keymap_data;
681 struct tegra_kbc *kbc; 703 struct tegra_kbc *kbc;
682 struct input_dev *input_dev; 704 struct input_dev *input_dev;
683 struct resource *res; 705 struct resource *res;
@@ -757,29 +779,26 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev)
757 kbc->repoll_dly = KBC_ROW_SCAN_DLY + scan_time_rows + pdata->repeat_cnt; 779 kbc->repoll_dly = KBC_ROW_SCAN_DLY + scan_time_rows + pdata->repeat_cnt;
758 kbc->repoll_dly = DIV_ROUND_UP(kbc->repoll_dly, KBC_CYCLE_MS); 780 kbc->repoll_dly = DIV_ROUND_UP(kbc->repoll_dly, KBC_CYCLE_MS);
759 781
782 kbc->wakeup_key = pdata->wakeup_key;
783 kbc->use_fn_map = pdata->use_fn_map;
784 kbc->use_ghost_filter = pdata->use_ghost_filter;
785
760 input_dev->name = pdev->name; 786 input_dev->name = pdev->name;
761 input_dev->id.bustype = BUS_HOST; 787 input_dev->id.bustype = BUS_HOST;
762 input_dev->dev.parent = &pdev->dev; 788 input_dev->dev.parent = &pdev->dev;
763 input_dev->open = tegra_kbc_open; 789 input_dev->open = tegra_kbc_open;
764 input_dev->close = tegra_kbc_close; 790 input_dev->close = tegra_kbc_close;
765 791
766 input_set_drvdata(input_dev, kbc); 792 err = tegra_kbd_setup_keymap(kbc);
793 if (err) {
794 dev_err(&pdev->dev, "failed to setup keymap\n");
795 goto err_put_clk;
796 }
767 797
768 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); 798 __set_bit(EV_REP, input_dev->evbit);
769 input_set_capability(input_dev, EV_MSC, MSC_SCAN); 799 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
770 800
771 input_dev->keycode = kbc->keycode; 801 input_set_drvdata(input_dev, kbc);
772 input_dev->keycodesize = sizeof(kbc->keycode[0]);
773 input_dev->keycodemax = KBC_MAX_KEY;
774 if (pdata->use_fn_map)
775 input_dev->keycodemax *= 2;
776
777 kbc->use_fn_map = pdata->use_fn_map;
778 kbc->use_ghost_filter = pdata->use_ghost_filter;
779 keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data;
780 matrix_keypad_build_keymap(keymap_data, KBC_ROW_SHIFT,
781 input_dev->keycode, input_dev->keybit);
782 kbc->wakeup_key = pdata->wakeup_key;
783 802
784 err = request_irq(kbc->irq, tegra_kbc_isr, 803 err = request_irq(kbc->irq, tegra_kbc_isr,
785 IRQF_NO_SUSPEND | IRQF_TRIGGER_HIGH, pdev->name, kbc); 804 IRQF_NO_SUSPEND | IRQF_TRIGGER_HIGH, pdev->name, kbc);
@@ -799,9 +818,6 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev)
799 platform_set_drvdata(pdev, kbc); 818 platform_set_drvdata(pdev, kbc);
800 device_init_wakeup(&pdev->dev, pdata->wakeup); 819 device_init_wakeup(&pdev->dev, pdata->wakeup);
801 820
802 if (!pdev->dev.platform_data)
803 matrix_keyboard_of_free_keymap(pdata->keymap_data);
804
805 return 0; 821 return 0;
806 822
807err_free_irq: 823err_free_irq:
@@ -816,10 +832,8 @@ err_free_mem:
816 input_free_device(input_dev); 832 input_free_device(input_dev);
817 kfree(kbc); 833 kfree(kbc);
818err_free_pdata: 834err_free_pdata:
819 if (!pdev->dev.platform_data) { 835 if (!pdev->dev.platform_data)
820 matrix_keyboard_of_free_keymap(pdata->keymap_data);
821 kfree(pdata); 836 kfree(pdata);
822 }
823 837
824 return err; 838 return err;
825} 839}
diff --git a/drivers/input/keyboard/tnetv107x-keypad.c b/drivers/input/keyboard/tnetv107x-keypad.c
index fb39c94b6fdd..a4a445fb7020 100644
--- a/drivers/input/keyboard/tnetv107x-keypad.c
+++ b/drivers/input/keyboard/tnetv107x-keypad.c
@@ -247,15 +247,11 @@ static int __devinit keypad_probe(struct platform_device *pdev)
247 error = -ENOMEM; 247 error = -ENOMEM;
248 goto error_input; 248 goto error_input;
249 } 249 }
250 input_set_drvdata(kp->input_dev, kp);
251 250
252 kp->input_dev->name = pdev->name; 251 kp->input_dev->name = pdev->name;
253 kp->input_dev->dev.parent = &pdev->dev; 252 kp->input_dev->dev.parent = &pdev->dev;
254 kp->input_dev->open = keypad_start; 253 kp->input_dev->open = keypad_start;
255 kp->input_dev->close = keypad_stop; 254 kp->input_dev->close = keypad_stop;
256 kp->input_dev->evbit[0] = BIT_MASK(EV_KEY);
257 if (!pdata->no_autorepeat)
258 kp->input_dev->evbit[0] |= BIT_MASK(EV_REP);
259 255
260 clk_enable(kp->clk); 256 clk_enable(kp->clk);
261 rev = keypad_read(kp, rev); 257 rev = keypad_read(kp, rev);
@@ -264,15 +260,20 @@ static int __devinit keypad_probe(struct platform_device *pdev)
264 kp->input_dev->id.version = ((rev >> 16) & 0xfff); 260 kp->input_dev->id.version = ((rev >> 16) & 0xfff);
265 clk_disable(kp->clk); 261 clk_disable(kp->clk);
266 262
267 kp->input_dev->keycode = kp->keycodes; 263 error = matrix_keypad_build_keymap(keymap_data, NULL,
268 kp->input_dev->keycodesize = sizeof(kp->keycodes[0]); 264 kp->rows, kp->cols,
269 kp->input_dev->keycodemax = kp->rows << kp->row_shift; 265 kp->keycodes, kp->input_dev);
270 266 if (error) {
271 matrix_keypad_build_keymap(keymap_data, kp->row_shift, kp->keycodes, 267 dev_err(dev, "Failed to build keymap\n");
272 kp->input_dev->keybit); 268 goto error_reg;
269 }
273 270
271 if (!pdata->no_autorepeat)
272 kp->input_dev->evbit[0] |= BIT_MASK(EV_REP);
274 input_set_capability(kp->input_dev, EV_MSC, MSC_SCAN); 273 input_set_capability(kp->input_dev, EV_MSC, MSC_SCAN);
275 274
275 input_set_drvdata(kp->input_dev, kp);
276
276 error = input_register_device(kp->input_dev); 277 error = input_register_device(kp->input_dev);
277 if (error < 0) { 278 if (error < 0) {
278 dev_err(dev, "Could not register input device\n"); 279 dev_err(dev, "Could not register input device\n");
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
index 67bec14e8b96..a2c6f79aa101 100644
--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -361,14 +361,6 @@ static int __devinit twl4030_kp_probe(struct platform_device *pdev)
361 kp->irq = platform_get_irq(pdev, 0); 361 kp->irq = platform_get_irq(pdev, 0);
362 362
363 /* setup input device */ 363 /* setup input device */
364 __set_bit(EV_KEY, input->evbit);
365
366 /* Enable auto repeat feature of Linux input subsystem */
367 if (pdata->rep)
368 __set_bit(EV_REP, input->evbit);
369
370 input_set_capability(input, EV_MSC, MSC_SCAN);
371
372 input->name = "TWL4030 Keypad"; 364 input->name = "TWL4030 Keypad";
373 input->phys = "twl4030_keypad/input0"; 365 input->phys = "twl4030_keypad/input0";
374 input->dev.parent = &pdev->dev; 366 input->dev.parent = &pdev->dev;
@@ -378,12 +370,19 @@ static int __devinit twl4030_kp_probe(struct platform_device *pdev)
378 input->id.product = 0x0001; 370 input->id.product = 0x0001;
379 input->id.version = 0x0003; 371 input->id.version = 0x0003;
380 372
381 input->keycode = kp->keymap; 373 error = matrix_keypad_build_keymap(keymap_data, NULL,
382 input->keycodesize = sizeof(kp->keymap[0]); 374 TWL4030_MAX_ROWS,
383 input->keycodemax = ARRAY_SIZE(kp->keymap); 375 1 << TWL4030_ROW_SHIFT,
376 kp->keymap, input);
377 if (error) {
378 dev_err(kp->dbg_dev, "Failed to build keymap\n");
379 goto err1;
380 }
384 381
385 matrix_keypad_build_keymap(keymap_data, TWL4030_ROW_SHIFT, 382 input_set_capability(input, EV_MSC, MSC_SCAN);
386 input->keycode, input->keybit); 383 /* Enable auto repeat feature of Linux input subsystem */
384 if (pdata->rep)
385 __set_bit(EV_REP, input->evbit);
387 386
388 error = input_register_device(input); 387 error = input_register_device(input);
389 if (error) { 388 if (error) {
diff --git a/drivers/input/keyboard/w90p910_keypad.c b/drivers/input/keyboard/w90p910_keypad.c
index 99bbb7e775ae..085ede4d972d 100644
--- a/drivers/input/keyboard/w90p910_keypad.c
+++ b/drivers/input/keyboard/w90p910_keypad.c
@@ -42,7 +42,8 @@
42#define KGET_RAW(n) (((n) & KEY0R) >> 3) 42#define KGET_RAW(n) (((n) & KEY0R) >> 3)
43#define KGET_COLUMN(n) ((n) & KEY0C) 43#define KGET_COLUMN(n) ((n) & KEY0C)
44 44
45#define W90P910_MAX_KEY_NUM (8 * 8) 45#define W90P910_NUM_ROWS 8
46#define W90P910_NUM_COLS 8
46#define W90P910_ROW_SHIFT 3 47#define W90P910_ROW_SHIFT 3
47 48
48struct w90p910_keypad { 49struct w90p910_keypad {
@@ -51,7 +52,7 @@ struct w90p910_keypad {
51 struct input_dev *input_dev; 52 struct input_dev *input_dev;
52 void __iomem *mmio_base; 53 void __iomem *mmio_base;
53 int irq; 54 int irq;
54 unsigned short keymap[W90P910_MAX_KEY_NUM]; 55 unsigned short keymap[W90P910_NUM_ROWS * W90P910_NUM_COLS];
55}; 56};
56 57
57static void w90p910_keypad_scan_matrix(struct w90p910_keypad *keypad, 58static void w90p910_keypad_scan_matrix(struct w90p910_keypad *keypad,
@@ -190,17 +191,13 @@ static int __devinit w90p910_keypad_probe(struct platform_device *pdev)
190 input_dev->close = w90p910_keypad_close; 191 input_dev->close = w90p910_keypad_close;
191 input_dev->dev.parent = &pdev->dev; 192 input_dev->dev.parent = &pdev->dev;
192 193
193 input_dev->keycode = keypad->keymap; 194 error = matrix_keypad_build_keymap(keymap_data, NULL,
194 input_dev->keycodesize = sizeof(keypad->keymap[0]); 195 W90P910_NUM_ROWS, W90P910_NUM_COLS,
195 input_dev->keycodemax = ARRAY_SIZE(keypad->keymap); 196 keypad->keymap, input_dev);
196 197 if (error) {
197 input_set_drvdata(input_dev, keypad); 198 dev_err(&pdev->dev, "failed to build keymap\n");
198 199 goto failed_put_clk;
199 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); 200 }
200 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
201
202 matrix_keypad_build_keymap(keymap_data, W90P910_ROW_SHIFT,
203 input_dev->keycode, input_dev->keybit);
204 201
205 error = request_irq(keypad->irq, w90p910_keypad_irq_handler, 202 error = request_irq(keypad->irq, w90p910_keypad_irq_handler,
206 0, pdev->name, keypad); 203 0, pdev->name, keypad);
@@ -209,6 +206,10 @@ static int __devinit w90p910_keypad_probe(struct platform_device *pdev)
209 goto failed_put_clk; 206 goto failed_put_clk;
210 } 207 }
211 208
209 __set_bit(EV_REP, input_dev->evbit);
210 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
211 input_set_drvdata(input_dev, keypad);
212
212 /* Register the input device */ 213 /* Register the input device */
213 error = input_register_device(input_dev); 214 error = input_register_device(input_dev);
214 if (error) { 215 if (error) {
diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c
index 37b01d777a4a..d050d9d0011b 100644
--- a/drivers/input/keyboard/xtkbd.c
+++ b/drivers/input/keyboard/xtkbd.c
@@ -169,15 +169,4 @@ static struct serio_driver xtkbd_drv = {
169 .disconnect = xtkbd_disconnect, 169 .disconnect = xtkbd_disconnect,
170}; 170};
171 171
172static int __init xtkbd_init(void) 172module_serio_driver(xtkbd_drv);
173{
174 return serio_register_driver(&xtkbd_drv);
175}
176
177static void __exit xtkbd_exit(void)
178{
179 serio_unregister_driver(&xtkbd_drv);
180}
181
182module_init(xtkbd_init);
183module_exit(xtkbd_exit);