2 * TP-LINK TL-WR741ND v4/TL-MR3220 v2 board support
4 * Copyright (C) 2011-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>
13 #include <asm/mach-ath79/ath79.h>
14 #include <asm/mach-ath79/ar71xx_regs.h>
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-m25p80.h"
23 #include "machtypes.h"
25 #define TL_WR741NDV4_GPIO_BTN_RESET 11
26 #define TL_WR741NDV4_GPIO_BTN_WPS 26
28 #define TL_WR741NDV4_GPIO_LED_WLAN 0
29 #define TL_WR741NDV4_GPIO_LED_QSS 1
30 #define TL_WR741NDV4_GPIO_LED_WAN 13
31 #define TL_WR741NDV4_GPIO_LED_LAN1 14
32 #define TL_WR741NDV4_GPIO_LED_LAN2 15
33 #define TL_WR741NDV4_GPIO_LED_LAN3 16
34 #define TL_WR741NDV4_GPIO_LED_LAN4 17
35 #define TL_WR741NDV4_GPIO_LED_SYSTEM 27
37 #define TL_MR3220V2_GPIO_BTN_WPS 11
38 #define TL_MR3220V2_GPIO_BTN_WIFI 24
40 #define TL_MR3220V2_GPIO_LED_3G 26
41 #define TL_MR3220V2_GPIO_USB_POWER 8
43 #define TL_WR741NDV4_KEYS_POLL_INTERVAL 20 /* msecs */
44 #define TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR741NDV4_KEYS_POLL_INTERVAL)
46 static const char *tl_wr741ndv4_part_probes[] = {
51 static struct flash_platform_data tl_wr741ndv4_flash_data = {
52 .part_probes = tl_wr741ndv4_part_probes,
55 static struct gpio_led tl_wr741ndv4_leds_gpio[] __initdata = {
57 .name = "tp-link:green:lan1",
58 .gpio = TL_WR741NDV4_GPIO_LED_LAN1,
61 .name = "tp-link:green:lan2",
62 .gpio = TL_WR741NDV4_GPIO_LED_LAN2,
65 .name = "tp-link:green:lan3",
66 .gpio = TL_WR741NDV4_GPIO_LED_LAN3,
69 .name = "tp-link:green:lan4",
70 .gpio = TL_WR741NDV4_GPIO_LED_LAN4,
73 .name = "tp-link:green:qss",
74 .gpio = TL_WR741NDV4_GPIO_LED_QSS,
77 .name = "tp-link:green:system",
78 .gpio = TL_WR741NDV4_GPIO_LED_SYSTEM,
81 .name = "tp-link:green:wan",
82 .gpio = TL_WR741NDV4_GPIO_LED_WAN,
85 .name = "tp-link:green:wlan",
86 .gpio = TL_WR741NDV4_GPIO_LED_WLAN,
89 /* the 3G LED is only present on the MR3220 v2 */
90 .name = "tp-link:green:3g",
91 .gpio = TL_MR3220V2_GPIO_LED_3G,
96 static struct gpio_keys_button tl_wr741ndv4_gpio_keys[] __initdata = {
101 .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
102 .gpio = TL_WR741NDV4_GPIO_BTN_RESET,
107 .code = KEY_WPS_BUTTON,
108 .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
109 .gpio = TL_WR741NDV4_GPIO_BTN_WPS,
114 static struct gpio_keys_button tl_mr3220v2_gpio_keys[] __initdata = {
118 .code = KEY_WPS_BUTTON,
119 .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
120 .gpio = TL_MR3220V2_GPIO_BTN_WPS,
123 .desc = "WIFI button",
126 .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
127 .gpio = TL_MR3220V2_GPIO_BTN_WIFI,
132 static void __init tl_ap121_setup(void)
134 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
135 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
137 ath79_setup_ar933x_phy4_switch(true, true);
139 ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
140 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
141 AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
142 AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
143 AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
145 ath79_register_m25p80(&tl_wr741ndv4_flash_data);
146 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
147 ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
149 ath79_register_mdio(0, 0x0);
150 ath79_register_eth(1);
151 ath79_register_eth(0);
153 ath79_register_wmac(ee, mac);
156 static void __init tl_wr741ndv4_setup(void)
160 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio) - 1,
161 tl_wr741ndv4_leds_gpio);
162 ath79_register_gpio_keys_polled(1, TL_WR741NDV4_KEYS_POLL_INTERVAL,
163 ARRAY_SIZE(tl_wr741ndv4_gpio_keys),
164 tl_wr741ndv4_gpio_keys);
167 MIPS_MACHINE(ATH79_MACH_TL_WR741ND_V4, "TL-WR741ND-v4",
168 "TP-LINK TL-WR741ND v4", tl_wr741ndv4_setup);
170 static void __init tl_mr3220v2_setup(void)
174 gpio_request_one(TL_MR3220V2_GPIO_USB_POWER,
175 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
177 ath79_register_usb();
179 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio),
180 tl_wr741ndv4_leds_gpio);
181 ath79_register_gpio_keys_polled(1, TL_WR741NDV4_KEYS_POLL_INTERVAL,
182 ARRAY_SIZE(tl_mr3220v2_gpio_keys),
183 tl_mr3220v2_gpio_keys);
186 MIPS_MACHINE(ATH79_MACH_TL_MR3220_V2, "TL-MR3220-v2",
187 "TP-LINK TL-MR3220 v2", tl_mr3220v2_setup);