MIPS: BCM47XX: Prepare support for LEDs
authorRafał Miłecki <zajec5@gmail.com>
Tue, 14 Jan 2014 11:14:41 +0000 (12:14 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Fri, 24 Jan 2014 21:39:51 +0000 (22:39 +0100)
So far this is mostly just a proof of concept, database consists of a
single device. Creating a nice iterateable array wasn't an option
because devices have different amount of LEDs. And we don't want to
waste memory just because of support for a device with dozens on LEDs.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: John Crispin <blogic@openwrt.org>
Patchwork: http://patchwork.linux-mips.org/patch/6299/

arch/mips/bcm47xx/Kconfig
arch/mips/bcm47xx/Makefile
arch/mips/bcm47xx/bcm47xx_private.h [new file with mode: 0644]
arch/mips/bcm47xx/leds.c [new file with mode: 0644]
arch/mips/bcm47xx/setup.c

index df549af380afc2e627b4a66bf83dcf54fcc945b7..09cb6f7aa3dbf4b368c5bfb456c491c90d176757 100644 (file)
@@ -12,6 +12,7 @@ config BCM47XX_SSB
        select SSB_PCICORE_HOSTMODE if PCI
        select SSB_DRIVER_GPIO
        select GPIOLIB
+       select LEDS_GPIO_REGISTER
        default y
        help
         Add support for old Broadcom BCM47xx boards with Sonics Silicon Backplane support.
@@ -29,6 +30,7 @@ config BCM47XX_BCMA
        select BCMA_DRIVER_PCI_HOSTMODE if PCI
        select BCMA_DRIVER_GPIO
        select GPIOLIB
+       select LEDS_GPIO_REGISTER
        default y
        help
         Add support for new Broadcom BCM47xx boards with Broadcom specific Advanced Microcontroller Bus.
index c52daf9b05c638afbe4062ea204bb6522c15ccd1..84e9aed25027698d3fc199aaf76c8ef18ab0b8b5 100644 (file)
@@ -4,5 +4,5 @@
 #
 
 obj-y                          += irq.o nvram.o prom.o serial.o setup.o time.o sprom.o
-obj-y                          += board.o
+obj-y                          += board.o leds.o
 obj-$(CONFIG_BCM47XX_SSB)      += wgt634u.o
diff --git a/arch/mips/bcm47xx/bcm47xx_private.h b/arch/mips/bcm47xx/bcm47xx_private.h
new file mode 100644 (file)
index 0000000..1a1e600
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef LINUX_BCM47XX_PRIVATE_H_
+#define LINUX_BCM47XX_PRIVATE_H_
+
+#include <linux/kernel.h>
+
+/* leds.c */
+void __init bcm47xx_leds_register(void);
+
+#endif
diff --git a/arch/mips/bcm47xx/leds.c b/arch/mips/bcm47xx/leds.c
new file mode 100644 (file)
index 0000000..6a49d4c
--- /dev/null
@@ -0,0 +1,73 @@
+#include "bcm47xx_private.h"
+
+#include <linux/leds.h>
+#include <bcm47xx_board.h>
+
+static const struct gpio_led
+bcm47xx_leds_netgear_wndr4500_v1_leds[] __initconst = {
+       {
+               .name           = "bcm47xx:green:wps",
+               .gpio           = 1,
+               .active_low     = 1,
+               .default_state  = LEDS_GPIO_DEFSTATE_KEEP,
+       },
+       {
+               .name           = "bcm47xx:green:power",
+               .gpio           = 2,
+               .active_low     = 1,
+               .default_state  = LEDS_GPIO_DEFSTATE_KEEP,
+       },
+       {
+               .name           = "bcm47xx:orange:power",
+               .gpio           = 3,
+               .active_low     = 1,
+               .default_state  = LEDS_GPIO_DEFSTATE_KEEP,
+       },
+       {
+               .name           = "bcm47xx:green:usb1",
+               .gpio           = 8,
+               .active_low     = 1,
+               .default_state  = LEDS_GPIO_DEFSTATE_KEEP,
+       },
+       {
+               .name           = "bcm47xx:green:2ghz",
+               .gpio           = 9,
+               .active_low     = 1,
+               .default_state  = LEDS_GPIO_DEFSTATE_KEEP,
+       },
+       {
+               .name           = "bcm47xx:blue:5ghz",
+               .gpio           = 11,
+               .active_low     = 1,
+               .default_state  = LEDS_GPIO_DEFSTATE_KEEP,
+       },
+       {
+               .name           = "bcm47xx:green:usb2",
+               .gpio           = 14,
+               .active_low     = 1,
+               .default_state  = LEDS_GPIO_DEFSTATE_KEEP,
+       },
+};
+
+static struct gpio_led_platform_data bcm47xx_leds_pdata;
+
+#define bcm47xx_set_pdata(dev_leds) do {                               \
+       bcm47xx_leds_pdata.leds = dev_leds;                             \
+       bcm47xx_leds_pdata.num_leds = ARRAY_SIZE(dev_leds);             \
+} while (0)
+
+void __init bcm47xx_leds_register(void)
+{
+       enum bcm47xx_board board = bcm47xx_board_get();
+
+       switch (board) {
+       case BCM47XX_BOARD_NETGEAR_WNDR4500V1:
+               bcm47xx_set_pdata(bcm47xx_leds_netgear_wndr4500_v1_leds);
+               break;
+       default:
+               pr_debug("No LEDs configuration found for this device\n");
+               return;
+       }
+
+       gpio_led_register_device(-1, &bcm47xx_leds_pdata);
+}
index aa2d8e39a9b0daf5262090127caea3bdd549789a..91166967f8f7fd51def5169c228231a1fa7fd176 100644 (file)
@@ -26,6 +26,8 @@
  *  675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include "bcm47xx_private.h"
+
 #include <linux/export.h>
 #include <linux/types.h>
 #include <linux/ssb/ssb.h>
@@ -253,6 +255,8 @@ static int __init bcm47xx_register_bus_complete(void)
                break;
 #endif
        }
+       bcm47xx_leds_register();
+
        return 0;
 }
 device_initcall(bcm47xx_register_bus_complete);