2 * TP-LINK TL-WR841N/ND v9/v11 / TL-WR842N/ND v3
4 * Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
5 * Copyright (C) 2016 Cezary Jackiewicz <cezary@eko.one.pl>
6 * Copyright (C) 2016 Stijn Segers <francesco.borromini@gmail.com>
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"
26 #include "machtypes.h"
28 #define TL_WR841NV9_GPIO_LED_WLAN 13
29 #define TL_WR841NV9_GPIO_LED_QSS 3
30 #define TL_WR841NV9_GPIO_LED_WAN 4
31 #define TL_WR841NV9_GPIO_LED_LAN1 16
32 #define TL_WR841NV9_GPIO_LED_LAN2 15
33 #define TL_WR841NV9_GPIO_LED_LAN3 14
34 #define TL_WR841NV9_GPIO_LED_LAN4 11
36 #define TL_WR841NV9_GPIO_BTN_RESET 12
37 #define TL_WR841NV9_GPIO_BTN_WIFI 17
39 #define TL_WR841NV11_GPIO_LED_SYSTEM 1
40 #define TL_WR841NV11_GPIO_LED_QSS 3
41 #define TL_WR841NV11_GPIO_LED_WAN 4
42 #define TL_WR841NV11_GPIO_LED_WAN_STATUS 2
43 #define TL_WR841NV11_GPIO_LED_WLAN 13
44 #define TL_WR841NV11_GPIO_LED_LAN1 16
45 #define TL_WR841NV11_GPIO_LED_LAN2 15
46 #define TL_WR841NV11_GPIO_LED_LAN3 14
47 #define TL_WR841NV11_GPIO_LED_LAN4 11
49 #define TL_WR841NV11_GPIO_BTN_RESET 12
50 #define TL_WR841NV11_GPIO_BTN_WIFI 17
52 #define TL_WR842NV3_GPIO_LED_SYSTEM 2
53 #define TL_WR842NV3_GPIO_LED_WLAN 3
54 #define TL_WR842NV3_GPIO_LED_WAN_RED 4
55 #define TL_WR842NV3_GPIO_LED_WAN_GREEN 11
56 #define TL_WR842NV3_GPIO_LED_LAN1 12
57 #define TL_WR842NV3_GPIO_LED_LAN2 13
58 #define TL_WR842NV3_GPIO_LED_LAN3 14
59 #define TL_WR842NV3_GPIO_LED_LAN4 15
60 #define TL_WR842NV3_GPIO_LED_3G 16
61 #define TL_WR842NV3_GPIO_LED_WPS 17
63 #define TL_WR842NV3_GPIO_BTN_RESET 1
64 #define TL_WR842NV3_GPIO_BTN_WIFI 0
66 #define TL_WR841NV9_KEYS_POLL_INTERVAL 20 /* msecs */
67 #define TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR841NV9_KEYS_POLL_INTERVAL)
69 static const char *tl_wr841n_v9_part_probes
[] = {
74 static struct flash_platform_data tl_wr841n_v9_flash_data
= {
75 .part_probes
= tl_wr841n_v9_part_probes
,
78 static struct gpio_led tl_wr841n_v9_leds_gpio
[] __initdata
= {
80 .name
= "tp-link:green:lan1",
81 .gpio
= TL_WR841NV9_GPIO_LED_LAN1
,
84 .name
= "tp-link:green:lan2",
85 .gpio
= TL_WR841NV9_GPIO_LED_LAN2
,
88 .name
= "tp-link:green:lan3",
89 .gpio
= TL_WR841NV9_GPIO_LED_LAN3
,
92 .name
= "tp-link:green:lan4",
93 .gpio
= TL_WR841NV9_GPIO_LED_LAN4
,
96 .name
= "tp-link:green:qss",
97 .gpio
= TL_WR841NV9_GPIO_LED_QSS
,
100 .name
= "tp-link:green:wan",
101 .gpio
= TL_WR841NV9_GPIO_LED_WAN
,
104 .name
= "tp-link:green:wlan",
105 .gpio
= TL_WR841NV9_GPIO_LED_WLAN
,
110 static struct gpio_keys_button tl_wr841n_v9_gpio_keys
[] __initdata
= {
112 .desc
= "Reset button",
115 .debounce_interval
= TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL
,
116 .gpio
= TL_WR841NV9_GPIO_BTN_RESET
,
119 .desc
= "WIFI button",
122 .debounce_interval
= TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL
,
123 .gpio
= TL_WR841NV9_GPIO_BTN_WIFI
,
128 static struct gpio_led tl_wr841n_v11_leds_gpio
[] __initdata
= {
130 .name
= "tp-link:green:lan1",
131 .gpio
= TL_WR841NV9_GPIO_LED_LAN1
,
134 .name
= "tp-link:green:lan2",
135 .gpio
= TL_WR841NV9_GPIO_LED_LAN2
,
138 .name
= "tp-link:green:lan3",
139 .gpio
= TL_WR841NV9_GPIO_LED_LAN3
,
142 .name
= "tp-link:green:lan4",
143 .gpio
= TL_WR841NV9_GPIO_LED_LAN4
,
146 .name
= "tp-link:green:qss",
147 .gpio
= TL_WR841NV9_GPIO_LED_QSS
,
150 .name
= "tp-link:green:system",
151 .gpio
= TL_WR841NV11_GPIO_LED_SYSTEM
,
154 .name
= "tp-link:green:wan",
155 .gpio
= TL_WR841NV9_GPIO_LED_WAN
,
158 .name
= "tp-link:green:wan_status",
159 .gpio
= TL_WR841NV11_GPIO_LED_WAN_STATUS
,
162 .name
= "tp-link:green:wlan",
163 .gpio
= TL_WR841NV9_GPIO_LED_WLAN
,
168 static struct gpio_led tl_wr842n_v3_leds_gpio
[] __initdata
= {
170 .name
= "tp-link:green:lan1",
171 .gpio
= TL_WR842NV3_GPIO_LED_LAN1
,
174 .name
= "tp-link:green:lan2",
175 .gpio
= TL_WR842NV3_GPIO_LED_LAN2
,
178 .name
= "tp-link:green:lan3",
179 .gpio
= TL_WR842NV3_GPIO_LED_LAN3
,
182 .name
= "tp-link:green:lan4",
183 .gpio
= TL_WR842NV3_GPIO_LED_LAN4
,
186 .name
= "tp-link:green:wan",
187 .gpio
= TL_WR842NV3_GPIO_LED_WAN_GREEN
,
190 .name
= "tp-link:red:wan",
191 .gpio
= TL_WR842NV3_GPIO_LED_WAN_RED
,
194 .name
= "tp-link:green:wlan",
195 .gpio
= TL_WR842NV3_GPIO_LED_WLAN
,
198 .name
= "tp-link:green:system",
199 .gpio
= TL_WR842NV3_GPIO_LED_SYSTEM
,
202 .name
= "tp-link:green:3g",
203 .gpio
= TL_WR842NV3_GPIO_LED_3G
,
206 .name
= "tp-link:green:wps",
207 .gpio
= TL_WR842NV3_GPIO_LED_WPS
,
212 static struct gpio_keys_button tl_wr842n_v3_gpio_keys
[] __initdata
= {
214 .desc
= "Reset button",
217 .debounce_interval
= TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL
,
218 .gpio
= TL_WR842NV3_GPIO_BTN_RESET
,
221 .desc
= "WIFI button",
224 .debounce_interval
= TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL
,
225 .gpio
= TL_WR842NV3_GPIO_BTN_WIFI
,
231 static void __init
tl_ap143_setup(void)
233 u8
*mac
= (u8
*) KSEG1ADDR(0x1f01fc00);
234 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
237 ath79_register_m25p80(&tl_wr841n_v9_flash_data
);
239 ath79_setup_ar933x_phy4_switch(false, false);
241 ath79_register_mdio(0, 0x0);
244 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_GMII
;
245 ath79_eth1_data
.duplex
= DUPLEX_FULL
;
246 ath79_switch_data
.phy_poll_mask
|= BIT(4);
247 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 0);
248 ath79_register_eth(1);
251 ath79_switch_data
.phy4_mii_en
= 1;
252 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
253 ath79_eth0_data
.duplex
= DUPLEX_FULL
;
254 ath79_eth0_data
.speed
= SPEED_100
;
255 ath79_eth0_data
.phy_mask
= BIT(4);
256 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 1);
257 ath79_register_eth(0);
259 ath79_init_mac(tmpmac
, mac
, 0);
260 ath79_register_wmac(ee
, tmpmac
);
263 static void __init
tl_wr841n_v9_setup(void)
267 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v9_leds_gpio
),
268 tl_wr841n_v9_leds_gpio
);
270 ath79_register_gpio_keys_polled(1, TL_WR841NV9_KEYS_POLL_INTERVAL
,
271 ARRAY_SIZE(tl_wr841n_v9_gpio_keys
),
272 tl_wr841n_v9_gpio_keys
);
275 MIPS_MACHINE(ATH79_MACH_TL_WR841N_V9
, "TL-WR841N-v9", "TP-LINK TL-WR841N/ND v9",
278 static void __init
tl_wr841n_v11_setup(void)
282 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v11_leds_gpio
),
283 tl_wr841n_v11_leds_gpio
);
285 ath79_register_gpio_keys_polled(1, TL_WR841NV9_KEYS_POLL_INTERVAL
,
286 ARRAY_SIZE(tl_wr841n_v9_gpio_keys
),
287 tl_wr841n_v9_gpio_keys
);
290 MIPS_MACHINE(ATH79_MACH_TL_WR841N_V11
, "TL-WR841N-v11", "TP-LINK TL-WR841N/ND v11",
291 tl_wr841n_v11_setup
);
293 static void __init
tl_wr842n_v3_setup(void)
297 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr842n_v3_leds_gpio
),
298 tl_wr842n_v3_leds_gpio
);
300 ath79_register_gpio_keys_polled(1, TL_WR841NV9_KEYS_POLL_INTERVAL
,
301 ARRAY_SIZE(tl_wr842n_v3_gpio_keys
),
302 tl_wr842n_v3_gpio_keys
);
304 ath79_register_usb();
307 MIPS_MACHINE(ATH79_MACH_TL_WR842N_V3
, "TL-WR842N-v3", "TP-LINK TL-WR842N/ND v3",