* [PATCH 0/4] input: keyboard: tegra: cleanups and DT supports @ 2013-01-04 11:02 Laxman Dewangan [not found] ` <1357297330-28878-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> 2013-01-04 11:02 ` [PATCH 3/4] input: keyboard: tegra: add support for rows/cols configuration from dt Laxman Dewangan 0 siblings, 2 replies; 8+ messages in thread From: Laxman Dewangan @ 2013-01-04 11:02 UTC (permalink / raw) To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w Cc: grant.likely-s3s/WqlpOiPyB63q8FvJNQ, rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, swarren-DDmLM1+adcrQT0dZR+AlfA, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-doc-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-input-u79uwXL29TY76Z2rM5mHXA, linux-tegra-u79uwXL29TY76Z2rM5mHXA, Laxman Dewangan This patch series: - fix build warning, - use devm_* for allocation, - make column/rows configuration through DT and - remove the rarely used key mapping table. Laxman Dewangan (4): input: keyboard: tegra: fix build warning input: keyboard: tegra: use devm_* for resource allocation input: keyboard: tegra: add support for rows/cols configuration from dt input: keyboard: tegra: remove default key mapping .../bindings/input/nvidia,tegra20-kbc.txt | 22 ++ drivers/input/keyboard/tegra-kbc.c | 346 ++++++-------------- 2 files changed, 120 insertions(+), 248 deletions(-) ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <1357297330-28878-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>]
* [PATCH 1/4] input: keyboard: tegra: fix build warning [not found] ` <1357297330-28878-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> @ 2013-01-04 11:02 ` Laxman Dewangan 2013-01-04 11:02 ` [PATCH 2/4] input: keyboard: tegra: use devm_* for resource allocation Laxman Dewangan 2013-01-04 11:02 ` [PATCH 4/4] input: keyboard: tegra: remove default key mapping Laxman Dewangan 2 siblings, 0 replies; 8+ messages in thread From: Laxman Dewangan @ 2013-01-04 11:02 UTC (permalink / raw) To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w Cc: swarren-DDmLM1+adcrQT0dZR+AlfA, linux-doc-u79uwXL29TY76Z2rM5mHXA, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA, rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, Laxman Dewangan, linux-input-u79uwXL29TY76Z2rM5mHXA, linux-tegra-u79uwXL29TY76Z2rM5mHXA Fix the following build warning when building driver with CONFIG_PM_SLEEP not selected. tegra-kbc.c:360:13: warning: 'tegra_kbc_set_keypress_interrupt' defined but not used [-Wunused-function] Signed-off-by: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> --- drivers/input/keyboard/tegra-kbc.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index c76f968..f1d3ba0 100644 --- a/drivers/input/keyboard/tegra-kbc.c +++ b/drivers/input/keyboard/tegra-kbc.c @@ -357,18 +357,6 @@ static void tegra_kbc_set_fifo_interrupt(struct tegra_kbc *kbc, bool enable) writel(val, kbc->mmio + KBC_CONTROL_0); } -static void tegra_kbc_set_keypress_interrupt(struct tegra_kbc *kbc, bool enable) -{ - u32 val; - - val = readl(kbc->mmio + KBC_CONTROL_0); - if (enable) - val |= KBC_CONTROL_KEYPRESS_INT_EN; - else - val &= ~KBC_CONTROL_KEYPRESS_INT_EN; - writel(val, kbc->mmio + KBC_CONTROL_0); -} - static void tegra_kbc_keypress_timer(unsigned long data) { struct tegra_kbc *kbc = (struct tegra_kbc *)data; @@ -866,6 +854,18 @@ static int tegra_kbc_remove(struct platform_device *pdev) } #ifdef CONFIG_PM_SLEEP +static void tegra_kbc_set_keypress_interrupt(struct tegra_kbc *kbc, bool enable) +{ + u32 val; + + val = readl(kbc->mmio + KBC_CONTROL_0); + if (enable) + val |= KBC_CONTROL_KEYPRESS_INT_EN; + else + val &= ~KBC_CONTROL_KEYPRESS_INT_EN; + writel(val, kbc->mmio + KBC_CONTROL_0); +} + static int tegra_kbc_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); -- 1.7.1.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/4] input: keyboard: tegra: use devm_* for resource allocation [not found] ` <1357297330-28878-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> 2013-01-04 11:02 ` [PATCH 1/4] input: keyboard: tegra: fix build warning Laxman Dewangan @ 2013-01-04 11:02 ` Laxman Dewangan 2013-01-04 11:02 ` [PATCH 4/4] input: keyboard: tegra: remove default key mapping Laxman Dewangan 2 siblings, 0 replies; 8+ messages in thread From: Laxman Dewangan @ 2013-01-04 11:02 UTC (permalink / raw) To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w Cc: swarren-DDmLM1+adcrQT0dZR+AlfA, linux-doc-u79uwXL29TY76Z2rM5mHXA, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA, rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, Laxman Dewangan, linux-input-u79uwXL29TY76Z2rM5mHXA, linux-tegra-u79uwXL29TY76Z2rM5mHXA Use devm_* for memory, clock, input device allocation. This reduces code for freeing these resources. Signed-off-by: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> --- drivers/input/keyboard/tegra-kbc.c | 93 +++++++++++------------------------- 1 files changed, 28 insertions(+), 65 deletions(-) diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index f1d3ba0..c036425 100644 --- a/drivers/input/keyboard/tegra-kbc.c +++ b/drivers/input/keyboard/tegra-kbc.c @@ -618,7 +618,7 @@ static struct tegra_kbc_platform_data *tegra_kbc_dt_parse_pdata( if (!np) return NULL; - pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return NULL; @@ -700,33 +700,36 @@ static int tegra_kbc_probe(struct platform_device *pdev) if (!pdata) pdata = tegra_kbc_dt_parse_pdata(pdev); - if (!pdata) + if (!pdata) { + dev_err(&pdev->dev, "Platform data missing\n"); return -EINVAL; - - if (!tegra_kbc_check_pin_cfg(pdata, &pdev->dev, &num_rows)) { - err = -EINVAL; - goto err_free_pdata; } + if (!tegra_kbc_check_pin_cfg(pdata, &pdev->dev, &num_rows)) + return -EINVAL; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "failed to get I/O memory\n"); - err = -ENXIO; - goto err_free_pdata; + return -ENXIO; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "failed to get keyboard IRQ\n"); - err = -ENXIO; - goto err_free_pdata; + return -ENXIO; + } + + kbc = devm_kzalloc(&pdev->dev, sizeof(*kbc), GFP_KERNEL); + if (!kbc) { + dev_err(&pdev->dev, "failed to alloc memory for kbc\n"); + return -ENOMEM; } - kbc = kzalloc(sizeof(*kbc), GFP_KERNEL); - input_dev = input_allocate_device(); - if (!kbc || !input_dev) { - err = -ENOMEM; - goto err_free_mem; + input_dev = devm_input_allocate_device(&pdev->dev); + if (!input_dev) { + dev_err(&pdev->dev, "failed to allocate input device\n"); + return -ENOMEM; } kbc->pdata = pdata; @@ -735,25 +738,16 @@ static int tegra_kbc_probe(struct platform_device *pdev) spin_lock_init(&kbc->lock); setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc); - res = request_mem_region(res->start, resource_size(res), pdev->name); - if (!res) { - dev_err(&pdev->dev, "failed to request I/O memory\n"); - err = -EBUSY; - goto err_free_mem; - } - - kbc->mmio = ioremap(res->start, resource_size(res)); + kbc->mmio = devm_request_and_ioremap(&pdev->dev, res); if (!kbc->mmio) { - dev_err(&pdev->dev, "failed to remap I/O memory\n"); - err = -ENXIO; - goto err_free_mem_region; + dev_err(&pdev->dev, "Cannot request memregion/iomap address\n"); + return -EADDRNOTAVAIL; } - kbc->clk = clk_get(&pdev->dev, NULL); + kbc->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(kbc->clk)) { dev_err(&pdev->dev, "failed to get keyboard clock\n"); - err = PTR_ERR(kbc->clk); - goto err_iounmap; + return PTR_ERR(kbc->clk); } /* @@ -778,9 +772,9 @@ static int tegra_kbc_probe(struct platform_device *pdev) input_dev->close = tegra_kbc_close; err = tegra_kbd_setup_keymap(kbc); - if (err) { + if (err < 0) { dev_err(&pdev->dev, "failed to setup keymap\n"); - goto err_put_clk; + return err; } __set_bit(EV_REP, input_dev->evbit); @@ -790,15 +784,15 @@ static int tegra_kbc_probe(struct platform_device *pdev) err = request_irq(kbc->irq, tegra_kbc_isr, IRQF_NO_SUSPEND | IRQF_TRIGGER_HIGH, pdev->name, kbc); - if (err) { + if (err < 0) { dev_err(&pdev->dev, "failed to request keyboard IRQ\n"); - goto err_put_clk; + return err; } disable_irq(kbc->irq); err = input_register_device(kbc->idev); - if (err) { + if (err < 0) { dev_err(&pdev->dev, "failed to register input device\n"); goto err_free_irq; } @@ -810,46 +804,15 @@ static int tegra_kbc_probe(struct platform_device *pdev) err_free_irq: free_irq(kbc->irq, pdev); -err_put_clk: - clk_put(kbc->clk); -err_iounmap: - iounmap(kbc->mmio); -err_free_mem_region: - release_mem_region(res->start, resource_size(res)); -err_free_mem: - input_free_device(input_dev); - kfree(kbc); -err_free_pdata: - if (!pdev->dev.platform_data) - kfree(pdata); - return err; } static int tegra_kbc_remove(struct platform_device *pdev) { struct tegra_kbc *kbc = platform_get_drvdata(pdev); - struct resource *res; - - platform_set_drvdata(pdev, NULL); free_irq(kbc->irq, pdev); - clk_put(kbc->clk); - input_unregister_device(kbc->idev); - iounmap(kbc->mmio); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - release_mem_region(res->start, resource_size(res)); - - /* - * If we do not have platform data attached to the device we - * allocated it ourselves and thus need to free it. - */ - if (!pdev->dev.platform_data) - kfree(kbc->pdata); - - kfree(kbc); - return 0; } -- 1.7.1.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/4] input: keyboard: tegra: remove default key mapping [not found] ` <1357297330-28878-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> 2013-01-04 11:02 ` [PATCH 1/4] input: keyboard: tegra: fix build warning Laxman Dewangan 2013-01-04 11:02 ` [PATCH 2/4] input: keyboard: tegra: use devm_* for resource allocation Laxman Dewangan @ 2013-01-04 11:02 ` Laxman Dewangan [not found] ` <1357297330-28878-5-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> 2 siblings, 1 reply; 8+ messages in thread From: Laxman Dewangan @ 2013-01-04 11:02 UTC (permalink / raw) To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w Cc: swarren-DDmLM1+adcrQT0dZR+AlfA, linux-doc-u79uwXL29TY76Z2rM5mHXA, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA, rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, Laxman Dewangan, linux-input-u79uwXL29TY76Z2rM5mHXA, linux-tegra-u79uwXL29TY76Z2rM5mHXA Tegra KBC driver have the default key mapping for 16x8 configuration. The key mapping can be provided through platform data or through DT and the mapping varies from platform to platform, hence this default mapping is not so useful. Remove the default mapping to reduce the code lines of the driver. Signed-off-by: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> --- drivers/input/keyboard/tegra-kbc.c | 156 +----------------------------------- 1 files changed, 1 insertions(+), 155 deletions(-) diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index 69f8b04..4e33929 100644 --- a/drivers/input/keyboard/tegra-kbc.c +++ b/drivers/input/keyboard/tegra-kbc.c @@ -87,147 +87,6 @@ struct tegra_kbc { struct clk *clk; }; -static const u32 tegra_kbc_default_keymap[] = { - KEY(0, 2, KEY_W), - KEY(0, 3, KEY_S), - KEY(0, 4, KEY_A), - KEY(0, 5, KEY_Z), - KEY(0, 7, KEY_FN), - - KEY(1, 7, KEY_LEFTMETA), - - KEY(2, 6, KEY_RIGHTALT), - KEY(2, 7, KEY_LEFTALT), - - KEY(3, 0, KEY_5), - KEY(3, 1, KEY_4), - KEY(3, 2, KEY_R), - KEY(3, 3, KEY_E), - KEY(3, 4, KEY_F), - KEY(3, 5, KEY_D), - KEY(3, 6, KEY_X), - - KEY(4, 0, KEY_7), - KEY(4, 1, KEY_6), - KEY(4, 2, KEY_T), - KEY(4, 3, KEY_H), - KEY(4, 4, KEY_G), - KEY(4, 5, KEY_V), - KEY(4, 6, KEY_C), - KEY(4, 7, KEY_SPACE), - - KEY(5, 0, KEY_9), - KEY(5, 1, KEY_8), - KEY(5, 2, KEY_U), - KEY(5, 3, KEY_Y), - KEY(5, 4, KEY_J), - KEY(5, 5, KEY_N), - KEY(5, 6, KEY_B), - KEY(5, 7, KEY_BACKSLASH), - - KEY(6, 0, KEY_MINUS), - KEY(6, 1, KEY_0), - KEY(6, 2, KEY_O), - KEY(6, 3, KEY_I), - KEY(6, 4, KEY_L), - KEY(6, 5, KEY_K), - KEY(6, 6, KEY_COMMA), - KEY(6, 7, KEY_M), - - KEY(7, 1, KEY_EQUAL), - KEY(7, 2, KEY_RIGHTBRACE), - KEY(7, 3, KEY_ENTER), - KEY(7, 7, KEY_MENU), - - KEY(8, 4, KEY_RIGHTSHIFT), - KEY(8, 5, KEY_LEFTSHIFT), - - KEY(9, 5, KEY_RIGHTCTRL), - KEY(9, 7, KEY_LEFTCTRL), - - KEY(11, 0, KEY_LEFTBRACE), - KEY(11, 1, KEY_P), - KEY(11, 2, KEY_APOSTROPHE), - KEY(11, 3, KEY_SEMICOLON), - KEY(11, 4, KEY_SLASH), - KEY(11, 5, KEY_DOT), - - KEY(12, 0, KEY_F10), - KEY(12, 1, KEY_F9), - KEY(12, 2, KEY_BACKSPACE), - KEY(12, 3, KEY_3), - KEY(12, 4, KEY_2), - KEY(12, 5, KEY_UP), - KEY(12, 6, KEY_PRINT), - KEY(12, 7, KEY_PAUSE), - - KEY(13, 0, KEY_INSERT), - KEY(13, 1, KEY_DELETE), - KEY(13, 3, KEY_PAGEUP), - KEY(13, 4, KEY_PAGEDOWN), - KEY(13, 5, KEY_RIGHT), - KEY(13, 6, KEY_DOWN), - KEY(13, 7, KEY_LEFT), - - KEY(14, 0, KEY_F11), - KEY(14, 1, KEY_F12), - KEY(14, 2, KEY_F8), - KEY(14, 3, KEY_Q), - KEY(14, 4, KEY_F4), - KEY(14, 5, KEY_F3), - KEY(14, 6, KEY_1), - KEY(14, 7, KEY_F7), - - KEY(15, 0, KEY_ESC), - KEY(15, 1, KEY_GRAVE), - KEY(15, 2, KEY_F5), - KEY(15, 3, KEY_TAB), - KEY(15, 4, KEY_F1), - KEY(15, 5, KEY_F2), - KEY(15, 6, KEY_CAPSLOCK), - KEY(15, 7, KEY_F6), - - /* Software Handled Function Keys */ - KEY(20, 0, KEY_KP7), - - KEY(21, 0, KEY_KP9), - KEY(21, 1, KEY_KP8), - KEY(21, 2, KEY_KP4), - KEY(21, 4, KEY_KP1), - - KEY(22, 1, KEY_KPSLASH), - KEY(22, 2, KEY_KP6), - KEY(22, 3, KEY_KP5), - KEY(22, 4, KEY_KP3), - KEY(22, 5, KEY_KP2), - KEY(22, 7, KEY_KP0), - - KEY(27, 1, KEY_KPASTERISK), - KEY(27, 3, KEY_KPMINUS), - KEY(27, 4, KEY_KPPLUS), - KEY(27, 5, KEY_KPDOT), - - KEY(28, 5, KEY_VOLUMEUP), - - KEY(29, 3, KEY_HOME), - KEY(29, 4, KEY_END), - KEY(29, 5, KEY_BRIGHTNESSDOWN), - KEY(29, 6, KEY_VOLUMEDOWN), - KEY(29, 7, KEY_BRIGHTNESSUP), - - KEY(30, 0, KEY_NUMLOCK), - KEY(30, 1, KEY_SCROLLLOCK), - KEY(30, 2, KEY_MUTE), - - KEY(31, 4, KEY_HELP), -}; - -static const -struct matrix_keymap_data tegra_kbc_default_keymap_data = { - .keymap = tegra_kbc_default_keymap, - .keymap_size = ARRAY_SIZE(tegra_kbc_default_keymap), -}; - static void tegra_kbc_report_released_keys(struct input_dev *input, unsigned short old_keycodes[], unsigned int old_num_keys, @@ -704,26 +563,13 @@ static int 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, + return 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 tegra_kbc_probe(struct platform_device *pdev) -- 1.7.1.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
[parent not found: <1357297330-28878-5-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 4/4] input: keyboard: tegra: remove default key mapping [not found] ` <1357297330-28878-5-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> @ 2013-01-04 19:52 ` Stephen Warren 2013-01-05 7:20 ` Laxman Dewangan 0 siblings, 1 reply; 8+ messages in thread From: Stephen Warren @ 2013-01-04 19:52 UTC (permalink / raw) To: Laxman Dewangan Cc: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w, grant.likely-s3s/WqlpOiPyB63q8FvJNQ, rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, swarren-DDmLM1+adcrQT0dZR+AlfA, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-doc-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-input-u79uwXL29TY76Z2rM5mHXA, linux-tegra-u79uwXL29TY76Z2rM5mHXA On 01/04/2013 04:02 AM, Laxman Dewangan wrote: > Tegra KBC driver have the default key mapping for 16x8 configuration. > The key mapping can be provided through platform data or through DT > and the mapping varies from platform to platform, hence this default > mapping is not so useful. Remove the default mapping to reduce the code > lines of the driver. Overall, I agree with the intent of this change, but I /think/ the default keymap described here actually /is/ useful for the Seaboard/Springbank platforms. I guess the KBC driver isn't in the device tree for that (or any) board yet, so removing this keymap isn't really a regression, but it would be nice if you could come up with a change to add suitable keymaps to the device tree files too. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 4/4] input: keyboard: tegra: remove default key mapping 2013-01-04 19:52 ` Stephen Warren @ 2013-01-05 7:20 ` Laxman Dewangan 0 siblings, 0 replies; 8+ messages in thread From: Laxman Dewangan @ 2013-01-05 7:20 UTC (permalink / raw) To: Stephen Warren Cc: dmitry.torokhov@gmail.com, grant.likely@secretlab.ca, rob.herring@calxeda.com, Stephen Warren, devicetree-discuss@lists.ozlabs.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-tegra@vger.kernel.org On Saturday 05 January 2013 01:22 AM, Stephen Warren wrote: > On 01/04/2013 04:02 AM, Laxman Dewangan wrote: >> Tegra KBC driver have the default key mapping for 16x8 configuration. >> The key mapping can be provided through platform data or through DT >> and the mapping varies from platform to platform, hence this default >> mapping is not so useful. Remove the default mapping to reduce the code >> lines of the driver. > Overall, I agree with the intent of this change, but I /think/ the > default keymap described here actually /is/ useful for the > Seaboard/Springbank platforms. I guess the KBC driver isn't in the > device tree for that (or any) board yet, so removing this keymap isn't > really a regression, but it would be nice if you could come up with a > change to add suitable keymaps to the device tree files too. OK, I will push the patch for enabling keys in seaboard along with the other changes for DT files for tegra. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/4] input: keyboard: tegra: add support for rows/cols configuration from dt 2013-01-04 11:02 [PATCH 0/4] input: keyboard: tegra: cleanups and DT supports Laxman Dewangan [not found] ` <1357297330-28878-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> @ 2013-01-04 11:02 ` Laxman Dewangan 2013-01-04 19:50 ` Stephen Warren 1 sibling, 1 reply; 8+ messages in thread From: Laxman Dewangan @ 2013-01-04 11:02 UTC (permalink / raw) To: dmitry.torokhov Cc: grant.likely, rob.herring, swarren, devicetree-discuss, linux-doc, linux-kernel, linux-input, linux-tegra, Laxman Dewangan The NVIDIA's Tegra KBC has maximum 24 pins to make matrix keypad. Any pin can be configured as row or column. The maximum column pin can be 8 and maximum row pin can be 16. Remove the assumption that all first 16 pins will be used as row and remaining as columns and Add the property for configuring pins to either row or column from DT. Update the devicetree binding document accordingly. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> --- .../bindings/input/nvidia,tegra20-kbc.txt | 22 ++++++ drivers/input/keyboard/tegra-kbc.c | 73 +++++++++++++++---- 2 files changed, 79 insertions(+), 16 deletions(-) diff --git a/Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt b/Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt index 72683be..71c17d9 100644 --- a/Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt +++ b/Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt @@ -1,7 +1,18 @@ * Tegra keyboard controller +The key controller has maximum 24 pins to make matrix keypad. Any pin +can be configured as row or column. The maximum column pin can be 8 +and maximum row pins can be 16 for Tegra20/Tegra30. Required properties: - compatible: "nvidia,tegra20-kbc" +- reg: Register base address of KBC. +- interrupts: Interrupt number for the KBC. +- nvidia,kbc-rows: The KBC pins which are configured as row. This is the + array of pinmnumber. +- nvidia,kbc-cols: The KBC pins which are configured as column. This is the + array of pinmnumber. +- linux,keymap: The keymap for keys as described in the binding document + devicetree/bindings/input/matrix-keymap.txt. Optional properties, in addition to those specified by the shared matrix-keyboard bindings: @@ -19,5 +30,16 @@ Example: keyboard: keyboard { compatible = "nvidia,tegra20-kbc"; reg = <0x7000e200 0x100>; + interrupts = <0 85 0x04>; nvidia,ghost-filter; + nvidia,debounce-delay-ms = <640>; + nvidia,kbc-rows = <0 1 2>; /* pin 0, 1 and 2 are mapped as rows */ + nvidia,kbc-cols = <11 12 13>; /* pin 11, 12 and 13 are mapped as cols */ + linux,keymap = < 0x00000074 + 0x00010067 + 0x00020066 + 0x01010068 + 0x02000069 + 0x02010070 + 0x02020071 >; }; diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index c036425..69f8b04 100644 --- a/drivers/input/keyboard/tegra-kbc.c +++ b/drivers/input/keyboard/tegra-kbc.c @@ -614,13 +614,16 @@ static struct tegra_kbc_platform_data *tegra_kbc_dt_parse_pdata( struct device_node *np = pdev->dev.of_node; u32 prop; int i; - - if (!np) - return NULL; + u32 num_rows = 0; + u32 num_cols = 0; + u32 cols_cfg[KBC_MAX_GPIO]; + u32 rows_cfg[KBC_MAX_GPIO]; + int proplen; + int ret; pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) - return NULL; + return ERR_PTR(-ENOMEM); if (!of_property_read_u32(np, "nvidia,debounce-delay-ms", &prop)) pdata->debounce_cnt = prop; @@ -634,18 +637,56 @@ static struct tegra_kbc_platform_data *tegra_kbc_dt_parse_pdata( if (of_find_property(np, "nvidia,wakeup-source", NULL)) pdata->wakeup = true; - /* - * All currently known keymaps with device tree support use the same - * pin_cfg, so set it up here. - */ - for (i = 0; i < KBC_MAX_ROW; i++) { + if (!of_get_property(np, "nvidia,kbc-rows", &proplen)) { + dev_err(&pdev->dev, "property nvidia,kbc-rows not defined\n"); + return ERR_PTR(-ENOENT); + } + num_rows = proplen / sizeof(u32); + + if (!of_get_property(np, "nvidia,kbc-cols", &proplen)) { + dev_err(&pdev->dev, "property nvidia,kbc-cols not defined\n"); + return ERR_PTR(-ENOENT); + } + num_cols = proplen / sizeof(u32); + + if (!of_get_property(np, "linux,keymap", &proplen)) { + dev_err(&pdev->dev, "property nvidia,kbc-cols not defined\n"); + return ERR_PTR(-ENOENT); + } + + if (!num_rows || !num_cols || ((num_rows + num_cols) > KBC_MAX_GPIO)) { + dev_err(&pdev->dev, "keypad rows/columns not porperly specified\n"); + return ERR_PTR(-EINVAL); + } + + /* Set all pins as non-configured */ + for (i = 0; i < KBC_MAX_GPIO; i++) { pdata->pin_cfg[i].num = i; - pdata->pin_cfg[i].type = PIN_CFG_ROW; + pdata->pin_cfg[i].type = PIN_CFG_IGNORE; + } + + ret = of_property_read_u32_array(np, "nvidia,kbc-rows", + rows_cfg, num_rows); + if (ret < 0) { + dev_err(&pdev->dev, "Rows configurations are not proper\n"); + return ERR_PTR(-ENOENT); + } + + ret = of_property_read_u32_array(np, "nvidia,kbc-cols", + cols_cfg, num_cols); + if (ret < 0) { + dev_err(&pdev->dev, "Cols configurations are not proper\n"); + return ERR_PTR(-ENOENT); + } + + for (i = 0; i < num_rows; i++) { + pdata->pin_cfg[rows_cfg[i]].type = PIN_CFG_ROW; + pdata->pin_cfg[rows_cfg[i]].num = i; } - for (i = 0; i < KBC_MAX_COL; i++) { - pdata->pin_cfg[KBC_MAX_ROW + i].num = i; - pdata->pin_cfg[KBC_MAX_ROW + i].type = PIN_CFG_COL; + for (i = 0; i < num_cols; i++) { + pdata->pin_cfg[cols_cfg[i]].type = PIN_CFG_COL; + pdata->pin_cfg[cols_cfg[i]].num = i; } return pdata; @@ -697,12 +738,12 @@ static int tegra_kbc_probe(struct platform_device *pdev) unsigned int debounce_cnt; unsigned int scan_time_rows; - if (!pdata) + if (!pdata && pdev->dev.of_node) pdata = tegra_kbc_dt_parse_pdata(pdev); - if (!pdata) { + if (IS_ERR_OR_NULL(pdata)) { dev_err(&pdev->dev, "Platform data missing\n"); - return -EINVAL; + return (pdata) ? PTR_ERR(pdata) : -EINVAL; } if (!tegra_kbc_check_pin_cfg(pdata, &pdev->dev, &num_rows)) -- 1.7.1.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/4] input: keyboard: tegra: add support for rows/cols configuration from dt 2013-01-04 11:02 ` [PATCH 3/4] input: keyboard: tegra: add support for rows/cols configuration from dt Laxman Dewangan @ 2013-01-04 19:50 ` Stephen Warren 0 siblings, 0 replies; 8+ messages in thread From: Stephen Warren @ 2013-01-04 19:50 UTC (permalink / raw) To: Laxman Dewangan Cc: dmitry.torokhov, grant.likely, rob.herring, swarren, devicetree-discuss, linux-doc, linux-kernel, linux-input, linux-tegra On 01/04/2013 04:02 AM, Laxman Dewangan wrote: > The NVIDIA's Tegra KBC has maximum 24 pins to make matrix keypad. > Any pin can be configured as row or column. The maximum column pin > can be 8 and maximum row pin can be 16. > > Remove the assumption that all first 16 pins will be used as row > and remaining as columns and Add the property for configuring pins > to either row or column from DT. Update the devicetree binding > document accordingly. > diff --git a/Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt b/Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt > Required properties: > +- nvidia,kbc-rows: The KBC pins which are configured as row. This is the > + array of pinmnumber. > +- nvidia,kbc-cols: The KBC pins which are configured as column. This is the > + array of pinmnumber. "the array of pinmnumber" -> "an array of pin numbers"? I wonder if "row-pins" and "col-pins" would be a better name; "rows" and "cols" sound like a count not a lines. But perhaps that's just bike-shedding. > + linux,keymap = < 0x00000074 > + 0x00010067 > + 0x00020066 > + 0x01010068 > + 0x02000069 > + 0x02010070 > + 0x02020071 >; Nit-pick: no space after < or before >. At least, the Tegra DTs are all currently cleaned up that way. > diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c > + /* Set all pins as non-configured */ > + for (i = 0; i < KBC_MAX_GPIO; i++) { > pdata->pin_cfg[i].num = i; > + pdata->pin_cfg[i].type = PIN_CFG_IGNORE; > + } ... > + for (i = 0; i < num_rows; i++) { > + pdata->pin_cfg[rows_cfg[i]].type = PIN_CFG_ROW; > + pdata->pin_cfg[rows_cfg[i]].num = i; If we're setting up "num" here for the valid rows/cols, then why is the ".num = i" assignment needed in the loop above that sets .type = IGNORE? > } > > + for (i = 0; i < num_cols; i++) { > + pdata->pin_cfg[cols_cfg[i]].type = PIN_CFG_COL; > + pdata->pin_cfg[cols_cfg[i]].num = i; > } > - if (!pdata) { > + if (IS_ERR_OR_NULL(pdata)) { > dev_err(&pdev->dev, "Platform data missing\n"); > - return -EINVAL; > + return (pdata) ? PTR_ERR(pdata) : -EINVAL; No need for () around the first use of pdata there. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-01-05 7:21 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-01-04 11:02 [PATCH 0/4] input: keyboard: tegra: cleanups and DT supports Laxman Dewangan [not found] ` <1357297330-28878-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> 2013-01-04 11:02 ` [PATCH 1/4] input: keyboard: tegra: fix build warning Laxman Dewangan 2013-01-04 11:02 ` [PATCH 2/4] input: keyboard: tegra: use devm_* for resource allocation Laxman Dewangan 2013-01-04 11:02 ` [PATCH 4/4] input: keyboard: tegra: remove default key mapping Laxman Dewangan [not found] ` <1357297330-28878-5-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> 2013-01-04 19:52 ` Stephen Warren 2013-01-05 7:20 ` Laxman Dewangan 2013-01-04 11:02 ` [PATCH 3/4] input: keyboard: tegra: add support for rows/cols configuration from dt Laxman Dewangan 2013-01-04 19:50 ` Stephen Warren
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).