ar71xx: rename COMFAST CF-E355AC to CF-E355AC v1
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-cf-e316n-v2.c
1 /*
2 * Support for COMFAST boards:
3 * - CF-E316N v2 (AR9341)
4 * - CF-E320N v2 (QCA9531)
5 * - CF-E355AC v1 (QCA9531 + QCA9882)
6 * - CF-E355AC v2 (QCA9531 + QCA9886)
7 * - CF-E375AC (QCA9563 + QCA9886 + QCA8337)
8 * - CF-E380AC v1/v2 (QCA9558)
9 * - CF-E520N/CF-E530N (QCA9531)
10 *
11 * Copyright (C) 2016 Piotr Dymacz <pepe2k@gmail.com>
12 * Copyright (C) 2016 Gareth Parker <gareth41@orcon.net.nz>
13 * Copyright (C) 2015 Paul Fertser <fercerpav@gmail.com>
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License version 2 as published
17 * by the Free Software Foundation.
18 */
19
20 #include <linux/gpio.h>
21 #include <linux/ar8216_platform.h>
22 #include <linux/platform_data/phy-at803x.h>
23 #include <linux/platform_device.h>
24 #include <linux/timer.h>
25
26 #include <asm/mach-ath79/ath79.h>
27 #include <asm/mach-ath79/ar71xx_regs.h>
28
29 #include "common.h"
30 #include "dev-ap9x-pci.h"
31 #include "dev-eth.h"
32 #include "dev-gpio-buttons.h"
33 #include "dev-leds-gpio.h"
34 #include "dev-m25p80.h"
35 #include "dev-wmac.h"
36 #include "dev-usb.h"
37 #include "machtypes.h"
38
39 #define CF_EXXXN_KEYS_POLL_INTERVAL 20
40 #define CF_EXXXN_KEYS_DEBOUNCE_INTERVAL (3 * CF_EXXXN_KEYS_POLL_INTERVAL)
41
42 /* CF-E316N v2 */
43 #define CF_E316N_V2_GPIO_LED_DIAG_B 0
44 #define CF_E316N_V2_GPIO_LED_DIAG_R 2
45 #define CF_E316N_V2_GPIO_LED_DIAG_G 3
46 #define CF_E316N_V2_GPIO_LED_WLAN 12
47 #define CF_E316N_V2_GPIO_LED_WAN 17
48 #define CF_E316N_V2_GPIO_LED_LAN 19
49
50 #define CF_E316N_V2_GPIO_EXT_WDT 16
51
52 #define CF_E316N_V2_GPIO_EXTERNAL_PA0 13
53 #define CF_E316N_V2_GPIO_EXTERNAL_PA1 14
54
55 #define CF_E316N_V2_GPIO_BTN_RESET 20
56
57 static struct gpio_led cf_e316n_v2_leds_gpio[] __initdata = {
58 {
59 .name = "cf-e316n-v2:blue:diag",
60 .gpio = CF_E316N_V2_GPIO_LED_DIAG_B,
61 .active_low = 0,
62 }, {
63 .name = "cf-e316n-v2:red:diag",
64 .gpio = CF_E316N_V2_GPIO_LED_DIAG_R,
65 .active_low = 0,
66 }, {
67 .name = "cf-e316n-v2:green:diag",
68 .gpio = CF_E316N_V2_GPIO_LED_DIAG_G,
69 .active_low = 0,
70 }, {
71 .name = "cf-e316n-v2:blue:wlan",
72 .gpio = CF_E316N_V2_GPIO_LED_WLAN,
73 .active_low = 1,
74 }, {
75 .name = "cf-e316n-v2:blue:wan",
76 .gpio = CF_E316N_V2_GPIO_LED_WAN,
77 .active_low = 1,
78 }, {
79 .name = "cf-e316n-v2:blue:lan",
80 .gpio = CF_E316N_V2_GPIO_LED_LAN,
81 .active_low = 1,
82 },
83 };
84
85 static struct gpio_keys_button cf_e316n_v2_gpio_keys[] __initdata = {
86 {
87 .desc = "reset",
88 .type = EV_KEY,
89 .code = KEY_RESTART,
90 .debounce_interval = CF_EXXXN_KEYS_DEBOUNCE_INTERVAL,
91 .gpio = CF_E316N_V2_GPIO_BTN_RESET,
92 .active_low = 1,
93 },
94 };
95
96 /* CF-E320N v2 */
97 #define CF_E320N_V2_GPIO_LED_WLAN 0
98 #define CF_E320N_V2_GPIO_LED_WAN 2
99 #define CF_E320N_V2_GPIO_LED_LAN 3
100
101 #define CF_E320N_V2_GPIO_HEADER_J9_1 14
102 #define CF_E320N_V2_GPIO_HEADER_J9_2 12
103 #define CF_E320N_V2_GPIO_HEADER_J9_3 11
104 #define CF_E320N_V2_GPIO_HEADER_J9_4 16
105
106 #define CF_E320N_V2_GPIO_EXT_WDT 13
107
108 #define CF_E320N_V2_GPIO_BTN_RESET 17
109
110 static struct gpio_led cf_e320n_v2_leds_gpio[] __initdata = {
111 {
112 .name = "cf-e320n-v2:green:lan",
113 .gpio = CF_E320N_V2_GPIO_LED_LAN,
114 .active_low = 0,
115 }, {
116 .name = "cf-e320n-v2:red:wan",
117 .gpio = CF_E320N_V2_GPIO_LED_WAN,
118 .active_low = 0,
119 }, {
120 .name = "cf-e320n-v2:blue:wlan",
121 .gpio = CF_E320N_V2_GPIO_LED_WLAN,
122 .active_low = 0,
123 },
124 };
125
126 static struct gpio_keys_button cf_e320n_v2_gpio_keys[] __initdata = {
127 {
128 .desc = "Reset button",
129 .type = EV_KEY,
130 .code = KEY_RESTART,
131 .debounce_interval = CF_EXXXN_KEYS_DEBOUNCE_INTERVAL,
132 .gpio = CF_E320N_V2_GPIO_BTN_RESET,
133 .active_low = 1,
134 },
135 };
136
137 /* CF-E355AC v1/v2 */
138 #define CF_E355AC_GPIO_LED_LAN 3
139 #define CF_E355AC_GPIO_LED_WLAN2G 0
140 #define CF_E355AC_GPIO_LED_WLAN5G 2
141
142 #define CF_E355AC_GPIO_EXT_WDT 13
143
144 #define CF_E355AC_GPIO_BTN_RESET 17
145
146 static struct gpio_led cf_e355ac_v1_leds_gpio[] __initdata = {
147 {
148 .name = "cf-e355ac-v1:green:lan",
149 .gpio = CF_E355AC_GPIO_LED_LAN,
150 .active_low = 0,
151 }, {
152 .name = "cf-e355ac-v1:blue:wlan2g",
153 .gpio = CF_E355AC_GPIO_LED_WLAN2G,
154 .active_low = 0,
155 }, {
156 .name = "cf-e355ac-v1:red:wlan5g",
157 .gpio = CF_E355AC_GPIO_LED_WLAN5G,
158 .active_low = 0,
159 },
160 };
161
162 static struct gpio_led cf_e355ac_v2_leds_gpio[] __initdata = {
163 {
164 .name = "cf-e355ac-v2:green:lan",
165 .gpio = CF_E355AC_GPIO_LED_LAN,
166 .active_low = 0,
167 }, {
168 .name = "cf-e355ac-v2:blue:wlan2g",
169 .gpio = CF_E355AC_GPIO_LED_WLAN2G,
170 .active_low = 0,
171 }, {
172 .name = "cf-e355ac-v2:red:wlan5g",
173 .gpio = CF_E355AC_GPIO_LED_WLAN5G,
174 .active_low = 0,
175 },
176 };
177
178 static struct gpio_keys_button cf_e355ac_gpio_keys[] __initdata = {
179 {
180 .desc = "Reset button",
181 .type = EV_KEY,
182 .code = KEY_RESTART,
183 .debounce_interval = CF_EXXXN_KEYS_DEBOUNCE_INTERVAL,
184 .gpio = CF_E355AC_GPIO_BTN_RESET,
185 .active_low = 1,
186 },
187 };
188
189 #define CF_E375AC_GPIO_XWDT_TRIGGER 6
190
191 #define CF_E375AC_GPIO_BTN_RESET_WPS 2
192
193 #define CF_E375AC_GPIO_LED_WAN 15
194 #define CF_E375AC_GPIO_LED_LAN 17
195 #define CF_E375AC_GPIO_LED_WLAN 16
196
197 static struct gpio_led cf_e375ac_leds_gpio[] __initdata = {
198 {
199 .name = "comfast:red:wan",
200 .gpio = CF_E375AC_GPIO_LED_WAN,
201 .active_low = 0,
202 }, {
203 .name = "comfast:green:lan",
204 .gpio = CF_E375AC_GPIO_LED_LAN,
205 .active_low = 0,
206 }, {
207 .name = "comfast:blue:wlan",
208 .gpio = CF_E375AC_GPIO_LED_WLAN,
209 .active_low = 0,
210 },
211 };
212
213 static struct gpio_keys_button cf_e375ac_gpio_keys[] __initdata = {
214 {
215 .desc = "Reset button/WPS button",
216 .type = EV_KEY,
217 .code = KEY_RESTART,
218 .debounce_interval = CF_EXXXN_KEYS_DEBOUNCE_INTERVAL,
219 .gpio = CF_E375AC_GPIO_BTN_RESET_WPS,
220 .active_low = 1,
221 },
222 };
223
224 static struct ar8327_pad_cfg cf_e375ac_ar8337_pad0_cfg = {
225 .mode = AR8327_PAD_MAC_SGMII,
226 .sgmii_delay_en = true,
227 };
228
229 static struct ar8327_platform_data cf_e375ac_ar8337_data = {
230 .pad0_cfg = &cf_e375ac_ar8337_pad0_cfg,
231 .port0_cfg = {
232 .force_link = 1,
233 .speed = AR8327_PORT_SPEED_1000,
234 .duplex = 1,
235 .txpause = 1,
236 .rxpause = 1,
237 },
238 };
239
240 static struct mdio_board_info cf_e375ac_mdio0_info[] = {
241 {
242 .bus_id = "ag71xx-mdio.0",
243 .phy_addr = 0,
244 .platform_data = &cf_e375ac_ar8337_data,
245 },
246 };
247
248 /* CF-E380AC v1/v2 */
249 #define CF_E380AC_V1V2_GPIO_LED_LAN 0
250 #define CF_E380AC_V1V2_GPIO_LED_WLAN2G 2
251 #define CF_E380AC_V1V2_GPIO_LED_WLAN5G 3
252
253 #define CF_E380AC_V1V2_GPIO_EXT_WDT 17
254
255 #define CF_E380AC_V1V2_GPIO_BTN_RESET 19
256
257 static struct gpio_led cf_e380ac_v1_leds_gpio[] __initdata = {
258 {
259 .name = "cf-e380ac-v1:green:lan",
260 .gpio = CF_E380AC_V1V2_GPIO_LED_LAN,
261 .active_low = 0,
262 }, {
263 .name = "cf-e380ac-v1:blue:wlan2g",
264 .gpio = CF_E380AC_V1V2_GPIO_LED_WLAN2G,
265 .active_low = 0,
266 }, {
267 .name = "cf-e380ac-v1:red:wlan5g",
268 .gpio = CF_E380AC_V1V2_GPIO_LED_WLAN5G,
269 .active_low = 0,
270 },
271 };
272
273 static struct gpio_led cf_e380ac_v2_leds_gpio[] __initdata = {
274 {
275 .name = "cf-e380ac-v2:green:lan",
276 .gpio = CF_E380AC_V1V2_GPIO_LED_LAN,
277 .active_low = 0,
278 }, {
279 .name = "cf-e380ac-v2:blue:wlan2g",
280 .gpio = CF_E380AC_V1V2_GPIO_LED_WLAN2G,
281 .active_low = 0,
282 }, {
283 .name = "cf-e380ac-v2:red:wlan5g",
284 .gpio = CF_E380AC_V1V2_GPIO_LED_WLAN5G,
285 .active_low = 0,
286 },
287 };
288
289 static struct gpio_keys_button cf_e380ac_v1v2_gpio_keys[] __initdata = {
290 {
291 .desc = "Reset button",
292 .type = EV_KEY,
293 .code = KEY_RESTART,
294 .debounce_interval = CF_EXXXN_KEYS_DEBOUNCE_INTERVAL,
295 .gpio = CF_E380AC_V1V2_GPIO_BTN_RESET,
296 .active_low = 1,
297 },
298 };
299
300 static struct at803x_platform_data cf_e380ac_v1v2_at803x_data = {
301 .disable_smarteee = 1,
302 };
303
304 static struct mdio_board_info cf_e380ac_v1v2_mdio0_info[] = {
305 {
306 .bus_id = "ag71xx-mdio.0",
307 .phy_addr = 0,
308 .platform_data = &cf_e380ac_v1v2_at803x_data,
309 },
310 };
311
312 /* CF-E520N/CF-E530N */
313 #define CF_E5X0N_GPIO_LED_WAN 11
314 #define CF_E5X0N_GPIO_BTN_RESET 17
315
316 static struct gpio_led cf_e520n_leds_gpio[] __initdata = {
317 {
318 .name = "cf-e520n:blue:wan",
319 .gpio = CF_E5X0N_GPIO_LED_WAN,
320 .active_low = 1,
321 }
322 };
323
324 static struct gpio_led cf_e530n_leds_gpio[] __initdata = {
325 {
326 .name = "cf-e530n:blue:wan",
327 .gpio = CF_E5X0N_GPIO_LED_WAN,
328 .active_low = 1,
329 }
330 };
331
332 /*
333 * Some COMFAST devices include external hardware watchdog chip,
334 * Pericon Technology PT7A7514, connected to a selected GPIO
335 * and WiSoC RESET_L input. Watchdog time-out is ~1.6 s.
336 */
337 #define CF_EXXXN_EXT_WDT_TIMEOUT_MS 500
338
339 static struct timer_list gpio_wdt_timer;
340
341 static void gpio_wdt_toggle(unsigned long gpio)
342 {
343 static int state;
344
345 state = !state;
346 gpio_set_value(gpio, state);
347
348 mod_timer(&gpio_wdt_timer,
349 jiffies + msecs_to_jiffies(CF_EXXXN_EXT_WDT_TIMEOUT_MS));
350 }
351
352 static void __init cf_exxxn_common_setup(unsigned long art_ofs, int gpio_wdt)
353 {
354 u8 *art = (u8 *) KSEG1ADDR(0x1f001000 + art_ofs);
355
356 if (gpio_wdt > -1) {
357 gpio_request_one(gpio_wdt, GPIOF_OUT_INIT_HIGH,
358 "PT7A7514 watchdog");
359
360 setup_timer(&gpio_wdt_timer, gpio_wdt_toggle, gpio_wdt);
361 gpio_wdt_toggle(gpio_wdt);
362 }
363
364 ath79_register_m25p80(NULL);
365
366 ath79_register_wmac(art, NULL);
367
368 ath79_register_usb();
369 }
370
371 static void __init cf_e316n_v2_setup(void)
372 {
373 u8 *mac = (u8 *) KSEG1ADDR(0x1f010000);
374
375 cf_exxxn_common_setup(0x10000, CF_E316N_V2_GPIO_EXT_WDT);
376
377 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
378
379 ath79_register_mdio(1, 0x0);
380
381 /* GMAC0 is connected to the PHY0 of the internal switch */
382 ath79_switch_data.phy4_mii_en = 1;
383 ath79_switch_data.phy_poll_mask = BIT(0);
384 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
385 ath79_eth0_data.phy_mask = BIT(0);
386 ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
387 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
388 ath79_register_eth(0);
389
390 /* GMAC1 is connected to the internal switch */
391 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
392 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 2);
393 ath79_register_eth(1);
394
395 /* Enable 2x Skyworks SE2576L WLAN power amplifiers */
396 gpio_request_one(CF_E316N_V2_GPIO_EXTERNAL_PA0, GPIOF_OUT_INIT_HIGH,
397 "WLAN PA0");
398 gpio_request_one(CF_E316N_V2_GPIO_EXTERNAL_PA1, GPIOF_OUT_INIT_HIGH,
399 "WLAN PA1");
400
401 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e316n_v2_leds_gpio),
402 cf_e316n_v2_leds_gpio);
403
404 ath79_register_gpio_keys_polled(1, CF_EXXXN_KEYS_POLL_INTERVAL,
405 ARRAY_SIZE(cf_e316n_v2_gpio_keys),
406 cf_e316n_v2_gpio_keys);
407 }
408
409 MIPS_MACHINE(ATH79_MACH_CF_E316N_V2, "CF-E316N-V2", "COMFAST CF-E316N v2",
410 cf_e316n_v2_setup);
411
412 static void __init cf_exxxn_qca953x_eth_setup(void)
413 {
414 u8 *mac = (u8 *) KSEG1ADDR(0x1f010000);
415
416 ath79_setup_ar933x_phy4_switch(false, false);
417
418 ath79_register_mdio(0, 0x0);
419
420 ath79_switch_data.phy4_mii_en = 1;
421 ath79_switch_data.phy_poll_mask |= BIT(4);
422
423 /* LAN */
424 ath79_eth1_data.duplex = DUPLEX_FULL;
425 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
426 ath79_eth1_data.speed = SPEED_1000;
427 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 2);
428 ath79_register_eth(1);
429
430 /* WAN */
431 ath79_eth0_data.duplex = DUPLEX_FULL;
432 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
433 ath79_eth0_data.speed = SPEED_100;
434 ath79_eth0_data.phy_mask = BIT(4);
435 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
436 ath79_register_eth(0);
437 }
438
439 static void __init cf_e320n_v2_setup(void)
440 {
441 cf_exxxn_common_setup(0x10000, CF_E320N_V2_GPIO_EXT_WDT);
442
443 cf_exxxn_qca953x_eth_setup();
444
445 /* Disable JTAG (enables GPIO0-3) */
446 ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
447
448 ath79_gpio_direction_select(CF_E320N_V2_GPIO_LED_LAN, true);
449 ath79_gpio_direction_select(CF_E320N_V2_GPIO_LED_WAN, true);
450 ath79_gpio_direction_select(CF_E320N_V2_GPIO_LED_WLAN, true);
451
452 ath79_gpio_output_select(CF_E320N_V2_GPIO_LED_LAN, 0);
453 ath79_gpio_output_select(CF_E320N_V2_GPIO_LED_WAN, 0);
454 ath79_gpio_output_select(CF_E320N_V2_GPIO_LED_WLAN, 0);
455
456 /* Enable GPIO function for GPIOs in J9 header */
457 ath79_gpio_output_select(CF_E320N_V2_GPIO_HEADER_J9_1, 0);
458 ath79_gpio_output_select(CF_E320N_V2_GPIO_HEADER_J9_2, 0);
459 ath79_gpio_output_select(CF_E320N_V2_GPIO_HEADER_J9_3, 0);
460 ath79_gpio_output_select(CF_E320N_V2_GPIO_HEADER_J9_4, 0);
461
462 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e320n_v2_leds_gpio),
463 cf_e320n_v2_leds_gpio);
464
465 ath79_register_gpio_keys_polled(-1, CF_EXXXN_KEYS_POLL_INTERVAL,
466 ARRAY_SIZE(cf_e320n_v2_gpio_keys),
467 cf_e320n_v2_gpio_keys);
468 }
469
470 MIPS_MACHINE(ATH79_MACH_CF_E320N_V2, "CF-E320N-V2", "COMFAST CF-E320N v2",
471 cf_e320n_v2_setup);
472
473 static void __init cf_e355ac_setup(void)
474 {
475 u8 *art = (u8 *) KSEG1ADDR(0x1f010000);
476
477 /* Disable JTAG, enabling GPIOs 0-3 */
478 ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE, 0);
479
480 cf_exxxn_common_setup(0x10000, CF_E355AC_GPIO_EXT_WDT);
481
482 cf_exxxn_qca953x_eth_setup();
483
484 ath79_gpio_output_select(CF_E355AC_GPIO_LED_LAN, 0);
485 ath79_gpio_output_select(CF_E355AC_GPIO_LED_WLAN2G, 0);
486 ath79_gpio_output_select(CF_E355AC_GPIO_LED_WLAN5G, 0);
487
488 ap91_pci_init(art + 0x5000, NULL);
489
490 ath79_register_gpio_keys_polled(1, CF_EXXXN_KEYS_POLL_INTERVAL,
491 ARRAY_SIZE(cf_e355ac_gpio_keys),
492 cf_e355ac_gpio_keys);
493 }
494
495 static void __init cf_e355ac_v1_setup(void)
496 {
497 cf_e355ac_setup();
498
499 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e355ac_v1_leds_gpio),
500 cf_e355ac_v1_leds_gpio);
501 }
502
503 static void __init cf_e355ac_v2_setup(void)
504 {
505 cf_e355ac_setup();
506
507 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e355ac_v2_leds_gpio),
508 cf_e355ac_v2_leds_gpio);
509 }
510
511 MIPS_MACHINE(ATH79_MACH_CF_E355AC, "CF-E355AC-V1", "COMFAST CF-E355AC v1",
512 cf_e355ac_v1_setup);
513
514 MIPS_MACHINE(ATH79_MACH_CF_E355AC_V2, "CF-E355AC-V2", "COMFAST CF-E355AC v2",
515 cf_e355ac_v2_setup);
516
517 static void __init cf_e375ac_setup(void)
518 {
519 u8 *mac = (u8 *) KSEG1ADDR(0x1f040000);
520 u8 *art = (u8 *) KSEG1ADDR(0x1f040000);
521 u8 wlan1_mac[ETH_ALEN];
522
523 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
524 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
525 ath79_init_mac(wlan1_mac, art, 3);
526
527 /* Disable JTAG, enabling GPIOs 0-3 */
528 /* Configure OBS4 line, for GPIO 4*/
529 ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE, 0);
530
531 cf_exxxn_common_setup(0x40000, CF_E375AC_GPIO_XWDT_TRIGGER);
532
533 ath79_gpio_output_select(CF_E375AC_GPIO_LED_WAN, 0);
534 ath79_gpio_output_select(CF_E375AC_GPIO_LED_LAN, 0);
535 ath79_gpio_output_select(CF_E375AC_GPIO_LED_WLAN, 0);
536
537 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e375ac_leds_gpio),
538 cf_e375ac_leds_gpio);
539 ath79_register_gpio_keys_polled(-1, CF_EXXXN_KEYS_POLL_INTERVAL,
540 ARRAY_SIZE(cf_e375ac_gpio_keys),
541 cf_e375ac_gpio_keys);
542
543 platform_device_register(&ath79_mdio0_device);
544
545 mdiobus_register_board_info(cf_e375ac_mdio0_info,
546 ARRAY_SIZE(cf_e375ac_mdio0_info));
547
548 /* GMAC0 is connected to an AR8337 switch */
549 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
550 ath79_eth0_data.speed = SPEED_1000;
551 ath79_eth0_data.duplex = DUPLEX_FULL;
552 ath79_eth0_data.phy_mask = BIT(0);
553 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
554 ath79_register_eth(0);
555
556 ap91_pci_init(art + 0x5000, wlan1_mac);
557 }
558 MIPS_MACHINE(ATH79_MACH_CF_E375AC, "CF-E375AC", "COMFAST CF-E375AC", cf_e375ac_setup);
559
560 static void __init cf_e380ac_v1v2_common_setup(unsigned long art_ofs)
561 {
562 u8 *mac = (u8 *) KSEG1ADDR(0x1f000000 + art_ofs);
563
564 cf_exxxn_common_setup(art_ofs, CF_E380AC_V1V2_GPIO_EXT_WDT);
565
566 ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
567
568 ath79_register_mdio(0, 0x0);
569 mdiobus_register_board_info(cf_e380ac_v1v2_mdio0_info,
570 ARRAY_SIZE(cf_e380ac_v1v2_mdio0_info));
571
572 /* LAN */
573 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
574 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
575 ath79_eth0_data.phy_mask = BIT(0);
576 ath79_eth0_pll_data.pll_1000 = 0xbe000000;
577 ath79_eth0_pll_data.pll_100 = 0xb0000101;
578 ath79_eth0_pll_data.pll_10 = 0xb0001313;
579 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
580 ath79_register_eth(0);
581
582 ap91_pci_init(mac + 0x5000, NULL);
583
584 /* Disable JTAG (enables GPIO0-3) */
585 ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
586
587 ath79_gpio_direction_select(CF_E380AC_V1V2_GPIO_LED_LAN, true);
588 ath79_gpio_direction_select(CF_E380AC_V1V2_GPIO_LED_WLAN2G, true);
589 ath79_gpio_direction_select(CF_E380AC_V1V2_GPIO_LED_WLAN5G, true);
590
591 ath79_gpio_output_select(CF_E380AC_V1V2_GPIO_LED_LAN, 0);
592 ath79_gpio_output_select(CF_E380AC_V1V2_GPIO_LED_WLAN2G, 0);
593 ath79_gpio_output_select(CF_E380AC_V1V2_GPIO_LED_WLAN5G, 0);
594
595 /* For J7-4 */
596 ath79_gpio_function_disable(AR934X_GPIO_FUNC_CLK_OBS4_EN);
597
598 ath79_register_gpio_keys_polled(-1, CF_EXXXN_KEYS_POLL_INTERVAL,
599 ARRAY_SIZE(cf_e380ac_v1v2_gpio_keys),
600 cf_e380ac_v1v2_gpio_keys);
601 }
602
603 static void __init cf_e380ac_v1_setup(void)
604 {
605 cf_e380ac_v1v2_common_setup(0x20000);
606
607 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e380ac_v1_leds_gpio),
608 cf_e380ac_v1_leds_gpio);
609 }
610
611 MIPS_MACHINE(ATH79_MACH_CF_E380AC_V1, "CF-E380AC-V1", "COMFAST CF-E380AC v1",
612 cf_e380ac_v1_setup);
613
614 static void __init cf_e380ac_v2_setup(void)
615 {
616 cf_e380ac_v1v2_common_setup(0x40000);
617
618 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e380ac_v2_leds_gpio),
619 cf_e380ac_v2_leds_gpio);
620 }
621
622 MIPS_MACHINE(ATH79_MACH_CF_E380AC_V2, "CF-E380AC-V2", "COMFAST CF-E380AC v2",
623 cf_e380ac_v2_setup);
624
625 static void __init cf_e5x0n_gpio_setup(void)
626 {
627 ath79_gpio_direction_select(CF_E5X0N_GPIO_LED_WAN, true);
628
629 ath79_gpio_output_select(CF_E5X0N_GPIO_LED_WAN, 0);
630
631 ath79_register_gpio_keys_polled(-1, CF_EXXXN_KEYS_POLL_INTERVAL,
632 ARRAY_SIZE(cf_e320n_v2_gpio_keys),
633 cf_e320n_v2_gpio_keys);
634 }
635
636 static void __init cf_e520n_setup(void)
637 {
638 cf_exxxn_common_setup(0x10000, -1);
639
640 cf_exxxn_qca953x_eth_setup();
641
642 cf_e5x0n_gpio_setup();
643
644 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e520n_leds_gpio),
645 cf_e520n_leds_gpio);
646 }
647
648 MIPS_MACHINE(ATH79_MACH_CF_E520N, "CF-E520N", "COMFAST CF-E520N",
649 cf_e520n_setup);
650
651 static void __init cf_e530n_setup(void)
652 {
653 cf_exxxn_common_setup(0x10000, -1);
654
655 cf_exxxn_qca953x_eth_setup();
656
657 cf_e5x0n_gpio_setup();
658
659 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e530n_leds_gpio),
660 cf_e530n_leds_gpio);
661 }
662
663 MIPS_MACHINE(ATH79_MACH_CF_E530N, "CF-E530N", "COMFAST CF-E530N",
664 cf_e530n_setup);