ar71xx: add support for Ubiquiti Litebeam M5
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-ubnt-xm.c
1 /*
2 * Ubiquiti Networks XM (rev 1.0) board support
3 *
4 * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
5 *
6 * Derived from: mach-pb44.c
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 */
12
13 #include <linux/init.h>
14 #include <linux/pci.h>
15 #include <linux/gpio.h>
16 #include <linux/platform_device.h>
17 #include <linux/ath9k_platform.h>
18 #include <linux/etherdevice.h>
19 #include <linux/ar8216_platform.h>
20 #include <linux/platform_data/phy-at803x.h>
21
22 #include <asm/mach-ath79/ath79.h>
23 #include <asm/mach-ath79/irq.h>
24 #include <asm/mach-ath79/ar71xx_regs.h>
25
26 #include <linux/platform_data/phy-at803x.h>
27
28 #include "common.h"
29 #include "dev-ap9x-pci.h"
30 #include "dev-eth.h"
31 #include "dev-gpio-buttons.h"
32 #include "dev-leds-gpio.h"
33 #include "dev-m25p80.h"
34 #include "dev-usb.h"
35 #include "dev-wmac.h"
36 #include "machtypes.h"
37
38 #define UBNT_XM_GPIO_LED_L1 0
39 #define UBNT_XM_GPIO_LED_L2 1
40 #define UBNT_XM_GPIO_LED_L3 11
41 #define UBNT_XM_GPIO_LED_L4 7
42
43 #define UBNT_XM_GPIO_BTN_RESET 12
44
45 #define UBNT_XM_KEYS_POLL_INTERVAL 20
46 #define UBNT_XM_KEYS_DEBOUNCE_INTERVAL (3 * UBNT_XM_KEYS_POLL_INTERVAL)
47
48 #define UBNT_XM_EEPROM_ADDR 0x1fff1000
49
50 static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
51 {
52 .name = "ubnt:red:link1",
53 .gpio = UBNT_XM_GPIO_LED_L1,
54 .active_low = 0,
55 }, {
56 .name = "ubnt:orange:link2",
57 .gpio = UBNT_XM_GPIO_LED_L2,
58 .active_low = 0,
59 }, {
60 .name = "ubnt:green:link3",
61 .gpio = UBNT_XM_GPIO_LED_L3,
62 .active_low = 0,
63 }, {
64 .name = "ubnt:green:link4",
65 .gpio = UBNT_XM_GPIO_LED_L4,
66 .active_low = 0,
67 },
68 };
69
70 static struct gpio_keys_button ubnt_xm_gpio_keys[] __initdata = {
71 {
72 .desc = "reset",
73 .type = EV_KEY,
74 .code = KEY_RESTART,
75 .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
76 .gpio = UBNT_XM_GPIO_BTN_RESET,
77 .active_low = 1,
78 }
79 };
80
81 #define UBNT_M_WAN_PHYMASK BIT(4)
82
83 static void __init ubnt_xm_init(void)
84 {
85 u8 *eeprom = (u8 *) KSEG1ADDR(UBNT_XM_EEPROM_ADDR);
86 u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
87 u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
88
89 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
90 ubnt_xm_leds_gpio);
91
92 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
93 ARRAY_SIZE(ubnt_xm_gpio_keys),
94 ubnt_xm_gpio_keys);
95
96 ath79_register_m25p80(NULL);
97 ap91_pci_init(eeprom, NULL);
98
99 ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
100 ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
101 ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
102 ath79_register_eth(0);
103 }
104
105 MIPS_MACHINE(ATH79_MACH_UBNT_XM,
106 "UBNT-XM",
107 "Ubiquiti Networks XM (rev 1.0) board",
108 ubnt_xm_init);
109
110 MIPS_MACHINE(ATH79_MACH_UBNT_BULLET_M, "UBNT-BM", "Ubiquiti Bullet M",
111 ubnt_xm_init);
112
113 static void __init ubnt_rocket_m_setup(void)
114 {
115 ubnt_xm_init();
116 ath79_register_usb();
117 }
118
119 MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M, "UBNT-RM", "Ubiquiti Rocket M",
120 ubnt_rocket_m_setup);
121
122 static void __init ubnt_nano_m_setup(void)
123 {
124 ubnt_xm_init();
125 ath79_register_eth(1);
126 }
127
128 MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M, "UBNT-NM", "Ubiquiti Nanostation M",
129 ubnt_nano_m_setup);
130
131 static struct gpio_led ubnt_airrouter_leds_gpio[] __initdata = {
132 {
133 .name = "ubnt:green:globe",
134 .gpio = 0,
135 .active_low = 1,
136 }, {
137 .name = "ubnt:green:power",
138 .gpio = 11,
139 .active_low = 1,
140 .default_state = LEDS_GPIO_DEFSTATE_ON,
141 }
142 };
143
144 static void __init ubnt_airrouter_setup(void)
145 {
146 u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
147 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
148
149 ath79_register_m25p80(NULL);
150 ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
151
152 ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
153 ath79_init_local_mac(ath79_eth1_data.mac_addr, mac1);
154
155 ath79_register_eth(1);
156 ath79_register_eth(0);
157 ath79_register_usb();
158
159 ap91_pci_init(ee, NULL);
160 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airrouter_leds_gpio),
161 ubnt_airrouter_leds_gpio);
162
163 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
164 ARRAY_SIZE(ubnt_xm_gpio_keys),
165 ubnt_xm_gpio_keys);
166 }
167
168 MIPS_MACHINE(ATH79_MACH_UBNT_AIRROUTER, "UBNT-AR", "Ubiquiti AirRouter",
169 ubnt_airrouter_setup);
170
171 static struct gpio_led ubnt_unifi_leds_gpio[] __initdata = {
172 {
173 .name = "ubnt:orange:dome",
174 .gpio = 1,
175 .active_low = 0,
176 }, {
177 .name = "ubnt:green:dome",
178 .gpio = 0,
179 .active_low = 0,
180 }
181 };
182
183 static struct gpio_led ubnt_unifi_outdoor_leds_gpio[] __initdata = {
184 {
185 .name = "ubnt:orange:front",
186 .gpio = 1,
187 .active_low = 0,
188 }, {
189 .name = "ubnt:green:front",
190 .gpio = 0,
191 .active_low = 0,
192 }
193 };
194
195 static struct gpio_led ubnt_unifi_outdoor_plus_leds_gpio[] __initdata = {
196 {
197 .name = "ubnt:white:front",
198 .gpio = 1,
199 .active_low = 0,
200 }, {
201 .name = "ubnt:blue:front",
202 .gpio = 0,
203 .active_low = 0,
204 }
205 };
206
207
208 static void __init ubnt_unifi_setup(void)
209 {
210 u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
211 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
212
213 ath79_register_m25p80(NULL);
214
215 ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
216
217 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
218 ath79_register_eth(0);
219
220 ap91_pci_init(ee, NULL);
221
222 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_leds_gpio),
223 ubnt_unifi_leds_gpio);
224
225 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
226 ARRAY_SIZE(ubnt_xm_gpio_keys),
227 ubnt_xm_gpio_keys);
228 }
229
230 MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI, "UBNT-UF", "Ubiquiti UniFi",
231 ubnt_unifi_setup);
232
233
234 #define UBNT_UNIFIOD_PRI_PHYMASK BIT(4)
235 #define UBNT_UNIFIOD_2ND_PHYMASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
236
237 static void __init ubnt_unifi_outdoor_setup(void)
238 {
239 u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
240 u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
241 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
242
243 ath79_register_m25p80(NULL);
244
245 ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
246 UBNT_UNIFIOD_2ND_PHYMASK));
247
248 ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
249 ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
250 ath79_register_eth(0);
251 ath79_register_eth(1);
252
253 ap91_pci_init(ee, NULL);
254
255 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_leds_gpio),
256 ubnt_unifi_outdoor_leds_gpio);
257
258 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
259 ARRAY_SIZE(ubnt_xm_gpio_keys),
260 ubnt_xm_gpio_keys);
261 }
262
263 MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR, "UBNT-U20",
264 "Ubiquiti UniFiAP Outdoor",
265 ubnt_unifi_outdoor_setup);
266
267
268 static void __init ubnt_unifi_outdoor_plus_setup(void)
269 {
270 u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
271 u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
272 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
273
274 ath79_register_m25p80(NULL);
275
276 ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
277 UBNT_UNIFIOD_2ND_PHYMASK));
278
279 ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
280 ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
281 ath79_register_eth(0);
282 ath79_register_eth(1);
283
284 ap9x_pci_get_wmac_data(0)->ubnt_hsr = true;
285 ap91_pci_init(ee, NULL);
286
287 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_plus_leds_gpio),
288 ubnt_unifi_outdoor_plus_leds_gpio);
289
290 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
291 ARRAY_SIZE(ubnt_xm_gpio_keys),
292 ubnt_xm_gpio_keys);
293 }
294
295 MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR_PLUS, "UBNT-UOP",
296 "Ubiquiti UniFiAP Outdoor+",
297 ubnt_unifi_outdoor_plus_setup);
298
299
300 static struct gpio_led ubnt_uap_pro_gpio_leds[] __initdata = {
301 {
302 .name = "ubnt:white:dome",
303 .gpio = 12,
304 }, {
305 .name = "ubnt:blue:dome",
306 .gpio = 13,
307 }
308 };
309
310 static struct gpio_keys_button uap_pro_gpio_keys[] __initdata = {
311 {
312 .desc = "reset",
313 .type = EV_KEY,
314 .code = KEY_RESTART,
315 .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
316 .gpio = 17,
317 .active_low = 1,
318 }
319 };
320
321 static struct ar8327_pad_cfg uap_pro_ar8327_pad0_cfg = {
322 .mode = AR8327_PAD_MAC_RGMII,
323 .txclk_delay_en = true,
324 .rxclk_delay_en = true,
325 .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
326 .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
327 };
328
329 static struct ar8327_platform_data uap_pro_ar8327_data = {
330 .pad0_cfg = &uap_pro_ar8327_pad0_cfg,
331 .port0_cfg = {
332 .force_link = 1,
333 .speed = AR8327_PORT_SPEED_1000,
334 .duplex = 1,
335 .txpause = 1,
336 .rxpause = 1,
337 },
338 };
339
340 static struct mdio_board_info uap_pro_mdio0_info[] = {
341 {
342 .bus_id = "ag71xx-mdio.0",
343 .phy_addr = 0,
344 .platform_data = &uap_pro_ar8327_data,
345 },
346 };
347
348 #define UAP_PRO_MAC0_OFFSET 0x0000
349 #define UAP_PRO_MAC1_OFFSET 0x0006
350 #define UAP_PRO_WMAC_CALDATA_OFFSET 0x1000
351 #define UAP_PRO_PCI_CALDATA_OFFSET 0x5000
352
353 static void __init ubnt_uap_pro_setup(void)
354 {
355 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
356
357 ath79_register_m25p80(NULL);
358
359 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_uap_pro_gpio_leds),
360 ubnt_uap_pro_gpio_leds);
361 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
362 ARRAY_SIZE(uap_pro_gpio_keys),
363 uap_pro_gpio_keys);
364
365 ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
366 ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
367
368 ath79_register_mdio(0, 0x0);
369 mdiobus_register_board_info(uap_pro_mdio0_info,
370 ARRAY_SIZE(uap_pro_mdio0_info));
371
372 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
373 ath79_init_mac(ath79_eth0_data.mac_addr,
374 eeprom + UAP_PRO_MAC0_OFFSET, 0);
375
376 /* GMAC0 is connected to an AR8327 switch */
377 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
378 ath79_eth0_data.phy_mask = BIT(0);
379 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
380 ath79_eth0_pll_data.pll_1000 = 0x06000000;
381 ath79_register_eth(0);
382 }
383
384 MIPS_MACHINE(ATH79_MACH_UBNT_UAP_PRO, "UAP-PRO", "Ubiquiti UniFi AP Pro",
385 ubnt_uap_pro_setup);
386
387 #define UBNT_XW_GPIO_LED_L1 11
388 #define UBNT_XW_GPIO_LED_L2 16
389 #define UBNT_XW_GPIO_LED_L3 13
390 #define UBNT_XW_GPIO_LED_L4 14
391
392 static struct gpio_led ubnt_xw_leds_gpio[] __initdata = {
393 {
394 .name = "ubnt:red:link1",
395 .gpio = UBNT_XW_GPIO_LED_L1,
396 .active_low = 1,
397 }, {
398 .name = "ubnt:orange:link2",
399 .gpio = UBNT_XW_GPIO_LED_L2,
400 .active_low = 1,
401 }, {
402 .name = "ubnt:green:link3",
403 .gpio = UBNT_XW_GPIO_LED_L3,
404 .active_low = 1,
405 }, {
406 .name = "ubnt:green:link4",
407 .gpio = UBNT_XW_GPIO_LED_L4,
408 .active_low = 1,
409 },
410 };
411
412 #define UBNT_ROCKET_TI_GPIO_LED_L1 16
413 #define UBNT_ROCKET_TI_GPIO_LED_L2 17
414 #define UBNT_ROCKET_TI_GPIO_LED_L3 18
415 #define UBNT_ROCKET_TI_GPIO_LED_L4 19
416 #define UBNT_ROCKET_TI_GPIO_LED_L5 20
417 #define UBNT_ROCKET_TI_GPIO_LED_L6 21
418 static struct gpio_led ubnt_rocket_ti_leds_gpio[] __initdata = {
419 {
420 .name = "ubnt:green:link1",
421 .gpio = UBNT_ROCKET_TI_GPIO_LED_L1,
422 .active_low = 1,
423 }, {
424 .name = "ubnt:green:link2",
425 .gpio = UBNT_ROCKET_TI_GPIO_LED_L2,
426 .active_low = 1,
427 }, {
428 .name = "ubnt:green:link3",
429 .gpio = UBNT_ROCKET_TI_GPIO_LED_L3,
430 .active_low = 1,
431 }, {
432 .name = "ubnt:green:link4",
433 .gpio = UBNT_ROCKET_TI_GPIO_LED_L4,
434 .active_low = 0,
435 }, {
436 .name = "ubnt:green:link5",
437 .gpio = UBNT_ROCKET_TI_GPIO_LED_L5,
438 .active_low = 0,
439 }, {
440 .name = "ubnt:green:link6",
441 .gpio = UBNT_ROCKET_TI_GPIO_LED_L6,
442 .active_low = 0,
443 },
444 };
445
446 static void __init ubnt_xw_init(void)
447 {
448 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
449
450 ath79_register_m25p80(NULL);
451
452 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xw_leds_gpio),
453 ubnt_xw_leds_gpio);
454 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
455 ARRAY_SIZE(ubnt_xm_gpio_keys),
456 ubnt_xm_gpio_keys);
457
458 ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
459 ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
460
461
462 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_MII_GMAC0 | AR934X_ETH_CFG_MII_GMAC0_SLAVE);
463 ath79_init_mac(ath79_eth0_data.mac_addr,
464 eeprom + UAP_PRO_MAC0_OFFSET, 0);
465
466 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
467 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
468 }
469
470 static void __init ubnt_nano_m_xw_setup(void)
471 {
472 ubnt_xw_init();
473
474 /* GMAC0 is connected to an AR8326 switch */
475 ath79_register_mdio(0, ~(BIT(0) | BIT(1) | BIT(5)));
476 ath79_eth0_data.phy_mask = (BIT(0) | BIT(1) | BIT(5));
477 ath79_eth0_data.speed = SPEED_100;
478 ath79_eth0_data.duplex = DUPLEX_FULL;
479 ath79_register_eth(0);
480 }
481
482 static struct at803x_platform_data ubnt_loco_m_xw_at803x_data = {
483 .has_reset_gpio = 1,
484 .reset_gpio = 0,
485 };
486
487 static struct mdio_board_info ubnt_loco_m_xw_mdio_info[] = {
488 {
489 .bus_id = "ag71xx-mdio.0",
490 .phy_addr = 1,
491 .platform_data = &ubnt_loco_m_xw_at803x_data,
492 },
493 };
494
495 static void __init ubnt_loco_m_xw_setup(void)
496 {
497 ubnt_xw_init();
498
499 mdiobus_register_board_info(ubnt_loco_m_xw_mdio_info,
500 ARRAY_SIZE(ubnt_loco_m_xw_mdio_info));
501
502 ath79_register_mdio(0, ~BIT(1));
503 ath79_eth0_data.phy_mask = BIT(1);
504 ath79_register_eth(0);
505 }
506
507 #define UBNT_LBE_M5_GPIO_LED_LAN 13
508 #define UBNT_LBE_M5_GPIO_LED_WLAN 14
509 #define UBNT_LBE_M5_GPIO_LED_SYS 16
510
511 static struct gpio_led ubnt_lbe_m5_leds_gpio[] __initdata = {
512 {
513 .name = "ubnt:green:lan",
514 .gpio = UBNT_LBE_M5_GPIO_LED_LAN,
515 .active_low = 1,
516 }, {
517 .name = "ubnt:green:wlan",
518 .gpio = UBNT_LBE_M5_GPIO_LED_WLAN,
519 .active_low = 1,
520 }, {
521 .name = "ubnt:green:sys",
522 .gpio = UBNT_LBE_M5_GPIO_LED_SYS,
523 .active_low = 1,
524 },
525 };
526
527 static void __init ubnt_lbe_m5_setup(void)
528 {
529 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
530
531 ath79_register_m25p80(NULL);
532
533 ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
534 ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
535
536 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_lbe_m5_leds_gpio),
537 ubnt_lbe_m5_leds_gpio);
538 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
539 ARRAY_SIZE(ubnt_xm_gpio_keys),
540 ubnt_xm_gpio_keys);
541
542 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_MII_GMAC0 |
543 AR934X_ETH_CFG_MII_GMAC0_SLAVE);
544 ath79_init_mac(ath79_eth0_data.mac_addr,
545 eeprom + UAP_PRO_MAC0_OFFSET, 0);
546
547 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
548 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
549
550 gpio_request_one(0, GPIOF_OUT_INIT_LOW | GPIOF_ACTIVE_LOW |
551 GPIOF_EXPORT_DIR_FIXED, "SPI nWP");
552
553 mdiobus_register_board_info(ubnt_loco_m_xw_mdio_info,
554 ARRAY_SIZE(ubnt_loco_m_xw_mdio_info));
555
556 ath79_register_mdio(0, ~BIT(1));
557 ath79_eth0_data.phy_mask = BIT(1);
558 ath79_register_eth(0);
559 }
560
561 static void __init ubnt_rocket_m_xw_setup(void)
562 {
563 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
564
565 ath79_register_m25p80(NULL);
566
567 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xw_leds_gpio),
568 ubnt_xw_leds_gpio);
569 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
570 ARRAY_SIZE(ubnt_xm_gpio_keys),
571 ubnt_xm_gpio_keys);
572
573 ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
574 ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
575
576 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
577 ath79_init_mac(ath79_eth0_data.mac_addr,
578 eeprom + UAP_PRO_MAC0_OFFSET, 0);
579
580 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
581 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
582
583 ath79_register_mdio(0, ~BIT(4));
584 ath79_eth0_data.phy_mask = BIT(4);
585 ath79_eth0_pll_data.pll_1000 = 0x06000000;
586 ath79_register_eth(0);
587 }
588
589 static struct at803x_platform_data ubnt_rocket_m_ti_at803_data = {
590 .disable_smarteee = 1,
591 .enable_rgmii_rx_delay = 1,
592 .enable_rgmii_tx_delay = 1,
593 };
594 static struct mdio_board_info ubnt_rocket_m_ti_mdio_info[] = {
595 {
596 .bus_id = "ag71xx-mdio.0",
597 .phy_addr = 4,
598 .platform_data = &ubnt_rocket_m_ti_at803_data,
599 },
600 };
601
602 static void __init ubnt_rocket_m_ti_setup(void)
603 {
604 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
605
606 ath79_register_m25p80(NULL);
607
608 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_rocket_ti_leds_gpio),
609 ubnt_rocket_ti_leds_gpio);
610 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
611 ARRAY_SIZE(ubnt_xm_gpio_keys),
612 ubnt_xm_gpio_keys);
613
614 ap91_pci_init(eeprom + 0x1000, NULL);
615
616 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
617 ath79_setup_ar934x_eth_rx_delay(3, 3);
618 ath79_init_mac(ath79_eth0_data.mac_addr,
619 eeprom + UAP_PRO_MAC0_OFFSET, 0);
620 ath79_init_mac(ath79_eth1_data.mac_addr,
621 eeprom + UAP_PRO_MAC1_OFFSET, 0);
622
623 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
624 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
625 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
626 ath79_eth1_data.mii_bus_dev = &ath79_mdio1_device.dev;
627
628 mdiobus_register_board_info(ubnt_rocket_m_ti_mdio_info,
629 ARRAY_SIZE(ubnt_rocket_m_ti_mdio_info));
630 ath79_register_mdio(0, 0x0);
631
632
633 ath79_eth0_data.phy_mask = BIT(4);
634 /* read out from vendor */
635 ath79_eth0_pll_data.pll_1000 = 0x2000000;
636 ath79_eth0_pll_data.pll_10 = 0x1313;
637 ath79_register_eth(0);
638
639 ath79_register_mdio(1, 0x0);
640 ath79_eth1_data.phy_mask = BIT(3);
641 ath79_register_eth(1);
642 }
643
644
645 MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M_XW, "UBNT-NM-XW", "Ubiquiti Nanostation M XW",
646 ubnt_nano_m_xw_setup);
647
648 MIPS_MACHINE(ATH79_MACH_UBNT_LBE_M5, "UBNT-LBE-M5", "Ubiquiti Litebeam M5",
649 ubnt_lbe_m5_setup);
650
651 MIPS_MACHINE(ATH79_MACH_UBNT_LOCO_M_XW, "UBNT-LOCO-XW", "Ubiquiti Loco M XW",
652 ubnt_loco_m_xw_setup);
653
654 MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M_XW, "UBNT-RM-XW", "Ubiquiti Rocket M XW",
655 ubnt_rocket_m_xw_setup);
656
657 MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M_TI, "UBNT-RM-TI", "Ubiquiti Rocket M TI",
658 ubnt_rocket_m_ti_setup);
659
660 static struct gpio_led ubnt_airgateway_gpio_leds[] __initdata = {
661 {
662 .name = "ubnt:blue:wlan",
663 .gpio = 0,
664 }, {
665 .name = "ubnt:white:status",
666 .gpio = 1,
667 },
668 };
669
670 static struct gpio_keys_button airgateway_gpio_keys[] __initdata = {
671 {
672 .desc = "reset",
673 .type = EV_KEY,
674 .code = KEY_RESTART,
675 .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
676 .gpio = 12,
677 .active_low = 1,
678 }
679 };
680
681 static void __init ubnt_airgateway_setup(void)
682 {
683 u32 t;
684 u8 *mac0 = (u8 *) KSEG1ADDR(0x1fff0000);
685 u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
686 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
687
688
689 ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
690 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
691 AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
692 AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
693 AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
694
695 t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
696 t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
697 ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
698
699 ath79_register_m25p80(NULL);
700 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airgateway_gpio_leds),
701 ubnt_airgateway_gpio_leds);
702
703 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
704 ARRAY_SIZE(airgateway_gpio_keys),
705 airgateway_gpio_keys);
706
707 ath79_init_mac(ath79_eth1_data.mac_addr, mac0, 0);
708 ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
709
710 ath79_register_mdio(0, 0x0);
711
712 ath79_register_eth(1);
713 ath79_register_eth(0);
714
715 ath79_register_wmac(ee, NULL);
716 }
717
718 MIPS_MACHINE(ATH79_MACH_UBNT_AIRGW, "UBNT-AGW", "Ubiquiti AirGateway",
719 ubnt_airgateway_setup);
720
721 static struct gpio_led ubnt_airgateway_pro_gpio_leds[] __initdata = {
722 {
723 .name = "ubnt:blue:wlan",
724 .gpio = 13,
725 }, {
726 .name = "ubnt:white:status",
727 .gpio = 17,
728 },
729 };
730
731
732 static struct gpio_keys_button airgateway_pro_gpio_keys[] __initdata = {
733 {
734 .desc = "reset",
735 .type = EV_KEY,
736 .code = KEY_RESTART,
737 .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
738 .gpio = 12,
739 .active_low = 1,
740 }
741 };
742
743 static void __init ubnt_airgateway_pro_setup(void)
744 {
745 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
746 u8 *mac0 = (u8 *) KSEG1ADDR(0x1fff0000);
747
748 ath79_register_m25p80(NULL);
749 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airgateway_pro_gpio_leds),
750 ubnt_airgateway_pro_gpio_leds);
751
752 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
753 ARRAY_SIZE(airgateway_pro_gpio_keys),
754 airgateway_pro_gpio_keys);
755
756 ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
757 ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
758
759
760 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
761
762 ath79_register_mdio(1, 0x0);
763
764 /* GMAC0 is left unused in this configuration */
765
766 /* GMAC1 is connected to MAC0 on the internal switch */
767 /* The PoE/WAN port connects to port 5 on the internal switch */
768 /* The LAN port connects to port 4 on the internal switch */
769 ath79_init_mac(ath79_eth1_data.mac_addr, mac0, 0);
770 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
771 ath79_register_eth(1);
772
773 }
774
775 MIPS_MACHINE(ATH79_MACH_UBNT_AIRGWP, "UBNT-AGWP", "Ubiquiti AirGateway Pro",
776 ubnt_airgateway_pro_setup);