2 * TP-Link Archer C60 v1 board support
4 * Copyright (C) 2017 Henryk Heisig <hyniu@o2.pl>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
10 #include <linux/platform_device.h>
11 #include <linux/ath9k_platform.h>
12 #include <linux/ar8216_platform.h>
13 #include <asm/mach-ath79/ar71xx_regs.h>
14 #include <linux/gpio.h>
17 #include "dev-m25p80.h"
18 #include "machtypes.h"
20 #include "dev-ap9x-pci.h"
22 #include "dev-gpio-buttons.h"
23 #include "dev-leds-gpio.h"
28 #define ARCHER_C60_V1_GPIO_LED_LAN 2
29 #define ARCHER_C60_V1_GPIO_LED_POWER 16
30 #define ARCHER_C60_V1_GPIO_LED_WLAN2 17
31 #define ARCHER_C60_V1_GPIO_LED_WLAN5 18
32 #define ARCHER_C60_V1_GPIO_LED_WPS 19
33 #define ARCHER_C60_V1_GPIO_LED_WAN_GREEN 20
34 #define ARCHER_C60_V1_GPIO_LED_WAN_AMBER 22
37 #define ARCHER_C60_V1_KEYS_POLL_INTERVAL 20
38 #define ARCHER_C60_V1_KEYS_DEBOUNCE_INTERVAL (3 * ARCHER_C60_V1_KEYS_POLL_INTERVAL)
40 #define ARCHER_C60_V1_GPIO_BTN_RESET 21
41 #define ARCHER_C60_V1_GPIO_BTN_RFKILL 1
45 #define ARCHER_C60_V1_WMAC_CALDATA_OFFSET 0x1000
46 #define ARCHER_C60_V1_PCI_CALDATA_OFFSET 0x5000
48 static struct gpio_led archer_c60_v1_leds_gpio
[] __initdata
= {
50 .name
= "archer-c60-v1:green:power",
51 .gpio
= ARCHER_C60_V1_GPIO_LED_POWER
,
55 .name
= "archer-c60-v1:green:wlan2g",
56 .gpio
= ARCHER_C60_V1_GPIO_LED_WLAN2
,
60 .name
= "archer-c60-v1:green:wlan5g",
61 .gpio
= ARCHER_C60_V1_GPIO_LED_WLAN5
,
65 .name
= "archer-c60-v1:green:lan",
66 .gpio
= ARCHER_C60_V1_GPIO_LED_LAN
,
70 .name
= "archer-c60-v1:green:wan",
71 .gpio
= ARCHER_C60_V1_GPIO_LED_WAN_GREEN
,
75 .name
= "archer-c60-v1:amber:wan",
76 .gpio
= ARCHER_C60_V1_GPIO_LED_WAN_AMBER
,
80 .name
= "archer-c60-v1:green:wps",
81 .gpio
= ARCHER_C60_V1_GPIO_LED_WPS
,
86 static struct gpio_led archer_c60_v2_leds_gpio
[] __initdata
= {
88 .name
= "archer-c60-v2:green:power",
89 .gpio
= ARCHER_C60_V1_GPIO_LED_POWER
,
93 .name
= "archer-c60-v2:green:wlan2g",
94 .gpio
= ARCHER_C60_V1_GPIO_LED_WLAN2
,
98 .name
= "archer-c60-v2:green:wlan5g",
99 .gpio
= ARCHER_C60_V1_GPIO_LED_WLAN5
,
103 .name
= "archer-c60-v2:green:lan",
104 .gpio
= ARCHER_C60_V1_GPIO_LED_LAN
,
108 .name
= "archer-c60-v2:green:wan",
109 .gpio
= ARCHER_C60_V1_GPIO_LED_WAN_GREEN
,
113 .name
= "archer-c60-v2:amber:wan",
114 .gpio
= ARCHER_C60_V1_GPIO_LED_WAN_AMBER
,
118 .name
= "archer-c60-v2:green:wps",
119 .gpio
= ARCHER_C60_V1_GPIO_LED_WPS
,
124 static struct gpio_keys_button archer_c60_v1_gpio_keys
[] __initdata
= {
126 .desc
= "Reset button",
129 .debounce_interval
= ARCHER_C60_V1_KEYS_DEBOUNCE_INTERVAL
,
130 .gpio
= ARCHER_C60_V1_GPIO_BTN_RESET
,
134 .desc
= "RFKILL button",
137 .debounce_interval
= ARCHER_C60_V1_KEYS_DEBOUNCE_INTERVAL
,
138 .gpio
= ARCHER_C60_V1_GPIO_BTN_RFKILL
,
143 static void __init
archer_c60_v1_setup(void)
145 u8
*mac
= (u8
*) KSEG1ADDR(0x1f010008);
146 u8
*art
= (u8
*) KSEG1ADDR(0x1f7f0000);
148 ath79_register_m25p80(NULL
);
150 ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c60_v1_leds_gpio
),
151 archer_c60_v1_leds_gpio
);
153 ath79_register_gpio_keys_polled(-1, ARCHER_C60_V1_KEYS_POLL_INTERVAL
,
154 ARRAY_SIZE(archer_c60_v1_gpio_keys
),
155 archer_c60_v1_gpio_keys
);
157 ath79_register_mdio(0, 0x0);
158 ath79_register_mdio(1, 0x0);
160 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 0);
161 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 1);
164 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
165 ath79_eth0_data
.speed
= SPEED_100
;
166 ath79_eth0_data
.duplex
= DUPLEX_FULL
;
167 ath79_eth0_data
.phy_mask
= BIT(4);
168 ath79_register_eth(0);
171 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_GMII
;
172 ath79_eth1_data
.speed
= SPEED_1000
;
173 ath79_eth1_data
.duplex
= DUPLEX_FULL
;
174 ath79_switch_data
.phy_poll_mask
|= BIT(4);
175 ath79_switch_data
.phy4_mii_en
= 1;
176 ath79_register_eth(1);
178 ath79_register_wmac(art
+ ARCHER_C60_V1_WMAC_CALDATA_OFFSET
, mac
);
179 ap91_pci_init(art
+ ARCHER_C60_V1_PCI_CALDATA_OFFSET
, NULL
);
182 MIPS_MACHINE(ATH79_MACH_ARCHER_C60_V1
, "ARCHER-C60-V1",
183 "TP-LINK Archer C60 v1", archer_c60_v1_setup
);
185 static void __init
archer_c60_v2_setup(void)
187 u8
*mac
= (u8
*) KSEG1ADDR(0x1f01fb08);
188 u8
*art
= (u8
*) KSEG1ADDR(0x1f7f0000);
190 ath79_register_m25p80(NULL
);
192 ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c60_v2_leds_gpio
),
193 archer_c60_v2_leds_gpio
);
195 ath79_register_gpio_keys_polled(-1, ARCHER_C60_V1_KEYS_POLL_INTERVAL
,
196 ARRAY_SIZE(archer_c60_v1_gpio_keys
),
197 archer_c60_v1_gpio_keys
);
199 ath79_register_mdio(0, 0x0);
200 ath79_register_mdio(1, 0x0);
202 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 0);
203 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 1);
206 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
207 ath79_eth0_data
.speed
= SPEED_100
;
208 ath79_eth0_data
.duplex
= DUPLEX_FULL
;
209 ath79_eth0_data
.phy_mask
= BIT(4);
210 ath79_register_eth(0);
213 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_GMII
;
214 ath79_eth1_data
.speed
= SPEED_1000
;
215 ath79_eth1_data
.duplex
= DUPLEX_FULL
;
216 ath79_switch_data
.phy_poll_mask
|= BIT(4);
217 ath79_switch_data
.phy4_mii_en
= 1;
218 ath79_register_eth(1);
220 ath79_register_wmac(art
+ ARCHER_C60_V1_WMAC_CALDATA_OFFSET
, mac
);
221 ap91_pci_init(art
+ ARCHER_C60_V1_PCI_CALDATA_OFFSET
, NULL
);
224 MIPS_MACHINE(ATH79_MACH_ARCHER_C60_V2
, "ARCHER-C60-V2",
225 "TP-LINK Archer C60 v2", archer_c60_v2_setup
);