add generic led support to atheros target
[openwrt/staging/florian.git] / target / linux / atheros / files / arch / mips / atheros / ar5312 / board.c
index 21073dbbbb78765be0486ca0a9bc6cb7f4d62acb..f58d08cba775bcde1a20c18210bf85bfeb8108d3 100644 (file)
 #include <asm/time.h>
 #include <asm/irq.h>
 #include <asm/io.h>
-#include "../ar531x.h"
+#include <ar531x.h>
+#include <linux/leds.h>
 
 #define NO_PHY 0x1f
 
 static int is_5312 = 0;
-static struct platform_device *ar5312_devs[5];
+static struct platform_device *ar5312_devs[6];
 
 static struct resource ar5312_eth0_res[] = {
        {
@@ -150,7 +151,7 @@ static struct physmap_flash_data ar5312_flash_data = {
 
 static struct resource ar5312_flash_resource = {
        .start  = AR531X_FLASH,
-       .end    = AR531X_FLASH + 0x400000 - 1,
+       .end    = AR531X_FLASH + 0x800000 - 1,
        .flags  = IORESOURCE_MEM,
 };
 
@@ -164,6 +165,24 @@ static struct platform_device ar5312_physmap_flash = {
        .resource   = &ar5312_flash_resource,
 };
 
+#ifdef CONFIG_LEDS_GPIO
+static struct gpio_led ar5312_leds[] = {
+       { .name = "wlan", .gpio = 0, .active_low = 1, },
+};
+
+static const struct gpio_led_platform_data ar5312_led_data = {
+       .num_leds = ARRAY_SIZE(ar5312_leds),
+       .leds = (void *) ar5312_leds,
+};
+
+static struct platform_device ar5312_gpio_leds = {
+       .name = "leds-gpio",
+       .id = -1,
+       .dev = {
+               .platform_data = (void *) &ar5312_led_data,
+       }
+};
+#endif
 
 /*
  * NB: This mapping size is larger than the actual flash size,
@@ -269,6 +288,9 @@ int __init ar5312_init_devices(void)
 
        ar5312_devs[dev++] = &ar5312_physmap_flash;
 
+       ar5312_leds[0].gpio = bcfg->sysLedGpio;
+       ar5312_devs[dev++] = &ar5312_gpio_leds;
+
        if (!memcmp(bcfg->enet0Mac, "\xff\xff\xff\xff\xff\xff", 6))
                memcpy(bcfg->enet0Mac, bcfg->enet1Mac, 6);