ar71xx: image: simplify Embedded Wireless definitions
[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 (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 */
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_leds_gpio[] __initdata = {
147 {
148 .name = "cf-e355ac:green:lan",
149 .gpio = CF_E355AC_GPIO_LED_LAN,
150 .active_low = 0,
151 }, {
152 .name = "cf-e355ac:blue:wlan2g",
153 .gpio = CF_E355AC_GPIO_LED_WLAN2G,
154 .active_low = 0,
155 }, {
156 .name = "cf-e355ac:red:wlan5g",
157 .gpio = CF_E355AC_GPIO_LED_WLAN5G,
158 .active_low = 0,
159 },
160 };
161
162 static struct gpio_keys_button cf_e355ac_gpio_keys[] __initdata = {
163 {
164 .desc = "Reset button",
165 .type = EV_KEY,
166 .code = KEY_RESTART,
167 .debounce_interval = CF_EXXXN_KEYS_DEBOUNCE_INTERVAL,
168 .gpio = CF_E355AC_GPIO_BTN_RESET,
169 .active_low = 1,
170 },
171 };
172
173 #define CF_E375AC_GPIO_XWDT_TRIGGER 6
174
175 #define CF_E375AC_GPIO_BTN_RESET_WPS 2
176
177 #define CF_E375AC_GPIO_LED_WAN 15
178 #define CF_E375AC_GPIO_LED_LAN 17
179 #define CF_E375AC_GPIO_LED_WLAN 16
180
181 static struct gpio_led cf_e375ac_leds_gpio[] __initdata = {
182 {
183 .name = "comfast:red:wan",
184 .gpio = CF_E375AC_GPIO_LED_WAN,
185 .active_low = 0,
186 }, {
187 .name = "comfast:green:lan",
188 .gpio = CF_E375AC_GPIO_LED_LAN,
189 .active_low = 0,
190 }, {
191 .name = "comfast:blue:wlan",
192 .gpio = CF_E375AC_GPIO_LED_WLAN,
193 .active_low = 0,
194 },
195 };
196
197 static struct gpio_keys_button cf_e375ac_gpio_keys[] __initdata = {
198 {
199 .desc = "Reset button/WPS button",
200 .type = EV_KEY,
201 .code = KEY_RESTART,
202 .debounce_interval = CF_EXXXN_KEYS_DEBOUNCE_INTERVAL,
203 .gpio = CF_E375AC_GPIO_BTN_RESET_WPS,
204 .active_low = 1,
205 },
206 };
207
208 static struct ar8327_pad_cfg cf_e375ac_ar8337_pad0_cfg = {
209 .mode = AR8327_PAD_MAC_SGMII,
210 .sgmii_delay_en = true,
211 };
212
213 static struct ar8327_platform_data cf_e375ac_ar8337_data = {
214 .pad0_cfg = &cf_e375ac_ar8337_pad0_cfg,
215 .port0_cfg = {
216 .force_link = 1,
217 .speed = AR8327_PORT_SPEED_1000,
218 .duplex = 1,
219 .txpause = 1,
220 .rxpause = 1,
221 },
222 };
223
224 static struct mdio_board_info cf_e375ac_mdio0_info[] = {
225 {
226 .bus_id = "ag71xx-mdio.0",
227 .phy_addr = 0,
228 .platform_data = &cf_e375ac_ar8337_data,
229 },
230 };
231
232 /* CF-E380AC v1/v2 */
233 #define CF_E380AC_V1V2_GPIO_LED_LAN 0
234 #define CF_E380AC_V1V2_GPIO_LED_WLAN2G 2
235 #define CF_E380AC_V1V2_GPIO_LED_WLAN5G 3
236
237 #define CF_E380AC_V1V2_GPIO_EXT_WDT 17
238
239 #define CF_E380AC_V1V2_GPIO_BTN_RESET 19
240
241 static struct gpio_led cf_e380ac_v1_leds_gpio[] __initdata = {
242 {
243 .name = "cf-e380ac-v1:green:lan",
244 .gpio = CF_E380AC_V1V2_GPIO_LED_LAN,
245 .active_low = 0,
246 }, {
247 .name = "cf-e380ac-v1:blue:wlan2g",
248 .gpio = CF_E380AC_V1V2_GPIO_LED_WLAN2G,
249 .active_low = 0,
250 }, {
251 .name = "cf-e380ac-v1:red:wlan5g",
252 .gpio = CF_E380AC_V1V2_GPIO_LED_WLAN5G,
253 .active_low = 0,
254 },
255 };
256
257 static struct gpio_led cf_e380ac_v2_leds_gpio[] __initdata = {
258 {
259 .name = "cf-e380ac-v2:green:lan",
260 .gpio = CF_E380AC_V1V2_GPIO_LED_LAN,
261 .active_low = 0,
262 }, {
263 .name = "cf-e380ac-v2:blue:wlan2g",
264 .gpio = CF_E380AC_V1V2_GPIO_LED_WLAN2G,
265 .active_low = 0,
266 }, {
267 .name = "cf-e380ac-v2:red:wlan5g",
268 .gpio = CF_E380AC_V1V2_GPIO_LED_WLAN5G,
269 .active_low = 0,
270 },
271 };
272
273 static struct gpio_keys_button cf_e380ac_v1v2_gpio_keys[] __initdata = {
274 {
275 .desc = "Reset button",
276 .type = EV_KEY,
277 .code = KEY_RESTART,
278 .debounce_interval = CF_EXXXN_KEYS_DEBOUNCE_INTERVAL,
279 .gpio = CF_E380AC_V1V2_GPIO_BTN_RESET,
280 .active_low = 1,
281 },
282 };
283
284 static struct at803x_platform_data cf_e380ac_v1v2_at803x_data = {
285 .disable_smarteee = 1,
286 };
287
288 static struct mdio_board_info cf_e380ac_v1v2_mdio0_info[] = {
289 {
290 .bus_id = "ag71xx-mdio.0",
291 .phy_addr = 0,
292 .platform_data = &cf_e380ac_v1v2_at803x_data,
293 },
294 };
295
296 /* CF-E520N/CF-E530N */
297 #define CF_E5X0N_GPIO_LED_WAN 11
298 #define CF_E5X0N_GPIO_BTN_RESET 17
299
300 static struct gpio_led cf_e520n_leds_gpio[] __initdata = {
301 {
302 .name = "cf-e520n:blue:wan",
303 .gpio = CF_E5X0N_GPIO_LED_WAN,
304 .active_low = 1,
305 }
306 };
307
308 static struct gpio_led cf_e530n_leds_gpio[] __initdata = {
309 {
310 .name = "cf-e530n:blue:wan",
311 .gpio = CF_E5X0N_GPIO_LED_WAN,
312 .active_low = 1,
313 }
314 };
315
316 /*
317 * Some COMFAST devices include external hardware watchdog chip,
318 * Pericon Technology PT7A7514, connected to a selected GPIO
319 * and WiSoC RESET_L input. Watchdog time-out is ~1.6 s.
320 */
321 #define CF_EXXXN_EXT_WDT_TIMEOUT_MS 500
322
323 static struct timer_list gpio_wdt_timer;
324
325 static void gpio_wdt_toggle(unsigned long gpio)
326 {
327 static int state;
328
329 state = !state;
330 gpio_set_value(gpio, state);
331
332 mod_timer(&gpio_wdt_timer,
333 jiffies + msecs_to_jiffies(CF_EXXXN_EXT_WDT_TIMEOUT_MS));
334 }
335
336 static void __init cf_exxxn_common_setup(unsigned long art_ofs, int gpio_wdt)
337 {
338 u8 *art = (u8 *) KSEG1ADDR(0x1f001000 + art_ofs);
339
340 if (gpio_wdt > -1) {
341 gpio_request_one(gpio_wdt, GPIOF_OUT_INIT_HIGH,
342 "PT7A7514 watchdog");
343
344 setup_timer(&gpio_wdt_timer, gpio_wdt_toggle, gpio_wdt);
345 gpio_wdt_toggle(gpio_wdt);
346 }
347
348 ath79_register_m25p80(NULL);
349
350 ath79_register_wmac(art, NULL);
351
352 ath79_register_usb();
353 }
354
355 static void __init cf_e316n_v2_setup(void)
356 {
357 u8 *mac = (u8 *) KSEG1ADDR(0x1f010000);
358
359 cf_exxxn_common_setup(0x10000, CF_E316N_V2_GPIO_EXT_WDT);
360
361 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
362
363 ath79_register_mdio(1, 0x0);
364
365 /* GMAC0 is connected to the PHY0 of the internal switch */
366 ath79_switch_data.phy4_mii_en = 1;
367 ath79_switch_data.phy_poll_mask = BIT(0);
368 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
369 ath79_eth0_data.phy_mask = BIT(0);
370 ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
371 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
372 ath79_register_eth(0);
373
374 /* GMAC1 is connected to the internal switch */
375 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
376 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 2);
377 ath79_register_eth(1);
378
379 /* Enable 2x Skyworks SE2576L WLAN power amplifiers */
380 gpio_request_one(CF_E316N_V2_GPIO_EXTERNAL_PA0, GPIOF_OUT_INIT_HIGH,
381 "WLAN PA0");
382 gpio_request_one(CF_E316N_V2_GPIO_EXTERNAL_PA1, GPIOF_OUT_INIT_HIGH,
383 "WLAN PA1");
384
385 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e316n_v2_leds_gpio),
386 cf_e316n_v2_leds_gpio);
387
388 ath79_register_gpio_keys_polled(1, CF_EXXXN_KEYS_POLL_INTERVAL,
389 ARRAY_SIZE(cf_e316n_v2_gpio_keys),
390 cf_e316n_v2_gpio_keys);
391 }
392
393 MIPS_MACHINE(ATH79_MACH_CF_E316N_V2, "CF-E316N-V2", "COMFAST CF-E316N v2",
394 cf_e316n_v2_setup);
395
396 static void __init cf_exxxn_qca953x_eth_setup(void)
397 {
398 u8 *mac = (u8 *) KSEG1ADDR(0x1f010000);
399
400 ath79_setup_ar933x_phy4_switch(false, false);
401
402 ath79_register_mdio(0, 0x0);
403
404 ath79_switch_data.phy4_mii_en = 1;
405 ath79_switch_data.phy_poll_mask |= BIT(4);
406
407 /* LAN */
408 ath79_eth1_data.duplex = DUPLEX_FULL;
409 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
410 ath79_eth1_data.speed = SPEED_1000;
411 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 2);
412 ath79_register_eth(1);
413
414 /* WAN */
415 ath79_eth0_data.duplex = DUPLEX_FULL;
416 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
417 ath79_eth0_data.speed = SPEED_100;
418 ath79_eth0_data.phy_mask = BIT(4);
419 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
420 ath79_register_eth(0);
421 }
422
423 static void __init cf_e320n_v2_setup(void)
424 {
425 cf_exxxn_common_setup(0x10000, CF_E320N_V2_GPIO_EXT_WDT);
426
427 cf_exxxn_qca953x_eth_setup();
428
429 /* Disable JTAG (enables GPIO0-3) */
430 ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
431
432 ath79_gpio_direction_select(CF_E320N_V2_GPIO_LED_LAN, true);
433 ath79_gpio_direction_select(CF_E320N_V2_GPIO_LED_WAN, true);
434 ath79_gpio_direction_select(CF_E320N_V2_GPIO_LED_WLAN, true);
435
436 ath79_gpio_output_select(CF_E320N_V2_GPIO_LED_LAN, 0);
437 ath79_gpio_output_select(CF_E320N_V2_GPIO_LED_WAN, 0);
438 ath79_gpio_output_select(CF_E320N_V2_GPIO_LED_WLAN, 0);
439
440 /* Enable GPIO function for GPIOs in J9 header */
441 ath79_gpio_output_select(CF_E320N_V2_GPIO_HEADER_J9_1, 0);
442 ath79_gpio_output_select(CF_E320N_V2_GPIO_HEADER_J9_2, 0);
443 ath79_gpio_output_select(CF_E320N_V2_GPIO_HEADER_J9_3, 0);
444 ath79_gpio_output_select(CF_E320N_V2_GPIO_HEADER_J9_4, 0);
445
446 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e320n_v2_leds_gpio),
447 cf_e320n_v2_leds_gpio);
448
449 ath79_register_gpio_keys_polled(-1, CF_EXXXN_KEYS_POLL_INTERVAL,
450 ARRAY_SIZE(cf_e320n_v2_gpio_keys),
451 cf_e320n_v2_gpio_keys);
452 }
453
454 MIPS_MACHINE(ATH79_MACH_CF_E320N_V2, "CF-E320N-V2", "COMFAST CF-E320N v2",
455 cf_e320n_v2_setup);
456
457 static void __init cf_e355ac_setup(void)
458 {
459 u8 *art = (u8 *) KSEG1ADDR(0x1f010000);
460
461 /* Disable JTAG, enabling GPIOs 0-3 */
462 ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE, 0);
463
464 cf_exxxn_common_setup(0x10000, CF_E355AC_GPIO_EXT_WDT);
465
466 cf_exxxn_qca953x_eth_setup();
467
468 ath79_gpio_output_select(CF_E355AC_GPIO_LED_LAN, 0);
469 ath79_gpio_output_select(CF_E355AC_GPIO_LED_WLAN2G, 0);
470 ath79_gpio_output_select(CF_E355AC_GPIO_LED_WLAN5G, 0);
471
472 ap91_pci_init(art + 0x5000, NULL);
473
474 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e355ac_leds_gpio),
475 cf_e355ac_leds_gpio);
476
477 ath79_register_gpio_keys_polled(1, CF_EXXXN_KEYS_POLL_INTERVAL,
478 ARRAY_SIZE(cf_e355ac_gpio_keys),
479 cf_e355ac_gpio_keys);
480 }
481
482 MIPS_MACHINE(ATH79_MACH_CF_E355AC, "CF-E355AC", "COMFAST CF-E355AC",
483 cf_e355ac_setup);
484
485 MIPS_MACHINE(ATH79_MACH_CF_E355AC_V2, "CF-E355AC-V2", "COMFAST CF-E355AC v2",
486 cf_e355ac_setup);
487
488 static void __init cf_e375ac_setup(void)
489 {
490 u8 *mac = (u8 *) KSEG1ADDR(0x1f040000);
491 u8 *art = (u8 *) KSEG1ADDR(0x1f040000);
492 u8 wlan1_mac[ETH_ALEN];
493
494 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
495 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
496 ath79_init_mac(wlan1_mac, art, 3);
497
498 /* Disable JTAG, enabling GPIOs 0-3 */
499 /* Configure OBS4 line, for GPIO 4*/
500 ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE, 0);
501
502 cf_exxxn_common_setup(0x40000, CF_E375AC_GPIO_XWDT_TRIGGER);
503
504 ath79_gpio_output_select(CF_E375AC_GPIO_LED_WAN, 0);
505 ath79_gpio_output_select(CF_E375AC_GPIO_LED_LAN, 0);
506 ath79_gpio_output_select(CF_E375AC_GPIO_LED_WLAN, 0);
507
508 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e375ac_leds_gpio),
509 cf_e375ac_leds_gpio);
510 ath79_register_gpio_keys_polled(-1, CF_EXXXN_KEYS_POLL_INTERVAL,
511 ARRAY_SIZE(cf_e375ac_gpio_keys),
512 cf_e375ac_gpio_keys);
513
514 platform_device_register(&ath79_mdio0_device);
515
516 mdiobus_register_board_info(cf_e375ac_mdio0_info,
517 ARRAY_SIZE(cf_e375ac_mdio0_info));
518
519 /* GMAC0 is connected to an AR8337 switch */
520 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
521 ath79_eth0_data.speed = SPEED_1000;
522 ath79_eth0_data.duplex = DUPLEX_FULL;
523 ath79_eth0_data.phy_mask = BIT(0);
524 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
525 ath79_register_eth(0);
526
527 ap91_pci_init(art + 0x5000, wlan1_mac);
528 }
529 MIPS_MACHINE(ATH79_MACH_CF_E375AC, "CF-E375AC", "COMFAST CF-E375AC", cf_e375ac_setup);
530
531 static void __init cf_e380ac_v1v2_common_setup(unsigned long art_ofs)
532 {
533 u8 *mac = (u8 *) KSEG1ADDR(0x1f000000 + art_ofs);
534
535 cf_exxxn_common_setup(art_ofs, CF_E380AC_V1V2_GPIO_EXT_WDT);
536
537 ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
538
539 ath79_register_mdio(0, 0x0);
540 mdiobus_register_board_info(cf_e380ac_v1v2_mdio0_info,
541 ARRAY_SIZE(cf_e380ac_v1v2_mdio0_info));
542
543 /* LAN */
544 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
545 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
546 ath79_eth0_data.phy_mask = BIT(0);
547 ath79_eth0_pll_data.pll_1000 = 0xbe000000;
548 ath79_eth0_pll_data.pll_100 = 0xb0000101;
549 ath79_eth0_pll_data.pll_10 = 0xb0001313;
550 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
551 ath79_register_eth(0);
552
553 ap91_pci_init(mac + 0x5000, NULL);
554
555 /* Disable JTAG (enables GPIO0-3) */
556 ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
557
558 ath79_gpio_direction_select(CF_E380AC_V1V2_GPIO_LED_LAN, true);
559 ath79_gpio_direction_select(CF_E380AC_V1V2_GPIO_LED_WLAN2G, true);
560 ath79_gpio_direction_select(CF_E380AC_V1V2_GPIO_LED_WLAN5G, true);
561
562 ath79_gpio_output_select(CF_E380AC_V1V2_GPIO_LED_LAN, 0);
563 ath79_gpio_output_select(CF_E380AC_V1V2_GPIO_LED_WLAN2G, 0);
564 ath79_gpio_output_select(CF_E380AC_V1V2_GPIO_LED_WLAN5G, 0);
565
566 /* For J7-4 */
567 ath79_gpio_function_disable(AR934X_GPIO_FUNC_CLK_OBS4_EN);
568
569 ath79_register_gpio_keys_polled(-1, CF_EXXXN_KEYS_POLL_INTERVAL,
570 ARRAY_SIZE(cf_e380ac_v1v2_gpio_keys),
571 cf_e380ac_v1v2_gpio_keys);
572 }
573
574 static void __init cf_e380ac_v1_setup(void)
575 {
576 cf_e380ac_v1v2_common_setup(0x20000);
577
578 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e380ac_v1_leds_gpio),
579 cf_e380ac_v1_leds_gpio);
580 }
581
582 MIPS_MACHINE(ATH79_MACH_CF_E380AC_V1, "CF-E380AC-V1", "COMFAST CF-E380AC v1",
583 cf_e380ac_v1_setup);
584
585 static void __init cf_e380ac_v2_setup(void)
586 {
587 cf_e380ac_v1v2_common_setup(0x40000);
588
589 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e380ac_v2_leds_gpio),
590 cf_e380ac_v2_leds_gpio);
591 }
592
593 MIPS_MACHINE(ATH79_MACH_CF_E380AC_V2, "CF-E380AC-V2", "COMFAST CF-E380AC v2",
594 cf_e380ac_v2_setup);
595
596 static void __init cf_e5x0n_gpio_setup(void)
597 {
598 ath79_gpio_direction_select(CF_E5X0N_GPIO_LED_WAN, true);
599
600 ath79_gpio_output_select(CF_E5X0N_GPIO_LED_WAN, 0);
601
602 ath79_register_gpio_keys_polled(-1, CF_EXXXN_KEYS_POLL_INTERVAL,
603 ARRAY_SIZE(cf_e320n_v2_gpio_keys),
604 cf_e320n_v2_gpio_keys);
605 }
606
607 static void __init cf_e520n_setup(void)
608 {
609 cf_exxxn_common_setup(0x10000, -1);
610
611 cf_exxxn_qca953x_eth_setup();
612
613 cf_e5x0n_gpio_setup();
614
615 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e520n_leds_gpio),
616 cf_e520n_leds_gpio);
617 }
618
619 MIPS_MACHINE(ATH79_MACH_CF_E520N, "CF-E520N", "COMFAST CF-E520N",
620 cf_e520n_setup);
621
622 static void __init cf_e530n_setup(void)
623 {
624 cf_exxxn_common_setup(0x10000, -1);
625
626 cf_exxxn_qca953x_eth_setup();
627
628 cf_e5x0n_gpio_setup();
629
630 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e530n_leds_gpio),
631 cf_e530n_leds_gpio);
632 }
633
634 MIPS_MACHINE(ATH79_MACH_CF_E530N, "CF-E530N", "COMFAST CF-E530N",
635 cf_e530n_setup);