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