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