2 * TP-LINK TL-WR741ND v4 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"
22 #include "machtypes.h"
24 #define TL_WR741NDV4_GPIO_BTN_RESET 11
25 #define TL_WR741NDV4_GPIO_BTN_WPS 26
27 #define TL_WR741NDV4_GPIO_LED_WLAN 0
28 #define TL_WR741NDV4_GPIO_LED_QSS 1
29 #define TL_WR741NDV4_GPIO_LED_WAN 13
30 #define TL_WR741NDV4_GPIO_LED_LAN1 14
31 #define TL_WR741NDV4_GPIO_LED_LAN2 15
32 #define TL_WR741NDV4_GPIO_LED_LAN3 16
33 #define TL_WR741NDV4_GPIO_LED_LAN4 17
35 #define TL_WR741NDV4_GPIO_LED_SYSTEM 27
37 #define TL_WR741NDV4_KEYS_POLL_INTERVAL 20 /* msecs */
38 #define TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR741NDV4_KEYS_POLL_INTERVAL)
40 static const char *tl_wr741ndv4_part_probes
[] = {
45 static struct flash_platform_data tl_wr741ndv4_flash_data
= {
46 .part_probes
= tl_wr741ndv4_part_probes
,
49 static struct gpio_led tl_wr741ndv4_leds_gpio
[] __initdata
= {
51 .name
= "tp-link:green:lan1",
52 .gpio
= TL_WR741NDV4_GPIO_LED_LAN1
,
55 .name
= "tp-link:green:lan2",
56 .gpio
= TL_WR741NDV4_GPIO_LED_LAN2
,
59 .name
= "tp-link:green:lan3",
60 .gpio
= TL_WR741NDV4_GPIO_LED_LAN3
,
63 .name
= "tp-link:green:lan4",
64 .gpio
= TL_WR741NDV4_GPIO_LED_LAN4
,
67 .name
= "tp-link:green:qss",
68 .gpio
= TL_WR741NDV4_GPIO_LED_QSS
,
71 .name
= "tp-link:green:system",
72 .gpio
= TL_WR741NDV4_GPIO_LED_SYSTEM
,
75 .name
= "tp-link:green:wan",
76 .gpio
= TL_WR741NDV4_GPIO_LED_WAN
,
79 .name
= "tp-link:green:wlan",
80 .gpio
= TL_WR741NDV4_GPIO_LED_WLAN
,
85 static struct gpio_keys_button tl_wr741ndv4_gpio_keys
[] __initdata
= {
90 .debounce_interval
= TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL
,
91 .gpio
= TL_WR741NDV4_GPIO_BTN_RESET
,
96 .code
= KEY_WPS_BUTTON
,
97 .debounce_interval
= TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL
,
98 .gpio
= TL_WR741NDV4_GPIO_BTN_WPS
,
103 static void __init
tl_wr741ndv4_gmac_setup(void)
108 base
= ioremap(AR933X_GMAC_BASE
, AR933X_GMAC_SIZE
);
110 t
= __raw_readl(base
+ AR933X_GMAC_REG_ETH_CFG
);
111 t
|= (AR933X_ETH_CFG_SW_PHY_SWAP
| AR933X_ETH_CFG_SW_PHY_ADDR_SWAP
);
112 __raw_writel(t
, base
+ AR933X_GMAC_REG_ETH_CFG
);
117 static void __init
tl_wr741ndv4_setup(void)
119 u8
*mac
= (u8
*) KSEG1ADDR(0x1f01fc00);
120 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
122 tl_wr741ndv4_gmac_setup();
124 ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
125 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
126 AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
127 AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
128 AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
130 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio
),
131 tl_wr741ndv4_leds_gpio
);
133 ath79_register_gpio_keys_polled(1, TL_WR741NDV4_KEYS_POLL_INTERVAL
,
134 ARRAY_SIZE(tl_wr741ndv4_gpio_keys
),
135 tl_wr741ndv4_gpio_keys
);
137 ath79_register_m25p80(&tl_wr741ndv4_flash_data
);
138 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 1);
139 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, -1);
141 ath79_register_mdio(0, 0x0);
142 ath79_register_eth(1);
143 ath79_register_eth(0);
145 ath79_register_wmac(ee
, mac
);
148 MIPS_MACHINE(ATH79_MACH_TL_WR741ND_V4
, "TL-WR741ND-v4",
149 "TP-LINK TL-WR741ND v4", tl_wr741ndv4_setup
);