330-board_leds.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. --- a/arch/mips/ath25/ar2315.c
  2. +++ b/arch/mips/ath25/ar2315.c
  3. @@ -23,6 +23,7 @@
  4. #include <linux/reboot.h>
  5. #include <linux/delay.h>
  6. #include <linux/gpio.h>
  7. +#include <linux/leds.h>
  8. #include <asm/bootinfo.h>
  9. #include <asm/reboot.h>
  10. #include <asm/time.h>
  11. @@ -260,6 +261,50 @@ static struct platform_device ar2315_spi
  12. .num_resources = ARRAY_SIZE(ar2315_spiflash_res)
  13. };
  14. +#ifdef CONFIG_LEDS_GPIO
  15. +static struct gpio_led ar2315_leds[6];
  16. +static struct gpio_led_platform_data ar2315_led_data = {
  17. + .leds = (void *)ar2315_leds,
  18. +};
  19. +
  20. +static struct platform_device ar2315_gpio_leds = {
  21. + .name = "leds-gpio",
  22. + .id = -1,
  23. + .dev = {
  24. + .platform_data = (void *)&ar2315_led_data,
  25. + }
  26. +};
  27. +
  28. +static void __init ar2315_init_gpio_leds(void)
  29. +{
  30. + static char led_names[6][6];
  31. + int i, led = 0;
  32. +
  33. + ar2315_led_data.num_leds = 0;
  34. + for (i = 1; i < 8; i++) {
  35. + if ((i == AR2315_RESET_GPIO) ||
  36. + (i == ath25_board.config->reset_config_gpio))
  37. + continue;
  38. +
  39. + if (i == ath25_board.config->sys_led_gpio)
  40. + strcpy(led_names[led], "wlan");
  41. + else
  42. + sprintf(led_names[led], "gpio%d", i);
  43. +
  44. + ar2315_leds[led].name = led_names[led];
  45. + ar2315_leds[led].gpio = i;
  46. + ar2315_leds[led].active_low = 0;
  47. + led++;
  48. + }
  49. + ar2315_led_data.num_leds = led;
  50. + platform_device_register(&ar2315_gpio_leds);
  51. +}
  52. +#else
  53. +static inline void ar2315_init_gpio_leds(void)
  54. +{
  55. +}
  56. +#endif
  57. +
  58. void __init ar2315_init_devices(void)
  59. {
  60. /* Find board configuration */
  61. @@ -270,6 +315,8 @@ void __init ar2315_init_devices(void)
  62. ar2315_gpio_res[1].end = ar2315_gpio_res[1].start;
  63. platform_device_register(&ar2315_gpio);
  64. + ar2315_init_gpio_leds();
  65. +
  66. ar2315_wdt_res[1].start = irq_create_mapping(ar2315_misc_irq_domain,
  67. AR2315_MISC_IRQ_WATCHDOG);
  68. ar2315_wdt_res[1].end = ar2315_wdt_res[1].start;
  69. --- a/arch/mips/ath25/ar5312.c
  70. +++ b/arch/mips/ath25/ar5312.c
  71. @@ -23,6 +23,7 @@
  72. #include <linux/mtd/physmap.h>
  73. #include <linux/reboot.h>
  74. #include <linux/gpio.h>
  75. +#include <linux/leds.h>
  76. #include <asm/bootinfo.h>
  77. #include <asm/reboot.h>
  78. #include <asm/time.h>
  79. @@ -231,6 +232,23 @@ static struct platform_device ar5312_gpi
  80. .num_resources = ARRAY_SIZE(ar5312_gpio_res),
  81. };
  82. +#ifdef CONFIG_LEDS_GPIO
  83. +static struct gpio_led ar5312_leds[] = {
  84. + { .name = "wlan", .gpio = 0, .active_low = 1, },
  85. +};
  86. +
  87. +static const struct gpio_led_platform_data ar5312_led_data = {
  88. + .num_leds = ARRAY_SIZE(ar5312_leds),
  89. + .leds = (void *)ar5312_leds,
  90. +};
  91. +
  92. +static struct platform_device ar5312_gpio_leds = {
  93. + .name = "leds-gpio",
  94. + .id = -1,
  95. + .dev.platform_data = (void *)&ar5312_led_data,
  96. +};
  97. +#endif
  98. +
  99. static void __init ar5312_flash_init(void)
  100. {
  101. void __iomem *flashctl_base;
  102. @@ -301,6 +319,11 @@ void __init ar5312_init_devices(void)
  103. platform_device_register(&ar5312_gpio);
  104. +#ifdef CONFIG_LEDS_GPIO
  105. + ar5312_leds[0].gpio = config->sys_led_gpio;
  106. + platform_device_register(&ar5312_gpio_leds);
  107. +#endif
  108. +
  109. /* Fix up MAC addresses if necessary */
  110. if (is_broadcast_ether_addr(config->enet0_mac))
  111. ether_addr_copy(config->enet0_mac, config->enet1_mac);