diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-05-11 09:37:15 +0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-05-11 09:39:43 +0400 |
commit | b45c8f35a7fec17bdd159a7815203b6137c00ab9 (patch) | |
tree | c6fc8efe76ff2b382e8290d6df59129200032a5d /drivers/input/keyboard/tegra-kbc.c | |
parent | 1932811f426fee71b7ece67e70aeba7e1b0ebb6d (diff) | |
download | linux-b45c8f35a7fec17bdd159a7815203b6137c00ab9.tar.xz |
Input: matrix-keymap - wire up device tree support
When platform keymap is not supplied to matrix_keypad_build_keymap()
and device tree support is enabled, try locating specified property
and load keymap from it. If property name is not defined, try using
"linux,keymap".
Based on earlier patch by Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/keyboard/tegra-kbc.c')
-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, } #ifdef CONFIG_OF -static struct tegra_kbc_platform_data * __devinit -tegra_kbc_dt_parse_pdata(struct platform_device *pdev) +static struct tegra_kbc_platform_data * __devinit tegra_kbc_dt_parse_pdata( + struct platform_device *pdev) { struct tegra_kbc_platform_data *pdata; struct device_node *np = pdev->dev.of_node; @@ -660,10 +660,6 @@ tegra_kbc_dt_parse_pdata(struct platform_device *pdev) pdata->pin_cfg[KBC_MAX_ROW + i].type = PIN_CFG_COL; } - pdata->keymap_data = matrix_keyboard_of_fill_keymap(np, "linux,keymap"); - - /* FIXME: Add handling of linux,fn-keymap here */ - return pdata; } #else @@ -674,10 +670,36 @@ static inline struct tegra_kbc_platform_data *tegra_kbc_dt_parse_pdata( } #endif +static int __devinit tegra_kbd_setup_keymap(struct tegra_kbc *kbc) +{ + const struct tegra_kbc_platform_data *pdata = kbc->pdata; + const struct matrix_keymap_data *keymap_data = pdata->keymap_data; + unsigned int keymap_rows = KBC_MAX_KEY; + int retval; + + if (keymap_data && pdata->use_fn_map) + keymap_rows *= 2; + + retval = matrix_keypad_build_keymap(keymap_data, NULL, + keymap_rows, KBC_MAX_COL, + kbc->keycode, kbc->idev); + if (retval == -ENOSYS || retval == -ENOENT) { + /* + * If there is no OF support in kernel or keymap + * property is missing, use default keymap. + */ + retval = matrix_keypad_build_keymap( + &tegra_kbc_default_keymap_data, NULL, + keymap_rows, KBC_MAX_COL, + kbc->keycode, kbc->idev); + } + + return retval; +} + static int __devinit tegra_kbc_probe(struct platform_device *pdev) { const struct tegra_kbc_platform_data *pdata = pdev->dev.platform_data; - const struct matrix_keymap_data *keymap_data; struct tegra_kbc *kbc; struct input_dev *input_dev; struct resource *res; @@ -686,7 +708,6 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev) int num_rows = 0; unsigned int debounce_cnt; unsigned int scan_time_rows; - unsigned int keymap_rows; if (!pdata) pdata = tegra_kbc_dt_parse_pdata(pdev); @@ -768,17 +789,9 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev) input_dev->open = tegra_kbc_open; input_dev->close = tegra_kbc_close; - keymap_rows = KBC_MAX_KEY; - if (pdata->use_fn_map) - keymap_rows *= 2; - - keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data; - - err = matrix_keypad_build_keymap(keymap_data, NULL, - keymap_rows, KBC_MAX_COL, - kbc->keycode, input_dev); + err = tegra_kbd_setup_keymap(kbc); if (err) { - dev_err(&pdev->dev, "failed to build keymap\n"); + dev_err(&pdev->dev, "failed to setup keymap\n"); goto err_put_clk; } @@ -805,9 +818,6 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, kbc); device_init_wakeup(&pdev->dev, pdata->wakeup); - if (!pdev->dev.platform_data) - matrix_keyboard_of_free_keymap(pdata->keymap_data); - return 0; err_free_irq: @@ -822,10 +832,8 @@ err_free_mem: input_free_device(input_dev); kfree(kbc); err_free_pdata: - if (!pdev->dev.platform_data) { - matrix_keyboard_of_free_keymap(pdata->keymap_data); + if (!pdev->dev.platform_data) kfree(pdata); - } return err; } |