ar71xx: move arch specific files to files-2.6.39
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files-2.6.39 / arch / mips / ar71xx / mach-tl-wr741nd-v4.c
1 /*
2 * TP-LINK TL-WR741ND v4 board support
3 *
4 * Copyright (C) 2011 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
13 #include <asm/mach-ar71xx/ar71xx.h>
14
15 #include "machtype.h"
16 #include "devices.h"
17 #include "dev-ar9xxx-wmac.h"
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-m25p80.h"
21
22 #define TL_WR741NDV4_GPIO_BTN_RESET 11
23 #define TL_WR741NDV4_GPIO_BTN_WPS 26
24
25 #define TL_WR741NDV4_GPIO_LED_WLAN 0
26 #define TL_WR741NDV4_GPIO_LED_QSS 1
27 #define TL_WR741NDV4_GPIO_LED_WAN 13
28 #define TL_WR741NDV4_GPIO_LED_LAN1 14
29 #define TL_WR741NDV4_GPIO_LED_LAN2 15
30 #define TL_WR741NDV4_GPIO_LED_LAN3 16
31 #define TL_WR741NDV4_GPIO_LED_LAN4 17
32
33 #define TL_WR741NDV4_GPIO_LED_SYSTEM 27
34
35 #define TL_WR741NDV4_KEYS_POLL_INTERVAL 20 /* msecs */
36 #define TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR741NDV4_KEYS_POLL_INTERVAL)
37
38 static const char *tl_wr741ndv4_part_probes[] = {
39 "tp-link",
40 NULL,
41 };
42
43 static struct flash_platform_data tl_wr741ndv4_flash_data = {
44 .part_probes = tl_wr741ndv4_part_probes,
45 };
46
47 static struct gpio_led tl_wr741ndv4_leds_gpio[] __initdata = {
48 {
49 .name = "tp-link:green:lan1",
50 .gpio = TL_WR741NDV4_GPIO_LED_LAN1,
51 .active_low = 0,
52 }, {
53 .name = "tp-link:green:lan2",
54 .gpio = TL_WR741NDV4_GPIO_LED_LAN2,
55 .active_low = 0,
56 }, {
57 .name = "tp-link:green:lan3",
58 .gpio = TL_WR741NDV4_GPIO_LED_LAN3,
59 .active_low = 0,
60 }, {
61 .name = "tp-link:green:lan4",
62 .gpio = TL_WR741NDV4_GPIO_LED_LAN4,
63 .active_low = 1,
64 }, {
65 .name = "tp-link:green:qss",
66 .gpio = TL_WR741NDV4_GPIO_LED_QSS,
67 .active_low = 0,
68 }, {
69 .name = "tp-link:green:system",
70 .gpio = TL_WR741NDV4_GPIO_LED_SYSTEM,
71 .active_low = 1,
72 }, {
73 .name = "tp-link:green:wan",
74 .gpio = TL_WR741NDV4_GPIO_LED_WAN,
75 .active_low = 0,
76 }, {
77 .name = "tp-link:green:wlan",
78 .gpio = TL_WR741NDV4_GPIO_LED_WLAN,
79 .active_low = 0,
80 },
81 };
82
83 static struct gpio_keys_button tl_wr741ndv4_gpio_keys[] __initdata = {
84 {
85 .desc = "reset",
86 .type = EV_KEY,
87 .code = KEY_RESTART,
88 .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
89 .gpio = TL_WR741NDV4_GPIO_BTN_RESET,
90 .active_low = 1,
91 } , {
92 .desc = "WPS",
93 .type = EV_KEY,
94 .code = KEY_WPS_BUTTON,
95 .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
96 .gpio = TL_WR741NDV4_GPIO_BTN_WPS,
97 .active_low = 1,
98 }
99 };
100
101 static void __init tl_wr741ndv4_gmac_setup(void)
102 {
103 void __iomem *base;
104 u32 t;
105
106 base = ioremap(AR933X_GMAC_BASE, AR933X_GMAC_SIZE);
107
108 t = __raw_readl(base + AR933X_GMAC_REG_ETH_CFG);
109 t |= (AR933X_ETH_CFG_SW_PHY_SWAP | AR933X_ETH_CFG_SW_PHY_ADDR_SWAP);
110 __raw_writel(t, base + AR933X_GMAC_REG_ETH_CFG);
111
112 iounmap(base);
113 }
114
115 static void __init tl_wr741ndv4_setup(void)
116 {
117 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
118 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
119
120 tl_wr741ndv4_gmac_setup();
121
122 ar71xx_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
123 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
124 AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
125 AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
126 AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
127
128 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio),
129 tl_wr741ndv4_leds_gpio);
130
131 ar71xx_register_gpio_keys_polled(1, TL_WR741NDV4_KEYS_POLL_INTERVAL,
132 ARRAY_SIZE(tl_wr741ndv4_gpio_keys),
133 tl_wr741ndv4_gpio_keys);
134
135 ar71xx_add_device_m25p80(&tl_wr741ndv4_flash_data);
136 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 1);
137 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, -1);
138
139 ar71xx_add_device_mdio(0, 0x0);
140 ar71xx_add_device_eth(1);
141 ar71xx_add_device_eth(0);
142
143 ar9xxx_add_device_wmac(ee, mac);
144 }
145
146 MIPS_MACHINE(AR71XX_MACH_TL_WR741ND_V4, "TL-WR741ND-v4",
147 "TP-LINK TL-WR741ND v4", tl_wr741ndv4_setup);