1 From 98e54a60a7346ef31cb851b670a238ad428b58fe Mon Sep 17 00:00:00 2001
2 From: Rafa? Mi?ecki <zajec5@gmail.com>
3 Date: Thu, 2 Jan 2014 13:27:15 +0100
4 Subject: [PATCH 029/110] MIPS: BCM47XX: Prepare support for LEDs
6 So far this is mostly just a proof of concept, database consists of a
7 single device. Creating a nice iterateable array wasn't an option
8 because devices have different amount of LEDs. And we don't want to
9 waste memory just because of support for a device with dozens on LEDs.
11 Signed-off-by: Rafa? Mi?ecki <zajec5@gmail.com>
12 Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
13 Acked-by: John Crispin <blogic@openwrt.org>
14 Patchwork: http://patchwork.linux-mips.org/patch/6299/
16 arch/mips/bcm47xx/Kconfig | 2 +
17 arch/mips/bcm47xx/Makefile | 2 +-
18 arch/mips/bcm47xx/bcm47xx_private.h | 9 +++++
19 arch/mips/bcm47xx/leds.c | 73 +++++++++++++++++++++++++++++++++++
20 arch/mips/bcm47xx/setup.c | 6 +++
21 5 files changed, 91 insertions(+), 1 deletion(-)
22 create mode 100644 arch/mips/bcm47xx/bcm47xx_private.h
23 create mode 100644 arch/mips/bcm47xx/leds.c
25 --- a/arch/mips/bcm47xx/Kconfig
26 +++ b/arch/mips/bcm47xx/Kconfig
27 @@ -12,6 +12,7 @@ config BCM47XX_SSB
28 select SSB_PCICORE_HOSTMODE if PCI
29 select SSB_DRIVER_GPIO
31 + select LEDS_GPIO_REGISTER
34 Add support for old Broadcom BCM47xx boards with Sonics Silicon Backplane support.
35 @@ -29,6 +30,7 @@ config BCM47XX_BCMA
36 select BCMA_DRIVER_PCI_HOSTMODE if PCI
37 select BCMA_DRIVER_GPIO
39 + select LEDS_GPIO_REGISTER
42 Add support for new Broadcom BCM47xx boards with Broadcom specific Advanced Microcontroller Bus.
43 --- a/arch/mips/bcm47xx/Makefile
44 +++ b/arch/mips/bcm47xx/Makefile
48 obj-y += irq.o nvram.o prom.o serial.o setup.o time.o sprom.o
50 +obj-y += board.o leds.o
51 obj-$(CONFIG_BCM47XX_SSB) += wgt634u.o
53 +++ b/arch/mips/bcm47xx/bcm47xx_private.h
55 +#ifndef LINUX_BCM47XX_PRIVATE_H_
56 +#define LINUX_BCM47XX_PRIVATE_H_
58 +#include <linux/kernel.h>
61 +void __init bcm47xx_leds_register(void);
65 +++ b/arch/mips/bcm47xx/leds.c
67 +#include "bcm47xx_private.h"
69 +#include <linux/leds.h>
70 +#include <bcm47xx_board.h>
72 +static const struct gpio_led
73 +bcm47xx_leds_netgear_wndr4500_v1_leds[] __initconst = {
75 + .name = "bcm47xx:green:wps",
78 + .default_state = LEDS_GPIO_DEFSTATE_KEEP,
81 + .name = "bcm47xx:green:power",
84 + .default_state = LEDS_GPIO_DEFSTATE_KEEP,
87 + .name = "bcm47xx:orange:power",
90 + .default_state = LEDS_GPIO_DEFSTATE_KEEP,
93 + .name = "bcm47xx:green:usb1",
96 + .default_state = LEDS_GPIO_DEFSTATE_KEEP,
99 + .name = "bcm47xx:green:2ghz",
102 + .default_state = LEDS_GPIO_DEFSTATE_KEEP,
105 + .name = "bcm47xx:blue:5ghz",
108 + .default_state = LEDS_GPIO_DEFSTATE_KEEP,
111 + .name = "bcm47xx:green:usb2",
114 + .default_state = LEDS_GPIO_DEFSTATE_KEEP,
118 +static struct gpio_led_platform_data bcm47xx_leds_pdata;
120 +#define bcm47xx_set_pdata(dev_leds) do { \
121 + bcm47xx_leds_pdata.leds = dev_leds; \
122 + bcm47xx_leds_pdata.num_leds = ARRAY_SIZE(dev_leds); \
125 +void __init bcm47xx_leds_register(void)
127 + enum bcm47xx_board board = bcm47xx_board_get();
130 + case BCM47XX_BOARD_NETGEAR_WNDR4500V1:
131 + bcm47xx_set_pdata(bcm47xx_leds_netgear_wndr4500_v1_leds);
134 + pr_debug("No LEDs configuration found for this device\n");
138 + gpio_led_register_device(-1, &bcm47xx_leds_pdata);
140 --- a/arch/mips/bcm47xx/setup.c
141 +++ b/arch/mips/bcm47xx/setup.c
143 * 675 Mass Ave, Cambridge, MA 02139, USA.
146 +#include "bcm47xx_private.h"
148 #include <linux/export.h>
149 #include <linux/types.h>
150 #include <linux/ssb/ssb.h>
151 @@ -243,6 +245,9 @@ static int __init bcm47xx_register_bus_c
156 + bcm47xx_leds_register();
160 device_initcall(bcm47xx_register_bus_complete);