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)
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>
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.
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>
27 #include <asm/mach-ath79/ath79.h>
28 #include <asm/mach-ath79/ar71xx_regs.h>
31 #include "dev-ap9x-pci.h"
33 #include "dev-gpio-buttons.h"
34 #include "dev-leds-gpio.h"
35 #include "dev-m25p80.h"
38 #include "machtypes.h"
41 #define CF_EXXXN_KEYS_POLL_INTERVAL 20
42 #define CF_EXXXN_KEYS_DEBOUNCE_INTERVAL (3 * CF_EXXXN_KEYS_POLL_INTERVAL)
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
52 #define CF_E316N_V2_GPIO_EXT_WDT 16
54 #define CF_E316N_V2_GPIO_EXTERNAL_PA0 13
55 #define CF_E316N_V2_GPIO_EXTERNAL_PA1 14
57 #define CF_E316N_V2_GPIO_BTN_RESET 20
59 static struct gpio_led cf_e316n_v2_leds_gpio
[] __initdata
= {
61 .name
= "cf-e316n-v2:blue:diag",
62 .gpio
= CF_E316N_V2_GPIO_LED_DIAG_B
,
65 .name
= "cf-e316n-v2:red:diag",
66 .gpio
= CF_E316N_V2_GPIO_LED_DIAG_R
,
69 .name
= "cf-e316n-v2:green:diag",
70 .gpio
= CF_E316N_V2_GPIO_LED_DIAG_G
,
73 .name
= "cf-e316n-v2:blue:wlan",
74 .gpio
= CF_E316N_V2_GPIO_LED_WLAN
,
77 .name
= "cf-e316n-v2:blue:wan",
78 .gpio
= CF_E316N_V2_GPIO_LED_WAN
,
81 .name
= "cf-e316n-v2:blue:lan",
82 .gpio
= CF_E316N_V2_GPIO_LED_LAN
,
87 static struct gpio_keys_button cf_e316n_v2_gpio_keys
[] __initdata
= {
92 .debounce_interval
= CF_EXXXN_KEYS_DEBOUNCE_INTERVAL
,
93 .gpio
= CF_E316N_V2_GPIO_BTN_RESET
,
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
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
108 #define CF_E320N_V2_GPIO_EXT_WDT 13
110 #define CF_E320N_V2_GPIO_BTN_RESET 17
112 static struct gpio_led cf_e320n_v2_leds_gpio
[] __initdata
= {
114 .name
= "cf-e320n-v2:green:lan",
115 .gpio
= CF_E320N_V2_GPIO_LED_LAN
,
118 .name
= "cf-e320n-v2:red:wan",
119 .gpio
= CF_E320N_V2_GPIO_LED_WAN
,
122 .name
= "cf-e320n-v2:blue:wlan",
123 .gpio
= CF_E320N_V2_GPIO_LED_WLAN
,
128 static struct gpio_keys_button cf_e320n_v2_gpio_keys
[] __initdata
= {
130 .desc
= "Reset button",
133 .debounce_interval
= CF_EXXXN_KEYS_DEBOUNCE_INTERVAL
,
134 .gpio
= CF_E320N_V2_GPIO_BTN_RESET
,
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
144 #define CF_E355AC_GPIO_EXT_WDT 13
146 #define CF_E355AC_GPIO_BTN_RESET 17
148 static struct gpio_led cf_e355ac_v1_leds_gpio
[] __initdata
= {
150 .name
= "cf-e355ac-v1:green:lan",
151 .gpio
= CF_E355AC_GPIO_LED_LAN
,
154 .name
= "cf-e355ac-v1:blue:wlan2g",
155 .gpio
= CF_E355AC_GPIO_LED_WLAN2G
,
158 .name
= "cf-e355ac-v1:red:wlan5g",
159 .gpio
= CF_E355AC_GPIO_LED_WLAN5G
,
164 static struct gpio_led cf_e355ac_v2_leds_gpio
[] __initdata
= {
166 .name
= "cf-e355ac-v2:green:lan",
167 .gpio
= CF_E355AC_GPIO_LED_LAN
,
170 .name
= "cf-e355ac-v2:blue:wlan2g",
171 .gpio
= CF_E355AC_GPIO_LED_WLAN2G
,
174 .name
= "cf-e355ac-v2:red:wlan5g",
175 .gpio
= CF_E355AC_GPIO_LED_WLAN5G
,
180 static struct gpio_keys_button cf_e355ac_gpio_keys
[] __initdata
= {
182 .desc
= "Reset button",
185 .debounce_interval
= CF_EXXXN_KEYS_DEBOUNCE_INTERVAL
,
186 .gpio
= CF_E355AC_GPIO_BTN_RESET
,
191 #define CF_E375AC_GPIO_XWDT_TRIGGER 6
193 #define CF_E375AC_GPIO_BTN_RESET_WPS 2
195 #define CF_E375AC_GPIO_LED_WAN 15
196 #define CF_E375AC_GPIO_LED_LAN 17
197 #define CF_E375AC_GPIO_LED_WLAN 16
199 static struct gpio_led cf_e375ac_leds_gpio
[] __initdata
= {
201 .name
= "comfast:red:wan",
202 .gpio
= CF_E375AC_GPIO_LED_WAN
,
205 .name
= "comfast:green:lan",
206 .gpio
= CF_E375AC_GPIO_LED_LAN
,
209 .name
= "comfast:blue:wlan",
210 .gpio
= CF_E375AC_GPIO_LED_WLAN
,
215 static struct gpio_keys_button cf_e375ac_gpio_keys
[] __initdata
= {
217 .desc
= "Reset button/WPS button",
220 .debounce_interval
= CF_EXXXN_KEYS_DEBOUNCE_INTERVAL
,
221 .gpio
= CF_E375AC_GPIO_BTN_RESET_WPS
,
226 static struct ar8327_pad_cfg cf_e375ac_ar8337_pad0_cfg
= {
227 .mode
= AR8327_PAD_MAC_SGMII
,
228 .sgmii_delay_en
= true,
231 static struct ar8327_platform_data cf_e375ac_ar8337_data
= {
232 .pad0_cfg
= &cf_e375ac_ar8337_pad0_cfg
,
235 .speed
= AR8327_PORT_SPEED_1000
,
242 static struct mdio_board_info cf_e375ac_mdio0_info
[] = {
244 .bus_id
= "ag71xx-mdio.0",
246 .platform_data
= &cf_e375ac_ar8337_data
,
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
255 #define CF_E38XAC_GPIO_EXT_WDT 17
257 #define CF_E38XAC_GPIO_BTN_RESET 19
259 static struct gpio_led cf_e380ac_v1_leds_gpio
[] __initdata
= {
261 .name
= "cf-e380ac-v1:green:lan",
262 .gpio
= CF_E38XAC_GPIO_LED_LAN
,
265 .name
= "cf-e380ac-v1:blue:wlan2g",
266 .gpio
= CF_E38XAC_GPIO_LED_WLAN2G
,
269 .name
= "cf-e380ac-v1:red:wlan5g",
270 .gpio
= CF_E38XAC_GPIO_LED_WLAN5G
,
275 static struct gpio_led cf_e380ac_v2_leds_gpio
[] __initdata
= {
277 .name
= "cf-e380ac-v2:green:lan",
278 .gpio
= CF_E38XAC_GPIO_LED_LAN
,
281 .name
= "cf-e380ac-v2:blue:wlan2g",
282 .gpio
= CF_E38XAC_GPIO_LED_WLAN2G
,
285 .name
= "cf-e380ac-v2:red:wlan5g",
286 .gpio
= CF_E38XAC_GPIO_LED_WLAN5G
,
291 static struct gpio_led cf_e385ac_leds_gpio
[] __initdata
= {
293 .name
= "cf-e385ac:green:lan",
294 .gpio
= CF_E38XAC_GPIO_LED_LAN
,
297 .name
= "cf-e385ac:blue:wlan2g",
298 .gpio
= CF_E38XAC_GPIO_LED_WLAN2G
,
301 .name
= "cf-e385ac:red:wlan5g",
302 .gpio
= CF_E38XAC_GPIO_LED_WLAN5G
,
307 static struct gpio_keys_button cf_e38xac_gpio_keys
[] __initdata
= {
309 .desc
= "Reset button",
312 .debounce_interval
= CF_EXXXN_KEYS_DEBOUNCE_INTERVAL
,
313 .gpio
= CF_E38XAC_GPIO_BTN_RESET
,
318 static struct at803x_platform_data cf_e380ac_v1v2_at803x_data
= {
319 .disable_smarteee
= 1,
322 static struct mdio_board_info cf_e380ac_v1v2_mdio0_info
[] = {
324 .bus_id
= "ag71xx-mdio.0",
326 .platform_data
= &cf_e380ac_v1v2_at803x_data
,
330 /* CF-E520N/CF-E530N */
331 #define CF_E5X0N_GPIO_LED_WAN 11
332 #define CF_E5X0N_GPIO_BTN_RESET 17
334 static struct gpio_led cf_e520n_leds_gpio
[] __initdata
= {
336 .name
= "cf-e520n:blue:wan",
337 .gpio
= CF_E5X0N_GPIO_LED_WAN
,
342 static struct gpio_led cf_e530n_leds_gpio
[] __initdata
= {
344 .name
= "cf-e530n:blue:wan",
345 .gpio
= CF_E5X0N_GPIO_LED_WAN
,
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.
355 #define CF_EXXXN_EXT_WDT_TIMEOUT_MS 500
357 static struct timer_list gpio_wdt_timer
;
359 static void gpio_wdt_toggle(unsigned long gpio
)
364 gpio_set_value(gpio
, state
);
366 mod_timer(&gpio_wdt_timer
,
367 jiffies
+ msecs_to_jiffies(CF_EXXXN_EXT_WDT_TIMEOUT_MS
));
370 static void __init
cf_exxxn_common_setup(unsigned long art_ofs
, int gpio_wdt
)
372 u8
*art
= (u8
*) KSEG1ADDR(0x1f001000 + art_ofs
);
375 gpio_request_one(gpio_wdt
, GPIOF_OUT_INIT_HIGH
,
376 "PT7A7514 watchdog");
378 setup_timer(&gpio_wdt_timer
, gpio_wdt_toggle
, gpio_wdt
);
379 gpio_wdt_toggle(gpio_wdt
);
382 ath79_register_m25p80(NULL
);
384 ath79_register_wmac(art
, NULL
);
386 ath79_register_usb();
389 static void __init
cf_e316n_v2_setup(void)
391 u8
*mac
= (u8
*) KSEG1ADDR(0x1f010000);
393 cf_exxxn_common_setup(0x10000, CF_E316N_V2_GPIO_EXT_WDT
);
395 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP
);
397 ath79_register_mdio(1, 0x0);
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);
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);
413 /* Enable 2x Skyworks SE2576L WLAN power amplifiers */
414 gpio_request_one(CF_E316N_V2_GPIO_EXTERNAL_PA0
, GPIOF_OUT_INIT_HIGH
,
416 gpio_request_one(CF_E316N_V2_GPIO_EXTERNAL_PA1
, GPIOF_OUT_INIT_HIGH
,
419 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e316n_v2_leds_gpio
),
420 cf_e316n_v2_leds_gpio
);
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
);
427 MIPS_MACHINE(ATH79_MACH_CF_E316N_V2
, "CF-E316N-V2", "COMFAST CF-E316N v2",
430 static void __init
cf_exxxn_qca953x_eth_setup(void)
432 u8
*mac
= (u8
*) KSEG1ADDR(0x1f010000);
434 ath79_setup_ar933x_phy4_switch(false, false);
436 ath79_register_mdio(0, 0x0);
438 ath79_switch_data
.phy4_mii_en
= 1;
439 ath79_switch_data
.phy_poll_mask
|= BIT(4);
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);
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);
457 static void __init
cf_e320n_v2_setup(void)
459 cf_exxxn_common_setup(0x10000, CF_E320N_V2_GPIO_EXT_WDT
);
461 cf_exxxn_qca953x_eth_setup();
463 /* Disable JTAG (enables GPIO0-3) */
464 ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE
);
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);
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);
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);
480 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e320n_v2_leds_gpio
),
481 cf_e320n_v2_leds_gpio
);
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
);
488 MIPS_MACHINE(ATH79_MACH_CF_E320N_V2
, "CF-E320N-V2", "COMFAST CF-E320N v2",
491 static void __init
cf_e355ac_setup(void)
493 u8
*art
= (u8
*) KSEG1ADDR(0x1f010000);
495 /* Disable JTAG, enabling GPIOs 0-3 */
496 ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE
, 0);
498 cf_exxxn_common_setup(0x10000, CF_E355AC_GPIO_EXT_WDT
);
500 cf_exxxn_qca953x_eth_setup();
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);
506 ap91_pci_init(art
+ 0x5000, NULL
);
508 ath79_register_gpio_keys_polled(1, CF_EXXXN_KEYS_POLL_INTERVAL
,
509 ARRAY_SIZE(cf_e355ac_gpio_keys
),
510 cf_e355ac_gpio_keys
);
513 static void __init
cf_e355ac_v1_setup(void)
517 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e355ac_v1_leds_gpio
),
518 cf_e355ac_v1_leds_gpio
);
521 static void __init
cf_e355ac_v2_setup(void)
525 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e355ac_v2_leds_gpio
),
526 cf_e355ac_v2_leds_gpio
);
529 MIPS_MACHINE(ATH79_MACH_CF_E355AC
, "CF-E355AC-V1", "COMFAST CF-E355AC v1",
532 MIPS_MACHINE(ATH79_MACH_CF_E355AC_V2
, "CF-E355AC-V2", "COMFAST CF-E355AC v2",
535 static void __init
cf_e375ac_setup(void)
537 u8
*mac
= (u8
*) KSEG1ADDR(0x1f040000);
538 u8
*art
= (u8
*) KSEG1ADDR(0x1f040000);
539 u8 wlan1_mac
[ETH_ALEN
];
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);
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);
549 cf_exxxn_common_setup(0x40000, CF_E375AC_GPIO_XWDT_TRIGGER
);
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);
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
);
561 platform_device_register(&ath79_mdio0_device
);
563 mdiobus_register_board_info(cf_e375ac_mdio0_info
,
564 ARRAY_SIZE(cf_e375ac_mdio0_info
));
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);
574 ap91_pci_init(art
+ 0x5000, wlan1_mac
);
576 MIPS_MACHINE(ATH79_MACH_CF_E375AC
, "CF-E375AC", "COMFAST CF-E375AC", cf_e375ac_setup
);
578 static void __init
cf_e38xac_common_setup(unsigned long art_ofs
)
580 cf_exxxn_common_setup(art_ofs
, CF_E38XAC_GPIO_EXT_WDT
);
582 ath79_register_pci();
584 /* Disable JTAG (enables GPIO0-3) */
585 ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE
);
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);
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);
596 ath79_gpio_function_disable(AR934X_GPIO_FUNC_CLK_OBS4_EN
);
598 ath79_register_gpio_keys_polled(-1, CF_EXXXN_KEYS_POLL_INTERVAL
,
599 ARRAY_SIZE(cf_e38xac_gpio_keys
),
600 cf_e38xac_gpio_keys
);
603 static void __init
cf_e380ac_v1v2_common_setup(unsigned long art_ofs
)
605 u8
*mac
= (u8
*) KSEG1ADDR(0x1f000000 + art_ofs
);
607 cf_e38xac_common_setup(art_ofs
);
609 ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN
);
611 ath79_register_mdio(0, 0x0);
612 mdiobus_register_board_info(cf_e380ac_v1v2_mdio0_info
,
613 ARRAY_SIZE(cf_e380ac_v1v2_mdio0_info
));
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);
626 static void __init
cf_e380ac_v1_setup(void)
628 cf_e380ac_v1v2_common_setup(0x20000);
630 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e380ac_v1_leds_gpio
),
631 cf_e380ac_v1_leds_gpio
);
634 MIPS_MACHINE(ATH79_MACH_CF_E380AC_V1
, "CF-E380AC-V1", "COMFAST CF-E380AC v1",
637 static void __init
cf_e380ac_v2_setup(void)
639 cf_e380ac_v1v2_common_setup(0x40000);
641 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e380ac_v2_leds_gpio
),
642 cf_e380ac_v2_leds_gpio
);
645 MIPS_MACHINE(ATH79_MACH_CF_E380AC_V2
, "CF-E380AC-V2", "COMFAST CF-E380AC v2",
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
,
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
,
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
,
669 .speed
= AR8327_PORT_SPEED_1000
,
676 .speed
= AR8327_PORT_SPEED_1000
,
683 static struct mdio_board_info cf_e385ac_mdio0_info
[] = {
685 .bus_id
= "ag71xx-mdio.0",
687 .platform_data
= &cf_e385ac_qca8337_data
,
691 static void __init
cf_e385ac_setup(void)
693 u8
*mac
= (u8
*) KSEG1ADDR(0x1f040000);
695 cf_e38xac_common_setup(0x40000);
697 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e385ac_leds_gpio
),
698 cf_e385ac_leds_gpio
);
700 mdiobus_register_board_info(cf_e385ac_mdio0_info
,
701 ARRAY_SIZE(cf_e385ac_mdio0_info
));
702 ath79_register_mdio(0, 0x0);
704 ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN
);
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;
712 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 0);
713 ath79_register_eth(0);
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;
721 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 1);
722 ath79_register_eth(1);
725 MIPS_MACHINE(ATH79_MACH_CF_E385AC
, "CF-E385AC", "COMFAST CF-E385AC",
728 static void __init
cf_e5x0n_gpio_setup(void)
730 ath79_gpio_direction_select(CF_E5X0N_GPIO_LED_WAN
, true);
732 ath79_gpio_output_select(CF_E5X0N_GPIO_LED_WAN
, 0);
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
);
739 static void __init
cf_e520n_setup(void)
741 cf_exxxn_common_setup(0x10000, -1);
743 cf_exxxn_qca953x_eth_setup();
745 cf_e5x0n_gpio_setup();
747 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e520n_leds_gpio
),
751 MIPS_MACHINE(ATH79_MACH_CF_E520N
, "CF-E520N", "COMFAST CF-E520N",
754 static void __init
cf_e530n_setup(void)
756 cf_exxxn_common_setup(0x10000, -1);
758 cf_exxxn_qca953x_eth_setup();
760 cf_e5x0n_gpio_setup();
762 ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e530n_leds_gpio
),
766 MIPS_MACHINE(ATH79_MACH_CF_E530N
, "CF-E530N", "COMFAST CF-E530N",