aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2014-01-14 06:14:41 -0500
committerRalf Baechle <ralf@linux-mips.org>2014-01-24 16:39:51 -0500
commit515fa75d4845c424c853a727a4f02b0e02340370 (patch)
treeaff49e83e72804e9bf1eb4cd2cc253263950cdf3
parent76b573e46016eabc79e6764a458a559a30dfa7e9 (diff)
MIPS: BCM47XX: Prepare support for LEDs
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/
-rw-r--r--arch/mips/bcm47xx/Kconfig2
-rw-r--r--arch/mips/bcm47xx/Makefile2
-rw-r--r--arch/mips/bcm47xx/bcm47xx_private.h9
-rw-r--r--arch/mips/bcm47xx/leds.c73
-rw-r--r--arch/mips/bcm47xx/setup.c4
5 files changed, 89 insertions, 1 deletions
diff --git a/arch/mips/bcm47xx/Kconfig b/arch/mips/bcm47xx/Kconfig
index df549af380af..09cb6f7aa3db 100644
--- a/arch/mips/bcm47xx/Kconfig
+++ b/arch/mips/bcm47xx/Kconfig
@@ -12,6 +12,7 @@ config BCM47XX_SSB
12 select SSB_PCICORE_HOSTMODE if PCI 12 select SSB_PCICORE_HOSTMODE if PCI
13 select SSB_DRIVER_GPIO 13 select SSB_DRIVER_GPIO
14 select GPIOLIB 14 select GPIOLIB
15 select LEDS_GPIO_REGISTER
15 default y 16 default y
16 help 17 help
17 Add support for old Broadcom BCM47xx boards with Sonics Silicon Backplane support. 18 Add support for old Broadcom BCM47xx boards with Sonics Silicon Backplane support.
@@ -29,6 +30,7 @@ config BCM47XX_BCMA
29 select BCMA_DRIVER_PCI_HOSTMODE if PCI 30 select BCMA_DRIVER_PCI_HOSTMODE if PCI
30 select BCMA_DRIVER_GPIO 31 select BCMA_DRIVER_GPIO
31 select GPIOLIB 32 select GPIOLIB
33 select LEDS_GPIO_REGISTER
32 default y 34 default y
33 help 35 help
34 Add support for new Broadcom BCM47xx boards with Broadcom specific Advanced Microcontroller Bus. 36 Add support for new Broadcom BCM47xx boards with Broadcom specific Advanced Microcontroller Bus.
diff --git a/arch/mips/bcm47xx/Makefile b/arch/mips/bcm47xx/Makefile
index c52daf9b05c6..84e9aed25027 100644
--- a/arch/mips/bcm47xx/Makefile
+++ b/arch/mips/bcm47xx/Makefile
@@ -4,5 +4,5 @@
4# 4#
5 5
6obj-y += irq.o nvram.o prom.o serial.o setup.o time.o sprom.o 6obj-y += irq.o nvram.o prom.o serial.o setup.o time.o sprom.o
7obj-y += board.o 7obj-y += board.o leds.o
8obj-$(CONFIG_BCM47XX_SSB) += wgt634u.o 8obj-$(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
index 000000000000..1a1e600b74e6
--- /dev/null
+++ b/arch/mips/bcm47xx/bcm47xx_private.h
@@ -0,0 +1,9 @@
1#ifndef LINUX_BCM47XX_PRIVATE_H_
2#define LINUX_BCM47XX_PRIVATE_H_
3
4#include <linux/kernel.h>
5
6/* leds.c */
7void __init bcm47xx_leds_register(void);
8
9#endif
diff --git a/arch/mips/bcm47xx/leds.c b/arch/mips/bcm47xx/leds.c
new file mode 100644
index 000000000000..6a49d4c6c9c3
--- /dev/null
+++ b/arch/mips/bcm47xx/leds.c
@@ -0,0 +1,73 @@
1#include "bcm47xx_private.h"
2
3#include <linux/leds.h>
4#include <bcm47xx_board.h>
5
6static const struct gpio_led
7bcm47xx_leds_netgear_wndr4500_v1_leds[] __initconst = {
8 {
9 .name = "bcm47xx:green:wps",
10 .gpio = 1,
11 .active_low = 1,
12 .default_state = LEDS_GPIO_DEFSTATE_KEEP,
13 },
14 {
15 .name = "bcm47xx:green:power",
16 .gpio = 2,
17 .active_low = 1,
18 .default_state = LEDS_GPIO_DEFSTATE_KEEP,
19 },
20 {
21 .name = "bcm47xx:orange:power",
22 .gpio = 3,
23 .active_low = 1,
24 .default_state = LEDS_GPIO_DEFSTATE_KEEP,
25 },
26 {
27 .name = "bcm47xx:green:usb1",
28 .gpio = 8,
29 .active_low = 1,
30 .default_state = LEDS_GPIO_DEFSTATE_KEEP,
31 },
32 {
33 .name = "bcm47xx:green:2ghz",
34 .gpio = 9,
35 .active_low = 1,
36 .default_state = LEDS_GPIO_DEFSTATE_KEEP,
37 },
38 {
39 .name = "bcm47xx:blue:5ghz",
40 .gpio = 11,
41 .active_low = 1,
42 .default_state = LEDS_GPIO_DEFSTATE_KEEP,
43 },
44 {
45 .name = "bcm47xx:green:usb2",
46 .gpio = 14,
47 .active_low = 1,
48 .default_state = LEDS_GPIO_DEFSTATE_KEEP,
49 },
50};
51
52static struct gpio_led_platform_data bcm47xx_leds_pdata;
53
54#define bcm47xx_set_pdata(dev_leds) do { \
55 bcm47xx_leds_pdata.leds = dev_leds; \
56 bcm47xx_leds_pdata.num_leds = ARRAY_SIZE(dev_leds); \
57} while (0)
58
59void __init bcm47xx_leds_register(void)
60{
61 enum bcm47xx_board board = bcm47xx_board_get();
62
63 switch (board) {
64 case BCM47XX_BOARD_NETGEAR_WNDR4500V1:
65 bcm47xx_set_pdata(bcm47xx_leds_netgear_wndr4500_v1_leds);
66 break;
67 default:
68 pr_debug("No LEDs configuration found for this device\n");
69 return;
70 }
71
72 gpio_led_register_device(-1, &bcm47xx_leds_pdata);
73}
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
index aa2d8e39a9b0..91166967f8f7 100644
--- a/arch/mips/bcm47xx/setup.c
+++ b/arch/mips/bcm47xx/setup.c
@@ -26,6 +26,8 @@
26 * 675 Mass Ave, Cambridge, MA 02139, USA. 26 * 675 Mass Ave, Cambridge, MA 02139, USA.
27 */ 27 */
28 28
29#include "bcm47xx_private.h"
30
29#include <linux/export.h> 31#include <linux/export.h>
30#include <linux/types.h> 32#include <linux/types.h>
31#include <linux/ssb/ssb.h> 33#include <linux/ssb/ssb.h>
@@ -253,6 +255,8 @@ static int __init bcm47xx_register_bus_complete(void)
253 break; 255 break;
254#endif 256#endif
255 } 257 }
258 bcm47xx_leds_register();
259
256 return 0; 260 return 0;
257} 261}
258device_initcall(bcm47xx_register_bus_complete); 262device_initcall(bcm47xx_register_bus_complete);