]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[ARM] 5262/2: [AT91] Support for GPIO-connected buttons on SAM9260-EK board
authorAndrew Victor <linux@maxim.org.za>
Sun, 21 Sep 2008 20:32:40 +0000 (21:32 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 21 Sep 2008 22:01:00 +0000 (23:01 +0100)
Add support or the GPIO-connected buttons on the Atmel AT91SAM9260-EK board.

Signed-off-by: Sedji Gaouaou <sedji.gaouaou@atmel.com>
Signed-off-by: Andrew Victor <linux@maxim.org.za>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-at91/board-sam9260ek.c

index e22433d5dfb63cd407427983aaacf946eb36fcac..b49eb6e4918acc52ba87fe400634fd3ec2ed1f80 100644 (file)
@@ -28,6 +28,8 @@
 #include <linux/spi/at73c213.h>
 #include <linux/clk.h>
 #include <linux/i2c/at24.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
 
 #include <asm/setup.h>
 #include <asm/mach-types.h>
@@ -240,6 +242,56 @@ static struct i2c_board_info __initdata ek_i2c_devices[] = {
        /* more devices can be added using expansion connectors */
 };
 
+
+/*
+ * GPIO Buttons
+ */
+#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
+static struct gpio_keys_button ek_buttons[] = {
+       {
+               .gpio           = AT91_PIN_PA30,
+               .code           = BTN_3,
+               .desc           = "Button 3",
+               .active_low     = 1,
+               .wakeup         = 1,
+       },
+       {
+               .gpio           = AT91_PIN_PA31,
+               .code           = BTN_4,
+               .desc           = "Button 4",
+               .active_low     = 1,
+               .wakeup         = 1,
+       }
+};
+
+static struct gpio_keys_platform_data ek_button_data = {
+       .buttons        = ek_buttons,
+       .nbuttons       = ARRAY_SIZE(ek_buttons),
+};
+
+static struct platform_device ek_button_device = {
+       .name           = "gpio-keys",
+       .id             = -1,
+       .num_resources  = 0,
+       .dev            = {
+               .platform_data  = &ek_button_data,
+       }
+};
+
+static void __init ek_add_device_buttons(void)
+{
+       at91_set_gpio_input(AT91_PIN_PA30, 1);  /* btn3 */
+       at91_set_deglitch(AT91_PIN_PA30, 1);
+       at91_set_gpio_input(AT91_PIN_PA31, 1);  /* btn4 */
+       at91_set_deglitch(AT91_PIN_PA31, 1);
+
+       platform_device_register(&ek_button_device);
+}
+#else
+static void __init ek_add_device_buttons(void) {}
+#endif
+
+
 static void __init ek_board_init(void)
 {
        /* Serial */
@@ -263,6 +315,8 @@ static void __init ek_board_init(void)
        at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
        /* LEDs */
        at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
+       /* Push Buttons */
+       ek_add_device_buttons();
 }
 
 MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK")