2 * TP-LINK TL-WA750RE v1/TL-WA801ND v2/TL-WA850RE v1 board support
4 * Copyright (C) 2013 Martijn Zilverschoon <thefriedzombie@gmail.com>
5 * Copyright (C) 2013 Jiri Pirko <jiri@resnulli.us>
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.
12 #include <linux/gpio.h>
13 #include <linux/platform_device.h>
15 #include <asm/mach-ath79/ath79.h>
16 #include <asm/mach-ath79/ar71xx_regs.h>
20 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
22 #include "dev-m25p80.h"
24 #include "machtypes.h"
26 #define TL_WAX50RE_GPIO_LED_LAN 20
27 #define TL_WAX50RE_GPIO_LED_WLAN 13
28 #define TL_WAX50RE_GPIO_LED_RE 15
29 #define TL_WAX50RE_GPIO_LED_SIGNAL1 0
30 #define TL_WAX50RE_GPIO_LED_SIGNAL2 1
31 #define TL_WAX50RE_GPIO_LED_SIGNAL3 2
32 #define TL_WAX50RE_GPIO_LED_SIGNAL4 3
33 #define TL_WAX50RE_GPIO_LED_SIGNAL5 4
35 #define TL_WA801ND_V2_GPIO_LED_LAN 18
36 #define TL_WA801ND_V2_GPIO_LED_SYSTEM 14
38 #define TL_WAX50RE_GPIO_BTN_RESET 17
39 #define TL_WAX50RE_GPIO_BTN_WPS 16
41 #define TL_WAX50RE_KEYS_POLL_INTERVAL 20 /* msecs */
42 #define TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL (3 * TL_WAX50RE_KEYS_POLL_INTERVAL)
44 static const char *tl_wax50re_part_probes[] = {
49 static struct flash_platform_data tl_wax50re_flash_data = {
50 .part_probes = tl_wax50re_part_probes,
53 static struct gpio_led tl_wa750re_leds_gpio[] __initdata = {
55 .name = "tp-link:orange:lan",
56 .gpio = TL_WAX50RE_GPIO_LED_LAN,
59 .name = "tp-link:orange:wlan",
60 .gpio = TL_WAX50RE_GPIO_LED_WLAN,
63 .name = "tp-link:orange:re",
64 .gpio = TL_WAX50RE_GPIO_LED_RE,
67 .name = "tp-link:orange:signal1",
68 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL1,
71 .name = "tp-link:orange:signal2",
72 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL2,
75 .name = "tp-link:orange:signal3",
76 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL3,
79 .name = "tp-link:orange:signal4",
80 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL4,
83 .name = "tp-link:orange:signal5",
84 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL5,
89 static struct gpio_led tl_wa850re_leds_gpio[] __initdata = {
91 .name = "tp-link:blue:lan",
92 .gpio = TL_WAX50RE_GPIO_LED_LAN,
95 .name = "tp-link:blue:wlan",
96 .gpio = TL_WAX50RE_GPIO_LED_WLAN,
99 .name = "tp-link:blue:re",
100 .gpio = TL_WAX50RE_GPIO_LED_RE,
103 .name = "tp-link:blue:signal1",
104 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL1,
107 .name = "tp-link:blue:signal2",
108 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL2,
111 .name = "tp-link:blue:signal3",
112 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL3,
115 .name = "tp-link:blue:signal4",
116 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL4,
119 .name = "tp-link:blue:signal5",
120 .gpio = TL_WAX50RE_GPIO_LED_SIGNAL5,
126 static struct gpio_keys_button tl_wax50re_gpio_keys[] __initdata = {
128 .desc = "Reset button",
131 .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
132 .gpio = TL_WAX50RE_GPIO_BTN_RESET,
137 .code = KEY_WPS_BUTTON,
138 .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
139 .gpio = TL_WAX50RE_GPIO_BTN_WPS,
144 static struct gpio_led tl_wa801nd_v2_leds_gpio[] __initdata = {
146 .name = "tp-link:green:lan",
147 .gpio = TL_WA801ND_V2_GPIO_LED_LAN,
150 .name = "tp-link:green:wlan",
151 .gpio = TL_WAX50RE_GPIO_LED_WLAN,
154 .name = "tp-link:green:qss",
155 .gpio = TL_WAX50RE_GPIO_LED_RE,
158 .name = "tp-link:green:system",
159 .gpio = TL_WA801ND_V2_GPIO_LED_SYSTEM,
164 static void __init tl_ap123_setup(void)
166 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
167 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
169 ath79_register_m25p80(&tl_wax50re_flash_data);
171 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
173 ath79_register_mdio(1, 0x0);
175 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
177 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
178 ath79_eth0_data.phy_mask = BIT(0);
179 ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
180 ath79_register_eth(0);
182 ath79_register_wmac(ee, mac);
185 static void __init tl_wa750re_setup(void)
188 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa750re_leds_gpio),
189 tl_wa750re_leds_gpio);
191 ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
192 ARRAY_SIZE(tl_wax50re_gpio_keys),
193 tl_wax50re_gpio_keys);
196 MIPS_MACHINE(ATH79_MACH_TL_WA750RE, "TL-WA750RE", "TP-LINK TL-WA750RE",
199 static void __init tl_wa801nd_v2_setup(void)
202 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa801nd_v2_leds_gpio),
203 tl_wa801nd_v2_leds_gpio);
205 ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
206 ARRAY_SIZE(tl_wax50re_gpio_keys),
207 tl_wax50re_gpio_keys);
210 MIPS_MACHINE(ATH79_MACH_TL_WA801ND_V2, "TL-WA801ND-v2", "TP-LINK TL-WA801ND v2",
211 tl_wa801nd_v2_setup);
213 static void __init tl_wa850re_setup(void)
216 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa850re_leds_gpio),
217 tl_wa850re_leds_gpio);
219 ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
220 ARRAY_SIZE(tl_wax50re_gpio_keys),
221 tl_wax50re_gpio_keys);
224 MIPS_MACHINE(ATH79_MACH_TL_WA850RE, "TL-WA850RE", "TP-LINK TL-WA850RE",