1 --- a/arch/mips/ath79/mach-ubnt-xm.c
2 +++ b/arch/mips/ath79/mach-ubnt-xm.c
5 #include <linux/init.h>
7 +#include <linux/platform_device.h>
8 #include <linux/ath9k_platform.h>
9 +#include <linux/etherdevice.h>
10 +#include <linux/ar8216_platform.h>
12 +#include <asm/mach-ath79/ath79.h>
13 #include <asm/mach-ath79/irq.h>
14 +#include <asm/mach-ath79/ar71xx_regs.h>
17 #include "dev-ap9x-pci.h"
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
23 +#include "dev-wmac.h"
24 #include "machtypes.h"
27 #define UBNT_XM_GPIO_LED_L1 0
28 #define UBNT_XM_GPIO_LED_L2 1
31 static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
33 - .name = "ubnt-xm:red:link1",
34 + .name = "ubnt:red:link1",
35 .gpio = UBNT_XM_GPIO_LED_L1,
38 - .name = "ubnt-xm:orange:link2",
39 + .name = "ubnt:orange:link2",
40 .gpio = UBNT_XM_GPIO_LED_L2,
43 - .name = "ubnt-xm:green:link3",
44 + .name = "ubnt:green:link3",
45 .gpio = UBNT_XM_GPIO_LED_L3,
48 - .name = "ubnt-xm:green:link4",
49 + .name = "ubnt:green:link4",
50 .gpio = UBNT_XM_GPIO_LED_L4,
53 @@ -66,9 +74,13 @@ static struct gpio_keys_button ubnt_xm_g
57 +#define UBNT_M_WAN_PHYMASK BIT(4)
59 static void __init ubnt_xm_init(void)
61 u8 *eeprom = (u8 *) KSEG1ADDR(UBNT_XM_EEPROM_ADDR);
62 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
63 + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
65 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
67 @@ -79,9 +91,428 @@ static void __init ubnt_xm_init(void)
69 ath79_register_m25p80(NULL);
70 ap91_pci_init(eeprom, NULL);
72 + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
73 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
74 + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
75 + ath79_register_eth(0);
78 MIPS_MACHINE(ATH79_MACH_UBNT_XM,
80 "Ubiquiti Networks XM (rev 1.0) board",
83 +MIPS_MACHINE(ATH79_MACH_UBNT_BULLET_M, "UBNT-BM", "Ubiquiti Bullet M",
86 +static void __init ubnt_rocket_m_setup(void)
89 + ath79_register_usb();
92 +MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M, "UBNT-RM", "Ubiquiti Rocket M",
93 + ubnt_rocket_m_setup);
95 +static void __init ubnt_nano_m_setup(void)
98 + ath79_register_eth(1);
101 +MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M, "UBNT-NM", "Ubiquiti Nanostation M",
102 + ubnt_nano_m_setup);
104 +static struct gpio_led ubnt_airrouter_leds_gpio[] __initdata = {
106 + .name = "ubnt:green:globe",
110 + .name = "ubnt:green:power",
113 + .default_state = LEDS_GPIO_DEFSTATE_ON,
117 +static void __init ubnt_airrouter_setup(void)
119 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
120 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
122 + ath79_register_m25p80(NULL);
123 + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
125 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
126 + ath79_init_local_mac(ath79_eth1_data.mac_addr, mac1);
128 + ath79_register_eth(1);
129 + ath79_register_eth(0);
130 + ath79_register_usb();
132 + ap91_pci_init(ee, NULL);
133 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airrouter_leds_gpio),
134 + ubnt_airrouter_leds_gpio);
136 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
137 + ARRAY_SIZE(ubnt_xm_gpio_keys),
138 + ubnt_xm_gpio_keys);
141 +MIPS_MACHINE(ATH79_MACH_UBNT_AIRROUTER, "UBNT-AR", "Ubiquiti AirRouter",
142 + ubnt_airrouter_setup);
144 +static struct gpio_led ubnt_unifi_leds_gpio[] __initdata = {
146 + .name = "ubnt:orange:dome",
150 + .name = "ubnt:green:dome",
156 +static struct gpio_led ubnt_unifi_outdoor_leds_gpio[] __initdata = {
158 + .name = "ubnt:orange:front",
162 + .name = "ubnt:green:front",
168 +static struct gpio_led ubnt_unifi_outdoor_plus_leds_gpio[] __initdata = {
170 + .name = "ubnt:white:front",
174 + .name = "ubnt:blue:front",
181 +static void __init ubnt_unifi_setup(void)
183 + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
184 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
186 + ath79_register_m25p80(NULL);
188 + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
190 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
191 + ath79_register_eth(0);
193 + ap91_pci_init(ee, NULL);
195 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_leds_gpio),
196 + ubnt_unifi_leds_gpio);
198 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
199 + ARRAY_SIZE(ubnt_xm_gpio_keys),
200 + ubnt_xm_gpio_keys);
203 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI, "UBNT-UF", "Ubiquiti UniFi",
207 +#define UBNT_UNIFIOD_PRI_PHYMASK BIT(4)
208 +#define UBNT_UNIFIOD_2ND_PHYMASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
210 +static void __init ubnt_unifi_outdoor_setup(void)
212 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
213 + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
214 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
216 + ath79_register_m25p80(NULL);
218 + ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
219 + UBNT_UNIFIOD_2ND_PHYMASK));
221 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
222 + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
223 + ath79_register_eth(0);
224 + ath79_register_eth(1);
226 + ap91_pci_init(ee, NULL);
228 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_leds_gpio),
229 + ubnt_unifi_outdoor_leds_gpio);
231 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
232 + ARRAY_SIZE(ubnt_xm_gpio_keys),
233 + ubnt_xm_gpio_keys);
236 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR, "UBNT-U20",
237 + "Ubiquiti UniFiAP Outdoor",
238 + ubnt_unifi_outdoor_setup);
241 +static void __init ubnt_unifi_outdoor_plus_setup(void)
243 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
244 + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
245 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
247 + ath79_register_m25p80(NULL);
249 + ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
250 + UBNT_UNIFIOD_2ND_PHYMASK));
252 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
253 + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
254 + ath79_register_eth(0);
255 + ath79_register_eth(1);
257 + ap91_pci_init(ee, NULL);
259 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_plus_leds_gpio),
260 + ubnt_unifi_outdoor_plus_leds_gpio);
262 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
263 + ARRAY_SIZE(ubnt_xm_gpio_keys),
264 + ubnt_xm_gpio_keys);
267 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR_PLUS, "UBNT-UOP",
268 + "Ubiquiti UniFiAP Outdoor+",
269 + ubnt_unifi_outdoor_plus_setup);
272 +static struct gpio_led ubnt_uap_pro_gpio_leds[] __initdata = {
274 + .name = "ubnt:white:dome",
277 + .name = "ubnt:blue:dome",
282 +static struct gpio_keys_button uap_pro_gpio_keys[] __initdata = {
286 + .code = KEY_RESTART,
287 + .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
293 +static struct ar8327_pad_cfg uap_pro_ar8327_pad0_cfg = {
294 + .mode = AR8327_PAD_MAC_RGMII,
295 + .txclk_delay_en = true,
296 + .rxclk_delay_en = true,
297 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
298 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
301 +static struct ar8327_platform_data uap_pro_ar8327_data = {
302 + .pad0_cfg = &uap_pro_ar8327_pad0_cfg,
305 + .speed = AR8327_PORT_SPEED_1000,
312 +static struct mdio_board_info uap_pro_mdio0_info[] = {
314 + .bus_id = "ag71xx-mdio.0",
316 + .platform_data = &uap_pro_ar8327_data,
320 +#define UAP_PRO_MAC0_OFFSET 0x0000
321 +#define UAP_PRO_MAC1_OFFSET 0x0006
322 +#define UAP_PRO_WMAC_CALDATA_OFFSET 0x1000
323 +#define UAP_PRO_PCI_CALDATA_OFFSET 0x5000
325 +static void __init ubnt_uap_pro_setup(void)
327 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
329 + ath79_register_m25p80(NULL);
331 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_uap_pro_gpio_leds),
332 + ubnt_uap_pro_gpio_leds);
333 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
334 + ARRAY_SIZE(uap_pro_gpio_keys),
335 + uap_pro_gpio_keys);
337 + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
338 + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
340 + ath79_register_mdio(0, 0x0);
341 + mdiobus_register_board_info(uap_pro_mdio0_info,
342 + ARRAY_SIZE(uap_pro_mdio0_info));
344 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
345 + ath79_init_mac(ath79_eth0_data.mac_addr,
346 + eeprom + UAP_PRO_MAC0_OFFSET, 0);
348 + /* GMAC0 is connected to an AR8327 switch */
349 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
350 + ath79_eth0_data.phy_mask = BIT(0);
351 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
352 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
353 + ath79_register_eth(0);
356 +MIPS_MACHINE(ATH79_MACH_UBNT_UAP_PRO, "UAP-PRO", "Ubiquiti UniFi AP Pro",
357 + ubnt_uap_pro_setup);
359 +#define UBNT_XW_GPIO_LED_L1 11
360 +#define UBNT_XW_GPIO_LED_L2 16
361 +#define UBNT_XW_GPIO_LED_L3 13
362 +#define UBNT_XW_GPIO_LED_L4 14
364 +static struct gpio_led ubnt_xw_leds_gpio[] __initdata = {
366 + .name = "ubnt:red:link1",
367 + .gpio = UBNT_XW_GPIO_LED_L1,
370 + .name = "ubnt:orange:link2",
371 + .gpio = UBNT_XW_GPIO_LED_L2,
374 + .name = "ubnt:green:link3",
375 + .gpio = UBNT_XW_GPIO_LED_L3,
378 + .name = "ubnt:green:link4",
379 + .gpio = UBNT_XW_GPIO_LED_L4,
384 +static void __init ubnt_xw_init(void)
386 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
388 + ath79_register_m25p80(NULL);
390 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xw_leds_gpio),
391 + ubnt_xw_leds_gpio);
392 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
393 + ARRAY_SIZE(ubnt_xm_gpio_keys),
394 + ubnt_xm_gpio_keys);
396 + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
397 + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
400 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_MII_GMAC0 | AR934X_ETH_CFG_MII_GMAC0_SLAVE);
401 + ath79_init_mac(ath79_eth0_data.mac_addr,
402 + eeprom + UAP_PRO_MAC0_OFFSET, 0);
404 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
405 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
408 +static void __init ubnt_nano_m_xw_setup(void)
412 + /* GMAC0 is connected to an AR8326 switch */
413 + ath79_register_mdio(0, ~(BIT(0) | BIT(1) | BIT(5)));
414 + ath79_eth0_data.phy_mask = (BIT(0) | BIT(1) | BIT(5));
415 + ath79_eth0_data.speed = SPEED_100;
416 + ath79_eth0_data.duplex = DUPLEX_FULL;
417 + ath79_register_eth(0);
420 +static void __init ubnt_loco_m_xw_setup(void)
424 + ath79_register_mdio(0, ~BIT(1));
425 + ath79_eth0_data.phy_mask = BIT(1);
426 + ath79_register_eth(0);
429 +MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M_XW, "UBNT-NM-XW", "Ubiquiti Nanostation M XW",
430 + ubnt_nano_m_xw_setup);
432 +MIPS_MACHINE(ATH79_MACH_UBNT_LOCO_M_XW, "UBNT-LOCO-XW", "Ubiquiti Loco M XW",
433 + ubnt_loco_m_xw_setup);
435 +static struct gpio_led ubnt_airgateway_gpio_leds[] __initdata = {
437 + .name = "ubnt:blue:wlan",
440 + .name = "ubnt:white:status",
445 +static struct gpio_keys_button airgateway_gpio_keys[] __initdata = {
449 + .code = KEY_RESTART,
450 + .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
456 +static void __init ubnt_airgateway_setup(void)
459 + u8 *mac0 = (u8 *) KSEG1ADDR(0x1fff0000);
460 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
461 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
464 + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
465 + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
466 + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
467 + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
468 + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
470 + t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
471 + t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
472 + ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
474 + ath79_register_m25p80(NULL);
475 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airgateway_gpio_leds),
476 + ubnt_airgateway_gpio_leds);
478 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
479 + ARRAY_SIZE(airgateway_gpio_keys),
480 + airgateway_gpio_keys);
482 + ath79_init_mac(ath79_eth1_data.mac_addr, mac0, 0);
483 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
485 + ath79_register_mdio(0, 0x0);
487 + ath79_register_eth(1);
488 + ath79_register_eth(0);
490 + ath79_register_wmac(ee, NULL);
493 +MIPS_MACHINE(ATH79_MACH_UBNT_AIRGW, "UBNT-AGW", "Ubiquiti AirGateway",
494 + ubnt_airgateway_setup);
496 --- a/arch/mips/ath79/Kconfig
497 +++ b/arch/mips/ath79/Kconfig
498 @@ -68,12 +68,16 @@ config ATH79_MACH_PB44
499 Atheros PB44 reference board.
501 config ATH79_MACH_UBNT_XM
502 - bool "Ubiquiti Networks XM (rev 1.0) board"
503 + bool "Ubiquiti Networks XM/UniFi boards"
506 select ATH79_DEV_AP9X_PCI if PCI
507 + select ATH79_DEV_ETH
508 select ATH79_DEV_GPIO_BUTTONS
509 select ATH79_DEV_LEDS_GPIO
510 select ATH79_DEV_M25P80
511 + select ATH79_DEV_USB
512 + select ATH79_DEV_WMAC
514 Say 'Y' here if you want your kernel to support the
515 Ubiquiti Networks XM (rev 1.0) board.
516 --- a/arch/mips/ath79/machtypes.h
517 +++ b/arch/mips/ath79/machtypes.h
518 @@ -22,6 +22,13 @@ enum ath79_mach_type {
519 ATH79_MACH_AP81, /* Atheros AP81 reference board */
520 ATH79_MACH_DB120, /* Atheros DB120 reference board */
521 ATH79_MACH_PB44, /* Atheros PB44 reference board */
522 + ATH79_MACH_UBNT_AIRROUTER, /* Ubiquiti AirRouter */
523 + ATH79_MACH_UBNT_BULLET_M, /* Ubiquiti Bullet M */
524 + ATH79_MACH_UBNT_NANO_M, /* Ubiquiti NanoStation M */
525 + ATH79_MACH_UBNT_ROCKET_M, /* Ubiquiti Rocket M */
526 + ATH79_MACH_UBNT_UAP_PRO, /* Ubiquiti UniFi AP Pro */
527 + ATH79_MACH_UBNT_UNIFI, /* Ubiquiti Unifi */
528 + ATH79_MACH_UBNT_UNIFI_OUTDOOR, /* Ubiquiti UnifiAP Outdoor */
529 ATH79_MACH_UBNT_XM, /* Ubiquiti Networks XM board rev 1.0 */