brcm47xx: add Luxul XAP-1500 and XWR-1750 WiFi LEDs
[openwrt/openwrt.git] / target / linux / brcm47xx / patches-4.4 / 032-MIPS-BCM47XX-Add-Luxul-XAP1500-XWR1750-WiFi-LEDs.patch
1 From 272641206100e89656038180da12eff4f03d79d1 Mon Sep 17 00:00:00 2001
2 From: Dan Haab <dan.haab@luxul.com>
3 Date: Tue, 27 Mar 2018 11:24:34 -0600
4 Subject: [PATCH] MIPS: BCM47XX: Add Luxul XAP1500/XWR1750 WiFi LEDs
5
6 Some Luxul devices use PCIe connected GPIO LEDs that are not available
7 until the PCI subsytem and its drivers load. Using the same array for
8 these LEDs would block registering any LEDs until all GPIOs become
9 available. This may be undesired behavior as some LEDs should be
10 available as early as possible (e.g. system status LED). This patch will
11 allow registering available LEDs while deferring these PCIe GPIO
12 connected 'extra' LEDs until they become available.
13
14 Signed-off-by: Dan Haab <dan.haab@luxul.com>
15 Cc: Ralf Baechle <ralf@linux-mips.org>
16 Cc: Hauke Mehrtens <hauke@hauke-m.de>
17 Cc: linux-mips@linux-mips.org
18 Patchwork: https://patchwork.linux-mips.org/patch/18952/
19 Signed-off-by: James Hogan <jhogan@kernel.org>
20 ---
21 arch/mips/bcm47xx/leds.c | 21 +++++++++++++++++++++
22 1 file changed, 21 insertions(+)
23
24 --- a/arch/mips/bcm47xx/leds.c
25 +++ b/arch/mips/bcm47xx/leds.c
26 @@ -408,6 +408,12 @@ bcm47xx_leds_luxul_xap_1500_v1[] __initc
27 };
28
29 static const struct gpio_led
30 +bcm47xx_leds_luxul_xap1500_v1_extra[] __initconst = {
31 + BCM47XX_GPIO_LED(44, "green", "5ghz", 0, LEDS_GPIO_DEFSTATE_OFF),
32 + BCM47XX_GPIO_LED(76, "green", "2ghz", 0, LEDS_GPIO_DEFSTATE_OFF),
33 +};
34 +
35 +static const struct gpio_led
36 bcm47xx_leds_luxul_xbr_4400_v1[] __initconst = {
37 BCM47XX_GPIO_LED(12, "green", "usb", 0, LEDS_GPIO_DEFSTATE_OFF),
38 BCM47XX_GPIO_LED_TRIGGER(15, "green", "status", 0, "timer"),
39 @@ -434,6 +440,11 @@ bcm47xx_leds_luxul_xwr_1750_v1[] __initc
40 BCM47XX_GPIO_LED(15, "green", "wps", 0, LEDS_GPIO_DEFSTATE_OFF),
41 };
42
43 +static const struct gpio_led
44 +bcm47xx_leds_luxul_xwr1750_v1_extra[] __initconst = {
45 + BCM47XX_GPIO_LED(76, "green", "2ghz", 0, LEDS_GPIO_DEFSTATE_OFF),
46 +};
47 +
48 /* Microsoft */
49
50 static const struct gpio_led
51 @@ -527,6 +538,12 @@ static struct gpio_led_platform_data bcm
52 bcm47xx_leds_pdata.num_leds = ARRAY_SIZE(dev_leds); \
53 } while (0)
54
55 +static struct gpio_led_platform_data bcm47xx_leds_pdata_extra __initdata = {};
56 +#define bcm47xx_set_pdata_extra(dev_leds) do { \
57 + bcm47xx_leds_pdata_extra.leds = dev_leds; \
58 + bcm47xx_leds_pdata_extra.num_leds = ARRAY_SIZE(dev_leds); \
59 +} while (0)
60 +
61 void __init bcm47xx_leds_register(void)
62 {
63 enum bcm47xx_board board = bcm47xx_board_get();
64 @@ -704,6 +721,7 @@ void __init bcm47xx_leds_register(void)
65 break;
66 case BCM47XX_BOARD_LUXUL_XAP_1500_V1:
67 bcm47xx_set_pdata(bcm47xx_leds_luxul_xap_1500_v1);
68 + bcm47xx_set_pdata_extra(bcm47xx_leds_luxul_xap1500_v1_extra);
69 break;
70 case BCM47XX_BOARD_LUXUL_XBR_4400_V1:
71 bcm47xx_set_pdata(bcm47xx_leds_luxul_xbr_4400_v1);
72 @@ -716,6 +734,7 @@ void __init bcm47xx_leds_register(void)
73 break;
74 case BCM47XX_BOARD_LUXUL_XWR_1750_V1:
75 bcm47xx_set_pdata(bcm47xx_leds_luxul_xwr_1750_v1);
76 + bcm47xx_set_pdata_extra(bcm47xx_leds_luxul_xwr1750_v1_extra);
77 break;
78
79 case BCM47XX_BOARD_MICROSOFT_MN700:
80 @@ -759,4 +778,6 @@ void __init bcm47xx_leds_register(void)
81 }
82
83 gpio_led_register_device(-1, &bcm47xx_leds_pdata);
84 + if (bcm47xx_leds_pdata_extra.num_leds)
85 + gpio_led_register_device(0, &bcm47xx_leds_pdata_extra);
86 }