OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * TP-LINK TL-WR841N/ND v8/TL-MR3420 v2 board support |
||
3 | * |
||
4 | * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org> |
||
5 | * |
||
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. |
||
9 | */ |
||
10 | |||
11 | #include <linux/gpio.h> |
||
12 | #include <linux/platform_device.h> |
||
13 | |||
14 | #include <asm/mach-ath79/ath79.h> |
||
15 | #include <asm/mach-ath79/ar71xx_regs.h> |
||
16 | |||
17 | #include "common.h" |
||
18 | #include "dev-eth.h" |
||
19 | #include "dev-gpio-buttons.h" |
||
20 | #include "dev-leds-gpio.h" |
||
21 | #include "dev-m25p80.h" |
||
22 | #include "dev-usb.h" |
||
23 | #include "dev-wmac.h" |
||
24 | #include "machtypes.h" |
||
25 | |||
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 |
||
34 | |||
35 | #define TL_WR841NV8_GPIO_BTN_RESET 17 |
||
36 | #define TL_WR841NV8_GPIO_SW_RFKILL 16 /* WPS for MR3420 v2 */ |
||
37 | |||
38 | #define TL_MR3420V2_GPIO_LED_3G 11 |
||
39 | #define TL_MR3420V2_GPIO_USB_POWER 4 |
||
40 | |||
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 |
||
49 | |||
50 | #define TL_WR841NV8_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
51 | #define TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR841NV8_KEYS_POLL_INTERVAL) |
||
52 | |||
53 | static const char *tl_wr841n_v8_part_probes[] = { |
||
54 | "tp-link", |
||
55 | NULL, |
||
56 | }; |
||
57 | |||
58 | static struct flash_platform_data tl_wr841n_v8_flash_data = { |
||
59 | .part_probes = tl_wr841n_v8_part_probes, |
||
60 | }; |
||
61 | |||
62 | static struct gpio_led tl_wr841n_v8_leds_gpio[] __initdata = { |
||
63 | { |
||
64 | .name = "tp-link:green:lan1", |
||
65 | .gpio = TL_WR841NV8_GPIO_LED_LAN1, |
||
66 | .active_low = 1, |
||
67 | }, { |
||
68 | .name = "tp-link:green:lan2", |
||
69 | .gpio = TL_WR841NV8_GPIO_LED_LAN2, |
||
70 | .active_low = 1, |
||
71 | }, { |
||
72 | .name = "tp-link:green:lan3", |
||
73 | .gpio = TL_WR841NV8_GPIO_LED_LAN3, |
||
74 | .active_low = 1, |
||
75 | }, { |
||
76 | .name = "tp-link:green:lan4", |
||
77 | .gpio = TL_WR841NV8_GPIO_LED_LAN4, |
||
78 | .active_low = 1, |
||
79 | }, { |
||
80 | .name = "tp-link:green:qss", |
||
81 | .gpio = TL_WR841NV8_GPIO_LED_QSS, |
||
82 | .active_low = 1, |
||
83 | }, { |
||
84 | .name = "tp-link:green:system", |
||
85 | .gpio = TL_WR841NV8_GPIO_LED_SYSTEM, |
||
86 | .active_low = 1, |
||
87 | }, { |
||
88 | .name = "tp-link:green:wan", |
||
89 | .gpio = TL_WR841NV8_GPIO_LED_WAN, |
||
90 | .active_low = 1, |
||
91 | }, { |
||
92 | .name = "tp-link:green:wlan", |
||
93 | .gpio = TL_WR841NV8_GPIO_LED_WLAN, |
||
94 | .active_low = 1, |
||
95 | }, { |
||
96 | /* the 3G LED is only present on the MR3420 v2 */ |
||
97 | .name = "tp-link:green:3g", |
||
98 | .gpio = TL_MR3420V2_GPIO_LED_3G, |
||
99 | .active_low = 1, |
||
100 | }, |
||
101 | }; |
||
102 | |||
103 | static struct gpio_keys_button tl_wr841n_v8_gpio_keys[] __initdata = { |
||
104 | { |
||
105 | .desc = "Reset button", |
||
106 | .type = EV_KEY, |
||
107 | .code = KEY_RESTART, |
||
108 | .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL, |
||
109 | .gpio = TL_WR841NV8_GPIO_BTN_RESET, |
||
110 | .active_low = 1, |
||
111 | }, { |
||
112 | .desc = "RFKILL switch", |
||
113 | .type = EV_SW, |
||
114 | .code = KEY_RFKILL, |
||
115 | .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL, |
||
116 | .gpio = TL_WR841NV8_GPIO_SW_RFKILL, |
||
117 | .active_low = 0, |
||
118 | } |
||
119 | }; |
||
120 | |||
121 | static struct gpio_keys_button tl_mr3420v2_gpio_keys[] __initdata = { |
||
122 | { |
||
123 | .desc = "Reset button", |
||
124 | .type = EV_KEY, |
||
125 | .code = KEY_RESTART, |
||
126 | .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL, |
||
127 | .gpio = TL_WR841NV8_GPIO_BTN_RESET, |
||
128 | .active_low = 1, |
||
129 | }, { |
||
130 | .desc = "WPS", |
||
131 | .type = EV_KEY, |
||
132 | .code = KEY_WPS_BUTTON, |
||
133 | .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL, |
||
134 | .gpio = TL_WR841NV8_GPIO_SW_RFKILL, |
||
135 | .active_low = 0, |
||
136 | } |
||
137 | }; |
||
138 | |||
139 | static struct gpio_led tl_wr941nd_v5_leds_gpio[] __initdata = { |
||
140 | { |
||
141 | .name = "tp-link:green:lan1", |
||
142 | .gpio = TL_WR941NDV5_GPIO_LED_LAN1, |
||
143 | .active_low = 1, |
||
144 | }, { |
||
145 | .name = "tp-link:green:lan2", |
||
146 | .gpio = TL_WR941NDV5_GPIO_LED_LAN2, |
||
147 | .active_low = 1, |
||
148 | }, { |
||
149 | .name = "tp-link:green:lan3", |
||
150 | .gpio = TL_WR941NDV5_GPIO_LED_LAN3, |
||
151 | .active_low = 1, |
||
152 | }, { |
||
153 | .name = "tp-link:green:lan4", |
||
154 | .gpio = TL_WR941NDV5_GPIO_LED_LAN4, |
||
155 | .active_low = 1, |
||
156 | }, { |
||
157 | .name = "tp-link:green:qss", |
||
158 | .gpio = TL_WR941NDV5_GPIO_LED_QSS, |
||
159 | .active_low = 1, |
||
160 | }, { |
||
161 | .name = "tp-link:green:system", |
||
162 | .gpio = TL_WR941NDV5_GPIO_LED_SYSTEM, |
||
163 | .active_low = 1, |
||
164 | }, { |
||
165 | .name = "tp-link:green:wan", |
||
166 | .gpio = TL_WR941NDV5_GPIO_LED_WAN, |
||
167 | .active_low = 1, |
||
168 | }, { |
||
169 | .name = "tp-link:green:wlan", |
||
170 | .gpio = TL_WR941NDV5_GPIO_LED_WLAN, |
||
171 | .active_low = 1, |
||
172 | }, |
||
173 | }; |
||
174 | |||
175 | static void __init tl_ap123_setup(void) |
||
176 | { |
||
177 | u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00); |
||
178 | u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); |
||
179 | |||
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); |
||
184 | |||
185 | /* config gpio4 as normal gpio function */ |
||
186 | ath79_gpio_output_select(TL_MR3420V2_GPIO_USB_POWER, |
||
187 | AR934X_GPIO_OUT_GPIO); |
||
188 | |||
189 | ath79_register_m25p80(&tl_wr841n_v8_flash_data); |
||
190 | |||
191 | ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP); |
||
192 | |||
193 | ath79_register_mdio(1, 0x0); |
||
194 | |||
195 | ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1); |
||
196 | ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0); |
||
197 | |||
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); |
||
205 | |||
206 | /* GMAC1 is connected to the internal switch */ |
||
207 | ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; |
||
208 | ath79_register_eth(1); |
||
209 | |||
210 | ath79_register_wmac(ee, mac); |
||
211 | } |
||
212 | |||
213 | static void __init tl_wr841n_v8_setup(void) |
||
214 | { |
||
215 | tl_ap123_setup(); |
||
216 | |||
217 | ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio) - 1, |
||
218 | tl_wr841n_v8_leds_gpio); |
||
219 | |||
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); |
||
223 | } |
||
224 | |||
225 | MIPS_MACHINE(ATH79_MACH_TL_WR841N_V8, "TL-WR841N-v8", "TP-LINK TL-WR841N/ND v8", |
||
226 | tl_wr841n_v8_setup); |
||
227 | |||
228 | |||
229 | static void __init tl_wr842n_v2_setup(void) |
||
230 | { |
||
231 | tl_ap123_setup(); |
||
232 | |||
233 | ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio), |
||
234 | tl_wr841n_v8_leds_gpio); |
||
235 | |||
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); |
||
239 | |||
240 | gpio_request_one(TL_MR3420V2_GPIO_USB_POWER, |
||
241 | GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED, |
||
242 | "USB power"); |
||
243 | |||
244 | ath79_register_usb(); |
||
245 | } |
||
246 | |||
247 | MIPS_MACHINE(ATH79_MACH_TL_WR842N_V2, "TL-WR842N-v2", "TP-LINK TL-WR842N/ND v2", |
||
248 | tl_wr842n_v2_setup); |
||
249 | |||
250 | static void __init tl_mr3420v2_setup(void) |
||
251 | { |
||
252 | tl_ap123_setup(); |
||
253 | |||
254 | ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio), |
||
255 | tl_wr841n_v8_leds_gpio); |
||
256 | |||
257 | ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL, |
||
258 | ARRAY_SIZE(tl_mr3420v2_gpio_keys), |
||
259 | tl_mr3420v2_gpio_keys); |
||
260 | |||
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, |
||
264 | "USB power"); |
||
265 | |||
266 | ath79_register_usb(); |
||
267 | } |
||
268 | |||
269 | MIPS_MACHINE(ATH79_MACH_TL_MR3420_V2, "TL-MR3420-v2", "TP-LINK TL-MR3420 v2", |
||
270 | tl_mr3420v2_setup); |
||
271 | |||
272 | |||
273 | static void __init tl_wr941nd_v5_setup(void) |
||
274 | { |
||
275 | tl_ap123_setup(); |
||
276 | |||
277 | ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr941nd_v5_leds_gpio), |
||
278 | tl_wr941nd_v5_leds_gpio); |
||
279 | |||
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); |
||
283 | } |
||
284 | |||
285 | MIPS_MACHINE(ATH79_MACH_TL_WR941ND_V5, "TL-WR941ND-v5", "TP-LINK TL-WR941N/ND v5", |
||
286 | tl_wr941nd_v5_setup); |