[ar71xx] change ag71xx platform device registration
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-rb-4xx.c
index a07f645d1c48c18ca9d05c2244e5e64b7e069bf4..8e63acac41e19b91498e9df6afcee0b0ebb04ace 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
 #include <linux/spi/mmc_spi.h>
-#include <linux/leds.h>
+#include <linux/input.h>
 
 #include <asm/mips_machine.h>
 #include <asm/mach-ar71xx/ar71xx.h>
 #include <asm/mach-ar71xx/platform.h>
 
 #define RB4XX_GPIO_USER_LED    4
+#define RB4XX_GPIO_RESET_SWITCH        7
 
-static struct gpio_led rb4xx_leds_gpio[] = {
+#define RB4XX_BUTTONS_POLL_INTERVAL    20
+
+static struct gpio_led rb4xx_leds_gpio[] __initdata = {
        {
                .name           = "rb4xx:yellow:user",
                .gpio           = RB4XX_GPIO_USER_LED,
@@ -32,16 +35,14 @@ static struct gpio_led rb4xx_leds_gpio[] = {
        },
 };
 
-static struct gpio_led_platform_data rb4xx_leds_gpio_data = {
-       .leds           = rb4xx_leds_gpio,
-       .num_leds       = ARRAY_SIZE(rb4xx_leds_gpio),
-};
-
-static struct platform_device rb4xx_leds_gpio_device = {
-       .name   = "leds-gpio",
-       .id     = -1,
-       .dev = {
-               .platform_data = &rb4xx_leds_gpio_data,
+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,
        }
 };
 
@@ -154,9 +155,19 @@ static void __init rb411_setup(void)
        rb4xx_add_device_spi();
 
        ar71xx_add_device_mdio(0xfffffffe);
-       ar71xx_add_device_eth(0, PHY_INTERFACE_MODE_MII, 0x00000001);
 
-       platform_device_register(&rb4xx_leds_gpio_device);
+       ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+       ar71xx_eth0_data.phy_mask = 0x00000001;
+
+       ar71xx_add_device_eth(0);
+
+       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);
@@ -169,10 +180,23 @@ static void __init rb433_setup(void)
        rb433_add_device_spi();
 
        ar71xx_add_device_mdio(0xffffffec);
-       ar71xx_add_device_eth(1, PHY_INTERFACE_MODE_RMII, 0x00000010);
-       ar71xx_add_device_eth(0, PHY_INTERFACE_MODE_MII, 0x00000003);
 
-       platform_device_register(&rb4xx_leds_gpio_device);
+       ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+       ar71xx_eth0_data.phy_mask = 0x00000003;
+
+       ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
+       ar71xx_eth1_data.phy_mask = 0x00000010;
+
+       ar71xx_add_device_eth(1);
+       ar71xx_add_device_eth(0);
+
+       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);
@@ -185,11 +209,56 @@ static void __init rb450_setup(void)
        rb4xx_add_device_spi();
 
        ar71xx_add_device_mdio(0xffffffe0);
-       ar71xx_add_device_eth(1, PHY_INTERFACE_MODE_RMII, 0x00000010);
-       ar71xx_add_device_eth(0, PHY_INTERFACE_MODE_MII, 0x0000000f);
 
-       platform_device_register(&rb4xx_leds_gpio_device);
+       ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+       ar71xx_eth0_data.phy_mask = 0x0000000f;
+
+       ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
+       ar71xx_eth1_data.phy_mask = 0x00000010;
+
+       ar71xx_add_device_eth(1);
+       ar71xx_add_device_eth(0);
+
+       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);
 }
 
 MIPS_MACHINE(MACH_AR71XX_RB_450, "MikroTik RouterBOARD 450", rb450_setup);
+
+static void __init rb493_setup(void)
+{
+       rb4xx_add_device_spi();
+
+       ar71xx_add_device_mdio(0x3fffff00);
+
+#if 0
+       ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+       ar71xx_eth0_data.phy_mask = 0;
+       ar71xx_eth0_data.speed = SPEED_100;
+       ar71xx_eth0_data.duplex = DUPLEX_FULL;
+
+       ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
+       ar71xx_eth1_data.phy_mask = 0x00000001;
+
+       ar71xx_add_device_eth(0);
+       ar71xx_add_device_eth(1);
+#endif
+
+       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);
+}
+
+MIPS_MACHINE(MACH_AR71XX_RB_493, "MikroTik RouterBOARD 493/AH", rb493_setup);
+