aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard/imx_keypad.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/keyboard/imx_keypad.c')
-rw-r--r--drivers/input/keyboard/imx_keypad.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index 6d150e3e1f55..98f9113251d2 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -20,6 +20,7 @@
20#include <linux/jiffies.h> 20#include <linux/jiffies.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/of.h>
23#include <linux/platform_device.h> 24#include <linux/platform_device.h>
24#include <linux/slab.h> 25#include <linux/slab.h>
25#include <linux/timer.h> 26#include <linux/timer.h>
@@ -414,15 +415,23 @@ open_err:
414 return -EIO; 415 return -EIO;
415} 416}
416 417
418#ifdef CONFIG_OF
419static struct of_device_id imx_keypad_of_match[] = {
420 { .compatible = "fsl,imx21-kpp", },
421 { /* sentinel */ }
422};
423MODULE_DEVICE_TABLE(of, imx_keypad_of_match);
424#endif
425
417static int imx_keypad_probe(struct platform_device *pdev) 426static int imx_keypad_probe(struct platform_device *pdev)
418{ 427{
419 const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data; 428 const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data;
420 struct imx_keypad *keypad; 429 struct imx_keypad *keypad;
421 struct input_dev *input_dev; 430 struct input_dev *input_dev;
422 struct resource *res; 431 struct resource *res;
423 int irq, error, i; 432 int irq, error, i, row, col;
424 433
425 if (keymap_data == NULL) { 434 if (!keymap_data && !pdev->dev.of_node) {
426 dev_err(&pdev->dev, "no keymap defined\n"); 435 dev_err(&pdev->dev, "no keymap defined\n");
427 return -EINVAL; 436 return -EINVAL;
428 } 437 }
@@ -480,22 +489,6 @@ static int imx_keypad_probe(struct platform_device *pdev)
480 goto failed_unmap; 489 goto failed_unmap;
481 } 490 }
482 491
483 /* Search for rows and cols enabled */
484 for (i = 0; i < keymap_data->keymap_size; i++) {
485 keypad->rows_en_mask |= 1 << KEY_ROW(keymap_data->keymap[i]);
486 keypad->cols_en_mask |= 1 << KEY_COL(keymap_data->keymap[i]);
487 }
488
489 if (keypad->rows_en_mask > ((1 << MAX_MATRIX_KEY_ROWS) - 1) ||
490 keypad->cols_en_mask > ((1 << MAX_MATRIX_KEY_COLS) - 1)) {
491 dev_err(&pdev->dev,
492 "invalid key data (too many rows or colums)\n");
493 error = -EINVAL;
494 goto failed_clock_put;
495 }
496 dev_dbg(&pdev->dev, "enabled rows mask: %x\n", keypad->rows_en_mask);
497 dev_dbg(&pdev->dev, "enabled cols mask: %x\n", keypad->cols_en_mask);
498
499 /* Init the Input device */ 492 /* Init the Input device */
500 input_dev->name = pdev->name; 493 input_dev->name = pdev->name;
501 input_dev->id.bustype = BUS_HOST; 494 input_dev->id.bustype = BUS_HOST;
@@ -512,6 +505,19 @@ static int imx_keypad_probe(struct platform_device *pdev)
512 goto failed_clock_put; 505 goto failed_clock_put;
513 } 506 }
514 507
508 /* Search for rows and cols enabled */
509 for (row = 0; row < MAX_MATRIX_KEY_ROWS; row++) {
510 for (col = 0; col < MAX_MATRIX_KEY_COLS; col++) {
511 i = MATRIX_SCAN_CODE(row, col, MATRIX_ROW_SHIFT);
512 if (keypad->keycodes[i] != KEY_RESERVED) {
513 keypad->rows_en_mask |= 1 << row;
514 keypad->cols_en_mask |= 1 << col;
515 }
516 }
517 }
518 dev_dbg(&pdev->dev, "enabled rows mask: %x\n", keypad->rows_en_mask);
519 dev_dbg(&pdev->dev, "enabled cols mask: %x\n", keypad->cols_en_mask);
520
515 __set_bit(EV_REP, input_dev->evbit); 521 __set_bit(EV_REP, input_dev->evbit);
516 input_set_capability(input_dev, EV_MSC, MSC_SCAN); 522 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
517 input_set_drvdata(input_dev, keypad); 523 input_set_drvdata(input_dev, keypad);
@@ -631,6 +637,7 @@ static struct platform_driver imx_keypad_driver = {
631 .name = "imx-keypad", 637 .name = "imx-keypad",
632 .owner = THIS_MODULE, 638 .owner = THIS_MODULE,
633 .pm = &imx_kbd_pm_ops, 639 .pm = &imx_kbd_pm_ops,
640 .of_match_table = of_match_ptr(imx_keypad_of_match),
634 }, 641 },
635 .probe = imx_keypad_probe, 642 .probe = imx_keypad_probe,
636 .remove = imx_keypad_remove, 643 .remove = imx_keypad_remove,