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