diff options
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r-- | drivers/input/keyboard/tegra-kbc.c | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index 6722d376e898..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 |
622 | static struct tegra_kbc_platform_data * __devinit | 622 | static struct tegra_kbc_platform_data * __devinit tegra_kbc_dt_parse_pdata( |
623 | tegra_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 | ||
673 | static 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 | |||
677 | static int __devinit tegra_kbc_probe(struct platform_device *pdev) | 700 | static 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; |
@@ -686,7 +708,6 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev) | |||
686 | int num_rows = 0; | 708 | int num_rows = 0; |
687 | unsigned int debounce_cnt; | 709 | unsigned int debounce_cnt; |
688 | unsigned int scan_time_rows; | 710 | unsigned int scan_time_rows; |
689 | unsigned int keymap_rows; | ||
690 | 711 | ||
691 | if (!pdata) | 712 | if (!pdata) |
692 | pdata = tegra_kbc_dt_parse_pdata(pdev); | 713 | pdata = tegra_kbc_dt_parse_pdata(pdev); |
@@ -768,17 +789,9 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev) | |||
768 | input_dev->open = tegra_kbc_open; | 789 | input_dev->open = tegra_kbc_open; |
769 | input_dev->close = tegra_kbc_close; | 790 | input_dev->close = tegra_kbc_close; |
770 | 791 | ||
771 | keymap_rows = KBC_MAX_KEY; | 792 | err = tegra_kbd_setup_keymap(kbc); |
772 | if (pdata->use_fn_map) | ||
773 | keymap_rows *= 2; | ||
774 | |||
775 | keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data; | ||
776 | |||
777 | err = matrix_keypad_build_keymap(keymap_data, NULL, | ||
778 | keymap_rows, KBC_MAX_COL, | ||
779 | kbc->keycode, input_dev); | ||
780 | if (err) { | 793 | if (err) { |
781 | dev_err(&pdev->dev, "failed to build keymap\n"); | 794 | dev_err(&pdev->dev, "failed to setup keymap\n"); |
782 | goto err_put_clk; | 795 | goto err_put_clk; |
783 | } | 796 | } |
784 | 797 | ||
@@ -805,9 +818,6 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev) | |||
805 | platform_set_drvdata(pdev, kbc); | 818 | platform_set_drvdata(pdev, kbc); |
806 | device_init_wakeup(&pdev->dev, pdata->wakeup); | 819 | device_init_wakeup(&pdev->dev, pdata->wakeup); |
807 | 820 | ||
808 | if (!pdev->dev.platform_data) | ||
809 | matrix_keyboard_of_free_keymap(pdata->keymap_data); | ||
810 | |||
811 | return 0; | 821 | return 0; |
812 | 822 | ||
813 | err_free_irq: | 823 | err_free_irq: |
@@ -822,10 +832,8 @@ err_free_mem: | |||
822 | input_free_device(input_dev); | 832 | input_free_device(input_dev); |
823 | kfree(kbc); | 833 | kfree(kbc); |
824 | err_free_pdata: | 834 | err_free_pdata: |
825 | if (!pdev->dev.platform_data) { | 835 | if (!pdev->dev.platform_data) |
826 | matrix_keyboard_of_free_keymap(pdata->keymap_data); | ||
827 | kfree(pdata); | 836 | kfree(pdata); |
828 | } | ||
829 | 837 | ||
830 | return err; | 838 | return err; |
831 | } | 839 | } |