| 1 | --- a/arch/mips/ath79/mach-ubnt-xm.c |
| 2 | +++ b/arch/mips/ath79/mach-ubnt-xm.c |
| 3 | @@ -12,16 +12,22 @@ |
| 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/irq.h> |
| 13 | +#include <asm/mach-ath79/ar71xx_regs.h> |
| 14 | |
| 15 | #include "dev-ap9x-pci.h" |
| 16 | +#include "dev-eth.h" |
| 17 | #include "dev-gpio-buttons.h" |
| 18 | #include "dev-leds-gpio.h" |
| 19 | #include "dev-m25p80.h" |
| 20 | +#include "dev-usb.h" |
| 21 | +#include "dev-wmac.h" |
| 22 | #include "machtypes.h" |
| 23 | -#include "pci.h" |
| 24 | |
| 25 | #define UBNT_XM_GPIO_LED_L1 0 |
| 26 | #define UBNT_XM_GPIO_LED_L2 1 |
| 27 | @@ -37,19 +43,19 @@ |
| 28 | |
| 29 | static struct gpio_led ubnt_xm_leds_gpio[] __initdata = { |
| 30 | { |
| 31 | - .name = "ubnt-xm:red:link1", |
| 32 | + .name = "ubnt:red:link1", |
| 33 | .gpio = UBNT_XM_GPIO_LED_L1, |
| 34 | .active_low = 0, |
| 35 | }, { |
| 36 | - .name = "ubnt-xm:orange:link2", |
| 37 | + .name = "ubnt:orange:link2", |
| 38 | .gpio = UBNT_XM_GPIO_LED_L2, |
| 39 | .active_low = 0, |
| 40 | }, { |
| 41 | - .name = "ubnt-xm:green:link3", |
| 42 | + .name = "ubnt:green:link3", |
| 43 | .gpio = UBNT_XM_GPIO_LED_L3, |
| 44 | .active_low = 0, |
| 45 | }, { |
| 46 | - .name = "ubnt-xm:green:link4", |
| 47 | + .name = "ubnt:green:link4", |
| 48 | .gpio = UBNT_XM_GPIO_LED_L4, |
| 49 | .active_low = 0, |
| 50 | }, |
| 51 | @@ -66,9 +72,13 @@ static struct gpio_keys_button ubnt_xm_g |
| 52 | } |
| 53 | }; |
| 54 | |
| 55 | +#define UBNT_M_WAN_PHYMASK BIT(4) |
| 56 | + |
| 57 | static void __init ubnt_xm_init(void) |
| 58 | { |
| 59 | u8 *eeprom = (u8 *) KSEG1ADDR(UBNT_XM_EEPROM_ADDR); |
| 60 | + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000); |
| 61 | + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN); |
| 62 | |
| 63 | ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio), |
| 64 | ubnt_xm_leds_gpio); |
| 65 | @@ -79,9 +89,242 @@ static void __init ubnt_xm_init(void) |
| 66 | |
| 67 | ath79_register_m25p80(NULL); |
| 68 | ap91_pci_init(eeprom, NULL); |
| 69 | + |
| 70 | + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK); |
| 71 | + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0); |
| 72 | + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0); |
| 73 | + ath79_register_eth(0); |
| 74 | } |
| 75 | |
| 76 | MIPS_MACHINE(ATH79_MACH_UBNT_XM, |
| 77 | "UBNT-XM", |
| 78 | "Ubiquiti Networks XM (rev 1.0) board", |
| 79 | ubnt_xm_init); |
| 80 | + |
| 81 | +MIPS_MACHINE(ATH79_MACH_UBNT_BULLET_M, "UBNT-BM", "Ubiquiti Bullet M", |
| 82 | + ubnt_xm_init); |
| 83 | + |
| 84 | +static void __init ubnt_rocket_m_setup(void) |
| 85 | +{ |
| 86 | + ubnt_xm_init(); |
| 87 | + ath79_register_usb(); |
| 88 | +} |
| 89 | + |
| 90 | +MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M, "UBNT-RM", "Ubiquiti Rocket M", |
| 91 | + ubnt_rocket_m_setup); |
| 92 | + |
| 93 | +static void __init ubnt_nano_m_setup(void) |
| 94 | +{ |
| 95 | + ubnt_xm_init(); |
| 96 | + ath79_register_eth(1); |
| 97 | +} |
| 98 | + |
| 99 | +MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M, "UBNT-NM", "Ubiquiti Nanostation M", |
| 100 | + ubnt_nano_m_setup); |
| 101 | + |
| 102 | +static struct gpio_led ubnt_airrouter_leds_gpio[] __initdata = { |
| 103 | + { |
| 104 | + .name = "ubnt:green:globe", |
| 105 | + .gpio = 0, |
| 106 | + .active_low = 1, |
| 107 | + }, { |
| 108 | + .name = "ubnt:green:power", |
| 109 | + .gpio = 11, |
| 110 | + .active_low = 1, |
| 111 | + .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 112 | + } |
| 113 | +}; |
| 114 | + |
| 115 | +static void __init ubnt_airrouter_setup(void) |
| 116 | +{ |
| 117 | + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000); |
| 118 | + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); |
| 119 | + |
| 120 | + ath79_register_m25p80(NULL); |
| 121 | + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK); |
| 122 | + |
| 123 | + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0); |
| 124 | + ath79_init_local_mac(ath79_eth1_data.mac_addr, mac1); |
| 125 | + |
| 126 | + ath79_register_eth(1); |
| 127 | + ath79_register_eth(0); |
| 128 | + ath79_register_usb(); |
| 129 | + |
| 130 | + ap91_pci_init(ee, NULL); |
| 131 | + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airrouter_leds_gpio), |
| 132 | + ubnt_airrouter_leds_gpio); |
| 133 | + |
| 134 | + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL, |
| 135 | + ARRAY_SIZE(ubnt_xm_gpio_keys), |
| 136 | + ubnt_xm_gpio_keys); |
| 137 | +} |
| 138 | + |
| 139 | +MIPS_MACHINE(ATH79_MACH_UBNT_AIRROUTER, "UBNT-AR", "Ubiquiti AirRouter", |
| 140 | + ubnt_airrouter_setup); |
| 141 | + |
| 142 | +static struct gpio_led ubnt_unifi_leds_gpio[] __initdata = { |
| 143 | + { |
| 144 | + .name = "ubnt:orange:dome", |
| 145 | + .gpio = 1, |
| 146 | + .active_low = 0, |
| 147 | + }, { |
| 148 | + .name = "ubnt:green:dome", |
| 149 | + .gpio = 0, |
| 150 | + .active_low = 0, |
| 151 | + } |
| 152 | +}; |
| 153 | + |
| 154 | +static struct gpio_led ubnt_unifi_outdoor_leds_gpio[] __initdata = { |
| 155 | + { |
| 156 | + .name = "ubnt:orange:front", |
| 157 | + .gpio = 1, |
| 158 | + .active_low = 0, |
| 159 | + }, { |
| 160 | + .name = "ubnt:green:front", |
| 161 | + .gpio = 0, |
| 162 | + .active_low = 0, |
| 163 | + } |
| 164 | +}; |
| 165 | + |
| 166 | +static void __init ubnt_unifi_setup(void) |
| 167 | +{ |
| 168 | + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000); |
| 169 | + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); |
| 170 | + |
| 171 | + ath79_register_m25p80(NULL); |
| 172 | + |
| 173 | + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK); |
| 174 | + |
| 175 | + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0); |
| 176 | + ath79_register_eth(0); |
| 177 | + |
| 178 | + ap91_pci_init(ee, NULL); |
| 179 | + |
| 180 | + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_leds_gpio), |
| 181 | + ubnt_unifi_leds_gpio); |
| 182 | + |
| 183 | + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL, |
| 184 | + ARRAY_SIZE(ubnt_xm_gpio_keys), |
| 185 | + ubnt_xm_gpio_keys); |
| 186 | +} |
| 187 | + |
| 188 | +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI, "UBNT-UF", "Ubiquiti UniFi", |
| 189 | + ubnt_unifi_setup); |
| 190 | + |
| 191 | + |
| 192 | +#define UBNT_UNIFIOD_PRI_PHYMASK BIT(4) |
| 193 | +#define UBNT_UNIFIOD_2ND_PHYMASK (BIT(0) | BIT(1) | BIT(2) | BIT(3)) |
| 194 | + |
| 195 | +static void __init ubnt_unifi_outdoor_setup(void) |
| 196 | +{ |
| 197 | + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000); |
| 198 | + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN); |
| 199 | + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); |
| 200 | + |
| 201 | + ath79_register_m25p80(NULL); |
| 202 | + |
| 203 | + ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK | |
| 204 | + UBNT_UNIFIOD_2ND_PHYMASK)); |
| 205 | + |
| 206 | + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0); |
| 207 | + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0); |
| 208 | + ath79_register_eth(0); |
| 209 | + ath79_register_eth(1); |
| 210 | + |
| 211 | + ap91_pci_init(ee, NULL); |
| 212 | + |
| 213 | + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_leds_gpio), |
| 214 | + ubnt_unifi_outdoor_leds_gpio); |
| 215 | +} |
| 216 | + |
| 217 | +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR, "UBNT-U20", |
| 218 | + "Ubiquiti UniFiAP Outdoor", |
| 219 | + ubnt_unifi_outdoor_setup); |
| 220 | + |
| 221 | +static struct gpio_led ubnt_uap_pro_gpio_leds[] __initdata = { |
| 222 | + { |
| 223 | + .name = "ubnt:white:dome", |
| 224 | + .gpio = 12, |
| 225 | + }, { |
| 226 | + .name = "ubnt:blue:dome", |
| 227 | + .gpio = 13, |
| 228 | + } |
| 229 | +}; |
| 230 | + |
| 231 | +static struct gpio_keys_button uap_pro_gpio_keys[] __initdata = { |
| 232 | + { |
| 233 | + .desc = "reset", |
| 234 | + .type = EV_KEY, |
| 235 | + .code = KEY_RESTART, |
| 236 | + .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL, |
| 237 | + .gpio = 17, |
| 238 | + .active_low = 1, |
| 239 | + } |
| 240 | +}; |
| 241 | + |
| 242 | +static struct ar8327_pad_cfg uap_pro_ar8327_pad0_cfg = { |
| 243 | + .mode = AR8327_PAD_MAC_RGMII, |
| 244 | + .txclk_delay_en = true, |
| 245 | + .rxclk_delay_en = true, |
| 246 | + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1, |
| 247 | + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2, |
| 248 | +}; |
| 249 | + |
| 250 | +static struct ar8327_platform_data uap_pro_ar8327_data = { |
| 251 | + .pad0_cfg = &uap_pro_ar8327_pad0_cfg, |
| 252 | + .port0_cfg = { |
| 253 | + .force_link = 1, |
| 254 | + .speed = AR8327_PORT_SPEED_1000, |
| 255 | + .duplex = 1, |
| 256 | + .txpause = 1, |
| 257 | + .rxpause = 1, |
| 258 | + }, |
| 259 | +}; |
| 260 | + |
| 261 | +static struct mdio_board_info uap_pro_mdio0_info[] = { |
| 262 | + { |
| 263 | + .bus_id = "ag71xx-mdio.0", |
| 264 | + .phy_addr = 0, |
| 265 | + .platform_data = &uap_pro_ar8327_data, |
| 266 | + }, |
| 267 | +}; |
| 268 | + |
| 269 | +#define UAP_PRO_MAC0_OFFSET 0x0000 |
| 270 | +#define UAP_PRO_MAC1_OFFSET 0x0006 |
| 271 | +#define UAP_PRO_WMAC_CALDATA_OFFSET 0x1000 |
| 272 | +#define UAP_PRO_PCI_CALDATA_OFFSET 0x5000 |
| 273 | + |
| 274 | +static void __init ubnt_uap_pro_setup(void) |
| 275 | +{ |
| 276 | + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000); |
| 277 | + |
| 278 | + ath79_register_m25p80(NULL); |
| 279 | + |
| 280 | + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_uap_pro_gpio_leds), |
| 281 | + ubnt_uap_pro_gpio_leds); |
| 282 | + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL, |
| 283 | + ARRAY_SIZE(uap_pro_gpio_keys), |
| 284 | + uap_pro_gpio_keys); |
| 285 | + |
| 286 | + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL); |
| 287 | + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL); |
| 288 | + |
| 289 | + ath79_register_mdio(0, 0x0); |
| 290 | + mdiobus_register_board_info(uap_pro_mdio0_info, |
| 291 | + ARRAY_SIZE(uap_pro_mdio0_info)); |
| 292 | + |
| 293 | + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0); |
| 294 | + ath79_init_mac(ath79_eth0_data.mac_addr, |
| 295 | + eeprom + UAP_PRO_MAC0_OFFSET, 0); |
| 296 | + |
| 297 | + /* GMAC0 is connected to an AR8327 switch */ |
| 298 | + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; |
| 299 | + ath79_eth0_data.phy_mask = BIT(0); |
| 300 | + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; |
| 301 | + ath79_eth0_pll_data.pll_1000 = 0x06000000; |
| 302 | + ath79_register_eth(0); |
| 303 | +} |
| 304 | + |
| 305 | +MIPS_MACHINE(ATH79_MACH_UBNT_UAP_PRO, "UAP-PRO", "Ubiquiti UniFi AP Pro", |
| 306 | + ubnt_uap_pro_setup); |
| 307 | + |
| 308 | --- a/arch/mips/ath79/Kconfig |
| 309 | +++ b/arch/mips/ath79/Kconfig |
| 310 | @@ -68,12 +68,16 @@ config ATH79_MACH_PB44 |
| 311 | Atheros PB44 reference board. |
| 312 | |
| 313 | config ATH79_MACH_UBNT_XM |
| 314 | - bool "Ubiquiti Networks XM (rev 1.0) board" |
| 315 | + bool "Ubiquiti Networks XM/UniFi boards" |
| 316 | select SOC_AR724X |
| 317 | + select SOC_AR934X |
| 318 | select ATH79_DEV_AP9X_PCI if PCI |
| 319 | + select ATH79_DEV_ETH |
| 320 | select ATH79_DEV_GPIO_BUTTONS |
| 321 | select ATH79_DEV_LEDS_GPIO |
| 322 | select ATH79_DEV_M25P80 |
| 323 | + select ATH79_DEV_USB |
| 324 | + select ATH79_DEV_WMAC |
| 325 | help |
| 326 | Say 'Y' here if you want your kernel to support the |
| 327 | Ubiquiti Networks XM (rev 1.0) board. |
| 328 | --- a/arch/mips/ath79/machtypes.h |
| 329 | +++ b/arch/mips/ath79/machtypes.h |
| 330 | @@ -22,6 +22,13 @@ enum ath79_mach_type { |
| 331 | ATH79_MACH_AP81, /* Atheros AP81 reference board */ |
| 332 | ATH79_MACH_DB120, /* Atheros DB120 reference board */ |
| 333 | ATH79_MACH_PB44, /* Atheros PB44 reference board */ |
| 334 | + ATH79_MACH_UBNT_AIRROUTER, /* Ubiquiti AirRouter */ |
| 335 | + ATH79_MACH_UBNT_BULLET_M, /* Ubiquiti Bullet M */ |
| 336 | + ATH79_MACH_UBNT_NANO_M, /* Ubiquiti NanoStation M */ |
| 337 | + ATH79_MACH_UBNT_ROCKET_M, /* Ubiquiti Rocket M */ |
| 338 | + ATH79_MACH_UBNT_UAP_PRO, /* Ubiquiti UniFi AP Pro */ |
| 339 | + ATH79_MACH_UBNT_UNIFI, /* Ubiquiti Unifi */ |
| 340 | + ATH79_MACH_UBNT_UNIFI_OUTDOOR, /* Ubiquiti UnifiAP Outdoor */ |
| 341 | ATH79_MACH_UBNT_XM, /* Ubiquiti Networks XM board rev 1.0 */ |
| 342 | }; |
| 343 | |
| 344 | |