ar71xx: add linux 3.14 support
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / patches-3.14 / 608-MIPS-ath79-ubnt-xm-add-more-boards.patch
1 --- a/arch/mips/ath79/mach-ubnt-xm.c
2 +++ b/arch/mips/ath79/mach-ubnt-xm.c
3 @@ -12,16 +12,22 @@
4
5 #include <linux/init.h>
6 #include <linux/pci.h>
7 +#include <linux/platform_device.h>
8 #include <linux/ath9k_platform.h>
9 +#include <linux/etherdevice.h>
10 +#include <linux/ar8216_platform.h>
11
12 #include <asm/mach-ath79/irq.h>
13 +#include <asm/mach-ath79/ar71xx_regs.h>
14
15 #include "dev-ap9x-pci.h"
16 +#include "dev-eth.h"
17 #include "dev-gpio-buttons.h"
18 #include "dev-leds-gpio.h"
19 #include "dev-m25p80.h"
20 +#include "dev-usb.h"
21 +#include "dev-wmac.h"
22 #include "machtypes.h"
23 -#include "pci.h"
24
25 #define UBNT_XM_GPIO_LED_L1 0
26 #define UBNT_XM_GPIO_LED_L2 1
27 @@ -37,19 +43,19 @@
28
29 static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
30 {
31 - .name = "ubnt-xm:red:link1",
32 + .name = "ubnt:red:link1",
33 .gpio = UBNT_XM_GPIO_LED_L1,
34 .active_low = 0,
35 }, {
36 - .name = "ubnt-xm:orange:link2",
37 + .name = "ubnt:orange:link2",
38 .gpio = UBNT_XM_GPIO_LED_L2,
39 .active_low = 0,
40 }, {
41 - .name = "ubnt-xm:green:link3",
42 + .name = "ubnt:green:link3",
43 .gpio = UBNT_XM_GPIO_LED_L3,
44 .active_low = 0,
45 }, {
46 - .name = "ubnt-xm:green:link4",
47 + .name = "ubnt:green:link4",
48 .gpio = UBNT_XM_GPIO_LED_L4,
49 .active_low = 0,
50 },
51 @@ -66,9 +72,13 @@ static struct gpio_keys_button ubnt_xm_g
52 }
53 };
54
55 +#define UBNT_M_WAN_PHYMASK BIT(4)
56 +
57 static void __init ubnt_xm_init(void)
58 {
59 u8 *eeprom = (u8 *) KSEG1ADDR(UBNT_XM_EEPROM_ADDR);
60 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
61 + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
62
63 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
64 ubnt_xm_leds_gpio);
65 @@ -79,9 +89,246 @@ static void __init ubnt_xm_init(void)
66
67 ath79_register_m25p80(NULL);
68 ap91_pci_init(eeprom, NULL);
69 +
70 + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
71 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
72 + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
73 + ath79_register_eth(0);
74 }
75
76 MIPS_MACHINE(ATH79_MACH_UBNT_XM,
77 "UBNT-XM",
78 "Ubiquiti Networks XM (rev 1.0) board",
79 ubnt_xm_init);
80 +
81 +MIPS_MACHINE(ATH79_MACH_UBNT_BULLET_M, "UBNT-BM", "Ubiquiti Bullet M",
82 + ubnt_xm_init);
83 +
84 +static void __init ubnt_rocket_m_setup(void)
85 +{
86 + ubnt_xm_init();
87 + ath79_register_usb();
88 +}
89 +
90 +MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M, "UBNT-RM", "Ubiquiti Rocket M",
91 + ubnt_rocket_m_setup);
92 +
93 +static void __init ubnt_nano_m_setup(void)
94 +{
95 + ubnt_xm_init();
96 + ath79_register_eth(1);
97 +}
98 +
99 +MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M, "UBNT-NM", "Ubiquiti Nanostation M",
100 + ubnt_nano_m_setup);
101 +
102 +static struct gpio_led ubnt_airrouter_leds_gpio[] __initdata = {
103 + {
104 + .name = "ubnt:green:globe",
105 + .gpio = 0,
106 + .active_low = 1,
107 + }, {
108 + .name = "ubnt:green:power",
109 + .gpio = 11,
110 + .active_low = 1,
111 + .default_state = LEDS_GPIO_DEFSTATE_ON,
112 + }
113 +};
114 +
115 +static void __init ubnt_airrouter_setup(void)
116 +{
117 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
118 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
119 +
120 + ath79_register_m25p80(NULL);
121 + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
122 +
123 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
124 + ath79_init_local_mac(ath79_eth1_data.mac_addr, mac1);
125 +
126 + ath79_register_eth(1);
127 + ath79_register_eth(0);
128 + ath79_register_usb();
129 +
130 + ap91_pci_init(ee, NULL);
131 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airrouter_leds_gpio),
132 + ubnt_airrouter_leds_gpio);
133 +
134 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
135 + ARRAY_SIZE(ubnt_xm_gpio_keys),
136 + ubnt_xm_gpio_keys);
137 +}
138 +
139 +MIPS_MACHINE(ATH79_MACH_UBNT_AIRROUTER, "UBNT-AR", "Ubiquiti AirRouter",
140 + ubnt_airrouter_setup);
141 +
142 +static struct gpio_led ubnt_unifi_leds_gpio[] __initdata = {
143 + {
144 + .name = "ubnt:orange:dome",
145 + .gpio = 1,
146 + .active_low = 0,
147 + }, {
148 + .name = "ubnt:green:dome",
149 + .gpio = 0,
150 + .active_low = 0,
151 + }
152 +};
153 +
154 +static struct gpio_led ubnt_unifi_outdoor_leds_gpio[] __initdata = {
155 + {
156 + .name = "ubnt:orange:front",
157 + .gpio = 1,
158 + .active_low = 0,
159 + }, {
160 + .name = "ubnt:green:front",
161 + .gpio = 0,
162 + .active_low = 0,
163 + }
164 +};
165 +
166 +static void __init ubnt_unifi_setup(void)
167 +{
168 + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
169 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
170 +
171 + ath79_register_m25p80(NULL);
172 +
173 + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
174 +
175 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
176 + ath79_register_eth(0);
177 +
178 + ap91_pci_init(ee, NULL);
179 +
180 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_leds_gpio),
181 + ubnt_unifi_leds_gpio);
182 +
183 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
184 + ARRAY_SIZE(ubnt_xm_gpio_keys),
185 + ubnt_xm_gpio_keys);
186 +}
187 +
188 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI, "UBNT-UF", "Ubiquiti UniFi",
189 + ubnt_unifi_setup);
190 +
191 +
192 +#define UBNT_UNIFIOD_PRI_PHYMASK BIT(4)
193 +#define UBNT_UNIFIOD_2ND_PHYMASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
194 +
195 +static void __init ubnt_unifi_outdoor_setup(void)
196 +{
197 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
198 + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
199 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
200 +
201 + ath79_register_m25p80(NULL);
202 +
203 + ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
204 + UBNT_UNIFIOD_2ND_PHYMASK));
205 +
206 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
207 + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
208 + ath79_register_eth(0);
209 + ath79_register_eth(1);
210 +
211 + ap91_pci_init(ee, NULL);
212 +
213 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_leds_gpio),
214 + ubnt_unifi_outdoor_leds_gpio);
215 +
216 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
217 + ARRAY_SIZE(ubnt_xm_gpio_keys),
218 + ubnt_xm_gpio_keys);
219 +}
220 +
221 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR, "UBNT-U20",
222 + "Ubiquiti UniFiAP Outdoor",
223 + ubnt_unifi_outdoor_setup);
224 +
225 +static struct gpio_led ubnt_uap_pro_gpio_leds[] __initdata = {
226 + {
227 + .name = "ubnt:white:dome",
228 + .gpio = 12,
229 + }, {
230 + .name = "ubnt:blue:dome",
231 + .gpio = 13,
232 + }
233 +};
234 +
235 +static struct gpio_keys_button uap_pro_gpio_keys[] __initdata = {
236 + {
237 + .desc = "reset",
238 + .type = EV_KEY,
239 + .code = KEY_RESTART,
240 + .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
241 + .gpio = 17,
242 + .active_low = 1,
243 + }
244 +};
245 +
246 +static struct ar8327_pad_cfg uap_pro_ar8327_pad0_cfg = {
247 + .mode = AR8327_PAD_MAC_RGMII,
248 + .txclk_delay_en = true,
249 + .rxclk_delay_en = true,
250 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
251 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
252 +};
253 +
254 +static struct ar8327_platform_data uap_pro_ar8327_data = {
255 + .pad0_cfg = &uap_pro_ar8327_pad0_cfg,
256 + .port0_cfg = {
257 + .force_link = 1,
258 + .speed = AR8327_PORT_SPEED_1000,
259 + .duplex = 1,
260 + .txpause = 1,
261 + .rxpause = 1,
262 + },
263 +};
264 +
265 +static struct mdio_board_info uap_pro_mdio0_info[] = {
266 + {
267 + .bus_id = "ag71xx-mdio.0",
268 + .phy_addr = 0,
269 + .platform_data = &uap_pro_ar8327_data,
270 + },
271 +};
272 +
273 +#define UAP_PRO_MAC0_OFFSET 0x0000
274 +#define UAP_PRO_MAC1_OFFSET 0x0006
275 +#define UAP_PRO_WMAC_CALDATA_OFFSET 0x1000
276 +#define UAP_PRO_PCI_CALDATA_OFFSET 0x5000
277 +
278 +static void __init ubnt_uap_pro_setup(void)
279 +{
280 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
281 +
282 + ath79_register_m25p80(NULL);
283 +
284 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_uap_pro_gpio_leds),
285 + ubnt_uap_pro_gpio_leds);
286 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
287 + ARRAY_SIZE(uap_pro_gpio_keys),
288 + uap_pro_gpio_keys);
289 +
290 + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
291 + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
292 +
293 + ath79_register_mdio(0, 0x0);
294 + mdiobus_register_board_info(uap_pro_mdio0_info,
295 + ARRAY_SIZE(uap_pro_mdio0_info));
296 +
297 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
298 + ath79_init_mac(ath79_eth0_data.mac_addr,
299 + eeprom + UAP_PRO_MAC0_OFFSET, 0);
300 +
301 + /* GMAC0 is connected to an AR8327 switch */
302 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
303 + ath79_eth0_data.phy_mask = BIT(0);
304 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
305 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
306 + ath79_register_eth(0);
307 +}
308 +
309 +MIPS_MACHINE(ATH79_MACH_UBNT_UAP_PRO, "UAP-PRO", "Ubiquiti UniFi AP Pro",
310 + ubnt_uap_pro_setup);
311 +
312 --- a/arch/mips/ath79/Kconfig
313 +++ b/arch/mips/ath79/Kconfig
314 @@ -68,12 +68,16 @@ config ATH79_MACH_PB44
315 Atheros PB44 reference board.
316
317 config ATH79_MACH_UBNT_XM
318 - bool "Ubiquiti Networks XM (rev 1.0) board"
319 + bool "Ubiquiti Networks XM/UniFi boards"
320 select SOC_AR724X
321 + select SOC_AR934X
322 select ATH79_DEV_AP9X_PCI if PCI
323 + select ATH79_DEV_ETH
324 select ATH79_DEV_GPIO_BUTTONS
325 select ATH79_DEV_LEDS_GPIO
326 select ATH79_DEV_M25P80
327 + select ATH79_DEV_USB
328 + select ATH79_DEV_WMAC
329 help
330 Say 'Y' here if you want your kernel to support the
331 Ubiquiti Networks XM (rev 1.0) board.
332 --- a/arch/mips/ath79/machtypes.h
333 +++ b/arch/mips/ath79/machtypes.h
334 @@ -22,6 +22,13 @@ enum ath79_mach_type {
335 ATH79_MACH_AP81, /* Atheros AP81 reference board */
336 ATH79_MACH_DB120, /* Atheros DB120 reference board */
337 ATH79_MACH_PB44, /* Atheros PB44 reference board */
338 + ATH79_MACH_UBNT_AIRROUTER, /* Ubiquiti AirRouter */
339 + ATH79_MACH_UBNT_BULLET_M, /* Ubiquiti Bullet M */
340 + ATH79_MACH_UBNT_NANO_M, /* Ubiquiti NanoStation M */
341 + ATH79_MACH_UBNT_ROCKET_M, /* Ubiquiti Rocket M */
342 + ATH79_MACH_UBNT_UAP_PRO, /* Ubiquiti UniFi AP Pro */
343 + ATH79_MACH_UBNT_UNIFI, /* Ubiquiti Unifi */
344 + ATH79_MACH_UBNT_UNIFI_OUTDOOR, /* Ubiquiti UnifiAP Outdoor */
345 ATH79_MACH_UBNT_XM, /* Ubiquiti Networks XM board rev 1.0 */
346 };
347