[adm5120] add button devices to several boards
authorGabor Juhos <juhosg@openwrt.org>
Sun, 8 Jun 2008 06:37:31 +0000 (06:37 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Sun, 8 Jun 2008 06:37:31 +0000 (06:37 +0000)
SVN-Revision: 11402

target/linux/adm5120/files/arch/mips/adm5120/boards/compex.c
target/linux/adm5120/files/arch/mips/adm5120/boards/edimax.c
target/linux/adm5120/files/arch/mips/adm5120/boards/mikrotik.c
target/linux/adm5120/files/arch/mips/adm5120/platform.c
target/linux/adm5120/files/include/asm-mips/mach-adm5120/adm5120_platform.h

index 0d856466d72a1ad51ce222570cb6a0591c67c4f3..1af0eb2d4bd9b4308dff8cf46555e5a393870d71 100644 (file)
@@ -3,8 +3,8 @@
  *
  *  Compex boards
  *
  *
  *  Compex boards
  *
- *  Copyright (C) 2007 OpenWrt.org
- *  Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
+ *  Copyright (C) 2007-2008 OpenWrt.org
+ *  Copyright (C) 2007-2008 Gabor Juhos <juhosg at openwrt.org>
  *
  *  This program is free software; you can redistribute it and/or modify it
  *  under the terms of the GNU General Public License version 2 as published
  *
  *  This program is free software; you can redistribute it and/or modify it
  *  under the terms of the GNU General Public License version 2 as published
@@ -57,6 +57,7 @@ static struct platform_device *np2xg_devices[] __initdata = {
 
 static struct platform_device *wp54_devices[] __initdata = {
        &adm5120_flash0_device,
 
 static struct platform_device *wp54_devices[] __initdata = {
        &adm5120_flash0_device,
+       &adm5120_buttons_device,
 };
 
 unsigned char np27g_vlans[6] __initdata = {
 };
 
 unsigned char np27g_vlans[6] __initdata = {
@@ -132,19 +133,17 @@ static void __init wp54_setup(void)
        /* setup data for flash0 device */
        adm5120_flash0_data.switch_bank = switch_bank_gpio5;
 
        /* setup data for flash0 device */
        adm5120_flash0_data.switch_bank = switch_bank_gpio5;
 
+       adm5120_buttons_data.nbuttons = 1;
+       adm5120_buttons[0].desc = "reset button";
+       adm5120_buttons[0].gpio = ADM5120_GPIO_PIN2;
+
        /* TODO: setup mac address */
 }
 
 static void __init wp54_wrt_setup(void)
 {
        /* TODO: setup mac address */
 }
 
 static void __init wp54_wrt_setup(void)
 {
-       gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
-       gpio_direction_output(ADM5120_GPIO_PIN5, 0);
-
-       gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */
-       gpio_direction_output(ADM5120_GPIO_PIN3, 1);
+       wp54_setup();
 
 
-       /* setup data for flash0 device */
-       adm5120_flash0_data.switch_bank = switch_bank_gpio5;
        adm5120_flash0_data.nr_parts = ARRAY_SIZE(wp54g_wrt_partitions);
        adm5120_flash0_data.parts = wp54g_wrt_partitions;
 
        adm5120_flash0_data.nr_parts = ARRAY_SIZE(wp54g_wrt_partitions);
        adm5120_flash0_data.parts = wp54g_wrt_partitions;
 
index fc3b0049ca2ad48212bdffc936d2b84643416ad0..65023ab6622555d8c17c26b63fb5dc1c6c9e7274 100644 (file)
@@ -3,8 +3,8 @@
  *
  *  Edimax boards
  *
  *
  *  Edimax boards
  *
- *  Copyright (C) 2007 OpenWrt.org
- *  Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
+ *  Copyright (C) 2007-2008 OpenWrt.org
+ *  Copyright (C) 2007-2008 Gabor Juhos <juhosg at openwrt.org>
  *
  *  This program is free software; you can redistribute it and/or modify it
  *  under the terms of the GNU General Public License version 2 as published
  *
  *  This program is free software; you can redistribute it and/or modify it
  *  under the terms of the GNU General Public License version 2 as published
@@ -46,6 +46,7 @@ static struct mtd_partition br61xx_partitions[] = {
 static struct platform_device *br6104k_devices[] __initdata = {
        &adm5120_flash0_device,
        &adm5120_hcd_device,
 static struct platform_device *br6104k_devices[] __initdata = {
        &adm5120_flash0_device,
        &adm5120_hcd_device,
+       &adm5120_buttons_device,
 };
 
 static struct platform_device *br61x4wg_devices[] __initdata = {
 };
 
 static struct platform_device *br61x4wg_devices[] __initdata = {
@@ -57,6 +58,10 @@ static void __init br61xx_setup(void) {
        adm5120_flash0_data.nr_parts = ARRAY_SIZE(br61xx_partitions);
        adm5120_flash0_data.parts = br61xx_partitions;
 
        adm5120_flash0_data.nr_parts = ARRAY_SIZE(br61xx_partitions);
        adm5120_flash0_data.parts = br61xx_partitions;
 
+       adm5120_buttons_data.nbuttons = 1;
+       adm5120_buttons[0].desc = "reset button";
+       adm5120_buttons[0].gpio = ADM5120_GPIO_PIN2;
+
        /* TODO: setup mac addresses, if possible */
 }
 
        /* TODO: setup mac addresses, if possible */
 }
 
index 48a7272afd7efd4fd55407d66abd740fb6de4331..772b0eba16c9f8f70cb17c71a9a97c9e7e7aae14 100644 (file)
@@ -3,8 +3,8 @@
  *
  *  Mikrotik RouterBOARD 1xx series
  *
  *
  *  Mikrotik RouterBOARD 1xx series
  *
- *  Copyright (C) 2007 OpenWrt.org
- *  Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
+ *  Copyright (C) 2007-2008 OpenWrt.org
+ *  Copyright (C) 2007-2008 Gabor Juhos <juhosg at openwrt.org>
  *
  *  NAND initialization code was based on a driver for Linux 2.6.19+ which
  *  was derived from the driver for Linux 2.4.xx published by Mikrotik for
  *
  *  NAND initialization code was based on a driver for Linux 2.6.19+ which
  *  was derived from the driver for Linux 2.4.xx published by Mikrotik for
@@ -248,6 +248,10 @@ static void __init rb1xx_setup(void)
        adm5120_nand_set_spn(1);
        adm5120_nand_set_wpn(0);
 
        adm5120_nand_set_spn(1);
        adm5120_nand_set_wpn(0);
 
+       adm5120_buttons_data.nbuttons = 1;
+       adm5120_buttons[0].desc = "reset button";
+       adm5120_buttons[0].gpio = ADM5120_GPIO_PIN7;
+
        rb1xx_flash_setup();
        rb1xx_mac_setup();
 }
        rb1xx_flash_setup();
        rb1xx_mac_setup();
 }
@@ -269,6 +273,10 @@ static void __init rb150_setup(void)
        adm5120_nand_data.ctrl.cmd_ctrl = rb150_nand_cmd_ctrl;
        adm5120_nand_data.ctrl.dev_ready = rb150_nand_ready;
 
        adm5120_nand_data.ctrl.cmd_ctrl = rb150_nand_cmd_ctrl;
        adm5120_nand_data.ctrl.dev_ready = rb150_nand_ready;
 
+       adm5120_buttons_data.nbuttons = 1;
+       adm5120_buttons[0].desc = "reset button";
+       adm5120_buttons[0].gpio = ADM5120_GPIO_PIN1;
+
        adm5120_flash0_data.window_size = 512*1024;
 
        rb1xx_flash_setup();
        adm5120_flash0_data.window_size = 512*1024;
 
        rb1xx_flash_setup();
index bc35162ccf7c790b93368b5838554b4afc0e04e5..841d68fa44493505d1948abf22f9a047992f9950 100644 (file)
@@ -3,8 +3,8 @@
  *
  *  Generic ADM5120 platform devices
  *
  *
  *  Generic ADM5120 platform devices
  *
- *  Copyright (C) 2007 OpenWrt.org
- *  Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
+ *  Copyright (C) 2007-2008 OpenWrt.org
+ *  Copyright (C) 2007-2008 Gabor Juhos <juhosg at openwrt.org>
  *
  *  This program is free software; you can redistribute it and/or modify it
  *  under the terms of the GNU General Public License version 2 as published
  *
  *  This program is free software; you can redistribute it and/or modify it
  *  under the terms of the GNU General Public License version 2 as published
@@ -177,6 +177,45 @@ struct amba_device adm5120_uart1_device = {
        .periphid       = 0x0041010,
 };
 
        .periphid       = 0x0041010,
 };
 
+#define ADM5120_BUTTON_THRESHOLD       5
+#define ADM5120_BUTTON_INTERVAL                20
+
+struct gpio_button adm5120_buttons[ADM5120_NUM_BUTTONS] = {
+       {
+               .type           = EV_KEY,
+               .code           = BTN_0,
+               .threshold      = ADM5120_BUTTON_THRESHOLD,
+       }, {
+               .type           = EV_KEY,
+               .code           = BTN_1,
+               .threshold      = ADM5120_BUTTON_THRESHOLD,
+       }, {
+               .type           = EV_KEY,
+               .code           = BTN_2,
+               .threshold      = ADM5120_BUTTON_THRESHOLD,
+       }, {
+               .type           = EV_KEY,
+               .code           = BTN_3,
+               .threshold      = ADM5120_BUTTON_THRESHOLD,
+       }, {
+               .type           = EV_KEY,
+               .code           = BTN_4,
+               .threshold      = ADM5120_BUTTON_THRESHOLD,
+       }
+};
+
+struct gpio_buttons_platform_data adm5120_buttons_data = {
+       .poll_interval  = ADM5120_BUTTON_INTERVAL,
+       .nbuttons       = ARRAY_SIZE(adm5120_buttons),
+       .buttons        = adm5120_buttons,
+};
+
+struct platform_device adm5120_buttons_device = {
+       .name           = "gpio-buttons",
+       .id             = 0,
+       .dev.platform_data = &adm5120_buttons_data,
+};
+
 void adm5120_uart_set_mctrl(struct amba_device *dev, void __iomem *base,
                unsigned int mctrl)
 {
 void adm5120_uart_set_mctrl(struct amba_device *dev, void __iomem *base,
                unsigned int mctrl)
 {
index d2ad373af3b60fba6a1f9dcfb253ea12c68d1286..ef895ed1c8cb23828d5f54cf9b6a7711c66c8b2c 100644 (file)
@@ -3,8 +3,8 @@
  *
  *  ADM5120 specific platform definitions
  *
  *
  *  ADM5120 specific platform definitions
  *
- *  Copyright (C) 2007 OpenWrt.org
- *  Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
+ *  Copyright (C) 2007-2008 OpenWrt.org
+ *  Copyright (C) 2007-2008 Gabor Juhos <juhosg at openwrt.org>
  *
  *  This program is free software; you can redistribute it and/or modify it
  *  under the terms of the GNU General Public License version 2 as published
  *
  *  This program is free software; you can redistribute it and/or modify it
  *  under the terms of the GNU General Public License version 2 as published
@@ -23,6 +23,9 @@
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/nand.h>
 
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/nand.h>
 
+#include <linux/input.h>
+#include <linux/gpio_buttons.h>
+
 #include <linux/amba/bus.h>
 #include <linux/amba/serial.h>
 
 #include <linux/amba/bus.h>
 #include <linux/amba/serial.h>
 
@@ -59,10 +62,14 @@ static inline void adm5120_pci_set_irq_map(unsigned int nr_irqs,
 }
 #endif
 
 }
 #endif
 
+#define ADM5120_NUM_BUTTONS    4
+
 extern struct adm5120_flash_platform_data adm5120_flash0_data;
 extern struct adm5120_flash_platform_data adm5120_flash1_data;
 extern struct platform_nand_data adm5120_nand_data;
 extern struct adm5120_switch_platform_data adm5120_switch_data;
 extern struct adm5120_flash_platform_data adm5120_flash0_data;
 extern struct adm5120_flash_platform_data adm5120_flash1_data;
 extern struct platform_nand_data adm5120_nand_data;
 extern struct adm5120_switch_platform_data adm5120_switch_data;
+extern struct gpio_button adm5120_buttons[ADM5120_NUM_BUTTONS];
+extern struct gpio_buttons_platform_data adm5120_buttons_data;
 extern struct amba_pl010_data adm5120_uart0_data;
 extern struct amba_pl010_data adm5120_uart1_data;
 
 extern struct amba_pl010_data adm5120_uart0_data;
 extern struct amba_pl010_data adm5120_uart1_data;
 
@@ -71,6 +78,7 @@ extern struct platform_device adm5120_flash1_device;
 extern struct platform_device adm5120_nand_device;
 extern struct platform_device adm5120_hcd_device;
 extern struct platform_device adm5120_switch_device;
 extern struct platform_device adm5120_nand_device;
 extern struct platform_device adm5120_hcd_device;
 extern struct platform_device adm5120_switch_device;
+extern struct platform_device adm5120_buttons_device;
 extern struct amba_device adm5120_uart0_device;
 extern struct amba_device adm5120_uart1_device;
 
 extern struct amba_device adm5120_uart0_device;
 extern struct amba_device adm5120_uart1_device;