OpenWrt – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * TP-Link Archer C58/C59 v1 board support |
||
3 | * |
||
4 | * Copyright (C) 2017 Henryk Heisig <hyniu@o2.pl> |
||
5 | * |
||
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. |
||
9 | */ |
||
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> |
||
15 | #include <linux/init.h> |
||
16 | #include <linux/spi/spi_gpio.h> |
||
17 | #include <linux/spi/74x164.h> |
||
18 | |||
19 | #include "common.h" |
||
20 | #include "dev-m25p80.h" |
||
21 | #include "machtypes.h" |
||
22 | #include "pci.h" |
||
23 | #include "dev-ap9x-pci.h" |
||
24 | #include "dev-eth.h" |
||
25 | #include "dev-gpio-buttons.h" |
||
26 | #include "dev-leds-gpio.h" |
||
27 | #include "dev-spi.h" |
||
28 | #include "dev-usb.h" |
||
29 | #include "dev-wmac.h" |
||
30 | |||
31 | #define ARCHER_C59_V1_KEYS_POLL_INTERVAL 20 |
||
32 | #define ARCHER_C59_V1_KEYS_DEBOUNCE_INTERVAL (3 * ARCHER_C59_V1_KEYS_POLL_INTERVAL) |
||
33 | |||
34 | #define ARCHER_C59_V1_GPIO_BTN_RESET 21 |
||
35 | #define ARCHER_C59_V1_GPIO_BTN_RFKILL 2 |
||
36 | #define ARCHER_C59_V1_GPIO_BTN_WPS 1 |
||
37 | |||
38 | #define ARCHER_C59_V1_GPIO_USB_POWER 22 |
||
39 | |||
40 | #define ARCHER_C59_GPIO_SHIFT_OE 16 |
||
41 | #define ARCHER_C59_GPIO_SHIFT_SER 17 |
||
42 | #define ARCHER_C59_GPIO_SHIFT_SRCLK 18 |
||
43 | #define ARCHER_C59_GPIO_SHIFT_SRCLR 19 |
||
44 | #define ARCHER_C59_GPIO_SHIFT_RCLK 20 |
||
45 | |||
46 | #define ARCHER_C59_74HC_GPIO_BASE 32 |
||
47 | #define ARCHER_C59_74HC_GPIO_LED_POWER (ARCHER_C59_74HC_GPIO_BASE + 0) |
||
48 | #define ARCHER_C59_74HC_GPIO_LED_WLAN2 (ARCHER_C59_74HC_GPIO_BASE + 1) |
||
49 | #define ARCHER_C59_74HC_GPIO_LED_WLAN5 (ARCHER_C59_74HC_GPIO_BASE + 2) |
||
50 | #define ARCHER_C59_74HC_GPIO_LED_LAN (ARCHER_C59_74HC_GPIO_BASE + 3) |
||
51 | #define ARCHER_C59_74HC_GPIO_LED_WAN_GREEN (ARCHER_C59_74HC_GPIO_BASE + 4) |
||
52 | #define ARCHER_C59_74HC_GPIO_LED_WAN_AMBER (ARCHER_C59_74HC_GPIO_BASE + 5) |
||
53 | #define ARCHER_C59_74HC_GPIO_LED_WPS (ARCHER_C59_74HC_GPIO_BASE + 6) |
||
54 | #define ARCHER_C59_74HC_GPIO_LED_USB (ARCHER_C59_74HC_GPIO_BASE + 7) |
||
55 | |||
56 | #define ARCHER_C59_V1_SSR_BIT_0 0 |
||
57 | #define ARCHER_C59_V1_SSR_BIT_1 1 |
||
58 | #define ARCHER_C59_V1_SSR_BIT_2 2 |
||
59 | #define ARCHER_C59_V1_SSR_BIT_3 3 |
||
60 | #define ARCHER_C59_V1_SSR_BIT_4 4 |
||
61 | #define ARCHER_C59_V1_SSR_BIT_5 5 |
||
62 | #define ARCHER_C59_V1_SSR_BIT_6 6 |
||
63 | #define ARCHER_C59_V1_SSR_BIT_7 7 |
||
64 | |||
65 | #define ARCHER_C59_V1_WMAC_CALDATA_OFFSET 0x1000 |
||
66 | #define ARCHER_C59_V1_PCI_CALDATA_OFFSET 0x5000 |
||
67 | |||
68 | static struct gpio_led archer_c58_v1_leds_gpio[] __initdata = { |
||
69 | { |
||
70 | .name = "archer-c58-v1:green:power", |
||
71 | .gpio = ARCHER_C59_74HC_GPIO_LED_POWER, |
||
72 | .active_low = 1, |
||
73 | }, |
||
74 | { |
||
75 | .name = "archer-c58-v1:green:wlan2g", |
||
76 | .gpio = ARCHER_C59_74HC_GPIO_LED_WLAN2, |
||
77 | .active_low = 1, |
||
78 | }, |
||
79 | { |
||
80 | .name = "archer-c58-v1:green:wlan5g", |
||
81 | .gpio = ARCHER_C59_74HC_GPIO_LED_WLAN5, |
||
82 | .active_low = 1, |
||
83 | }, |
||
84 | { |
||
85 | .name = "archer-c58-v1:green:lan", |
||
86 | .gpio = ARCHER_C59_74HC_GPIO_LED_LAN, |
||
87 | .active_low = 1, |
||
88 | }, |
||
89 | { |
||
90 | .name = "archer-c58-v1:green:wan", |
||
91 | .gpio = ARCHER_C59_74HC_GPIO_LED_WAN_GREEN, |
||
92 | .active_low = 1, |
||
93 | }, |
||
94 | { |
||
95 | .name = "archer-c58-v1:amber:wan", |
||
96 | .gpio = ARCHER_C59_74HC_GPIO_LED_WAN_AMBER, |
||
97 | .active_low = 1, |
||
98 | }, |
||
99 | { |
||
100 | .name = "archer-c58-v1:green:wps", |
||
101 | .gpio = ARCHER_C59_74HC_GPIO_LED_WPS, |
||
102 | .active_low = 1, |
||
103 | }, |
||
104 | }; |
||
105 | |||
106 | static struct gpio_led archer_c59_v1_leds_gpio[] __initdata = { |
||
107 | { |
||
108 | .name = "archer-c59-v1:green:power", |
||
109 | .gpio = ARCHER_C59_74HC_GPIO_LED_POWER, |
||
110 | .active_low = 1, |
||
111 | }, |
||
112 | { |
||
113 | .name = "archer-c59-v1:green:wlan2g", |
||
114 | .gpio = ARCHER_C59_74HC_GPIO_LED_WLAN2, |
||
115 | .active_low = 1, |
||
116 | }, |
||
117 | { |
||
118 | .name = "archer-c59-v1:green:wlan5g", |
||
119 | .gpio = ARCHER_C59_74HC_GPIO_LED_WLAN5, |
||
120 | .active_low = 1, |
||
121 | }, |
||
122 | { |
||
123 | .name = "archer-c59-v1:green:lan", |
||
124 | .gpio = ARCHER_C59_74HC_GPIO_LED_LAN, |
||
125 | .active_low = 1, |
||
126 | }, |
||
127 | { |
||
128 | .name = "archer-c59-v1:green:wan", |
||
129 | .gpio = ARCHER_C59_74HC_GPIO_LED_WAN_GREEN, |
||
130 | .active_low = 1, |
||
131 | }, |
||
132 | { |
||
133 | .name = "archer-c59-v1:amber:wan", |
||
134 | .gpio = ARCHER_C59_74HC_GPIO_LED_WAN_AMBER, |
||
135 | .active_low = 1, |
||
136 | }, |
||
137 | { |
||
138 | .name = "archer-c59-v1:green:wps", |
||
139 | .gpio = ARCHER_C59_74HC_GPIO_LED_WPS, |
||
140 | .active_low = 1, |
||
141 | }, |
||
142 | { |
||
143 | .name = "archer-c59-v1:green:usb", |
||
144 | .gpio = ARCHER_C59_74HC_GPIO_LED_USB, |
||
145 | .active_low = 1, |
||
146 | }, |
||
147 | }; |
||
148 | |||
149 | static struct gpio_keys_button archer_c59_v1_gpio_keys[] __initdata = { |
||
150 | { |
||
151 | .desc = "Reset button", |
||
152 | .type = EV_KEY, |
||
153 | .code = KEY_RESTART, |
||
154 | .debounce_interval = ARCHER_C59_V1_KEYS_DEBOUNCE_INTERVAL, |
||
155 | .gpio = ARCHER_C59_V1_GPIO_BTN_RESET, |
||
156 | .active_low = 1, |
||
157 | }, |
||
158 | { |
||
159 | .desc = "RFKILL button", |
||
160 | .type = EV_KEY, |
||
161 | .code = KEY_RFKILL, |
||
162 | .debounce_interval = ARCHER_C59_V1_KEYS_DEBOUNCE_INTERVAL, |
||
163 | .gpio = ARCHER_C59_V1_GPIO_BTN_RFKILL, |
||
164 | .active_low = 1, |
||
165 | }, |
||
166 | { |
||
167 | .desc = "WPS button", |
||
168 | .type = EV_KEY, |
||
169 | .code = KEY_WPS_BUTTON, |
||
170 | .debounce_interval = ARCHER_C59_V1_KEYS_DEBOUNCE_INTERVAL, |
||
171 | .gpio = ARCHER_C59_V1_GPIO_BTN_WPS, |
||
172 | .active_low = 1, |
||
173 | }, |
||
174 | }; |
||
175 | |||
176 | static struct spi_gpio_platform_data archer_c59_v1_spi_data = { |
||
177 | .sck = ARCHER_C59_GPIO_SHIFT_SRCLK, |
||
178 | .miso = SPI_GPIO_NO_MISO, |
||
179 | .mosi = ARCHER_C59_GPIO_SHIFT_SER, |
||
180 | .num_chipselect = 1, |
||
181 | }; |
||
182 | |||
183 | static u8 archer_c59_v1_ssr_initdata[] = { |
||
184 | BIT(ARCHER_C59_V1_SSR_BIT_7) | |
||
185 | BIT(ARCHER_C59_V1_SSR_BIT_6) | |
||
186 | BIT(ARCHER_C59_V1_SSR_BIT_5) | |
||
187 | BIT(ARCHER_C59_V1_SSR_BIT_4) | |
||
188 | BIT(ARCHER_C59_V1_SSR_BIT_3) | |
||
189 | BIT(ARCHER_C59_V1_SSR_BIT_2) | |
||
190 | BIT(ARCHER_C59_V1_SSR_BIT_1) |
||
191 | }; |
||
192 | |||
193 | static struct gen_74x164_chip_platform_data archer_c59_v1_ssr_data = { |
||
194 | .base = ARCHER_C59_74HC_GPIO_BASE, |
||
195 | .num_registers = ARRAY_SIZE(archer_c59_v1_ssr_initdata), |
||
196 | .init_data = archer_c59_v1_ssr_initdata, |
||
197 | }; |
||
198 | |||
199 | static struct platform_device archer_c59_v1_spi_device = { |
||
200 | .name = "spi_gpio", |
||
201 | .id = 1, |
||
202 | .dev = { |
||
203 | .platform_data = &archer_c59_v1_spi_data, |
||
204 | }, |
||
205 | }; |
||
206 | |||
207 | static struct spi_board_info archer_c59_v1_spi_info[] = { |
||
208 | { |
||
209 | .bus_num = 1, |
||
210 | .chip_select = 0, |
||
211 | .max_speed_hz = 10000000, |
||
212 | .modalias = "74x164", |
||
213 | .platform_data = &archer_c59_v1_ssr_data, |
||
214 | .controller_data = (void *) ARCHER_C59_GPIO_SHIFT_RCLK, |
||
215 | }, |
||
216 | }; |
||
217 | |||
3 | office | 218 | static void __init archer_c5x_v1_setup(void) |
1 | office | 219 | { |
3 | office | 220 | u8 *mac = (u8 *) KSEG1ADDR(0x1f010008); |
1 | office | 221 | u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); |
222 | |||
223 | ath79_register_m25p80(NULL); |
||
224 | spi_register_board_info(archer_c59_v1_spi_info, |
||
225 | ARRAY_SIZE(archer_c59_v1_spi_info)); |
||
226 | platform_device_register(&archer_c59_v1_spi_device); |
||
227 | |||
228 | ath79_register_gpio_keys_polled(-1, ARCHER_C59_V1_KEYS_POLL_INTERVAL, |
||
229 | ARRAY_SIZE(archer_c59_v1_gpio_keys), |
||
230 | archer_c59_v1_gpio_keys); |
||
231 | |||
232 | ath79_setup_qca956x_eth_cfg(QCA956X_ETH_CFG_SW_PHY_SWAP | |
||
233 | QCA956X_ETH_CFG_SW_PHY_ADDR_SWAP); |
||
234 | |||
235 | ath79_register_mdio(0, 0x0); |
||
236 | ath79_register_mdio(1, 0x0); |
||
237 | |||
238 | ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1); |
||
239 | ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0); |
||
240 | |||
241 | /* WAN port */ |
||
242 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; |
||
243 | ath79_eth0_data.speed = SPEED_100; |
||
244 | ath79_eth0_data.duplex = DUPLEX_FULL; |
||
245 | ath79_eth0_data.phy_mask = BIT(0); |
||
246 | ath79_register_eth(0); |
||
247 | |||
248 | /* LAN ports */ |
||
249 | ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; |
||
250 | ath79_eth1_data.speed = SPEED_1000; |
||
251 | ath79_eth1_data.duplex = DUPLEX_FULL; |
||
252 | ath79_switch_data.phy_poll_mask |= BIT(0); |
||
253 | ath79_switch_data.phy4_mii_en = 1; |
||
254 | ath79_register_eth(1); |
||
255 | |||
256 | ath79_register_wmac(art + ARCHER_C59_V1_WMAC_CALDATA_OFFSET, mac); |
||
257 | ap91_pci_init(art + ARCHER_C59_V1_PCI_CALDATA_OFFSET, NULL); |
||
258 | |||
259 | ath79_register_usb(); |
||
260 | gpio_request_one(ARCHER_C59_V1_GPIO_USB_POWER, |
||
261 | GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED, |
||
262 | "USB power"); |
||
263 | gpio_request_one(ARCHER_C59_GPIO_SHIFT_OE, |
||
264 | GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, |
||
265 | "LED control"); |
||
266 | gpio_request_one(ARCHER_C59_GPIO_SHIFT_SRCLR, |
||
267 | GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED, |
||
268 | "LED reset"); |
||
269 | } |
||
270 | |||
271 | static void __init archer_c58_v1_setup(void) |
||
272 | { |
||
3 | office | 273 | archer_c5x_v1_setup(); |
1 | office | 274 | ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c58_v1_leds_gpio), |
275 | archer_c58_v1_leds_gpio); |
||
276 | } |
||
277 | |||
278 | MIPS_MACHINE(ATH79_MACH_ARCHER_C58_V1, "ARCHER-C58-V1", |
||
279 | "TP-LINK Archer C58 v1", archer_c58_v1_setup); |
||
280 | |||
281 | static void __init archer_c59_v1_setup(void) |
||
282 | { |
||
3 | office | 283 | archer_c5x_v1_setup(); |
1 | office | 284 | ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c59_v1_leds_gpio), |
285 | archer_c59_v1_leds_gpio); |
||
286 | } |
||
287 | |||
288 | MIPS_MACHINE(ATH79_MACH_ARCHER_C59_V1, "ARCHER-C59-V1", |
||
289 | "TP-LINK Archer C59 v1", archer_c59_v1_setup); |