brcm47xx: backport upstream patches for Netgear WNR1000 V3
[openwrt/openwrt.git] / target / linux / brcm47xx / patches-4.4 / 033-MIPS-BCM47XX-Add-support-for-Netgear-WNR1000-V3.patch
1 From 88b882ba0b0b7439d16d2c9df7f111cdf793443b Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Sun, 8 Apr 2018 22:39:15 +0200
4 Subject: [PATCH] MIPS: BCM47XX: Add support for Netgear WNR1000 V3
5
6 This adds support for detecting this model board and registers some LEDs
7 and buttons.
8
9 There are two uncommon things regarding this device:
10 1) It can use two different "board_id" ID values.
11 Unit I have uses "U12H139T00_NETGEAR" value. This magic is also used
12 in firmware file header. There are two reports (one from an OpenWrt
13 user) of a different "U12H139T50_NETGEAR" magic though.
14 2) Power LEDs share GPIOs with buttons.
15 Amber one seems to share GPIO 2 with WPS button and green one seems
16 to share GPIO 3 with reset button. It remains unknown how to support
17 them and handle buttons at the same time. For that reason they aren't
18 added to the list of supported LEDs.
19 ---
20 arch/mips/bcm47xx/board.c | 2 ++
21 arch/mips/bcm47xx/buttons.c | 9 +++++++++
22 arch/mips/bcm47xx/leds.c | 9 +++++++++
23 arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h | 1 +
24 4 files changed, 21 insertions(+)
25
26 --- a/arch/mips/bcm47xx/board.c
27 +++ b/arch/mips/bcm47xx/board.c
28 @@ -171,6 +171,8 @@ struct bcm47xx_board_type_list1 bcm47xx_
29 {{BCM47XX_BOARD_NETGEAR_WNDR4000, "Netgear WNDR4000"}, "U12H181T00_NETGEAR"},
30 {{BCM47XX_BOARD_NETGEAR_WNDR4500V1, "Netgear WNDR4500 V1"}, "U12H189T00_NETGEAR"},
31 {{BCM47XX_BOARD_NETGEAR_WNDR4500V2, "Netgear WNDR4500 V2"}, "U12H224T00_NETGEAR"},
32 + {{BCM47XX_BOARD_NETGEAR_WNR1000_V3, "Netgear WNR1000 V3"}, "U12H139T00_NETGEAR"},
33 + {{BCM47XX_BOARD_NETGEAR_WNR1000_V3, "Netgear WNR1000 V3"}, "U12H139T50_NETGEAR"},
34 {{BCM47XX_BOARD_NETGEAR_WNR2000, "Netgear WNR2000"}, "U12H114T00_NETGEAR"},
35 {{BCM47XX_BOARD_NETGEAR_WNR3500L, "Netgear WNR3500L"}, "U12H136T99_NETGEAR"},
36 {{BCM47XX_BOARD_NETGEAR_WNR3500U, "Netgear WNR3500U"}, "U12H136T00_NETGEAR"},
37 --- a/arch/mips/bcm47xx/buttons.c
38 +++ b/arch/mips/bcm47xx/buttons.c
39 @@ -411,6 +411,12 @@ bcm47xx_buttons_netgear_wndr4500v1[] __i
40 };
41
42 static const struct gpio_keys_button
43 +bcm47xx_buttons_netgear_wnr1000_v3[] __initconst = {
44 + BCM47XX_GPIO_KEY(2, KEY_WPS_BUTTON),
45 + BCM47XX_GPIO_KEY(3, KEY_RESTART),
46 +};
47 +
48 +static const struct gpio_keys_button
49 bcm47xx_buttons_netgear_wnr3500lv1[] __initconst = {
50 BCM47XX_GPIO_KEY(4, KEY_RESTART),
51 BCM47XX_GPIO_KEY(6, KEY_WPS_BUTTON),
52 @@ -669,6 +675,9 @@ int __init bcm47xx_buttons_register(void
53 case BCM47XX_BOARD_NETGEAR_WNDR4500V1:
54 err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wndr4500v1);
55 break;
56 + case BCM47XX_BOARD_NETGEAR_WNR1000_V3:
57 + err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wnr1000_v3);
58 + break;
59 case BCM47XX_BOARD_NETGEAR_WNR3500L:
60 err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wnr3500lv1);
61 break;
62 --- a/arch/mips/bcm47xx/leds.c
63 +++ b/arch/mips/bcm47xx/leds.c
64 @@ -497,6 +497,12 @@ bcm47xx_leds_netgear_wndr4500v1[] __init
65 };
66
67 static const struct gpio_led
68 +bcm47xx_leds_netgear_wnr1000_v3[] __initconst = {
69 + BCM47XX_GPIO_LED(0, "blue", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF),
70 + BCM47XX_GPIO_LED(1, "green", "wps", 0, LEDS_GPIO_DEFSTATE_OFF),
71 +};
72 +
73 +static const struct gpio_led
74 bcm47xx_leds_netgear_wnr3500lv1[] __initconst = {
75 BCM47XX_GPIO_LED(0, "blue", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF),
76 BCM47XX_GPIO_LED(1, "green", "wps", 1, LEDS_GPIO_DEFSTATE_OFF),
77 @@ -757,6 +763,9 @@ void __init bcm47xx_leds_register(void)
78 case BCM47XX_BOARD_NETGEAR_WNDR4500V1:
79 bcm47xx_set_pdata(bcm47xx_leds_netgear_wndr4500v1);
80 break;
81 + case BCM47XX_BOARD_NETGEAR_WNR1000_V3:
82 + bcm47xx_set_pdata(bcm47xx_leds_netgear_wnr1000_v3);
83 + break;
84 case BCM47XX_BOARD_NETGEAR_WNR3500L:
85 bcm47xx_set_pdata(bcm47xx_leds_netgear_wnr3500lv1);
86 break;
87 --- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
88 +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
89 @@ -109,6 +109,7 @@ enum bcm47xx_board {
90 BCM47XX_BOARD_NETGEAR_WNDR4000,
91 BCM47XX_BOARD_NETGEAR_WNDR4500V1,
92 BCM47XX_BOARD_NETGEAR_WNDR4500V2,
93 + BCM47XX_BOARD_NETGEAR_WNR1000_V3,
94 BCM47XX_BOARD_NETGEAR_WNR2000,
95 BCM47XX_BOARD_NETGEAR_WNR3500L,
96 BCM47XX_BOARD_NETGEAR_WNR3500U,