2 * Qxwlan E600G/E600GAC v2 board support
4 * Copyright (C) 2017 Peng Zhang <sd20@qxwlan.com>
5 * Copyright (C) 2018 Piotr Dymacz <pepe2k@gmail.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
14 #include "dev-gpio-buttons.h"
15 #include "dev-leds-gpio.h"
16 #include "dev-m25p80.h"
19 #include "machtypes.h"
22 #define E600G_V2_GPIO_LED_LAN 16
23 #define E600G_V2_GPIO_LED_SYS 13
24 #define E600G_V2_GPIO_LED_WAN_B 4
25 #define E600G_V2_GPIO_LED_WAN_G 15
27 #define E600GAC_V2_GPIO_LED_CTRL_B 14
28 #define E600GAC_V2_GPIO_LED_CTRL_G 11
29 #define E600GAC_V2_GPIO_LED_CTRL_R 12
30 #define E600GAC_V2_GPIO_LED_LAN 16
31 #define E600GAC_V2_GPIO_LED_SYS 13
32 #define E600GAC_V2_GPIO_LED_WAN_G 15
33 #define E600GAC_V2_GPIO_LED_WAN_O 4
35 #define E600G_V2_GPIO_BTN_RESET 17
36 #define E600GAC_V2_GPIO_BTN_WPS 1
38 #define E600G_V2_KEYS_POLL_INTERVAL 20 /* msecs */
39 #define E600G_V2_KEYS_DEBOUNCE_INTERVAL (3 * E600G_V2_KEYS_POLL_INTERVAL)
41 static struct gpio_led e600g_v2_leds_gpio
[] __initdata
= {
43 .name
= "e600g-v2:blue:system",
44 .gpio
= E600G_V2_GPIO_LED_SYS
,
47 .name
= "e600g-v2:blue:wan",
48 .gpio
= E600G_V2_GPIO_LED_WAN_B
,
51 .name
= "e600g-v2:green:lan",
52 .gpio
= E600G_V2_GPIO_LED_LAN
,
55 .name
= "e600g-v2:green:wan",
56 .gpio
= E600G_V2_GPIO_LED_WAN_G
,
61 static struct gpio_led e600gac_v2_leds_gpio
[] __initdata
= {
63 .name
= "e600gac-v2:blue:control",
64 .gpio
= E600GAC_V2_GPIO_LED_CTRL_B
,
67 .name
= "e600gac-v2:green:control",
68 .gpio
= E600GAC_V2_GPIO_LED_CTRL_G
,
71 .name
= "e600gac-v2:red:control",
72 .gpio
= E600GAC_V2_GPIO_LED_CTRL_R
,
75 .name
= "e600gac-v2:green:system",
76 .gpio
= E600GAC_V2_GPIO_LED_SYS
,
79 .name
= "e600gac-v2:orange:wan",
80 .gpio
= E600GAC_V2_GPIO_LED_WAN_O
,
83 .name
= "e600gac-v2:green:lan",
84 .gpio
= E600GAC_V2_GPIO_LED_LAN
,
87 .name
= "e600gac-v2:green:wan",
88 .gpio
= E600GAC_V2_GPIO_LED_WAN_G
,
93 static struct gpio_keys_button e600g_v2_gpio_keys
[] __initdata
= {
98 .debounce_interval
= E600G_V2_KEYS_DEBOUNCE_INTERVAL
,
99 .gpio
= E600G_V2_GPIO_BTN_RESET
,
104 static struct gpio_keys_button e600gac_v2_gpio_keys
[] __initdata
= {
109 .debounce_interval
= E600G_V2_KEYS_DEBOUNCE_INTERVAL
,
110 .gpio
= E600G_V2_GPIO_BTN_RESET
,
115 .code
= KEY_WPS_BUTTON
,
116 .debounce_interval
= E600G_V2_KEYS_DEBOUNCE_INTERVAL
,
117 .gpio
= E600GAC_V2_GPIO_BTN_WPS
,
122 static void __init
e600g_v2_common_setup(void)
124 u8
*mac
= (u8
*) KSEG1ADDR(0x1f050400);
125 u8
*art
= (u8
*) KSEG1ADDR(0x1f061000);
127 ath79_register_m25p80(NULL
);
129 ath79_setup_ar933x_phy4_switch(false, false);
131 ath79_register_mdio(0, 0x0);
133 ath79_switch_data
.phy4_mii_en
= 1;
134 ath79_switch_data
.phy_poll_mask
= 0xfe;
137 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
138 ath79_eth0_data
.phy_mask
= BIT(4);
139 ath79_eth0_data
.speed
= SPEED_100
;
140 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 1);
141 ath79_register_eth(0);
144 ath79_eth1_data
.duplex
= DUPLEX_FULL
;
145 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_GMII
;
146 ath79_eth1_data
.phy_mask
= BIT(0);
147 ath79_eth1_data
.speed
= SPEED_1000
;
148 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 0);
149 ath79_register_eth(1);
151 ath79_register_pci();
152 ath79_register_usb();
153 ath79_register_wmac(art
, NULL
);
156 static void __init
e600g_v2_setup(void)
158 e600g_v2_common_setup();
160 ath79_register_leds_gpio(-1, ARRAY_SIZE(e600g_v2_leds_gpio
),
163 ath79_register_gpio_keys_polled(-1, E600G_V2_KEYS_POLL_INTERVAL
,
164 ARRAY_SIZE(e600g_v2_gpio_keys
),
168 static void __init
e600gac_v2_setup(void)
170 e600g_v2_common_setup();
172 ath79_register_leds_gpio(-1, ARRAY_SIZE(e600gac_v2_leds_gpio
),
173 e600gac_v2_leds_gpio
);
175 ath79_register_gpio_keys_polled(-1, E600G_V2_KEYS_POLL_INTERVAL
,
176 ARRAY_SIZE(e600gac_v2_gpio_keys
),
177 e600gac_v2_gpio_keys
);
180 MIPS_MACHINE(ATH79_MACH_E600G_V2
, "E600G-V2", "Qxwlan E600G v2",
183 MIPS_MACHINE(ATH79_MACH_E600GAC_V2
, "E600GAC-V2", "Qxwlan E600GAC v2",