diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2011-01-20 18:03:04 +0530 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2011-11-30 21:45:29 -0800 |
commit | 2c243e8050ed562693a2e835b76ca3bea0fa1437 (patch) | |
tree | 2d3ddfd5df28c92f34472cb5460bd05656a45d7e /arch/arm/mach-tegra/board-cardhu-kbc.c | |
parent | 8e01bcc2b2c62ae990507a346fb473d4df39f3e3 (diff) |
[arm] tegra:cardhu: Configuration for all possible keypads
The cardhu will use following options as keyboard:
- Keypad through tegra-kbc controller.
- Scroll wheel.
- Gpio based keypad.
Making required configuration for all option. The configuration
can be enabled through config variables in def config files.
Original-Change-Id: Icf0ae1d4a26c744a7791c2141c9f2b1318f59d50
Reviewed-on: http://git-master/r/16382
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Tested-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Scott Williams <scwilliams@nvidia.com>
Original-Change-Id: I5afc69ecb404c48bd42d141baea021c96465fcfc
Rebase-Id: R85314ce12d1ba70fef2d94295384348902af7bdf
Diffstat (limited to 'arch/arm/mach-tegra/board-cardhu-kbc.c')
-rw-r--r-- | arch/arm/mach-tegra/board-cardhu-kbc.c | 162 |
1 files changed, 156 insertions, 6 deletions
diff --git a/arch/arm/mach-tegra/board-cardhu-kbc.c b/arch/arm/mach-tegra/board-cardhu-kbc.c index cb798e951c17..2671e6cc586b 100644 --- a/arch/arm/mach-tegra/board-cardhu-kbc.c +++ b/arch/arm/mach-tegra/board-cardhu-kbc.c @@ -1,6 +1,6 @@ /* * arch/arm/mach-tegra/board-cardhu-kbc.c - * KBC configuration for Nvidia tegra3 cardhu platform. + * Keys configuration for Nvidia tegra3 cardhu platform. * * Copyright (C) 2011 NVIDIA, Inc. * @@ -23,19 +23,46 @@ #include <linux/platform_device.h> #include <linux/input.h> #include <linux/device.h> +#include <linux/gpio.h> +#include <linux/gpio_keys.h> +#include <linux/gpio_scrollwheel.h> #include <mach/irqs.h> #include <mach/io.h> #include <mach/iomap.h> #include <mach/kbc.h> -#define CARDHU_ROW_COUNT 2 -#define CARDHU_COL_COUNT 4 +#include "gpio-names.h" -static int plain_kbd_keycode[] = { - KEY_WAKEUP, KEY_RESERVED, KEY_VOLUMEDOWN, KEY_VOLUMEUP, - KEY_HOME, KEY_MENU, KEY_BACK, KEY_SEARCH}; +#ifdef CONFIG_KEYBOARD_TEGRA +#ifdef CONFIG_INPUT_ALPS_GPIO_SCROLLWHEEL +#define CARDHU_ROW_COUNT 3 +#define CARDHU_COL_COUNT 2 +#else +#define CARDHU_ROW_COUNT 4 +#define CARDHU_COL_COUNT 6 +#endif +#ifdef CONFIG_INPUT_ALPS_GPIO_SCROLLWHEEL +static int plain_kbd_keycode[] = { + KEY_POWER, KEY_RESERVED, + KEY_HOME, KEY_BACK, + KEY_RESERVED, KEY_RESERVED, +}; +#else +static int plain_kbd_keycode[] = { + KEY_POWER, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, + KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, + KEY_HOME, KEY_BACK, KEY_RESERVED, KEY_RESERVED, + KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, + KEY_CAMERA, KEY_CAMERA, KEY_RESERVED, KEY_RESERVED, + KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, + KEY_VOLUMEDOWN, KEY_VOLUMEUP, KEY_RESERVED, KEY_RESERVED, + KEY_RESERVED, KEY_RESERVED, KEY_PAUSE, + KEY_END, KEY_BACK, KEY_RESERVED, KEY_RESERVED, + KEY_RESERVED, KEY_PLAY, KEY_PHONE, +}; +#endif static struct tegra_kbc_wake_key cardhu_wake_cfg[] = { [0] = { .row = 0, @@ -103,3 +130,126 @@ int __init cardhu_kbc_init(void) platform_device_register(&cardhu_kbc_device); return 0; } +#else +int __init cardhu_kbc_init(void) +{ +} +#endif + +#ifdef CONFIG_INPUT_ALPS_GPIO_SCROLLWHEEL +#define GPIO_SCROLL(_pinaction, _gpio, _desc) \ +{ \ + .pinaction = GPIO_SCROLLWHEEL_PIN_##_pinaction, \ + .gpio = TEGRA_GPIO_##_gpio, \ + .desc = _desc, \ + .active_low = 1, \ + .debounce_interval = 2, \ +} + +static struct gpio_scrollwheel_button scroll_keys[] = { + [0] = GPIO_SCROLL(ONOFF, PR3, "sw_onoff"), + [1] = GPIO_SCROLL(PRESS, PQ5, "sw_press"), + [2] = GPIO_SCROLL(ROT1, PQ3, "sw_rot1"), + [3] = GPIO_SCROLL(ROT2, PQ4, "sw_rot2"), +}; + +static struct gpio_scrollwheel_platform_data cardhu_scroll_platform_data = { + .buttons = scroll_keys, + .nbuttons = ARRAY_SIZE(scroll_keys), +}; + +static struct platform_device cardhu_scroll_device = { + .name = "alps-gpio-scrollwheel", + .id = 0, + .dev = { + .platform_data = &cardhu_scroll_platform_data, + }, +}; + +int __init cardhu_scroll_init(void) +{ + int i; + /* Setting pins to gpio mode */ + for (i = 0; i < ARRAY_SIZE(scroll_keys); i++) + tegra_gpio_enable(scroll_keys[i].gpio); + + platform_device_register(&cardhu_scroll_device); + return 0; +} +#else +int __init cardhu_scroll_init(void) +{ + return 0; +} +#endif + +#ifdef CONFIG_KEYBOARD_GPIO +#define GPIO_KEY(_id, _gpio, _iswake) \ + { \ + .code = _id, \ + .gpio = TEGRA_GPIO_##_gpio, \ + .active_low = 1, \ + .desc = #_id, \ + .type = EV_KEY, \ + .wakeup = _iswake, \ + .debounce_interval = 10, \ + } + +static struct gpio_keys_button cardhu_keys[] = { + [0] = GPIO_KEY(KEY_HOME, PQ0, 0), + [1] = GPIO_KEY(KEY_MENU, PQ1, 0), + [2] = GPIO_KEY(KEY_SEARCH, PQ2, 0), + [3] = GPIO_KEY(KEY_BACK, PQ3, 0), + [4] = GPIO_KEY(KEY_VOLUMEUP, PR0, 0), + [5] = GPIO_KEY(KEY_VOLUMEDOWN, PR1, 0), + [6] = GPIO_KEY(KEY_POWER, PV0, 1), +}; + +static struct gpio_keys_platform_data cardhu_keys_platform_data = { + .buttons = cardhu_keys, + .nbuttons = ARRAY_SIZE(cardhu_keys), +}; + +static struct platform_device cardhu_keys_device = { + .name = "gpio-keys", + .id = 0, + .dev = { + .platform_data = &cardhu_keys_platform_data, + }, +}; + +int __init cardhu_keys_init(void) +{ + int i; + int ret; + + /* Set KB_ROW2 to 0 for capcitive switch to be in scan mode */ + ret = gpio_request(TEGRA_GPIO_PR2, "cap_sw_sl_scan"); + if (ret < 0) { + pr_err("%s: gpio_request failed #%d\n", + __func__, TEGRA_GPIO_PR2); + return ret; + } + ret = gpio_direction_output(TEGRA_GPIO_PR2, 0); + if (ret < 0) { + pr_err("%s: gpio_direction_output failed #%d\n", + __func__, TEGRA_GPIO_PR2); + gpio_free(TEGRA_GPIO_PR2); + return ret; + } + + tegra_gpio_enable(TEGRA_GPIO_PR2); + + /* Enable gpio mode for other pins */ + for (i = 0; i < ARRAY_SIZE(cardhu_keys); i++) + tegra_gpio_enable(cardhu_keys[i].gpio); + + platform_device_register(&cardhu_keys_device); + return 0; +} +#else +int __init cardhu_keys_init(void) +{ + return 0; +} +#endif |