2 * TP-LINK TL-WR841N/ND v9/TL-WR842N/ND v3
4 * Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
5 * Copyright (C) 2016 Cezary Jackiewicz <cezary@eko.one.pl>
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"
25 #include "machtypes.h"
27 #define TL_WR841NV9_GPIO_LED_WLAN 13
28 #define TL_WR841NV9_GPIO_LED_QSS 3
29 #define TL_WR841NV9_GPIO_LED_WAN 4
30 #define TL_WR841NV9_GPIO_LED_LAN1 16
31 #define TL_WR841NV9_GPIO_LED_LAN2 15
32 #define TL_WR841NV9_GPIO_LED_LAN3 14
33 #define TL_WR841NV9_GPIO_LED_LAN4 11
35 #define TL_WR841NV9_GPIO_BTN_RESET 12
36 #define TL_WR841NV9_GPIO_BTN_WIFI 17
38 #define TL_WR842NV3_GPIO_LED_SYSTEM 2
39 #define TL_WR842NV3_GPIO_LED_WLAN 3
40 #define TL_WR842NV3_GPIO_LED_WAN_RED 4
41 #define TL_WR842NV3_GPIO_LED_WAN_GREEN 11
42 #define TL_WR842NV3_GPIO_LED_LAN1 12
43 #define TL_WR842NV3_GPIO_LED_LAN2 13
44 #define TL_WR842NV3_GPIO_LED_LAN3 14
45 #define TL_WR842NV3_GPIO_LED_LAN4 15
46 #define TL_WR842NV3_GPIO_LED_3G 16
47 #define TL_WR842NV3_GPIO_LED_WPS 17
49 #define TL_WR842NV3_GPIO_BTN_RESET 1
50 #define TL_WR842NV3_GPIO_BTN_WIFI 0
52 #define TL_WR841NV9_KEYS_POLL_INTERVAL 20 /* msecs */
53 #define TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR841NV9_KEYS_POLL_INTERVAL)
55 static const char *tl_wr841n_v9_part_probes[] = {
60 static struct flash_platform_data tl_wr841n_v9_flash_data = {
61 .part_probes = tl_wr841n_v9_part_probes,
64 static struct gpio_led tl_wr841n_v9_leds_gpio[] __initdata = {
66 .name = "tp-link:green:lan1",
67 .gpio = TL_WR841NV9_GPIO_LED_LAN1,
70 .name = "tp-link:green:lan2",
71 .gpio = TL_WR841NV9_GPIO_LED_LAN2,
74 .name = "tp-link:green:lan3",
75 .gpio = TL_WR841NV9_GPIO_LED_LAN3,
78 .name = "tp-link:green:lan4",
79 .gpio = TL_WR841NV9_GPIO_LED_LAN4,
82 .name = "tp-link:green:qss",
83 .gpio = TL_WR841NV9_GPIO_LED_QSS,
86 .name = "tp-link:green:wan",
87 .gpio = TL_WR841NV9_GPIO_LED_WAN,
90 .name = "tp-link:green:wlan",
91 .gpio = TL_WR841NV9_GPIO_LED_WLAN,
96 static struct gpio_keys_button tl_wr841n_v9_gpio_keys[] __initdata = {
98 .desc = "Reset button",
101 .debounce_interval = TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL,
102 .gpio = TL_WR841NV9_GPIO_BTN_RESET,
105 .desc = "WIFI button",
108 .debounce_interval = TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL,
109 .gpio = TL_WR841NV9_GPIO_BTN_WIFI,
114 static struct gpio_led tl_wr842n_v3_leds_gpio[] __initdata = {
116 .name = "tp-link:green:lan1",
117 .gpio = TL_WR842NV3_GPIO_LED_LAN1,
120 .name = "tp-link:green:lan2",
121 .gpio = TL_WR842NV3_GPIO_LED_LAN2,
124 .name = "tp-link:green:lan3",
125 .gpio = TL_WR842NV3_GPIO_LED_LAN3,
128 .name = "tp-link:green:lan4",
129 .gpio = TL_WR842NV3_GPIO_LED_LAN4,
132 .name = "tp-link:green:wan",
133 .gpio = TL_WR842NV3_GPIO_LED_WAN_GREEN,
136 .name = "tp-link:red:wan",
137 .gpio = TL_WR842NV3_GPIO_LED_WAN_RED,
140 .name = "tp-link:green:wlan",
141 .gpio = TL_WR842NV3_GPIO_LED_WLAN,
144 .name = "tp-link:green:system",
145 .gpio = TL_WR842NV3_GPIO_LED_SYSTEM,
148 .name = "tp-link:green:3g",
149 .gpio = TL_WR842NV3_GPIO_LED_3G,
152 .name = "tp-link:green:wps",
153 .gpio = TL_WR842NV3_GPIO_LED_WPS,
158 static struct gpio_keys_button tl_wr842n_v3_gpio_keys[] __initdata = {
160 .desc = "Reset button",
163 .debounce_interval = TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL,
164 .gpio = TL_WR842NV3_GPIO_BTN_RESET,
167 .desc = "WIFI button",
170 .debounce_interval = TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL,
171 .gpio = TL_WR842NV3_GPIO_BTN_WIFI,
177 static void __init tl_ap143_setup(void)
179 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
180 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
183 ath79_register_m25p80(&tl_wr841n_v9_flash_data);
185 ath79_setup_ar933x_phy4_switch(false, false);
187 ath79_register_mdio(0, 0x0);
190 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
191 ath79_eth1_data.duplex = DUPLEX_FULL;
192 ath79_switch_data.phy_poll_mask |= BIT(4);
193 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
194 ath79_register_eth(1);
197 ath79_switch_data.phy4_mii_en = 1;
198 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
199 ath79_eth0_data.duplex = DUPLEX_FULL;
200 ath79_eth0_data.speed = SPEED_100;
201 ath79_eth0_data.phy_mask = BIT(4);
202 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
203 ath79_register_eth(0);
205 ath79_init_mac(tmpmac, mac, 0);
206 ath79_register_wmac(ee, tmpmac);
209 static void __init tl_wr841n_v9_setup(void)
213 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v9_leds_gpio),
214 tl_wr841n_v9_leds_gpio);
216 ath79_register_gpio_keys_polled(1, TL_WR841NV9_KEYS_POLL_INTERVAL,
217 ARRAY_SIZE(tl_wr841n_v9_gpio_keys),
218 tl_wr841n_v9_gpio_keys);
221 MIPS_MACHINE(ATH79_MACH_TL_WR841N_V9, "TL-WR841N-v9", "TP-LINK TL-WR841N/ND v9",
224 static void __init tl_wr842n_v3_setup(void)
228 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr842n_v3_leds_gpio),
229 tl_wr842n_v3_leds_gpio);
231 ath79_register_gpio_keys_polled(1, TL_WR841NV9_KEYS_POLL_INTERVAL,
232 ARRAY_SIZE(tl_wr842n_v3_gpio_keys),
233 tl_wr842n_v3_gpio_keys);
235 ath79_register_usb();
238 MIPS_MACHINE(ATH79_MACH_TL_WR842N_V3, "TL-WR842N-v3", "TP-LINK TL-WR842N/ND v3",