aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/Kconfig17
-rw-r--r--drivers/input/Makefile2
-rw-r--r--drivers/input/keyboard/Kconfig18
-rw-r--r--drivers/input/keyboard/ep93xx_keypad.c18
-rw-r--r--drivers/input/keyboard/imx_keypad.c17
-rw-r--r--drivers/input/keyboard/lm8333.c15
-rw-r--r--drivers/input/keyboard/matrix_keypad.c17
-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.c15
-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.c21
-rw-r--r--drivers/input/keyboard/stmpe-keypad.c16
-rw-r--r--drivers/input/keyboard/tc3589x-keypad.c19
-rw-r--r--drivers/input/keyboard/tca8418_keypad.c15
-rw-r--r--drivers/input/keyboard/tegra-kbc.c34
-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/matrix-keymap.c (renamed from drivers/input/of_keymap.c)59
21 files changed, 259 insertions, 177 deletions
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 33259798081..55f7e57d4e4 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -25,10 +25,6 @@ config INPUT
25 25
26if INPUT 26if INPUT
27 27
28config INPUT_OF_MATRIX_KEYMAP
29 depends on USE_OF
30 bool
31
32config INPUT_FF_MEMLESS 28config INPUT_FF_MEMLESS
33 tristate "Support for memoryless force-feedback devices" 29 tristate "Support for memoryless force-feedback devices"
34 help 30 help
@@ -68,6 +64,19 @@ config INPUT_SPARSEKMAP
68 To compile this driver as a module, choose M here: the 64 To compile this driver as a module, choose M here: the
69 module will be called sparse-keymap. 65 module will be called sparse-keymap.
70 66
67config INPUT_MATRIXKMAP
68 tristate "Matrix keymap support library"
69 help
70 Say Y here if you are using a driver for an input
71 device that uses matrix keymap. This option is only
72 useful for out-of-tree drivers since in-tree drivers
73 select it automatically.
74
75 If unsure, say N.
76
77 To compile this driver as a module, choose M here: the
78 module will be called matrix-keymap.
79
71comment "Userland interfaces" 80comment "Userland interfaces"
72 81
73config INPUT_MOUSEDEV 82config INPUT_MOUSEDEV
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index b173a13a73c..5ca3f631497 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -10,6 +10,7 @@ input-core-y := input.o input-compat.o input-mt.o ff-core.o
10obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o 10obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o
11obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o 11obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o
12obj-$(CONFIG_INPUT_SPARSEKMAP) += sparse-keymap.o 12obj-$(CONFIG_INPUT_SPARSEKMAP) += sparse-keymap.o
13obj-$(CONFIG_INPUT_MATRIXKMAP) += matrix-keymap.o
13 14
14obj-$(CONFIG_INPUT_MOUSEDEV) += mousedev.o 15obj-$(CONFIG_INPUT_MOUSEDEV) += mousedev.o
15obj-$(CONFIG_INPUT_JOYDEV) += joydev.o 16obj-$(CONFIG_INPUT_JOYDEV) += joydev.o
@@ -24,4 +25,3 @@ obj-$(CONFIG_INPUT_TOUCHSCREEN) += touchscreen/
24obj-$(CONFIG_INPUT_MISC) += misc/ 25obj-$(CONFIG_INPUT_MISC) += misc/
25 26
26obj-$(CONFIG_INPUT_APMPOWER) += apm-power.o 27obj-$(CONFIG_INPUT_APMPOWER) += apm-power.o
27obj-$(CONFIG_INPUT_OF_MATRIX_KEYMAP) += of_keymap.o
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index ea4bbaae9e0..c0e11ecc646 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
@@ -312,6 +315,7 @@ config KEYBOARD_LM8323
312config KEYBOARD_LM8333 315config KEYBOARD_LM8333
313 tristate "LM8333 keypad chip" 316 tristate "LM8333 keypad chip"
314 depends on I2C 317 depends on I2C
318 select INPUT_MATRIXKMAP
315 help 319 help
316 If you say yes here you get support for the National Semiconductor 320 If you say yes here you get support for the National Semiconductor
317 LM8333 keypad controller. 321 LM8333 keypad controller.
@@ -376,6 +380,7 @@ config KEYBOARD_MPR121
376config KEYBOARD_IMX 380config KEYBOARD_IMX
377 tristate "IMX keypad support" 381 tristate "IMX keypad support"
378 depends on ARCH_MXC 382 depends on ARCH_MXC
383 select INPUT_MATRIXKMAP
379 help 384 help
380 Enable support for IMX keypad port. 385 Enable support for IMX keypad port.
381 386
@@ -394,6 +399,7 @@ config KEYBOARD_NEWTON
394config KEYBOARD_NOMADIK 399config KEYBOARD_NOMADIK
395 tristate "ST-Ericsson Nomadik SKE keyboard" 400 tristate "ST-Ericsson Nomadik SKE keyboard"
396 depends on PLAT_NOMADIK 401 depends on PLAT_NOMADIK
402 select INPUT_MATRIXKMAP
397 help 403 help
398 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
399 used on the Ux500 and Nomadik platforms 405 used on the Ux500 and Nomadik platforms
@@ -404,7 +410,7 @@ config KEYBOARD_NOMADIK
404config KEYBOARD_TEGRA 410config KEYBOARD_TEGRA
405 tristate "NVIDIA Tegra internal matrix keyboard controller support" 411 tristate "NVIDIA Tegra internal matrix keyboard controller support"
406 depends on ARCH_TEGRA 412 depends on ARCH_TEGRA
407 select INPUT_OF_MATRIX_KEYMAP if USE_OF 413 select INPUT_MATRIXKMAP
408 help 414 help
409 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
410 to the internal keyboard controller on Tegra SoCs. 416 to the internal keyboard controller on Tegra SoCs.
@@ -442,6 +448,7 @@ config KEYBOARD_PXA930_ROTARY
442config KEYBOARD_PMIC8XXX 448config KEYBOARD_PMIC8XXX
443 tristate "Qualcomm PMIC8XXX keypad support" 449 tristate "Qualcomm PMIC8XXX keypad support"
444 depends on MFD_PM8XXX 450 depends on MFD_PM8XXX
451 select INPUT_MATRIXKMAP
445 help 452 help
446 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
447 keypad provided as a reference design from Qualcomm. This is intended 454 keypad provided as a reference design from Qualcomm. This is intended
@@ -453,6 +460,7 @@ config KEYBOARD_PMIC8XXX
453config KEYBOARD_SAMSUNG 460config KEYBOARD_SAMSUNG
454 tristate "Samsung keypad support" 461 tristate "Samsung keypad support"
455 depends on HAVE_CLK 462 depends on HAVE_CLK
463 select INPUT_MATRIXKMAP
456 help 464 help
457 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
458 device. 466 device.
@@ -495,6 +503,7 @@ config KEYBOARD_SH_KEYSC
495config KEYBOARD_STMPE 503config KEYBOARD_STMPE
496 tristate "STMPE keypad support" 504 tristate "STMPE keypad support"
497 depends on MFD_STMPE 505 depends on MFD_STMPE
506 select INPUT_MATRIXKMAP
498 help 507 help
499 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
500 expanders. 509 expanders.
@@ -515,6 +524,7 @@ config KEYBOARD_DAVINCI
515config KEYBOARD_OMAP 524config KEYBOARD_OMAP
516 tristate "TI OMAP keypad support" 525 tristate "TI OMAP keypad support"
517 depends on (ARCH_OMAP1 || ARCH_OMAP2) 526 depends on (ARCH_OMAP1 || ARCH_OMAP2)
527 select INPUT_MATRIXKMAP
518 help 528 help
519 Say Y here if you want to use the OMAP keypad. 529 Say Y here if you want to use the OMAP keypad.
520 530
@@ -523,6 +533,7 @@ config KEYBOARD_OMAP
523 533
524config KEYBOARD_OMAP4 534config KEYBOARD_OMAP4
525 tristate "TI OMAP4+ keypad support" 535 tristate "TI OMAP4+ keypad support"
536 select INPUT_MATRIXKMAP
526 help 537 help
527 Say Y here if you want to use the OMAP4+ keypad. 538 Say Y here if you want to use the OMAP4+ keypad.
528 539
@@ -532,6 +543,7 @@ config KEYBOARD_OMAP4
532config KEYBOARD_SPEAR 543config KEYBOARD_SPEAR
533 tristate "ST SPEAR keyboard support" 544 tristate "ST SPEAR keyboard support"
534 depends on PLAT_SPEAR 545 depends on PLAT_SPEAR
546 select INPUT_MATRIXKMAP
535 help 547 help
536 Say Y here if you want to use the SPEAR keyboard. 548 Say Y here if you want to use the SPEAR keyboard.
537 549
@@ -541,6 +553,7 @@ config KEYBOARD_SPEAR
541config KEYBOARD_TC3589X 553config KEYBOARD_TC3589X
542 tristate "TC3589X Keypad support" 554 tristate "TC3589X Keypad support"
543 depends on MFD_TC3589X 555 depends on MFD_TC3589X
556 select INPUT_MATRIXKMAP
544 help 557 help
545 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
546 TC35892/3 I/O expander. 559 TC35892/3 I/O expander.
@@ -551,6 +564,7 @@ config KEYBOARD_TC3589X
551config KEYBOARD_TNETV107X 564config KEYBOARD_TNETV107X
552 tristate "TI TNETV107X keypad support" 565 tristate "TI TNETV107X keypad support"
553 depends on ARCH_DAVINCI_TNETV107X 566 depends on ARCH_DAVINCI_TNETV107X
567 select INPUT_MATRIXKMAP
554 help 568 help
555 Say Y here if you want to use the TNETV107X keypad. 569 Say Y here if you want to use the TNETV107X keypad.
556 570
@@ -560,6 +574,7 @@ config KEYBOARD_TNETV107X
560config KEYBOARD_TWL4030 574config KEYBOARD_TWL4030
561 tristate "TI TWL4030/TWL5030/TPS659x0 keypad support" 575 tristate "TI TWL4030/TWL5030/TPS659x0 keypad support"
562 depends on TWL4030_CORE 576 depends on TWL4030_CORE
577 select INPUT_MATRIXKMAP
563 help 578 help
564 Say Y here if your board use the keypad controller on 579 Say Y here if your board use the keypad controller on
565 TWL4030 family chips. It's safe to say enable this 580 TWL4030 family chips. It's safe to say enable this
@@ -583,6 +598,7 @@ config KEYBOARD_XTKBD
583config KEYBOARD_W90P910 598config KEYBOARD_W90P910
584 tristate "W90P910 Matrix Keypad support" 599 tristate "W90P910 Matrix Keypad support"
585 depends on ARCH_W90X900 600 depends on ARCH_W90X900
601 select INPUT_MATRIXKMAP
586 help 602 help
587 Say Y here to enable the matrix keypad on evaluation board 603 Say Y here to enable the matrix keypad on evaluation board
588 based on W90P910. 604 based on W90P910.
diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
index df194bdaab5..c46fc818546 100644
--- a/drivers/input/keyboard/ep93xx_keypad.c
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -303,19 +303,16 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
303 input_dev->open = ep93xx_keypad_open; 303 input_dev->open = ep93xx_keypad_open;
304 input_dev->close = ep93xx_keypad_close; 304 input_dev->close = ep93xx_keypad_close;
305 input_dev->dev.parent = &pdev->dev; 305 input_dev->dev.parent = &pdev->dev;
306 input_dev->keycode = keypad->keycodes;
307 input_dev->keycodesize = sizeof(keypad->keycodes[0]);
308 input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
309 306
310 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;
311 312
312 input_dev->evbit[0] = BIT_MASK(EV_KEY);
313 if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT) 313 if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT)
314 input_dev->evbit[0] |= BIT_MASK(EV_REP); 314 __set_bit(EV_REP, input_dev->evbit);
315 315 input_set_drvdata(input_dev, keypad);
316 matrix_keypad_build_keymap(keymap_data, 3,
317 input_dev->keycode, input_dev->keybit);
318 platform_set_drvdata(pdev, keypad);
319 316
320 err = request_irq(keypad->irq, ep93xx_keypad_irq_handler, 317 err = request_irq(keypad->irq, ep93xx_keypad_irq_handler,
321 0, pdev->name, keypad); 318 0, pdev->name, keypad);
@@ -326,6 +323,7 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
326 if (err) 323 if (err)
327 goto failed_free_irq; 324 goto failed_free_irq;
328 325
326 platform_set_drvdata(pdev, keypad);
329 device_init_wakeup(&pdev->dev, 1); 327 device_init_wakeup(&pdev->dev, 1);
330 328
331 return 0; 329 return 0;
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index fb87b3bcadb..6ee7421e232 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/lm8333.c b/drivers/input/keyboard/lm8333.c
index 9a8c4a6cf5c..ca168a6679d 100644
--- a/drivers/input/keyboard/lm8333.c
+++ b/drivers/input/keyboard/lm8333.c
@@ -29,9 +29,9 @@
29 29
30#define LM8333_FIFO_TRANSFER_SIZE 16 30#define LM8333_FIFO_TRANSFER_SIZE 16
31 31
32#define LM8333_ROW_SHIFT 4
33#define LM8333_NUM_ROWS 8 32#define LM8333_NUM_ROWS 8
34 33#define LM8333_NUM_COLS 16
34#define LM8333_ROW_SHIFT 4
35 35
36struct lm8333 { 36struct lm8333 {
37 struct i2c_client *client; 37 struct i2c_client *client;
@@ -159,14 +159,13 @@ static int __devinit lm8333_probe(struct i2c_client *client,
159 input->dev.parent = &client->dev; 159 input->dev.parent = &client->dev;
160 input->id.bustype = BUS_I2C; 160 input->id.bustype = BUS_I2C;
161 161
162 input->keycode = lm8333->keycodes;
163 input->keycodesize = sizeof(lm8333->keycodes[0]);
164 input->keycodemax = ARRAY_SIZE(lm8333->keycodes);
165 input->evbit[0] = BIT_MASK(EV_KEY);
166 input_set_capability(input, EV_MSC, MSC_SCAN); 162 input_set_capability(input, EV_MSC, MSC_SCAN);
167 163
168 matrix_keypad_build_keymap(pdata->matrix_data, LM8333_ROW_SHIFT, 164 err = matrix_keypad_build_keymap(pdata->matrix_data, NULL,
169 input->keycode, input->keybit); 165 LM8333_NUM_ROWS, LM8333_NUM_COLS,
166 lm8333->keycodes, input);
167 if (err)
168 goto free_mem;
170 169
171 if (pdata->debounce_time) { 170 if (pdata->debounce_time) {
172 err = lm8333_write8(lm8333, LM8333_DEBOUNCE, 171 err = lm8333_write8(lm8333, LM8333_DEBOUNCE,
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index 98ae281bedb..18b72372028 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -437,19 +437,18 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
437 input_dev->name = pdev->name; 437 input_dev->name = pdev->name;
438 input_dev->id.bustype = BUS_HOST; 438 input_dev->id.bustype = BUS_HOST;
439 input_dev->dev.parent = &pdev->dev; 439 input_dev->dev.parent = &pdev->dev;
440 input_dev->evbit[0] = BIT_MASK(EV_KEY);
441 if (!pdata->no_autorepeat)
442 input_dev->evbit[0] |= BIT_MASK(EV_REP);
443 input_dev->open = matrix_keypad_start; 440 input_dev->open = matrix_keypad_start;
444 input_dev->close = matrix_keypad_stop; 441 input_dev->close = matrix_keypad_stop;
445 442
446 input_dev->keycode = keypad->keycodes; 443 err = matrix_keypad_build_keymap(keymap_data, NULL,
447 input_dev->keycodesize = sizeof(keypad->keycodes[0]); 444 pdata->num_row_gpios,
448 input_dev->keycodemax = pdata->num_row_gpios << row_shift; 445 pdata->num_col_gpios,
449 446 keypad->keycodes, input_dev);
450 matrix_keypad_build_keymap(keymap_data, row_shift, 447 if (err)
451 input_dev->keycode, input_dev->keybit); 448 goto err_free_mem;
452 449
450 if (!pdata->no_autorepeat)
451 __set_bit(EV_REP, input_dev->evbit);
453 input_set_capability(input_dev, EV_MSC, MSC_SCAN); 452 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
454 input_set_drvdata(input_dev, keypad); 453 input_set_drvdata(input_dev, keypad);
455 454
diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c
index 101e245944e..4ea4341a68c 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 6b630d9d3df..a0222db4dc8 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 28da0e46968..aed5f6999ce 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -322,20 +322,19 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev)
322 input_dev->open = omap4_keypad_open; 322 input_dev->open = omap4_keypad_open;
323 input_dev->close = omap4_keypad_close; 323 input_dev->close = omap4_keypad_close;
324 324
325 input_dev->keycode = keypad_data->keymap; 325 error = matrix_keypad_build_keymap(pdata->keymap_data, NULL,
326 input_dev->keycodesize = sizeof(keypad_data->keymap[0]); 326 pdata->rows, pdata->cols,
327 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 }
328 332
329 __set_bit(EV_KEY, input_dev->evbit);
330 __set_bit(EV_REP, input_dev->evbit); 333 __set_bit(EV_REP, input_dev->evbit);
331
332 input_set_capability(input_dev, EV_MSC, MSC_SCAN); 334 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
333 335
334 input_set_drvdata(input_dev, keypad_data); 336 input_set_drvdata(input_dev, keypad_data);
335 337
336 matrix_keypad_build_keymap(pdata->keymap_data, row_shift,
337 input_dev->keycode, input_dev->keybit);
338
339 error = request_irq(keypad_data->irq, omap4_keypad_interrupt, 338 error = request_irq(keypad_data->irq, omap4_keypad_interrupt,
340 IRQF_TRIGGER_RISING, 339 IRQF_TRIGGER_RISING,
341 "omap4-keypad", keypad_data); 340 "omap4-keypad", keypad_data);
diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c b/drivers/input/keyboard/pmic8xxx-keypad.c
index 01a1c9f8a38..52c34657d30 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 2391ae884fe..a061ba603a2 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 3b6b528f02f..e83cab27eb5 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -49,7 +49,9 @@
49#define KEY_VALUE 0x00FFFFFF 49#define KEY_VALUE 0x00FFFFFF
50#define ROW_MASK 0xF0 50#define ROW_MASK 0xF0
51#define COLUMN_MASK 0x0F 51#define COLUMN_MASK 0x0F
52#define ROW_SHIFT 4 52#define NUM_ROWS 16
53#define NUM_COLS 16
54
53#define KEY_MATRIX_SHIFT 6 55#define KEY_MATRIX_SHIFT 6
54 56
55struct spear_kbd { 57struct spear_kbd {
@@ -60,7 +62,7 @@ struct spear_kbd {
60 unsigned int irq; 62 unsigned int irq;
61 unsigned int mode; 63 unsigned int mode;
62 unsigned short last_key; 64 unsigned short last_key;
63 unsigned short keycodes[256]; 65 unsigned short keycodes[NUM_ROWS * NUM_COLS];
64}; 66};
65 67
66static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id) 68static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id)
@@ -212,18 +214,17 @@ static int __devinit spear_kbd_probe(struct platform_device *pdev)
212 input_dev->open = spear_kbd_open; 214 input_dev->open = spear_kbd_open;
213 input_dev->close = spear_kbd_close; 215 input_dev->close = spear_kbd_close;
214 216
215 __set_bit(EV_KEY, input_dev->evbit); 217 error = matrix_keypad_build_keymap(keymap, NULL, NUM_ROWS, NUM_COLS,
218 kbd->keycodes, input_dev);
219 if (error) {
220 dev_err(&pdev->dev, "Failed to build keymap\n");
221 goto err_put_clk;
222 }
223
216 if (pdata->rep) 224 if (pdata->rep)
217 __set_bit(EV_REP, input_dev->evbit); 225 __set_bit(EV_REP, input_dev->evbit);
218 input_set_capability(input_dev, EV_MSC, MSC_SCAN); 226 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
219 227
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); 228 input_set_drvdata(input_dev, kbd);
228 229
229 error = request_irq(irq, spear_kbd_interrupt, 0, "keyboard", kbd); 230 error = request_irq(irq, spear_kbd_interrupt, 0, "keyboard", kbd);
diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
index 9397cf9c625..470a8778dec 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/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c
index f4da2a7a697..7d498e69850 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 */
@@ -333,23 +333,22 @@ static int __devinit tc3589x_keypad_probe(struct platform_device *pdev)
333 input->name = pdev->name; 333 input->name = pdev->name;
334 input->dev.parent = &pdev->dev; 334 input->dev.parent = &pdev->dev;
335 335
336 input->keycode = keypad->keymap;
337 input->keycodesize = sizeof(keypad->keymap[0]);
338 input->keycodemax = ARRAY_SIZE(keypad->keymap);
339
340 input->open = tc3589x_keypad_open; 336 input->open = tc3589x_keypad_open;
341 input->close = tc3589x_keypad_close; 337 input->close = tc3589x_keypad_close;
342 338
343 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 }
344 346
345 input_set_capability(input, EV_MSC, MSC_SCAN); 347 input_set_capability(input, EV_MSC, MSC_SCAN);
346
347 __set_bit(EV_KEY, input->evbit);
348 if (!plat->no_autorepeat) 348 if (!plat->no_autorepeat)
349 __set_bit(EV_REP, input->evbit); 349 __set_bit(EV_REP, input->evbit);
350 350
351 matrix_keypad_build_keymap(plat->keymap_data, 0x3, 351 input_set_drvdata(input, keypad);
352 input->keycode, input->keybit);
353 352
354 error = request_threaded_irq(irq, NULL, 353 error = request_threaded_irq(irq, NULL,
355 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 958ec107bfb..5f87b28b319 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 fe4ac95ca6c..6722d376e89 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -686,6 +686,7 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev)
686 int num_rows = 0; 686 int num_rows = 0;
687 unsigned int debounce_cnt; 687 unsigned int debounce_cnt;
688 unsigned int scan_time_rows; 688 unsigned int scan_time_rows;
689 unsigned int keymap_rows;
689 690
690 if (!pdata) 691 if (!pdata)
691 pdata = tegra_kbc_dt_parse_pdata(pdev); 692 pdata = tegra_kbc_dt_parse_pdata(pdev);
@@ -757,29 +758,34 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev)
757 kbc->repoll_dly = KBC_ROW_SCAN_DLY + scan_time_rows + pdata->repeat_cnt; 758 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); 759 kbc->repoll_dly = DIV_ROUND_UP(kbc->repoll_dly, KBC_CYCLE_MS);
759 760
761 kbc->wakeup_key = pdata->wakeup_key;
762 kbc->use_fn_map = pdata->use_fn_map;
763 kbc->use_ghost_filter = pdata->use_ghost_filter;
764
760 input_dev->name = pdev->name; 765 input_dev->name = pdev->name;
761 input_dev->id.bustype = BUS_HOST; 766 input_dev->id.bustype = BUS_HOST;
762 input_dev->dev.parent = &pdev->dev; 767 input_dev->dev.parent = &pdev->dev;
763 input_dev->open = tegra_kbc_open; 768 input_dev->open = tegra_kbc_open;
764 input_dev->close = tegra_kbc_close; 769 input_dev->close = tegra_kbc_close;
765 770
766 input_set_drvdata(input_dev, kbc); 771 keymap_rows = KBC_MAX_KEY;
767
768 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
769 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
770
771 input_dev->keycode = kbc->keycode;
772 input_dev->keycodesize = sizeof(kbc->keycode[0]);
773 input_dev->keycodemax = KBC_MAX_KEY;
774 if (pdata->use_fn_map) 772 if (pdata->use_fn_map)
775 input_dev->keycodemax *= 2; 773 keymap_rows *= 2;
776 774
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; 775 keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data;
780 matrix_keypad_build_keymap(keymap_data, KBC_ROW_SHIFT, 776
781 input_dev->keycode, input_dev->keybit); 777 err = matrix_keypad_build_keymap(keymap_data, NULL,
782 kbc->wakeup_key = pdata->wakeup_key; 778 keymap_rows, KBC_MAX_COL,
779 kbc->keycode, input_dev);
780 if (err) {
781 dev_err(&pdev->dev, "failed to build keymap\n");
782 goto err_put_clk;
783 }
784
785 __set_bit(EV_REP, input_dev->evbit);
786 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
787
788 input_set_drvdata(input_dev, kbc);
783 789
784 err = request_irq(kbc->irq, tegra_kbc_isr, 790 err = request_irq(kbc->irq, tegra_kbc_isr,
785 IRQF_NO_SUSPEND | IRQF_TRIGGER_HIGH, pdev->name, kbc); 791 IRQF_NO_SUSPEND | IRQF_TRIGGER_HIGH, pdev->name, kbc);
diff --git a/drivers/input/keyboard/tnetv107x-keypad.c b/drivers/input/keyboard/tnetv107x-keypad.c
index fb39c94b6fd..a4a445fb702 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 67bec14e8b9..a2c6f79aa10 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 99bbb7e775a..085ede4d972 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/of_keymap.c b/drivers/input/matrix-keymap.c
index 061493d5768..de7992d55da 100644
--- a/drivers/input/of_keymap.c
+++ b/drivers/input/matrix-keymap.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Helpers for open firmware matrix keyboard bindings 2 * Helpers for matrix keyboard bindings
3 * 3 *
4 * Copyright (C) 2012 Google, Inc 4 * Copyright (C) 2012 Google, Inc
5 * 5 *
@@ -21,11 +21,65 @@
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/input.h> 22#include <linux/input.h>
23#include <linux/of.h> 23#include <linux/of.h>
24#include <linux/input/matrix_keypad.h>
25#include <linux/export.h> 24#include <linux/export.h>
26#include <linux/gfp.h> 25#include <linux/gfp.h>
27#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/input/matrix_keypad.h>
28
29
30/**
31 * matrix_keypad_build_keymap - convert platform keymap into matrix keymap
32 * @keymap_data: keymap supplied by the platform code
33 * @keymap_name: name of device tree property containing keymap (if device
34 * tree support is enabled).
35 * @rows: number of rows in target keymap array
36 * @cols: number of cols in target keymap array
37 * @keymap: expanded version of keymap that is suitable for use by
38 * matrix keyboard driver
39 * @input_dev: input devices for which we are setting up the keymap
40 *
41 * This function converts platform keymap (encoded with KEY() macro) into
42 * an array of keycodes that is suitable for using in a standard matrix
43 * keyboard driver that uses row and col as indices.
44 */
45int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
46 const char *keymap_name,
47 unsigned int rows, unsigned int cols,
48 unsigned short *keymap,
49 struct input_dev *input_dev)
50{
51 unsigned int row_shift = get_count_order(cols);
52 int i;
53
54 input_dev->keycode = keymap;
55 input_dev->keycodesize = sizeof(*keymap);
56 input_dev->keycodemax = rows << row_shift;
57
58 __set_bit(EV_KEY, input_dev->evbit);
59
60 for (i = 0; i < keymap_data->keymap_size; i++) {
61 unsigned int key = keymap_data->keymap[i];
62 unsigned int row = KEY_ROW(key);
63 unsigned int col = KEY_COL(key);
64 unsigned short code = KEY_VAL(key);
65
66 if (row >= rows || col >= cols) {
67 dev_err(input_dev->dev.parent,
68 "%s: invalid keymap entry %d (row: %d, col: %d, rows: %d, cols: %d)\n",
69 __func__, i, row, col, rows, cols);
70 return -EINVAL;
71 }
72
73 keymap[MATRIX_SCAN_CODE(row, col, row_shift)] = code;
74 __set_bit(code, input_dev->keybit);
75 }
76 __clear_bit(KEY_RESERVED, input_dev->keybit);
77
78 return 0;
79}
80EXPORT_SYMBOL(matrix_keypad_build_keymap);
28 81
82#ifdef CONFIG_OF
29struct matrix_keymap_data * 83struct matrix_keymap_data *
30matrix_keyboard_of_fill_keymap(struct device_node *np, 84matrix_keyboard_of_fill_keymap(struct device_node *np,
31 const char *propname) 85 const char *propname)
@@ -85,3 +139,4 @@ void matrix_keyboard_of_free_keymap(const struct matrix_keymap_data *kd)
85 } 139 }
86} 140}
87EXPORT_SYMBOL_GPL(matrix_keyboard_of_free_keymap); 141EXPORT_SYMBOL_GPL(matrix_keyboard_of_free_keymap);
142#endif