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_WA801ND_V2_GPIO_LED_LAN 18
37 #define TL_WA801ND_V2_GPIO_LED_SYSTEM 14
39 #define TL_WAX50RE_GPIO_BTN_RESET 17
40 #define TL_WAX50RE_GPIO_BTN_WPS 16
42 #define TL_WAX50RE_KEYS_POLL_INTERVAL 20 /* msecs */
43 #define TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL (3 * TL_WAX50RE_KEYS_POLL_INTERVAL)
45 static const char *tl_wax50re_part_probes[] = {
50 static struct flash_platform_data tl_wax50re_flash_data = {
51 .part_probes = tl_wax50re_part_probes,
54 static struct gpio_led tl_wa750re_leds_gpio[] __initdata = {
56 .name = "tp-link:orange:lan",
57 .gpio = TL_WAX50RE_GPIO_LED_LAN,
60 .name = "tp-link:orange:wlan",
61 .gpio = TL_WAX50RE_GPIO_LED_WLAN,
64 .name = "tp-link:orange:re",
65 .gpio = TL_WAX50RE_GPIO_LED_RE,
68 .name = "tp-link:orange:signal1",
69 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL1,
72 .name = "tp-link:orange:signal2",
73 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL2,
76 .name = "tp-link:orange:signal3",
77 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL3,
80 .name = "tp-link:orange:signal4",
81 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL4,
84 .name = "tp-link:orange:signal5",
85 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL5,
90 static struct gpio_led tl_wa850re_leds_gpio[] __initdata = {
92 .name = "tp-link:blue:lan",
93 .gpio = TL_WAX50RE_GPIO_LED_LAN,
96 .name = "tp-link:blue:wlan",
97 .gpio = TL_WAX50RE_GPIO_LED_WLAN,
100 .name = "tp-link:blue:re",
101 .gpio = TL_WAX50RE_GPIO_LED_RE,
104 .name = "tp-link:blue:signal1",
105 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL1,
108 .name = "tp-link:blue:signal2",
109 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL2,
112 .name = "tp-link:blue:signal3",
113 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL3,
116 .name = "tp-link:blue:signal4",
117 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL4,
120 .name = "tp-link:blue:signal5",
121 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL5,
127 static struct gpio_keys_button tl_wax50re_gpio_keys[] __initdata = {
129 .desc = "Reset button",
132 .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
133 .gpio = TL_WAX50RE_GPIO_BTN_RESET,
138 .code = KEY_WPS_BUTTON,
139 .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
140 .gpio = TL_WAX50RE_GPIO_BTN_WPS,
145 static struct gpio_led tl_wa801nd_v2_leds_gpio[] __initdata = {
147 .name = "tp-link:green:lan",
148 .gpio = TL_WA801ND_V2_GPIO_LED_LAN,
151 .name = "tp-link:green:wlan",
152 .gpio = TL_WAX50RE_GPIO_LED_WLAN,
155 .name = "tp-link:green:qss",
156 .gpio = TL_WAX50RE_GPIO_LED_RE,
159 .name = "tp-link:green:system",
160 .gpio = TL_WA801ND_V2_GPIO_LED_SYSTEM,
165 static void __init tl_ap123_setup(void)
167 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
168 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
170 ath79_register_m25p80(&tl_wax50re_flash_data);
172 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
174 ath79_register_mdio(1, 0x0);
176 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
178 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
179 ath79_eth0_data.phy_mask = BIT(0);
180 ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
181 ath79_register_eth(0);
183 ath79_register_wmac(ee, mac);
186 static void __init tl_wa750re_setup(void)
189 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa750re_leds_gpio),
190 tl_wa750re_leds_gpio);
192 ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
193 ARRAY_SIZE(tl_wax50re_gpio_keys),
194 tl_wax50re_gpio_keys);
197 MIPS_MACHINE(ATH79_MACH_TL_WA750RE, "TL-WA750RE", "TP-LINK TL-WA750RE",
200 static void __init tl_wa801nd_v2_setup(void)
203 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa801nd_v2_leds_gpio),
204 tl_wa801nd_v2_leds_gpio);
206 ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
207 ARRAY_SIZE(tl_wax50re_gpio_keys),
208 tl_wax50re_gpio_keys);
211 MIPS_MACHINE(ATH79_MACH_TL_WA801ND_V2, "TL-WA801ND-v2", "TP-LINK TL-WA801ND v2",
212 tl_wa801nd_v2_setup);
214 static void __init tl_wa850re_setup(void)
217 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa850re_leds_gpio),
218 tl_wa850re_leds_gpio);
220 ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
221 ARRAY_SIZE(tl_wax50re_gpio_keys),
222 tl_wax50re_gpio_keys);
225 MIPS_MACHINE(ATH79_MACH_TL_WA850RE, "TL-WA850RE", "TP-LINK TL-WA850RE",
228 static void __init tl_wa901nd_v3_setup(void)
231 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa801nd_v2_leds_gpio),
232 tl_wa801nd_v2_leds_gpio);
234 ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
235 ARRAY_SIZE(tl_wax50re_gpio_keys) - 1,
236 tl_wax50re_gpio_keys);
239 MIPS_MACHINE(ATH79_MACH_TL_WA901ND_V3, "TL-WA901ND-v3", "TP-LINK TL-WA901ND v3",
240 tl_wa901nd_v3_setup);