2 * TP-LINK TL-WA750RE v1/TL-WA801ND v2/TL-WA850RE v1/TL-WA901ND v3
5 * Copyright (C) 2013 Martijn Zilverschoon <thefriedzombie@gmail.com>
6 * Copyright (C) 2013 Jiri Pirko <jiri@resnulli.us>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
13 #include <linux/gpio.h>
14 #include <linux/platform_device.h>
16 #include <asm/mach-ath79/ath79.h>
17 #include <asm/mach-ath79/ar71xx_regs.h>
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-m25p80.h"
25 #include "machtypes.h"
27 #define TL_WAX50RE_GPIO_LED_LAN 20
28 #define TL_WAX50RE_GPIO_LED_WLAN 13
29 #define TL_WAX50RE_GPIO_LED_RE 15
30 #define TL_WAX50RE_GPIO_LED_SIGNAL1 0
31 #define TL_WAX50RE_GPIO_LED_SIGNAL2 1
32 #define TL_WAX50RE_GPIO_LED_SIGNAL3 2
33 #define TL_WAX50RE_GPIO_LED_SIGNAL4 3
34 #define TL_WAX50RE_GPIO_LED_SIGNAL5 4
36 #define TL_WA860RE_GPIO_LED_WLAN_ORANGE 0
37 #define TL_WA860RE_GPIO_LED_WLAN_GREEN 2
38 #define TL_WA860RE_GPIO_LED_POWER_ORANGE 12
39 #define TL_WA860RE_GPIO_LED_POWER_GREEN 14
40 #define TL_WA860RE_GPIO_LED_LAN 20
42 #define TL_WA801ND_V2_GPIO_LED_LAN 18
43 #define TL_WA801ND_V2_GPIO_LED_SYSTEM 14
45 #define TL_WAX50RE_GPIO_BTN_RESET 17
46 #define TL_WAX50RE_GPIO_BTN_WPS 16
48 #define TL_WA860RE_GPIO_BTN_RESET 17
49 #define TL_WA860RE_GPIO_BTN_WPS 16
50 #define TL_WA860RE_GPIO_BTN_ONOFF 11
52 #define TL_WAX50RE_KEYS_POLL_INTERVAL 20 /* msecs */
53 #define TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL (3 * TL_WAX50RE_KEYS_POLL_INTERVAL)
55 static const char *tl_wax50re_part_probes[] = {
60 static struct flash_platform_data tl_wax50re_flash_data = {
61 .part_probes = tl_wax50re_part_probes,
64 static struct gpio_led tl_wa750re_leds_gpio[] __initdata = {
66 .name = "tp-link:orange:lan",
67 .gpio = TL_WAX50RE_GPIO_LED_LAN,
70 .name = "tp-link:orange:wlan",
71 .gpio = TL_WAX50RE_GPIO_LED_WLAN,
74 .name = "tp-link:orange:re",
75 .gpio = TL_WAX50RE_GPIO_LED_RE,
78 .name = "tp-link:orange:signal1",
79 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL1,
82 .name = "tp-link:orange:signal2",
83 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL2,
86 .name = "tp-link:orange:signal3",
87 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL3,
90 .name = "tp-link:orange:signal4",
91 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL4,
94 .name = "tp-link:orange:signal5",
95 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL5,
100 static struct gpio_led tl_wa850re_leds_gpio[] __initdata = {
102 .name = "tp-link:blue:lan",
103 .gpio = TL_WAX50RE_GPIO_LED_LAN,
106 .name = "tp-link:blue:wlan",
107 .gpio = TL_WAX50RE_GPIO_LED_WLAN,
110 .name = "tp-link:blue:re",
111 .gpio = TL_WAX50RE_GPIO_LED_RE,
114 .name = "tp-link:blue:signal1",
115 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL1,
118 .name = "tp-link:blue:signal2",
119 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL2,
122 .name = "tp-link:blue:signal3",
123 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL3,
126 .name = "tp-link:blue:signal4",
127 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL4,
130 .name = "tp-link:blue:signal5",
131 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL5,
136 static struct gpio_led tl_wa860re_leds_gpio[] __initdata = {
138 .name = "tp-link:green:lan",
139 .gpio = TL_WA860RE_GPIO_LED_LAN,
142 .name = "tp-link:green:power",
143 .gpio = TL_WA860RE_GPIO_LED_POWER_GREEN,
146 .name = "tp-link:orange:power",
147 .gpio = TL_WA860RE_GPIO_LED_POWER_ORANGE,
150 .name = "tp-link:green:wlan",
151 .gpio = TL_WA860RE_GPIO_LED_WLAN_GREEN,
154 .name = "tp-link:orange:wlan",
155 .gpio = TL_WA860RE_GPIO_LED_WLAN_ORANGE,
161 static struct gpio_keys_button tl_wax50re_gpio_keys[] __initdata = {
163 .desc = "Reset button",
166 .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
167 .gpio = TL_WAX50RE_GPIO_BTN_RESET,
172 .code = KEY_WPS_BUTTON,
173 .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
174 .gpio = TL_WAX50RE_GPIO_BTN_WPS,
179 static struct gpio_keys_button tl_wa860re_gpio_keys[] __initdata = {
181 .desc = "Reset button",
184 .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
185 .gpio = TL_WA860RE_GPIO_BTN_RESET,
190 .code = KEY_WPS_BUTTON,
191 .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
192 .gpio = TL_WA860RE_GPIO_BTN_WPS,
198 .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
199 .gpio = TL_WA860RE_GPIO_BTN_ONOFF,
204 static struct gpio_led tl_wa801nd_v2_leds_gpio[] __initdata = {
206 .name = "tp-link:green:lan",
207 .gpio = TL_WA801ND_V2_GPIO_LED_LAN,
210 .name = "tp-link:green:wlan",
211 .gpio = TL_WAX50RE_GPIO_LED_WLAN,
214 .name = "tp-link:green:qss",
215 .gpio = TL_WAX50RE_GPIO_LED_RE,
218 .name = "tp-link:green:system",
219 .gpio = TL_WA801ND_V2_GPIO_LED_SYSTEM,
224 static void __init tl_ap123_setup(void)
226 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
227 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
229 ath79_register_m25p80(&tl_wax50re_flash_data);
231 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
233 ath79_register_mdio(1, 0x0);
235 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
237 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
238 ath79_eth0_data.phy_mask = BIT(0);
239 ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
240 ath79_register_eth(0);
242 ath79_register_wmac(ee, mac);
245 static void __init tl_wa750re_setup(void)
248 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa750re_leds_gpio),
249 tl_wa750re_leds_gpio);
251 ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
252 ARRAY_SIZE(tl_wax50re_gpio_keys),
253 tl_wax50re_gpio_keys);
256 MIPS_MACHINE(ATH79_MACH_TL_WA750RE, "TL-WA750RE", "TP-LINK TL-WA750RE",
259 static void __init tl_wa801nd_v2_setup(void)
262 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa801nd_v2_leds_gpio),
263 tl_wa801nd_v2_leds_gpio);
265 ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
266 ARRAY_SIZE(tl_wax50re_gpio_keys),
267 tl_wax50re_gpio_keys);
270 MIPS_MACHINE(ATH79_MACH_TL_WA801ND_V2, "TL-WA801ND-v2", "TP-LINK TL-WA801ND v2",
271 tl_wa801nd_v2_setup);
273 static void __init tl_wa850re_setup(void)
276 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa850re_leds_gpio),
277 tl_wa850re_leds_gpio);
279 ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
280 ARRAY_SIZE(tl_wax50re_gpio_keys),
281 tl_wax50re_gpio_keys);
284 MIPS_MACHINE(ATH79_MACH_TL_WA850RE, "TL-WA850RE", "TP-LINK TL-WA850RE",
287 static void __init tl_wa860re_setup(void)
290 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa860re_leds_gpio),
291 tl_wa860re_leds_gpio);
293 ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
294 ARRAY_SIZE(tl_wa860re_gpio_keys),
295 tl_wa860re_gpio_keys);
298 MIPS_MACHINE(ATH79_MACH_TL_WA860RE, "TL-WA860RE", "TP-LINK TL-WA860RE",
301 static void __init tl_wa901nd_v3_setup(void)
304 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa801nd_v2_leds_gpio),
305 tl_wa801nd_v2_leds_gpio);
307 ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
308 ARRAY_SIZE(tl_wax50re_gpio_keys) - 1,
309 tl_wax50re_gpio_keys);
312 MIPS_MACHINE(ATH79_MACH_TL_WA901ND_V3, "TL-WA901ND-v3", "TP-LINK TL-WA901ND v3",
313 tl_wa901nd_v3_setup);