From 047ae916310ac0f35826d424f0d2428f519d3f52 Mon Sep 17 00:00:00 2001 From: Justin Waters Date: Mon, 5 Apr 2010 16:11:53 -0400 Subject: Add support for GPIO buttons and leds --- arch/arm/mach-mx51/mx51_ccwmx51js.c | 92 ++++++++++++++++++++++++++++++++ arch/arm/mach-mx51/mx51_ccwmx51js_gpio.c | 22 ++++++++ 2 files changed, 114 insertions(+) diff --git a/arch/arm/mach-mx51/mx51_ccwmx51js.c b/arch/arm/mach-mx51/mx51_ccwmx51js.c index f02746a3dab0..803e26d3006c 100644 --- a/arch/arm/mach-mx51/mx51_ccwmx51js.c +++ b/arch/arm/mach-mx51/mx51_ccwmx51js.c @@ -44,6 +44,8 @@ #include #include #include +#include +#include #include #include "board-mx51_ccwmx51js.h" #include "iomux.h" @@ -649,6 +651,94 @@ static void mxc_init_wm8753(void) } +/* + * GPIO Buttons + */ +#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) +static struct gpio_keys_button ccwmx51js_buttons[] = { + { + .gpio = IOMUX_TO_GPIO(MX51_PIN_GPIO1_8), + .code = BTN_1, + .desc = "Button 1", + .active_low = 1, + .wakeup = 1, + }, + { + .gpio = IOMUX_TO_GPIO(MX51_PIN_GPIO1_1), + .code = BTN_2, + .desc = "Button 2", + .active_low = 1, + .wakeup = 1, + } +}; + +static struct gpio_keys_platform_data ccwmx51js_button_data = { + .buttons = ccwmx51js_buttons, + .nbuttons = ARRAY_SIZE(ccwmx51js_buttons), +}; + +static struct platform_device ccwmx51js_button_device = { + .name = "gpio-keys", + .id = -1, + .num_resources = 0, + .dev = { + .platform_data = &ccwmx51js_button_data, + } +}; + +static void __init ccwmx51js_add_device_buttons(void) +{ + platform_device_register(&ccwmx51js_button_device); +} +#else +static void __init ek_add_device_buttons(void) {} +#endif + + +#if defined(CONFIG_NEW_LEDS) + +/* + * GPIO LEDs + */ +static struct gpio_led_platform_data led_data; + +static struct gpio_led ccwmx51js_leds[] = { + { + .name = "LED1", + .gpio = IOMUX_TO_GPIO(MX51_PIN_NANDF_RB2), + .active_low = 1, + .default_trigger = "none", + }, + { + .name = "LED2", + .gpio = IOMUX_TO_GPIO(MX51_PIN_NANDF_RB1), + .active_low = 1, + .default_trigger = "none", + } +}; + +static struct platform_device ccwmx51js_gpio_leds_device = { + .name = "leds-gpio", + .id = -1, + .dev.platform_data = &led_data, +}; + +void __init ccwmx51js_gpio_leds(struct gpio_led *leds, int nr) +{ + if (!nr) + return; + + led_data.leds = leds; + led_data.num_leds = nr; + platform_device_register(&ccwmx51js_gpio_leds_device); +} + +#else +void __init at91_gpio_leds(struct gpio_led *leds, int nr) {} +#endif + + + /*! * Board specific initialization. */ @@ -685,6 +775,8 @@ static void __init mxc_board_init(void) #endif pm_power_off = mxc_power_off; mxc_init_fec(); + ccwmx51js_add_device_buttons(); + ccwmx51js_gpio_leds(ccwmx51js_leds, ARRAY_SIZE(ccwmx51js_leds)); } static void __init mx51_ccwmx51js_timer_init(void) diff --git a/arch/arm/mach-mx51/mx51_ccwmx51js_gpio.c b/arch/arm/mach-mx51/mx51_ccwmx51js_gpio.c index 14f28a9ceeda..625d044d8327 100644 --- a/arch/arm/mach-mx51/mx51_ccwmx51js_gpio.c +++ b/arch/arm/mach-mx51/mx51_ccwmx51js_gpio.c @@ -180,6 +180,28 @@ static struct mxc_iomux_pin_cfg __initdata mxc_iomux_pins[] = { MX51_PIN_DISP1_DAT23, IOMUX_CONFIG_ALT0, (PAD_CTL_HYS_NONE | PAD_CTL_DRV_LOW | PAD_CTL_SRE_FAST), }, +#endif + /* Push Buttons */ +#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) + { /* Button 1 */ + MX51_PIN_GPIO1_8, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION, + (PAD_CTL_HYS_NONE | PAD_CTL_DRV_LOW | PAD_CTL_SRE_FAST), + }, + { /* Button 2 */ + MX51_PIN_GPIO1_1, IOMUX_CONFIG_ALT1 | IOMUX_CONFIG_SION, + (PAD_CTL_HYS_NONE | PAD_CTL_DRV_LOW | PAD_CTL_SRE_FAST), + }, +#endif + /* LEDs */ +#if defined(CONFIG_NEW_LEDS) + { /* LED1 */ + MX51_PIN_NANDF_RB2, IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION, + (PAD_CTL_HYS_NONE | PAD_CTL_DRV_LOW | PAD_CTL_SRE_FAST), + }, + { /* LED2 */ + MX51_PIN_NANDF_RB1, IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION, + (PAD_CTL_HYS_NONE | PAD_CTL_DRV_LOW | PAD_CTL_SRE_FAST), + }, #endif /* I2C2 */ #ifdef CONFIG_I2C_MXC_SELECT2 -- cgit v1.2.3