#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
#include <linux/spi/mmc_spi.h>
-#include <linux/leds.h>
#include <asm/mips_machine.h>
#include <asm/mach-ar71xx/ar71xx.h>
#define RB4XX_GPIO_USER_LED 4
-static struct gpio_led rb4xx_leds_gpio[] = {
+static struct gpio_led rb4xx_leds_gpio[] __initdata = {
{
.name = "rb4xx:yellow:user",
.gpio = RB4XX_GPIO_USER_LED,
},
};
-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 platform_device rb4xx_nand_device = {
.name = "rb4xx-nand",
.id = -1,
ar71xx_add_device_mdio(0xfffffffe);
ar71xx_add_device_eth(0, PHY_INTERFACE_MODE_MII, 0x00000001);
- platform_device_register(&rb4xx_leds_gpio_device);
+ ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio),
+ rb4xx_leds_gpio);
+
platform_device_register(&rb4xx_nand_device);
ar71xx_pci_init(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
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_add_device_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio),
+ rb4xx_leds_gpio);
+
platform_device_register(&rb4xx_nand_device);
ar71xx_pci_init(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
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_add_device_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio),
+ rb4xx_leds_gpio);
+
platform_device_register(&rb4xx_nand_device);
}
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
-#include <linux/leds.h>
#include <asm/mips_machine.h>
#include <asm/mach-ar71xx/ar71xx.h>
}
};
-static struct gpio_led wp543_leds_gpio[] = {
+static struct gpio_led wp543_leds_gpio[] __initdata = {
{
.name = "wp543:green:led1",
.gpio = WP543_GPIO_LED_1,
}
};
-static struct gpio_led_platform_data wp543_leds_gpio_data = {
- .leds = wp543_leds_gpio,
- .num_leds = ARRAY_SIZE(wp543_leds_gpio),
-};
-
-static struct platform_device wp543_leds_gpio_device = {
- .name = "leds-gpio",
- .id = -1,
- .dev = {
- .platform_data = &wp543_leds_gpio_data,
- }
-};
-
static void __init wp543_setup(void)
{
ar71xx_add_device_spi(NULL, wp543_spi_info, ARRAY_SIZE(wp543_spi_info));
ar71xx_pci_init(ARRAY_SIZE(wp543_pci_irqs), wp543_pci_irqs);
- platform_device_register(&wp543_leds_gpio_device);
+ ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wp543_leds_gpio),
+ wp543_leds_gpio);
}
MIPS_MACHINE(MACH_AR71XX_WP543, "Compex WP543", wp543_setup);
platform_device_register(&ar71xx_spi_device);
}
+void __init ar71xx_add_device_leds_gpio(int id, unsigned num_leds,
+ struct gpio_led *leds)
+{
+ struct platform_device *pdev;
+ struct gpio_led_platform_data pdata;
+ struct gpio_led *p;
+ int err;
+
+ p = kmalloc(num_leds * sizeof(*p), GFP_KERNEL);
+ if (!p)
+ return;
+
+ memcpy(p, leds, num_leds * sizeof(*p));
+
+ pdev = platform_device_alloc("leds-gpio", id);
+ if (!pdev)
+ goto err_free_leds;
+
+ pdata.num_leds = num_leds;
+ pdata.leds = leds;
+
+ 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_leds:
+ kfree(p);
+}
+
void __init ar71xx_set_mac_base(char *mac_str)
{
u8 tmp[ETH_ALEN];
#include <linux/skbuff.h>
#include <linux/phy.h>
#include <linux/spi/spi.h>
+#include <linux/leds.h>
struct ag71xx_platform_data {
u32 reset_bit;
extern void ar71xx_add_device_mdio(u32 phy_mask) __init;
+extern void ar71xx_add_device_leds_gpio(int id,
+ unsigned num_leds,
+ struct gpio_led *leds) __init;
+
#endif /* __ASM_MACH_AR71XX_PLATFORM_H */