ar71xx: WPN824N: set WLAN LED name
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-wnr2000-v3.c
1 /*
2 * NETGEAR WNR2000v3/WNR612v2/WNR1000v2/WPN824N board support
3 *
4 * Copyright (C) 2015 Hartmut Knaack <knaack.h@gmx.de>
5 * Copyright (C) 2013 Mathieu Olivari <mathieu.olivari@gmail.com>
6 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
7 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
8 * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation.
13 */
14
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/partitions.h>
17 #include <linux/kernel.h> /* for max() macro */
18 #include <linux/platform_device.h> /* PLATFORM_DEVID_AUTO is defined here */
19
20 #include <asm/mach-ath79/ath79.h>
21 #include <asm/mach-ath79/ar71xx_regs.h> /* needed to disable switch LEDs */
22 #include "common.h" /* needed to disable switch LEDs */
23
24 #include "dev-ap9x-pci.h"
25 #include "dev-eth.h"
26 #include "dev-gpio-buttons.h"
27 #include "dev-leds-gpio.h"
28 #include "dev-m25p80.h"
29 #include "machtypes.h"
30
31 /* WNR2000v3 - connected through AR7241 */
32 #define WNR2000V3_GPIO_LED_WAN_GREEN 0
33 #define WNR2000V3_GPIO_LED_LAN1_AMBER 1
34 #define WNR2000V3_GPIO_LED_LAN2_AMBER 6
35 #define WNR2000V3_GPIO_LED_WPS_GREEN 7
36 #define WNR2000V3_GPIO_LED_LAN3_AMBER 8
37 #define WNR2000V3_GPIO_BTN_WPS 11
38 #define WNR2000V3_GPIO_LED_LAN4_AMBER 12
39 #define WNR2000V3_GPIO_LED_LAN1_GREEN 13
40 #define WNR2000V3_GPIO_LED_LAN2_GREEN 14
41 #define WNR2000V3_GPIO_LED_LAN3_GREEN 15
42 #define WNR2000V3_GPIO_LED_LAN4_GREEN 16
43 #define WNR2000V3_GPIO_LED_WAN_AMBER 17
44
45 /* WNR2000v3 - connected through AR9287 */
46 #define WNR2000V3_GPIO_WMAC_LED_WLAN_BLUE 1
47 #define WNR2000V3_GPIO_WMAC_LED_TEST_AMBER 2
48 #define WNR2000V3_GPIO_WMAC_LED_POWER_GREEN 3
49 #define WNR2000V3_GPIO_WMAC_BTN_RESET 8
50 #define WNR2000V3_GPIO_WMAC_BTN_RFKILL 9
51
52 /* WNR612v2 - connected through AR7241 */
53 #define WNR612V2_GPIO_LED_POWER_GREEN 11
54 #define WNR612V2_GPIO_LED_LAN1_GREEN 13
55 #define WNR612V2_GPIO_LED_LAN2_GREEN 14
56 #define WNR612V2_GPIO_LED_WAN_GREEN 17
57
58 /* WNR612v2 - connected through AR9285 */
59 #define WNR612V2_GPIO_WMAC_LED_WLAN_GREEN 1
60 #define WNR612V2_GPIO_WMAC_BTN_RESET 7
61
62 /* WNR1000v2 - connected through AR7240 */
63 #define WNR1000V2_GPIO_LED_WAN_AMBER 0
64 #define WNR1000V2_GPIO_LED_TEST_AMBER 1
65 #define WNR1000V2_GPIO_LED_LAN1_AMBER 6 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
66 #define WNR1000V2_GPIO_LED_LAN2_AMBER 7 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
67 #define WNR1000V2_GPIO_LED_LAN3_AMBER 8 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
68 #define WNR1000V2_GPIO_LED_POWER_GREEN 11
69 #define WNR1000V2_GPIO_LED_LAN4_AMBER 12
70 #define WNR1000V2_GPIO_LED_LAN1_GREEN 13 /* AR724X_..._ETH_SWITCH_LED0 */
71 #define WNR1000V2_GPIO_LED_LAN2_GREEN 14 /* AR724X_..._ETH_SWITCH_LED1 */
72 #define WNR1000V2_GPIO_LED_LAN3_GREEN 15 /* AR724X_..._ETH_SWITCH_LED2 */
73 #define WNR1000V2_GPIO_LED_LAN4_GREEN 16 /* AR724X_..._ETH_SWITCH_LED3 */
74 #define WNR1000V2_GPIO_LED_WAN_GREEN 17 /* AR724X_..._ETH_SWITCH_LED4 */
75
76 /* WNR1000v2 - connected through AR9285 */
77 #define WNR1000V2_GPIO_WMAC_LED_WLAN_BLUE 1
78 #define WNR1000V2_GPIO_WMAC_LED_WPS_GREEN 5
79 #define WNR1000V2_GPIO_WMAC_BTN_WPS 6
80 #define WNR1000V2_GPIO_WMAC_BTN_RESET 7
81 #define WNR1000V2_GPIO_WMAC_BTN_RFKILL 8
82
83 /* Connected through AR7240 */
84 #define WPN824N_GPIO_LED_WAN_AMBER 0
85 #define WPN824N_GPIO_LED_STATUS_AMBER 1
86 #define WPN824N_GPIO_LED_LAN1_AMBER 6 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
87 #define WPN824N_GPIO_LED_LAN2_AMBER 7 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
88 #define WPN824N_GPIO_LED_LAN3_AMBER 8 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
89 #define WPN824N_GPIO_LED_LAN4_AMBER 12
90 #define WPN824N_GPIO_LED_LAN1_GREEN 13
91 #define WPN824N_GPIO_LED_LAN2_GREEN 14
92 #define WPN824N_GPIO_LED_LAN3_GREEN 15 /* AR724X_GPIO_FUNC_CLK_OBS3_EN */
93 #define WPN824N_GPIO_LED_LAN4_GREEN 16
94 #define WPN824N_GPIO_LED_WAN_GREEN 17
95
96 /* Connected through AR9285 */
97 #define WPN824N_WGPIO_LED_PWR_GREEN 0
98 #define WPN824N_WGPIO_LED_WLAN_BLUE 1
99 #define WPN824N_WGPIO_LED_WPS1_BLUE 5
100 #define WPN824N_WGPIO_LED_WPS2_BLUE 9
101 #define WPN824N_WGPIO_LED_TEST_AMBER 10
102 #define WPN824N_WGPIO_BTN_PUSH 6 /* currently unused */
103 #define WPN824N_WGPIO_BTN_RESET 7 /* currently unused */
104 #define WPN824N_WGPIO_BTN_WLAN 8 /* currently unused */
105
106 #define WNR2000V3_KEYS_POLL_INTERVAL 20 /* msecs */
107 #define WNR2000V3_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000V3_KEYS_POLL_INTERVAL)
108
109 /* ART offsets for: WNR2000v3, WNR612v2, WNR1000v2 */
110 #define WNR2000V3_MAC0_OFFSET 0
111 #define WNR2000V3_MAC1_OFFSET 6
112 #define WNR2000V3_PCIE_CALDATA_OFFSET 0x1000
113 #define WNR2000V3_WMAC_OFFSET 0x108c /* wireless MAC is inside ART */
114
115 static struct gpio_led wnr2000v3_leds_gpio[] __initdata = {
116 {
117 .name = "netgear:green:wan",
118 .gpio = WNR2000V3_GPIO_LED_WAN_GREEN,
119 .active_low = 1,
120 }, {
121 .name = "netgear:amber:lan1",
122 .gpio = WNR2000V3_GPIO_LED_LAN1_AMBER,
123 .active_low = 1,
124 }, {
125 .name = "netgear:amber:lan2",
126 .gpio = WNR2000V3_GPIO_LED_LAN2_AMBER,
127 .active_low = 1,
128 }, {
129 .name = "netgear:amber:lan3",
130 .gpio = WNR2000V3_GPIO_LED_LAN3_AMBER,
131 .active_low = 1,
132 }, {
133 .name = "netgear:amber:lan4",
134 .gpio = WNR2000V3_GPIO_LED_LAN4_AMBER,
135 .active_low = 1,
136 }, {
137 .name = "netgear:green:wps",
138 .gpio = WNR2000V3_GPIO_LED_WPS_GREEN,
139 .active_low = 1,
140 }, {
141 .name = "netgear:green:lan1",
142 .gpio = WNR2000V3_GPIO_LED_LAN1_GREEN,
143 .active_low = 1,
144 }, {
145 .name = "netgear:green:lan2",
146 .gpio = WNR2000V3_GPIO_LED_LAN2_GREEN,
147 .active_low = 1,
148 }, {
149 .name = "netgear:green:lan3",
150 .gpio = WNR2000V3_GPIO_LED_LAN3_GREEN,
151 .active_low = 1,
152 }, {
153 .name = "netgear:green:lan4",
154 .gpio = WNR2000V3_GPIO_LED_LAN4_GREEN,
155 .active_low = 1,
156 }, {
157 .name = "netgear:amber:wan",
158 .gpio = WNR2000V3_GPIO_LED_WAN_AMBER,
159 .active_low = 1,
160 }
161 };
162
163 static struct gpio_led wnr2000v3_wmac_leds_gpio[] = {
164 {
165 .name = "netgear:green:power",
166 .gpio = WNR2000V3_GPIO_WMAC_LED_POWER_GREEN,
167 .active_low = 1,
168 .default_state = LEDS_GPIO_DEFSTATE_ON,
169 }, {
170 .name = "netgear:amber:test",
171 .gpio = WNR2000V3_GPIO_WMAC_LED_TEST_AMBER,
172 .active_low = 1,
173 }
174 };
175
176 /* Blue WLAN LED for: WNR2000v3, WNR1000v2, WPN824N */
177 static const char *wnr2000v3_wmac_led_name = "netgear:blue:wlan";
178
179 static struct gpio_led wnr612v2_leds_gpio[] __initdata = {
180 {
181 .name = "netgear:green:power",
182 .gpio = WNR612V2_GPIO_LED_POWER_GREEN,
183 .active_low = 1,
184 }, {
185 .name = "netgear:green:lan1",
186 .gpio = WNR612V2_GPIO_LED_LAN1_GREEN,
187 .active_low = 1,
188 }, {
189 .name = "netgear:green:lan2",
190 .gpio = WNR612V2_GPIO_LED_LAN2_GREEN,
191 .active_low = 1,
192 }, {
193 .name = "netgear:green:wan",
194 .gpio = WNR612V2_GPIO_LED_WAN_GREEN,
195 .active_low = 1,
196 }
197 };
198
199 static const char *wnr612v2_wmac_led_name = "netgear:green:wlan";
200
201 static struct gpio_led wnr1000v2_leds_gpio[] __initdata = {
202 {
203 .name = "netgear:amber:lan1",
204 .gpio = WNR1000V2_GPIO_LED_LAN1_AMBER,
205 .active_low = 1,
206 }, {
207 .name = "netgear:amber:lan2",
208 .gpio = WNR1000V2_GPIO_LED_LAN2_AMBER,
209 .active_low = 1,
210 }, {
211 .name = "netgear:amber:lan3",
212 .gpio = WNR1000V2_GPIO_LED_LAN3_AMBER,
213 .active_low = 1,
214 }, {
215 .name = "netgear:amber:lan4",
216 .gpio = WNR1000V2_GPIO_LED_LAN4_AMBER,
217 .active_low = 1,
218 }, {
219 .name = "netgear:amber:test",
220 .gpio = WNR1000V2_GPIO_LED_TEST_AMBER,
221 .active_low = 1,
222 }, {
223 .name = "netgear:amber:wan",
224 .gpio = WNR1000V2_GPIO_LED_WAN_AMBER,
225 .active_low = 1,
226 }, {
227 .name = "netgear:green:lan1",
228 .gpio = WNR1000V2_GPIO_LED_LAN1_GREEN,
229 .active_low = 1,
230 }, {
231 .name = "netgear:green:lan2",
232 .gpio = WNR1000V2_GPIO_LED_LAN2_GREEN,
233 .active_low = 1,
234 }, {
235 .name = "netgear:green:lan3",
236 .gpio = WNR1000V2_GPIO_LED_LAN3_GREEN,
237 .active_low = 1,
238 }, {
239 .name = "netgear:green:lan4",
240 .gpio = WNR1000V2_GPIO_LED_LAN4_GREEN,
241 .active_low = 1,
242 }, {
243 .name = "netgear:green:power",
244 .gpio = WNR1000V2_GPIO_LED_POWER_GREEN,
245 .active_low = 1,
246 }, {
247 .name = "netgear:green:wan",
248 .gpio = WNR1000V2_GPIO_LED_WAN_GREEN,
249 .active_low = 1,
250 }
251 };
252
253 static struct gpio_led wnr1000v2_wmac_leds_gpio[] = {
254 {
255 .name = "netgear:green:wps",
256 .gpio = WNR1000V2_GPIO_WMAC_LED_WPS_GREEN,
257 .active_low = 1,
258 }
259 };
260
261 static struct gpio_led wpn824n_leds_gpio[] __initdata = {
262 {
263 .name = "netgear:amber:wan",
264 .gpio = WPN824N_GPIO_LED_WAN_AMBER,
265 .active_low = 1,
266 }, {
267 .name = "netgear:amber:status",
268 .gpio = WPN824N_GPIO_LED_STATUS_AMBER,
269 .active_low = 1,
270 }, {
271 .name = "netgear:amber:lan1",
272 .gpio = WPN824N_GPIO_LED_LAN1_AMBER,
273 .active_low = 1,
274 }, {
275 .name = "netgear:amber:lan2",
276 .gpio = WPN824N_GPIO_LED_LAN2_AMBER,
277 .active_low = 1,
278 }, {
279 .name = "netgear:amber:lan3",
280 .gpio = WPN824N_GPIO_LED_LAN3_AMBER,
281 .active_low = 1,
282 }, {
283 .name = "netgear:amber:lan4",
284 .gpio = WPN824N_GPIO_LED_LAN4_AMBER,
285 .active_low = 1,
286 }, {
287 .name = "netgear:green:lan1",
288 .gpio = WPN824N_GPIO_LED_LAN1_GREEN,
289 .active_low = 1,
290 }, {
291 .name = "netgear:green:lan2",
292 .gpio = WPN824N_GPIO_LED_LAN2_GREEN,
293 .active_low = 1,
294 }, {
295 .name = "netgear:green:lan3",
296 .gpio = WPN824N_GPIO_LED_LAN3_GREEN,
297 .active_low = 1,
298 }, {
299 .name = "netgear:green:lan4",
300 .gpio = WPN824N_GPIO_LED_LAN4_GREEN,
301 .active_low = 1,
302 }, {
303 .name = "netgear:green:wan",
304 .gpio = WPN824N_GPIO_LED_WAN_GREEN,
305 .active_low = 1,
306 }
307 };
308
309 static struct gpio_led wpn824n_wmac_leds_gpio[] = {
310 {
311 .name = "netgear:green:power",
312 .gpio = WPN824N_WGPIO_LED_PWR_GREEN,
313 .active_low = 1,
314 }, {
315 .name = "netgear:blue:wps1",
316 .gpio = WPN824N_WGPIO_LED_WPS1_BLUE,
317 .active_low = 1,
318 }, {
319 .name = "netgear:blue:wps2",
320 .gpio = WPN824N_WGPIO_LED_WPS2_BLUE,
321 .active_low = 1,
322 }, {
323 .name = "netgear:amber:test",
324 .gpio = WPN824N_WGPIO_LED_TEST_AMBER,
325 .active_low = 1,
326 }
327 };
328
329 static struct gpio_keys_button wnr2000v3_keys_gpio[] __initdata = {
330 {
331 .desc = "wps",
332 .type = EV_KEY,
333 .code = KEY_WPS_BUTTON,
334 .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
335 .gpio = WNR2000V3_GPIO_BTN_WPS,
336 .active_low = 1,
337 }
338 };
339
340 static struct gpio_keys_button wnr2000v3_wmac_keys_gpio[] = {
341 {
342 .desc = "reset",
343 .type = EV_KEY,
344 .code = KEY_RESTART,
345 .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
346 .gpio = WNR2000V3_GPIO_WMAC_BTN_RESET,
347 .active_low = 1,
348 }, {
349 .desc = "rfkill",
350 .type = EV_KEY,
351 .code = KEY_RFKILL,
352 .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
353 .gpio = WNR2000V3_GPIO_WMAC_BTN_RFKILL,
354 .active_low = 1,
355 }
356 };
357
358 static struct gpio_keys_button wnr612v2_wmac_keys_gpio[] = {
359 {
360 .desc = "reset",
361 .type = EV_KEY,
362 .code = KEY_RESTART,
363 .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
364 .gpio = WNR612V2_GPIO_WMAC_BTN_RESET,
365 .active_low = 1,
366 }
367 };
368
369 static struct gpio_keys_button wnr1000v2_wmac_keys_gpio[] = {
370 {
371 .desc = "reset",
372 .type = EV_KEY,
373 .code = KEY_RESTART,
374 .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
375 .gpio = WNR1000V2_GPIO_WMAC_BTN_RESET,
376 .active_low = 1,
377 }, {
378 .desc = "rfkill",
379 .type = EV_KEY,
380 .code = KEY_RFKILL,
381 .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
382 .gpio = WNR1000V2_GPIO_WMAC_BTN_RFKILL,
383 .active_low = 1,
384 }, {
385 .desc = "wps",
386 .type = EV_KEY,
387 .code = KEY_WPS_BUTTON,
388 .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
389 .gpio = WNR1000V2_GPIO_WMAC_BTN_WPS,
390 .active_low = 1,
391 }
392 };
393
394 /*
395 * For WNR2000v3 ART flash area used for WLAN MAC is usually empty (0xff)
396 * so ath9k driver uses random MAC instead each time module is loaded.
397 * To fix that, assign permanent WLAN MAC equal to ethN's MAC plus 1,
398 * so network interfaces get sequential addresses.
399 * If ART wireless MAC address field has been filled by user, use it.
400 */
401 static void __init wnr_get_wmac(u8 *wmac_gen_addr, int mac0_art_offset,
402 int mac1_art_offset, int wmac_art_offset)
403 {
404 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
405 u8 *eth0_mac_addr = (u8 *) (art + mac0_art_offset);
406 u8 *eth1_mac_addr = (u8 *) (art + mac1_art_offset);
407 u8 *wlan_mac_addr = (u8 *) (art + wmac_art_offset);
408
409 /* only 0xff if all bits are set - address is invalid, empty area */
410 if ((wlan_mac_addr[0] & wlan_mac_addr[1] & wlan_mac_addr[2] &
411 wlan_mac_addr[3] & wlan_mac_addr[4] & wlan_mac_addr[5]) == 0xff) {
412 memcpy(wmac_gen_addr, eth0_mac_addr, 5);
413 wmac_gen_addr[5] = max(eth0_mac_addr[5], eth1_mac_addr[5]) + 1;
414
415 /* Avoid potential conflict in case max(0xff,0x00)+1==0x00 */
416 if (!wmac_gen_addr[5])
417 wmac_gen_addr[5] = 1;
418 } else
419 memcpy(wmac_gen_addr, wlan_mac_addr, 6);
420 }
421
422 static void __init wnr_common_setup(u8 *wmac_addr)
423 {
424 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
425
426 ath79_register_mdio(0, 0x0);
427
428 ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2000V3_MAC0_OFFSET, 0);
429 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
430 ath79_eth0_data.speed = SPEED_100;
431 ath79_eth0_data.duplex = DUPLEX_FULL;
432
433 ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2000V3_MAC1_OFFSET, 0);
434 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
435 ath79_eth1_data.phy_mask = 0x10;
436
437 ath79_register_eth(0);
438 ath79_register_eth(1);
439
440 ath79_register_m25p80(NULL);
441 ap91_pci_init(art + WNR2000V3_PCIE_CALDATA_OFFSET, wmac_addr);
442 }
443
444 static void __init wnr2000v3_setup(void)
445 {
446 u8 wlan_mac_addr[6];
447
448 /*
449 * Disable JTAG to use all AR724X GPIO LEDs.
450 * Also disable CLKs and bit 20 as u-boot does.
451 * Finally, allow OS to control all link LEDs.
452 */
453 ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE |
454 AR724X_GPIO_FUNC_UART_EN,
455 AR724X_GPIO_FUNC_CLK_OBS1_EN |
456 AR724X_GPIO_FUNC_CLK_OBS2_EN |
457 AR724X_GPIO_FUNC_CLK_OBS3_EN |
458 AR724X_GPIO_FUNC_CLK_OBS4_EN |
459 AR724X_GPIO_FUNC_CLK_OBS5_EN |
460 AR724X_GPIO_FUNC_GE0_MII_CLK_EN |
461 AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
462 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
463 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
464 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
465 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN |
466 BIT(20));
467
468 wnr_get_wmac(wlan_mac_addr, WNR2000V3_MAC0_OFFSET,
469 WNR2000V3_MAC1_OFFSET, WNR2000V3_WMAC_OFFSET);
470
471 wnr_common_setup(wlan_mac_addr);
472
473 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v3_leds_gpio),
474 wnr2000v3_leds_gpio);
475
476 /* Do not use id=-1, we can have more GPIO key-polled devices */
477 ath79_register_gpio_keys_polled(PLATFORM_DEVID_AUTO,
478 WNR2000V3_KEYS_POLL_INTERVAL,
479 ARRAY_SIZE(wnr2000v3_keys_gpio),
480 wnr2000v3_keys_gpio);
481
482 ap9x_pci_setup_wmac_led_pin(0, WNR2000V3_GPIO_WMAC_LED_WLAN_BLUE);
483 ap9x_pci_setup_wmac_led_name(0, wnr2000v3_wmac_led_name);
484
485 ap9x_pci_setup_wmac_leds(0, wnr2000v3_wmac_leds_gpio,
486 ARRAY_SIZE(wnr2000v3_wmac_leds_gpio));
487
488 ap9x_pci_setup_wmac_btns(0, wnr2000v3_wmac_keys_gpio,
489 ARRAY_SIZE(wnr2000v3_wmac_keys_gpio),
490 WNR2000V3_KEYS_POLL_INTERVAL);
491 }
492
493 MIPS_MACHINE(ATH79_MACH_WNR2000_V3, "WNR2000V3", "NETGEAR WNR2000 V3", wnr2000v3_setup);
494
495 static void __init wnr612v2_setup(void)
496 {
497 u8 wlan_mac_addr[6];
498
499 /*
500 * Disable JTAG and CLKs. Allow OS to control all link LEDs.
501 * Note: U-Boot for WNR612v2 sets undocumented bit 15 but
502 * we leave it for now.
503 */
504 ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE |
505 AR724X_GPIO_FUNC_UART_EN,
506 AR724X_GPIO_FUNC_CLK_OBS1_EN |
507 AR724X_GPIO_FUNC_CLK_OBS2_EN |
508 AR724X_GPIO_FUNC_CLK_OBS3_EN |
509 AR724X_GPIO_FUNC_CLK_OBS4_EN |
510 AR724X_GPIO_FUNC_CLK_OBS5_EN |
511 AR724X_GPIO_FUNC_GE0_MII_CLK_EN |
512 AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
513 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
514 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
515 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
516 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
517
518 wnr_get_wmac(wlan_mac_addr, WNR2000V3_MAC0_OFFSET,
519 WNR2000V3_MAC1_OFFSET, WNR2000V3_WMAC_OFFSET);
520
521 wnr_common_setup(wlan_mac_addr);
522
523 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr612v2_leds_gpio),
524 wnr612v2_leds_gpio);
525
526 /*
527 * This device has no buttons on AR7241 GPIO and no extra LEDs
528 * connected to AR9285 so setup is simpler than for WNR2000v3.
529 */
530 ap9x_pci_setup_wmac_led_pin(0, WNR612V2_GPIO_WMAC_LED_WLAN_GREEN);
531 ap9x_pci_setup_wmac_led_name(0, wnr612v2_wmac_led_name);
532
533 ap9x_pci_setup_wmac_leds(0, NULL, 0);
534
535 ap9x_pci_setup_wmac_btns(0, wnr612v2_wmac_keys_gpio,
536 ARRAY_SIZE(wnr612v2_wmac_keys_gpio),
537 WNR2000V3_KEYS_POLL_INTERVAL);
538 }
539
540 MIPS_MACHINE(ATH79_MACH_WNR612_V2, "WNR612V2", "NETGEAR WNR612 V2", wnr612v2_setup);
541
542 static void __init wnr1000v2_setup(void)
543 {
544 u8 wlan_mac_addr[6];
545
546 /*
547 * Disable JTAG and CLKs. Allow OS to control all link LEDs.
548 * Note: U-Boot for WNR1000v2 sets undocumented bit 15 but
549 * we leave it for now.
550 */
551 ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE |
552 AR724X_GPIO_FUNC_UART_EN,
553 AR724X_GPIO_FUNC_CLK_OBS1_EN |
554 AR724X_GPIO_FUNC_CLK_OBS2_EN |
555 AR724X_GPIO_FUNC_CLK_OBS3_EN |
556 AR724X_GPIO_FUNC_CLK_OBS4_EN |
557 AR724X_GPIO_FUNC_CLK_OBS5_EN |
558 AR724X_GPIO_FUNC_GE0_MII_CLK_EN |
559 AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
560 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
561 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
562 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
563 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
564
565 wnr_get_wmac(wlan_mac_addr, WNR2000V3_MAC0_OFFSET,
566 WNR2000V3_MAC1_OFFSET, WNR2000V3_WMAC_OFFSET);
567
568 wnr_common_setup(wlan_mac_addr);
569
570 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr1000v2_leds_gpio),
571 wnr1000v2_leds_gpio);
572
573 ap9x_pci_setup_wmac_led_pin(0, WNR1000V2_GPIO_WMAC_LED_WLAN_BLUE);
574 ap9x_pci_setup_wmac_led_name(0, wnr2000v3_wmac_led_name);
575
576 ap9x_pci_setup_wmac_leds(0, wnr1000v2_wmac_leds_gpio,
577 ARRAY_SIZE(wnr1000v2_wmac_leds_gpio));
578
579 /* All 3 buttons are connected to wireless chip */
580 ap9x_pci_setup_wmac_btns(0, wnr1000v2_wmac_keys_gpio,
581 ARRAY_SIZE(wnr1000v2_wmac_keys_gpio),
582 WNR2000V3_KEYS_POLL_INTERVAL);
583 }
584
585 MIPS_MACHINE(ATH79_MACH_WNR1000_V2, "WNR1000V2", "NETGEAR WNR1000 V2", wnr1000v2_setup);
586
587 static void __init wpn824n_setup(void)
588 {
589 ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
590 AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
591 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
592 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
593 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
594 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN |
595 AR724X_GPIO_FUNC_CLK_OBS3_EN);
596
597 wnr_common_setup(NULL);
598
599 ath79_register_leds_gpio(-1, ARRAY_SIZE(wpn824n_leds_gpio),
600 wpn824n_leds_gpio);
601
602 ap9x_pci_setup_wmac_led_pin(0, WPN824N_WGPIO_LED_WLAN_BLUE);
603 ap9x_pci_setup_wmac_led_name(0, wnr2000v3_wmac_led_name);
604 ap9x_pci_setup_wmac_leds(0, wpn824n_wmac_leds_gpio,
605 ARRAY_SIZE(wpn824n_wmac_leds_gpio));
606 }
607
608 MIPS_MACHINE(ATH79_MACH_WPN824N, "WPN824N", "NETGEAR WPN824N", wpn824n_setup);