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_LED_3G 26
38 #define TL_MR3220V2_GPIO_USB_POWER 8
40 #define TL_WR741NDV4_KEYS_POLL_INTERVAL 20 /* msecs */
41 #define TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR741NDV4_KEYS_POLL_INTERVAL)
43 static const char *tl_wr741ndv4_part_probes[] = {
48 static struct flash_platform_data tl_wr741ndv4_flash_data = {
49 .part_probes = tl_wr741ndv4_part_probes,
52 static struct gpio_led tl_wr741ndv4_leds_gpio[] __initdata = {
54 .name = "tp-link:green:lan1",
55 .gpio = TL_WR741NDV4_GPIO_LED_LAN1,
58 .name = "tp-link:green:lan2",
59 .gpio = TL_WR741NDV4_GPIO_LED_LAN2,
62 .name = "tp-link:green:lan3",
63 .gpio = TL_WR741NDV4_GPIO_LED_LAN3,
66 .name = "tp-link:green:lan4",
67 .gpio = TL_WR741NDV4_GPIO_LED_LAN4,
70 .name = "tp-link:green:qss",
71 .gpio = TL_WR741NDV4_GPIO_LED_QSS,
74 .name = "tp-link:green:system",
75 .gpio = TL_WR741NDV4_GPIO_LED_SYSTEM,
78 .name = "tp-link:green:wan",
79 .gpio = TL_WR741NDV4_GPIO_LED_WAN,
82 .name = "tp-link:green:wlan",
83 .gpio = TL_WR741NDV4_GPIO_LED_WLAN,
86 /* the 3G LED is only present on the MR3220 v2 */
87 .name = "tp-link:green:3g",
88 .gpio = TL_MR3220V2_GPIO_LED_3G,
93 static struct gpio_keys_button tl_wr741ndv4_gpio_keys[] __initdata = {
98 .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
99 .gpio = TL_WR741NDV4_GPIO_BTN_RESET,
102 /* the WPS button is only present on the WR741ND v4 */
105 .code = KEY_WPS_BUTTON,
106 .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
107 .gpio = TL_WR741NDV4_GPIO_BTN_WPS,
112 static void __init tl_ap121_setup(void)
114 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
115 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
117 ath79_setup_ar933x_phy4_switch(true, true);
119 ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
120 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
121 AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
122 AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
123 AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
125 ath79_register_m25p80(&tl_wr741ndv4_flash_data);
126 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
127 ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
129 ath79_register_mdio(0, 0x0);
130 ath79_register_eth(1);
131 ath79_register_eth(0);
133 ath79_register_wmac(ee, mac);
136 static void __init tl_wr741ndv4_setup(void)
140 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio) - 1,
141 tl_wr741ndv4_leds_gpio);
142 ath79_register_gpio_keys_polled(1, TL_WR741NDV4_KEYS_POLL_INTERVAL,
143 ARRAY_SIZE(tl_wr741ndv4_gpio_keys),
144 tl_wr741ndv4_gpio_keys);
147 MIPS_MACHINE(ATH79_MACH_TL_WR741ND_V4, "TL-WR741ND-v4",
148 "TP-LINK TL-WR741ND v4", tl_wr741ndv4_setup);
150 static void __init tl_mr3220v2_setup(void)
154 gpio_request_one(TL_MR3220V2_GPIO_USB_POWER,
155 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
157 ath79_register_usb();
159 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio),
160 tl_wr741ndv4_leds_gpio);
161 ath79_register_gpio_keys_polled(1, TL_WR741NDV4_KEYS_POLL_INTERVAL,
162 ARRAY_SIZE(tl_wr741ndv4_gpio_keys) - 1,
163 tl_wr741ndv4_gpio_keys);
166 MIPS_MACHINE(ATH79_MACH_TL_MR3220_V2, "TL-MR3220-v2",
167 "TP-LINK TL-MR3220 v2", tl_mr3220v2_setup);