brcm47xx: improve board detection for some devices
[openwrt/staging/chunkeey.git] / target / linux / brcm47xx / patches-3.10 / 149-MIPS-BCM47XX-add-some-more-devices.patch
1 From 35661c37bde151764e8526e77d4e02ca77e19160 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Mon, 14 Jul 2014 23:32:10 +0200
4 Subject: [PATCH 5/5] MIPS: BCM47XX: add some more devices
5
6 This adds Microsoft MN-700 and Asus WL500G.
7
8 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
9 ---
10 arch/mips/bcm47xx/board.c | 17 +++++++++++++++++
11 arch/mips/bcm47xx/buttons.c | 19 +++++++++++++++++++
12 arch/mips/bcm47xx/leds.c | 19 +++++++++++++++++++
13 arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h | 3 +++
14 4 files changed, 58 insertions(+)
15
16 --- a/arch/mips/bcm47xx/board.c
17 +++ b/arch/mips/bcm47xx/board.c
18 @@ -80,6 +80,14 @@ struct bcm47xx_board_type_list1 bcm47xx_
19 { {0}, NULL},
20 };
21
22 +/* hardware_version, boardnum */
23 +static const
24 +struct bcm47xx_board_type_list2 bcm47xx_board_list_hw_version_num[] __initconst = {
25 + {{BCM47XX_BOARD_MICROSOFT_MN700, "Microsoft MN-700"}, "WL500-", "mn700"},
26 + {{BCM47XX_BOARD_ASUS_WL500G, "Asus WL500G"}, "WL500-", "asusX"},
27 + { {0}, NULL},
28 +};
29 +
30 /* productid */
31 static const
32 struct bcm47xx_board_type_list1 bcm47xx_board_list_productid[] __initconst = {
33 @@ -237,6 +245,15 @@ static __init const struct bcm47xx_board
34 }
35 }
36
37 + if (bcm47xx_nvram_getenv("hardware_version", buf1, sizeof(buf1)) >= 0 &&
38 + bcm47xx_nvram_getenv("boardtype", buf2, sizeof(buf2)) >= 0) {
39 + for (e2 = bcm47xx_board_list_boot_hw; e2->value1; e2++) {
40 + if (!strstarts(buf1, e2->value1) &&
41 + !strcmp(buf2, e2->value2))
42 + return &e2->board;
43 + }
44 + }
45 +
46 if (bcm47xx_nvram_getenv("productid", buf1, sizeof(buf1)) >= 0) {
47 for (e1 = bcm47xx_board_list_productid; e1->value1; e1++) {
48 if (!strcmp(buf1, e1->value1))
49 --- a/arch/mips/bcm47xx/buttons.c
50 +++ b/arch/mips/bcm47xx/buttons.c
51 @@ -56,6 +56,11 @@ bcm47xx_buttons_asus_wl330ge[] __initcon
52 };
53
54 static const struct gpio_keys_button
55 +bcm47xx_buttons_asus_wl500g[] __initconst = {
56 + BCM47XX_GPIO_KEY(6, KEY_RESTART),
57 +};
58 +
59 +static const struct gpio_keys_button
60 bcm47xx_buttons_asus_wl500gd[] __initconst = {
61 BCM47XX_GPIO_KEY(6, KEY_RESTART),
62 };
63 @@ -288,6 +293,13 @@ bcm47xx_buttons_linksys_wrtsl54gs[] __in
64 BCM47XX_GPIO_KEY(6, KEY_RESTART),
65 };
66
67 +/* Microsoft */
68 +
69 +static const struct gpio_keys_button
70 +bcm47xx_buttons_microsoft_nm700[] __initconst = {
71 + BCM47XX_GPIO_KEY(7, KEY_RESTART),
72 +};
73 +
74 /* Motorola */
75
76 static const struct gpio_keys_button
77 @@ -401,6 +413,9 @@ int __init bcm47xx_buttons_register(void
78 case BCM47XX_BOARD_ASUS_WL330GE:
79 err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl330ge);
80 break;
81 + case BCM47XX_BOARD_ASUS_WL500G:
82 + err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl500g);
83 + break;
84 case BCM47XX_BOARD_ASUS_WL500GD:
85 err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl500gd);
86 break;
87 @@ -525,6 +540,10 @@ int __init bcm47xx_buttons_register(void
88 err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrtsl54gs);
89 break;
90
91 + case BCM47XX_BOARD_MICROSOFT_MN700:
92 + err = bcm47xx_copy_bdata(bcm47xx_buttons_microsoft_nm700);
93 + break;
94 +
95 case BCM47XX_BOARD_MOTOROLA_WE800G:
96 err = bcm47xx_copy_bdata(bcm47xx_buttons_motorola_we800g);
97 break;
98 --- a/arch/mips/bcm47xx/leds.c
99 +++ b/arch/mips/bcm47xx/leds.c
100 @@ -73,6 +73,11 @@ bcm47xx_leds_asus_wl330ge[] __initconst
101 };
102
103 static const struct gpio_led
104 +bcm47xx_leds_asus_wl500g[] __initconst = {
105 + BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON),
106 +};
107 +
108 +static const struct gpio_led
109 bcm47xx_leds_asus_wl500gd[] __initconst = {
110 BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON),
111 };
112 @@ -348,6 +353,13 @@ bcm47xx_leds_linksys_wrtsl54gs[] __initc
113 BCM47XX_GPIO_LED(7, "orange", "wps", 1, LEDS_GPIO_DEFSTATE_OFF),
114 };
115
116 +/* Microsoft */
117 +
118 +static const struct gpio_led
119 +bcm47xx_leds_microsoft_nm700[] __initconst = {
120 + BCM47XX_GPIO_LED(6, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON),
121 +};
122 +
123 /* Motorola */
124
125 static const struct gpio_led
126 @@ -460,6 +472,9 @@ void __init bcm47xx_leds_register(void)
127 case BCM47XX_BOARD_ASUS_WL330GE:
128 bcm47xx_set_pdata(bcm47xx_leds_asus_wl330ge);
129 break;
130 + case BCM47XX_BOARD_ASUS_WL500G:
131 + bcm47xx_set_pdata(bcm47xx_leds_asus_wl500g);
132 + break;
133 case BCM47XX_BOARD_ASUS_WL500GD:
134 bcm47xx_set_pdata(bcm47xx_leds_asus_wl500gd);
135 break;
136 @@ -586,6 +601,10 @@ void __init bcm47xx_leds_register(void)
137 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrtsl54gs);
138 break;
139
140 + case BCM47XX_BOARD_MICROSOFT_MN700:
141 + bcm47xx_set_pdata(bcm47xx_leds_microsoft_nm700);
142 + break;
143 +
144 case BCM47XX_BOARD_MOTOROLA_WE800G:
145 bcm47xx_set_pdata(bcm47xx_leds_motorola_we800g);
146 break;
147 --- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
148 +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
149 @@ -18,6 +18,7 @@ enum bcm47xx_board {
150 BCM47XX_BOARD_ASUS_WL300G,
151 BCM47XX_BOARD_ASUS_WL320GE,
152 BCM47XX_BOARD_ASUS_WL330GE,
153 + BCM47XX_BOARD_ASUS_WL500G,
154 BCM47XX_BOARD_ASUS_WL500GD,
155 BCM47XX_BOARD_ASUS_WL500GPV1,
156 BCM47XX_BOARD_ASUS_WL500GPV2,
157 @@ -77,6 +78,8 @@ enum bcm47xx_board {
158 BCM47XX_BOARD_LINKSYS_WRT610NV2,
159 BCM47XX_BOARD_LINKSYS_WRTSL54GS,
160
161 + BCM47XX_BOARD_MICROSOFT_MN700,
162 +
163 BCM47XX_BOARD_MOTOROLA_WE800G,
164 BCM47XX_BOARD_MOTOROLA_WR850GP,
165 BCM47XX_BOARD_MOTOROLA_WR850GV2V3,