diff options
Diffstat (limited to 'target')
4 files changed, 56 insertions, 34 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 a07f645d1..f2b5e0572 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,7 +15,6 @@ #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> @@ -24,7 +23,7 @@ #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, @@ -32,19 +31,6 @@ 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 platform_device rb4xx_nand_device = { .name = "rb4xx-nand", .id = -1, @@ -156,7 +142,9 @@ static void __init rb411_setup(void) 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); @@ -172,7 +160,9 @@ static void __init rb433_setup(void) 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); @@ -188,7 +178,9 @@ static void __init rb450_setup(void) 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); } 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 0bf45ad23..f8a2e3d76 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wp543.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wp543.c @@ -12,7 +12,6 @@ #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> @@ -51,7 +50,7 @@ static struct ar71xx_pci_irq wp543_pci_irqs[] __initdata = { } }; -static struct gpio_led wp543_leds_gpio[] = { +static struct gpio_led wp543_leds_gpio[] __initdata = { { .name = "wp543:green:led1", .gpio = WP543_GPIO_LED_1, @@ -75,19 +74,6 @@ static struct gpio_led wp543_leds_gpio[] = { } }; -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)); @@ -99,7 +85,8 @@ static void __init wp543_setup(void) 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); diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/platform.c b/target/linux/ar71xx/files/arch/mips/ar71xx/platform.c index 3c9b74ca2..3bda20e52 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/platform.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/platform.c @@ -334,6 +334,44 @@ void __init ar71xx_add_device_spi(struct ar71xx_spi_platform_data *pdata, 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]; 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 820a1cb1d..996924a0a 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 @@ -16,6 +16,7 @@ #include <linux/skbuff.h> #include <linux/phy.h> #include <linux/spi/spi.h> +#include <linux/leds.h> struct ag71xx_platform_data { u32 reset_bit; @@ -49,4 +50,8 @@ extern void ar71xx_add_device_eth(unsigned int id, phy_interface_t phy_if_mode, 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 */ |