2 * TP-LINK TL-WR841N/ND v8/TL-MR3420 v2 board support
4 * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
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.
11 #include <linux/gpio.h>
12 #include <linux/platform_device.h>
14 #include <asm/mach-ath79/ath79.h>
15 #include <asm/mach-ath79/ar71xx_regs.h>
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
24 #include "machtypes.h"
26 #define TL_WR841NV8_GPIO_LED_WLAN 13
27 #define TL_WR841NV8_GPIO_LED_QSS 15
28 #define TL_WR841NV8_GPIO_LED_WAN 18
29 #define TL_WR841NV8_GPIO_LED_LAN1 19
30 #define TL_WR841NV8_GPIO_LED_LAN2 20
31 #define TL_WR841NV8_GPIO_LED_LAN3 21
32 #define TL_WR841NV8_GPIO_LED_LAN4 12
33 #define TL_WR841NV8_GPIO_LED_SYSTEM 14
35 #define TL_WR841NV8_GPIO_BTN_RESET 17
36 #define TL_WR841NV8_GPIO_SW_RFKILL 16 /* WPS for MR3420 v2 */
38 #define TL_MR3420V2_GPIO_LED_3G 11
39 #define TL_MR3420V2_GPIO_USB_POWER 4
41 #define TL_WR941NDV5_GPIO_LED_WLAN 13
42 #define TL_WR941NDV5_GPIO_LED_QSS 15
43 #define TL_WR941NDV5_GPIO_LED_WAN 18
44 #define TL_WR941NDV5_GPIO_LED_LAN1 19
45 #define TL_WR941NDV5_GPIO_LED_LAN2 20
46 #define TL_WR941NDV5_GPIO_LED_LAN3 2
47 #define TL_WR941NDV5_GPIO_LED_LAN4 3
48 #define TL_WR941NDV5_GPIO_LED_SYSTEM 14
50 #define TL_WR841NV8_KEYS_POLL_INTERVAL 20 /* msecs */
51 #define TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR841NV8_KEYS_POLL_INTERVAL)
53 static const char *tl_wr841n_v8_part_probes
[] = {
58 static struct flash_platform_data tl_wr841n_v8_flash_data
= {
59 .part_probes
= tl_wr841n_v8_part_probes
,
62 static struct gpio_led tl_wr841n_v8_leds_gpio
[] __initdata
= {
64 .name
= "tp-link:green:lan1",
65 .gpio
= TL_WR841NV8_GPIO_LED_LAN1
,
68 .name
= "tp-link:green:lan2",
69 .gpio
= TL_WR841NV8_GPIO_LED_LAN2
,
72 .name
= "tp-link:green:lan3",
73 .gpio
= TL_WR841NV8_GPIO_LED_LAN3
,
76 .name
= "tp-link:green:lan4",
77 .gpio
= TL_WR841NV8_GPIO_LED_LAN4
,
80 .name
= "tp-link:green:qss",
81 .gpio
= TL_WR841NV8_GPIO_LED_QSS
,
84 .name
= "tp-link:green:system",
85 .gpio
= TL_WR841NV8_GPIO_LED_SYSTEM
,
88 .name
= "tp-link:green:wan",
89 .gpio
= TL_WR841NV8_GPIO_LED_WAN
,
92 .name
= "tp-link:green:wlan",
93 .gpio
= TL_WR841NV8_GPIO_LED_WLAN
,
96 /* the 3G LED is only present on the MR3420 v2 */
97 .name
= "tp-link:green:3g",
98 .gpio
= TL_MR3420V2_GPIO_LED_3G
,
103 static struct gpio_keys_button tl_wr841n_v8_gpio_keys
[] __initdata
= {
105 .desc
= "Reset button",
108 .debounce_interval
= TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL
,
109 .gpio
= TL_WR841NV8_GPIO_BTN_RESET
,
112 .desc
= "RFKILL switch",
115 .debounce_interval
= TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL
,
116 .gpio
= TL_WR841NV8_GPIO_SW_RFKILL
,
121 static struct gpio_keys_button tl_mr3420v2_gpio_keys
[] __initdata
= {
123 .desc
= "Reset button",
126 .debounce_interval
= TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL
,
127 .gpio
= TL_WR841NV8_GPIO_BTN_RESET
,
132 .code
= KEY_WPS_BUTTON
,
133 .debounce_interval
= TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL
,
134 .gpio
= TL_WR841NV8_GPIO_SW_RFKILL
,
139 static struct gpio_led tl_wr941nd_v5_leds_gpio
[] __initdata
= {
141 .name
= "tp-link:green:lan1",
142 .gpio
= TL_WR941NDV5_GPIO_LED_LAN1
,
145 .name
= "tp-link:green:lan2",
146 .gpio
= TL_WR941NDV5_GPIO_LED_LAN2
,
149 .name
= "tp-link:green:lan3",
150 .gpio
= TL_WR941NDV5_GPIO_LED_LAN3
,
153 .name
= "tp-link:green:lan4",
154 .gpio
= TL_WR941NDV5_GPIO_LED_LAN4
,
157 .name
= "tp-link:green:qss",
158 .gpio
= TL_WR941NDV5_GPIO_LED_QSS
,
161 .name
= "tp-link:green:system",
162 .gpio
= TL_WR941NDV5_GPIO_LED_SYSTEM
,
165 .name
= "tp-link:green:wan",
166 .gpio
= TL_WR941NDV5_GPIO_LED_WAN
,
169 .name
= "tp-link:green:wlan",
170 .gpio
= TL_WR941NDV5_GPIO_LED_WLAN
,
175 static void __init
tl_ap123_setup(void)
177 u8
*mac
= (u8
*) KSEG1ADDR(0x1f01fc00);
178 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
180 /* Disable JTAG, enabling GPIOs 0-3 */
181 /* Configure OBS4 line, for GPIO 4*/
182 ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE
,
183 AR934X_GPIO_FUNC_CLK_OBS4_EN
);
185 /* config gpio4 as normal gpio function */
186 ath79_gpio_output_select(TL_MR3420V2_GPIO_USB_POWER
,
187 AR934X_GPIO_OUT_GPIO
);
189 ath79_register_m25p80(&tl_wr841n_v8_flash_data
);
191 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP
);
193 ath79_register_mdio(1, 0x0);
195 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, -1);
196 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 0);
198 /* GMAC0 is connected to the PHY0 of the internal switch */
199 ath79_switch_data
.phy4_mii_en
= 1;
200 ath79_switch_data
.phy_poll_mask
= BIT(0);
201 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
202 ath79_eth0_data
.phy_mask
= BIT(0);
203 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio1_device
.dev
;
204 ath79_register_eth(0);
206 /* GMAC1 is connected to the internal switch */
207 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_GMII
;
208 ath79_register_eth(1);
210 ath79_register_wmac(ee
, mac
);
213 static void __init
tl_wr841n_v8_setup(void)
217 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio
) - 1,
218 tl_wr841n_v8_leds_gpio
);
220 ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL
,
221 ARRAY_SIZE(tl_wr841n_v8_gpio_keys
),
222 tl_wr841n_v8_gpio_keys
);
225 MIPS_MACHINE(ATH79_MACH_TL_WR841N_V8
, "TL-WR841N-v8", "TP-LINK TL-WR841N/ND v8",
229 static void __init
tl_wr842n_v2_setup(void)
233 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio
),
234 tl_wr841n_v8_leds_gpio
);
236 ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL
,
237 ARRAY_SIZE(tl_wr841n_v8_gpio_keys
),
238 tl_wr841n_v8_gpio_keys
);
240 gpio_request_one(TL_MR3420V2_GPIO_USB_POWER
,
241 GPIOF_OUT_INIT_HIGH
| GPIOF_EXPORT_DIR_FIXED
,
244 ath79_register_usb();
247 MIPS_MACHINE(ATH79_MACH_TL_WR842N_V2
, "TL-WR842N-v2", "TP-LINK TL-WR842N/ND v2",
250 static void __init
tl_mr3420v2_setup(void)
254 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio
),
255 tl_wr841n_v8_leds_gpio
);
257 ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL
,
258 ARRAY_SIZE(tl_mr3420v2_gpio_keys
),
259 tl_mr3420v2_gpio_keys
);
261 /* enable power for the USB port */
262 gpio_request_one(TL_MR3420V2_GPIO_USB_POWER
,
263 GPIOF_OUT_INIT_HIGH
| GPIOF_EXPORT_DIR_FIXED
,
266 ath79_register_usb();
269 MIPS_MACHINE(ATH79_MACH_TL_MR3420_V2
, "TL-MR3420-v2", "TP-LINK TL-MR3420 v2",
273 static void __init
tl_wr941nd_v5_setup(void)
277 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr941nd_v5_leds_gpio
),
278 tl_wr941nd_v5_leds_gpio
);
280 ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL
,
281 ARRAY_SIZE(tl_wr841n_v8_gpio_keys
),
282 tl_wr841n_v8_gpio_keys
);
285 MIPS_MACHINE(ATH79_MACH_TL_WR941ND_V5
, "TL-WR941ND-v5", "TP-LINK TL-WR941N/ND v5",
286 tl_wr941nd_v5_setup
);