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