diff options
author | Simon Horman <horms+renesas@verge.net.au> | 2013-05-13 16:04:31 +0900 |
---|---|---|
committer | Simon Horman <horms+renesas@verge.net.au> | 2013-06-07 14:26:31 +0900 |
commit | c3842e4fcbb7664276443b79187b7808c2e80a35 (patch) | |
tree | b3e5d47adf37a0cfe5d4f53e37ced6f19634c096 /arch/arm/mach-shmobile/board-lager.c | |
parent | 1034f4ee3f07b7d525c490d702b3dcbee3b56b54 (diff) | |
download | linux-c3842e4fcbb7664276443b79187b7808c2e80a35.tar.gz linux-c3842e4fcbb7664276443b79187b7808c2e80a35.tar.bz2 linux-c3842e4fcbb7664276443b79187b7808c2e80a35.zip |
ARM: shmobile: lager: support GPIO switches
The lager board has pins 1 - 4 of SW2 wired up to GPIO pins.
This patch allows access to those pins as KEYS 1 - 4 using
gpio-keys.
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'arch/arm/mach-shmobile/board-lager.c')
-rw-r--r-- | arch/arm/mach-shmobile/board-lager.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c index 6a1ba38fae26..d73e21d3ea8a 100644 --- a/arch/arm/mach-shmobile/board-lager.c +++ b/arch/arm/mach-shmobile/board-lager.c @@ -18,6 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include <linux/gpio.h> +#include <linux/gpio_keys.h> +#include <linux/input.h> #include <linux/interrupt.h> #include <linux/irqchip.h> #include <linux/kernel.h> @@ -47,11 +50,27 @@ static struct gpio_led lager_leds[] = { }, }; -static struct gpio_led_platform_data lager_leds_pdata = { +static __initdata struct gpio_led_platform_data lager_leds_pdata = { .leds = lager_leds, .num_leds = ARRAY_SIZE(lager_leds), }; +/* GPIO KEY */ +#define GPIO_KEY(c, g, d, ...) \ + { .code = c, .gpio = g, .desc = d, .active_low = 1 } + +static __initdata struct gpio_keys_button gpio_buttons[] = { + GPIO_KEY(KEY_4, RCAR_GP_PIN(1, 28), "SW2-pin4"), + GPIO_KEY(KEY_3, RCAR_GP_PIN(1, 26), "SW2-pin3"), + GPIO_KEY(KEY_2, RCAR_GP_PIN(1, 24), "SW2-pin2"), + GPIO_KEY(KEY_1, RCAR_GP_PIN(1, 14), "SW2-pin1"), +}; + +static __initdata struct gpio_keys_platform_data lager_keys_pdata = { + .buttons = gpio_buttons, + .nbuttons = ARRAY_SIZE(gpio_buttons), +}; + static const struct pinctrl_map lager_pinctrl_map[] = { /* SCIF0 (CN19: DEBUG SERIAL0) */ PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790", @@ -73,6 +92,9 @@ static void __init lager_add_standard_devices(void) platform_device_register_data(&platform_bus, "leds-gpio", -1, &lager_leds_pdata, sizeof(lager_leds_pdata)); + platform_device_register_data(&platform_bus, "gpio-keys", -1, + &lager_keys_pdata, + sizeof(lager_keys_pdata)); } static const char *lager_boards_compat_dt[] __initdata = { |