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 48static 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 68static 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 81static 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 103MIPS_MACHINE(ATH79_MACH_UBNT_XM, 104 "UBNT-XM", 105 "Ubiquiti Networks XM (rev 1.0) board", 106 ubnt_xm_init); 107 108MIPS_MACHINE(ATH79_MACH_UBNT_BULLET_M, "UBNT-BM", "Ubiquiti Bullet M", 109 ubnt_xm_init); 110 111static void __init ubnt_rocket_m_setup(void) 112{ 113 ubnt_xm_init(); 114 ath79_register_usb(); 115} 116 117MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M, "UBNT-RM", "Ubiquiti Rocket M", 118 ubnt_rocket_m_setup); 119 120static void __init ubnt_nano_m_setup(void) 121{ 122 ubnt_xm_init(); 123 ath79_register_eth(1); 124} 125 126MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M, "UBNT-NM", "Ubiquiti Nanostation M", 127 ubnt_nano_m_setup); 128 129static 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 142static 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 166MIPS_MACHINE(ATH79_MACH_UBNT_AIRROUTER, "UBNT-AR", "Ubiquiti AirRouter", 167 ubnt_airrouter_setup); 168 169static 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 181static 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 193static 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 206static 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 228MIPS_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 235static 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 261MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR, "UBNT-U20", 262 "Ubiquiti UniFiAP Outdoor", 263 ubnt_unifi_outdoor_setup); 264 265 266static 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 ap91_pci_init(ee, NULL); 283 284 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_plus_leds_gpio), 285 ubnt_unifi_outdoor_plus_leds_gpio); 286 287 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL, 288 ARRAY_SIZE(ubnt_xm_gpio_keys), 289 ubnt_xm_gpio_keys); 290} 291 292MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR_PLUS, "UBNT-UOP", 293 "Ubiquiti UniFiAP Outdoor+", 294 ubnt_unifi_outdoor_plus_setup); 295 296 297static struct gpio_led ubnt_uap_pro_gpio_leds[] __initdata = { 298 { 299 .name = "ubnt:white:dome", 300 .gpio = 12, 301 }, { 302 .name = "ubnt:blue:dome", 303 .gpio = 13, 304 } 305}; 306 307static struct gpio_keys_button uap_pro_gpio_keys[] __initdata = { 308 { 309 .desc = "reset", 310 .type = EV_KEY, 311 .code = KEY_RESTART, 312 .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL, 313 .gpio = 17, 314 .active_low = 1, 315 } 316}; 317 318static struct ar8327_pad_cfg uap_pro_ar8327_pad0_cfg = { 319 .mode = AR8327_PAD_MAC_RGMII, 320 .txclk_delay_en = true, 321 .rxclk_delay_en = true, 322 .txclk_delay_sel = AR8327_CLK_DELAY_SEL1, 323 .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2, 324}; 325 326static struct ar8327_platform_data uap_pro_ar8327_data = { 327 .pad0_cfg = &uap_pro_ar8327_pad0_cfg, 328 .port0_cfg = { 329 .force_link = 1, 330 .speed = AR8327_PORT_SPEED_1000, 331 .duplex = 1, 332 .txpause = 1, 333 .rxpause = 1, 334 }, 335}; 336 337static struct mdio_board_info uap_pro_mdio0_info[] = { 338 { 339 .bus_id = "ag71xx-mdio.0", 340 .phy_addr = 0, 341 .platform_data = &uap_pro_ar8327_data, 342 }, 343}; 344 345#define UAP_PRO_MAC0_OFFSET 0x0000 346#define UAP_PRO_MAC1_OFFSET 0x0006 347#define UAP_PRO_WMAC_CALDATA_OFFSET 0x1000 348#define UAP_PRO_PCI_CALDATA_OFFSET 0x5000 349 350static void __init ubnt_uap_pro_setup(void) 351{ 352 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000); 353 354 ath79_register_m25p80(NULL); 355 356 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_uap_pro_gpio_leds), 357 ubnt_uap_pro_gpio_leds); 358 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL, 359 ARRAY_SIZE(uap_pro_gpio_keys), 360 uap_pro_gpio_keys); 361 362 ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL); 363 ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL); 364 365 ath79_register_mdio(0, 0x0); 366 mdiobus_register_board_info(uap_pro_mdio0_info, 367 ARRAY_SIZE(uap_pro_mdio0_info)); 368 369 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0); 370 ath79_init_mac(ath79_eth0_data.mac_addr, 371 eeprom + UAP_PRO_MAC0_OFFSET, 0); 372 373 /* GMAC0 is connected to an AR8327 switch */ 374 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; 375 ath79_eth0_data.phy_mask = BIT(0); 376 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; 377 ath79_eth0_pll_data.pll_1000 = 0x06000000; 378 ath79_register_eth(0); 379} 380 381MIPS_MACHINE(ATH79_MACH_UBNT_UAP_PRO, "UAP-PRO", "Ubiquiti UniFi AP Pro", 382 ubnt_uap_pro_setup); 383 384#define UBNT_XW_GPIO_LED_L1 11 385#define UBNT_XW_GPIO_LED_L2 16 386#define UBNT_XW_GPIO_LED_L3 13 387#define UBNT_XW_GPIO_LED_L4 14 388 389static struct gpio_led ubnt_xw_leds_gpio[] __initdata = { 390 { 391 .name = "ubnt:red:link1", 392 .gpio = UBNT_XW_GPIO_LED_L1, 393 .active_low = 1, 394 }, { 395 .name = "ubnt:orange:link2", 396 .gpio = UBNT_XW_GPIO_LED_L2, 397 .active_low = 1, 398 }, { 399 .name = "ubnt:green:link3", 400 .gpio = UBNT_XW_GPIO_LED_L3, 401 .active_low = 1, 402 }, { 403 .name = "ubnt:green:link4", 404 .gpio = UBNT_XW_GPIO_LED_L4, 405 .active_low = 1, 406 }, 407}; 408 409#define UBNT_ROCKET_TI_GPIO_LED_L1 16 410#define UBNT_ROCKET_TI_GPIO_LED_L2 17 411#define UBNT_ROCKET_TI_GPIO_LED_L3 18 412#define UBNT_ROCKET_TI_GPIO_LED_L4 19 413#define UBNT_ROCKET_TI_GPIO_LED_L5 20 414#define UBNT_ROCKET_TI_GPIO_LED_L6 21 415static struct gpio_led ubnt_rocket_ti_leds_gpio[] __initdata = { 416 { 417 .name = "ubnt:green:link1", 418 .gpio = UBNT_ROCKET_TI_GPIO_LED_L1, 419 .active_low = 1, 420 }, { 421 .name = "ubnt:green:link2", 422 .gpio = UBNT_ROCKET_TI_GPIO_LED_L2, 423 .active_low = 1, 424 }, { 425 .name = "ubnt:green:link3", 426 .gpio = UBNT_ROCKET_TI_GPIO_LED_L3, 427 .active_low = 1, 428 }, { 429 .name = "ubnt:green:link4", 430 .gpio = UBNT_ROCKET_TI_GPIO_LED_L4, 431 .active_low = 0, 432 }, { 433 .name = "ubnt:green:link5", 434 .gpio = UBNT_ROCKET_TI_GPIO_LED_L5, 435 .active_low = 0, 436 }, { 437 .name = "ubnt:green:link6", 438 .gpio = UBNT_ROCKET_TI_GPIO_LED_L6, 439 .active_low = 0, 440 }, 441}; 442 443static void __init ubnt_xw_init(void) 444{ 445 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000); 446 447 ath79_register_m25p80(NULL); 448 449 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xw_leds_gpio), 450 ubnt_xw_leds_gpio); 451 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL, 452 ARRAY_SIZE(ubnt_xm_gpio_keys), 453 ubnt_xm_gpio_keys); 454 455 ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL); 456 ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL); 457 458 459 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_MII_GMAC0 | AR934X_ETH_CFG_MII_GMAC0_SLAVE); 460 ath79_init_mac(ath79_eth0_data.mac_addr, 461 eeprom + UAP_PRO_MAC0_OFFSET, 0); 462 463 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; 464 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; 465} 466 467static void __init ubnt_nano_m_xw_setup(void) 468{ 469 ubnt_xw_init(); 470 471 /* GMAC0 is connected to an AR8326 switch */ 472 ath79_register_mdio(0, ~(BIT(0) | BIT(1) | BIT(5))); 473 ath79_eth0_data.phy_mask = (BIT(0) | BIT(1) | BIT(5)); 474 ath79_eth0_data.speed = SPEED_100; 475 ath79_eth0_data.duplex = DUPLEX_FULL; 476 ath79_register_eth(0); 477} 478 479static void __init ubnt_loco_m_xw_setup(void) 480{ 481 ubnt_xw_init(); 482 483 ath79_register_mdio(0, ~BIT(1)); 484 ath79_eth0_data.phy_mask = BIT(1); 485 ath79_register_eth(0); 486} 487 488static void __init ubnt_rocket_m_xw_setup(void) 489{ 490 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000); 491 492 ath79_register_m25p80(NULL); 493 494 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xw_leds_gpio), 495 ubnt_xw_leds_gpio); 496 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL, 497 ARRAY_SIZE(ubnt_xm_gpio_keys), 498 ubnt_xm_gpio_keys); 499 500 ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL); 501 ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL); 502 503 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0); 504 ath79_init_mac(ath79_eth0_data.mac_addr, 505 eeprom + UAP_PRO_MAC0_OFFSET, 0); 506 507 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; 508 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; 509 510 ath79_register_mdio(0, ~BIT(4)); 511 ath79_eth0_data.phy_mask = BIT(4); 512 ath79_eth0_pll_data.pll_1000 = 0x06000000; 513 ath79_register_eth(0); 514} 515 516static struct at803x_platform_data ubnt_rocket_m_ti_at803_data = { 517 .disable_smarteee = 1, 518 .enable_rgmii_rx_delay = 1, 519 .enable_rgmii_tx_delay = 1, 520}; 521static struct mdio_board_info ubnt_rocket_m_ti_mdio_info[] = { 522 { 523 .bus_id = "ag71xx-mdio.0", 524 .phy_addr = 4, 525 .platform_data = &ubnt_rocket_m_ti_at803_data, 526 }, 527}; 528 529static void __init ubnt_rocket_m_ti_setup(void) 530{ 531 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000); 532 533 ath79_register_m25p80(NULL); 534 535 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_rocket_ti_leds_gpio), 536 ubnt_rocket_ti_leds_gpio); 537 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL, 538 ARRAY_SIZE(ubnt_xm_gpio_keys), 539 ubnt_xm_gpio_keys); 540 541 ap91_pci_init(eeprom + 0x1000, NULL); 542 543 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0); 544 ath79_setup_ar934x_eth_rx_delay(3, 3); 545 ath79_init_mac(ath79_eth0_data.mac_addr, 546 eeprom + UAP_PRO_MAC0_OFFSET, 0); 547 ath79_init_mac(ath79_eth1_data.mac_addr, 548 eeprom + UAP_PRO_MAC1_OFFSET, 0); 549 550 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; 551 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; 552 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; 553 ath79_eth1_data.mii_bus_dev = &ath79_mdio1_device.dev; 554 555 mdiobus_register_board_info(ubnt_rocket_m_ti_mdio_info, 556 ARRAY_SIZE(ubnt_rocket_m_ti_mdio_info)); 557 ath79_register_mdio(0, 0x0); 558 559 560 ath79_eth0_data.phy_mask = BIT(4); 561 /* read out from vendor */ 562 ath79_eth0_pll_data.pll_1000 = 0x2000000; 563 ath79_eth0_pll_data.pll_10 = 0x1313; 564 ath79_register_eth(0); 565 566 ath79_register_mdio(1, 0x0); 567 ath79_eth1_data.phy_mask = BIT(3); 568 ath79_register_eth(1); 569} 570 571 572MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M_XW, "UBNT-NM-XW", "Ubiquiti Nanostation M XW", 573 ubnt_nano_m_xw_setup); 574 575MIPS_MACHINE(ATH79_MACH_UBNT_LOCO_M_XW, "UBNT-LOCO-XW", "Ubiquiti Loco M XW", 576 ubnt_loco_m_xw_setup); 577 578MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M_XW, "UBNT-RM-XW", "Ubiquiti Rocket M XW", 579 ubnt_rocket_m_xw_setup); 580 581MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M_TI, "UBNT-RM-TI", "Ubiquiti Rocket M TI", 582 ubnt_rocket_m_ti_setup); 583 584static struct gpio_led ubnt_airgateway_gpio_leds[] __initdata = { 585 { 586 .name = "ubnt:blue:wlan", 587 .gpio = 0, 588 }, { 589 .name = "ubnt:white:status", 590 .gpio = 1, 591 }, 592}; 593 594static struct gpio_keys_button airgateway_gpio_keys[] __initdata = { 595 { 596 .desc = "reset", 597 .type = EV_KEY, 598 .code = KEY_RESTART, 599 .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL, 600 .gpio = 12, 601 .active_low = 1, 602 } 603}; 604 605static void __init ubnt_airgateway_setup(void) 606{ 607 u32 t; 608 u8 *mac0 = (u8 *) KSEG1ADDR(0x1fff0000); 609 u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN); 610 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); 611 612 613 ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN | 614 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN | 615 AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN | 616 AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN | 617 AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN); 618 619 t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP); 620 t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN; 621 ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t); 622 623 ath79_register_m25p80(NULL); 624 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airgateway_gpio_leds), 625 ubnt_airgateway_gpio_leds); 626 627 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL, 628 ARRAY_SIZE(airgateway_gpio_keys), 629 airgateway_gpio_keys); 630 631 ath79_init_mac(ath79_eth1_data.mac_addr, mac0, 0); 632 ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0); 633 634 ath79_register_mdio(0, 0x0); 635 636 ath79_register_eth(1); 637 ath79_register_eth(0); 638 639 ath79_register_wmac(ee, NULL); 640} 641 642MIPS_MACHINE(ATH79_MACH_UBNT_AIRGW, "UBNT-AGW", "Ubiquiti AirGateway", 643 ubnt_airgateway_setup); 644 645static struct gpio_led ubnt_airgateway_pro_gpio_leds[] __initdata = { 646 { 647 .name = "ubnt:blue:wlan", 648 .gpio = 13, 649 }, { 650 .name = "ubnt:white:status", 651 .gpio = 17, 652 }, 653}; 654 655 656static struct gpio_keys_button airgateway_pro_gpio_keys[] __initdata = { 657 { 658 .desc = "reset", 659 .type = EV_KEY, 660 .code = KEY_RESTART, 661 .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL, 662 .gpio = 12, 663 .active_low = 1, 664 } 665}; 666 667static void __init ubnt_airgateway_pro_setup(void) 668{ 669 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000); 670 u8 *mac0 = (u8 *) KSEG1ADDR(0x1fff0000); 671 672 ath79_register_m25p80(NULL); 673 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airgateway_pro_gpio_leds), 674 ubnt_airgateway_pro_gpio_leds); 675 676 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL, 677 ARRAY_SIZE(airgateway_pro_gpio_keys), 678 airgateway_pro_gpio_keys); 679 680 ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL); 681 ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL); 682 683 684 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE); 685 686 ath79_register_mdio(1, 0x0); 687 688 /* GMAC0 is left unused in this configuration */ 689 690 /* GMAC1 is connected to MAC0 on the internal switch */ 691 /* The PoE/WAN port connects to port 5 on the internal switch */ 692 /* The LAN port connects to port 4 on the internal switch */ 693 ath79_init_mac(ath79_eth1_data.mac_addr, mac0, 0); 694 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; 695 ath79_register_eth(1); 696 697} 698 699MIPS_MACHINE(ATH79_MACH_UBNT_AIRGWP, "UBNT-AGWP", "Ubiquiti AirGateway Pro", 700 ubnt_airgateway_pro_setup); 701