summaryrefslogtreecommitdiff
path: root/target/linux/ar71xx
diff options
context:
space:
mode:
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2008-09-07 09:47:37 +0000
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2008-09-07 09:47:37 +0000
commit213b89f9dd985ab728f9f0f485bc6402d0e4c256 (patch)
treea4fd5d93d2c7d96b51369b25ff98a38b1b49a938 /target/linux/ar71xx
parentd715ffc443e7dd9dc424105633290fa47356dec5 (diff)
[ar71xx] add gpio-buttons devices
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@12544 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ar71xx')
-rw-r--r--target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c27
-rw-r--r--target/linux/ar71xx/files/arch/mips/ar71xx/mach-wp543.c25
-rw-r--r--target/linux/ar71xx/files/arch/mips/ar71xx/platform.c42
-rw-r--r--target/linux/ar71xx/files/include/asm-mips/mach-ar71xx/platform.h6
4 files changed, 100 insertions, 0 deletions
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c
index f2b5e05722..7193849f35 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb-4xx.c
@@ -15,6 +15,7 @@
#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
#include <linux/spi/mmc_spi.h>
+#include <linux/input.h>
#include <asm/mips_machine.h>
#include <asm/mach-ar71xx/ar71xx.h>
@@ -22,6 +23,9 @@
#include <asm/mach-ar71xx/platform.h>
#define RB4XX_GPIO_USER_LED 4
+#define RB4XX_GPIO_RESET_SWITCH 7
+
+#define RB4XX_BUTTONS_POLL_INTERVAL 20
static struct gpio_led rb4xx_leds_gpio[] __initdata = {
{
@@ -31,6 +35,17 @@ static struct gpio_led rb4xx_leds_gpio[] __initdata = {
},
};
+static struct gpio_button rb4xx_gpio_buttons[] __initdata = {
+ {
+ .desc = "reset_switch",
+ .type = EV_KEY,
+ .code = BTN_0,
+ .threshold = 5,
+ .gpio = RB4XX_GPIO_RESET_SWITCH,
+ .active_low = 1,
+ }
+};
+
static struct platform_device rb4xx_nand_device = {
.name = "rb4xx-nand",
.id = -1,
@@ -145,6 +160,10 @@ static void __init rb411_setup(void)
ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio),
rb4xx_leds_gpio);
+ ar71xx_add_device_gpio_buttons(-1, RB4XX_BUTTONS_POLL_INTERVAL,
+ ARRAY_SIZE(rb4xx_gpio_buttons),
+ rb4xx_gpio_buttons);
+
platform_device_register(&rb4xx_nand_device);
ar71xx_pci_init(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
@@ -163,6 +182,10 @@ static void __init rb433_setup(void)
ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio),
rb4xx_leds_gpio);
+ ar71xx_add_device_gpio_buttons(-1, RB4XX_BUTTONS_POLL_INTERVAL,
+ ARRAY_SIZE(rb4xx_gpio_buttons),
+ rb4xx_gpio_buttons);
+
platform_device_register(&rb4xx_nand_device);
ar71xx_pci_init(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
@@ -181,6 +204,10 @@ static void __init rb450_setup(void)
ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio),
rb4xx_leds_gpio);
+ ar71xx_add_device_gpio_buttons(-1, RB4XX_BUTTONS_POLL_INTERVAL,
+ ARRAY_SIZE(rb4xx_gpio_buttons),
+ rb4xx_gpio_buttons);
+
platform_device_register(&rb4xx_nand_device);
}
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wp543.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wp543.c
index f8a2e3d765..9044011ed4 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wp543.c
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wp543.c
@@ -12,17 +12,22 @@
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
+#include <linux/input.h>
#include <asm/mips_machine.h>
#include <asm/mach-ar71xx/ar71xx.h>
#include <asm/mach-ar71xx/pci.h>
#include <asm/mach-ar71xx/platform.h>
+#define WP543_GPIO_SW6 2
#define WP543_GPIO_LED_1 3
#define WP543_GPIO_LED_2 4
#define WP543_GPIO_LED_WLAN 5
#define WP543_GPIO_LED_CONN 6
#define WP543_GPIO_LED_DIAG 7
+#define WP543_GPIO_SW4 8
+
+#define WP543_BUTTONS_POLL_INTERVAL 20
static struct flash_platform_data wp543_flash_data = {
/* TODO: add partition map */
@@ -74,6 +79,22 @@ static struct gpio_led wp543_leds_gpio[] __initdata = {
}
};
+static struct gpio_button wp543_gpio_buttons[] __initdata = {
+ {
+ .desc = "sw6",
+ .type = EV_KEY,
+ .code = BTN_0,
+ .threshold = 5,
+ .gpio = WP543_GPIO_SW6,
+ }, {
+ .desc = "sw4",
+ .type = EV_KEY,
+ .code = BTN_1,
+ .threshold = 5,
+ .gpio = WP543_GPIO_SW4,
+ }
+};
+
static void __init wp543_setup(void)
{
ar71xx_add_device_spi(NULL, wp543_spi_info, ARRAY_SIZE(wp543_spi_info));
@@ -87,6 +108,10 @@ static void __init wp543_setup(void)
ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wp543_leds_gpio),
wp543_leds_gpio);
+
+ ar71xx_add_device_gpio_buttons(-1, WP543_BUTTONS_POLL_INTERVAL,
+ ARRAY_SIZE(wp543_gpio_buttons),
+ wp543_gpio_buttons);
}
MIPS_MACHINE(MACH_AR71XX_WP543, "Compex WP543", wp543_setup);
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/platform.c b/target/linux/ar71xx/files/arch/mips/ar71xx/platform.c
index 3bda20e52d..db804fbb91 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/platform.c
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/platform.c
@@ -372,6 +372,48 @@ err_free_leds:
kfree(p);
}
+void __init ar71xx_add_device_gpio_buttons(int id,
+ unsigned poll_interval,
+ unsigned nbuttons,
+ struct gpio_button *buttons)
+{
+ struct platform_device *pdev;
+ struct gpio_buttons_platform_data pdata;
+ struct gpio_button *p;
+ int err;
+
+ p = kmalloc(nbuttons * sizeof(*p), GFP_KERNEL);
+ if (!p)
+ return;
+
+ memcpy(p, buttons, nbuttons * sizeof(*p));
+
+ pdev = platform_device_alloc("gpio-buttons", id);
+ if (!pdev)
+ goto err_free_buttons;
+
+ pdata.poll_interval = poll_interval;
+ pdata.nbuttons = nbuttons;
+ pdata.buttons = p;
+
+ err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
+ if (err)
+ goto err_put_pdev;
+
+
+ err = platform_device_add(pdev);
+ if (err)
+ goto err_put_pdev;
+
+ return;
+
+err_put_pdev:
+ platform_device_put(pdev);
+
+err_free_buttons:
+ kfree(p);
+}
+
void __init ar71xx_set_mac_base(char *mac_str)
{
u8 tmp[ETH_ALEN];
diff --git a/target/linux/ar71xx/files/include/asm-mips/mach-ar71xx/platform.h b/target/linux/ar71xx/files/include/asm-mips/mach-ar71xx/platform.h
index 996924a0aa..32ca2965eb 100644
--- a/target/linux/ar71xx/files/include/asm-mips/mach-ar71xx/platform.h
+++ b/target/linux/ar71xx/files/include/asm-mips/mach-ar71xx/platform.h
@@ -17,6 +17,7 @@
#include <linux/phy.h>
#include <linux/spi/spi.h>
#include <linux/leds.h>
+#include <linux/gpio_buttons.h>
struct ag71xx_platform_data {
u32 reset_bit;
@@ -54,4 +55,9 @@ extern void ar71xx_add_device_leds_gpio(int id,
unsigned num_leds,
struct gpio_led *leds) __init;
+extern void ar71xx_add_device_gpio_buttons(int id,
+ unsigned poll_interval,
+ unsigned nbuttons,
+ struct gpio_button *buttons) __init;
+
#endif /* __ASM_MACH_AR71XX_PLATFORM_H */