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/irq.h>
13 +#include <asm/mach-ath79/ar71xx_regs.h>
15 #include "dev-ap9x-pci.h"
17 #include "dev-gpio-buttons.h"
18 #include "dev-leds-gpio.h"
19 #include "dev-m25p80.h"
21 +#include "dev-wmac.h"
22 #include "machtypes.h"
25 #define UBNT_XM_GPIO_LED_L1 0
26 #define UBNT_XM_GPIO_LED_L2 1
29 static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
31 - .name = "ubnt-xm:red:link1",
32 + .name = "ubnt:red:link1",
33 .gpio = UBNT_XM_GPIO_LED_L1,
36 - .name = "ubnt-xm:orange:link2",
37 + .name = "ubnt:orange:link2",
38 .gpio = UBNT_XM_GPIO_LED_L2,
41 - .name = "ubnt-xm:green:link3",
42 + .name = "ubnt:green:link3",
43 .gpio = UBNT_XM_GPIO_LED_L3,
46 - .name = "ubnt-xm:green:link4",
47 + .name = "ubnt:green:link4",
48 .gpio = UBNT_XM_GPIO_LED_L4,
51 @@ -66,9 +72,13 @@ static struct gpio_keys_button ubnt_xm_g
55 +#define UBNT_M_WAN_PHYMASK BIT(4)
57 static void __init ubnt_xm_init(void)
59 u8 *eeprom = (u8 *) KSEG1ADDR(UBNT_XM_EEPROM_ADDR);
60 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
61 + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
63 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
65 @@ -79,9 +89,242 @@ static void __init ubnt_xm_init(void)
67 ath79_register_m25p80(NULL);
68 ap91_pci_init(eeprom, NULL);
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);
76 MIPS_MACHINE(ATH79_MACH_UBNT_XM,
78 "Ubiquiti Networks XM (rev 1.0) board",
81 +MIPS_MACHINE(ATH79_MACH_UBNT_BULLET_M, "UBNT-BM", "Ubiquiti Bullet M",
84 +static void __init ubnt_rocket_m_setup(void)
87 + ath79_register_usb();
90 +MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M, "UBNT-RM", "Ubiquiti Rocket M",
91 + ubnt_rocket_m_setup);
93 +static void __init ubnt_nano_m_setup(void)
96 + ath79_register_eth(1);
99 +MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M, "UBNT-NM", "Ubiquiti Nanostation M",
100 + ubnt_nano_m_setup);
102 +static struct gpio_led ubnt_airrouter_leds_gpio[] __initdata = {
104 + .name = "ubnt:green:globe",
108 + .name = "ubnt:green:power",
111 + .default_state = LEDS_GPIO_DEFSTATE_ON,
115 +static void __init ubnt_airrouter_setup(void)
117 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
118 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
120 + ath79_register_m25p80(NULL);
121 + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
123 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
124 + ath79_init_local_mac(ath79_eth1_data.mac_addr, mac1);
126 + ath79_register_eth(1);
127 + ath79_register_eth(0);
128 + ath79_register_usb();
130 + ap91_pci_init(ee, NULL);
131 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airrouter_leds_gpio),
132 + ubnt_airrouter_leds_gpio);
134 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
135 + ARRAY_SIZE(ubnt_xm_gpio_keys),
136 + ubnt_xm_gpio_keys);
139 +MIPS_MACHINE(ATH79_MACH_UBNT_AIRROUTER, "UBNT-AR", "Ubiquiti AirRouter",
140 + ubnt_airrouter_setup);
142 +static struct gpio_led ubnt_unifi_leds_gpio[] __initdata = {
144 + .name = "ubnt:orange:dome",
148 + .name = "ubnt:green:dome",
154 +static struct gpio_led ubnt_unifi_outdoor_leds_gpio[] __initdata = {
156 + .name = "ubnt:orange:front",
160 + .name = "ubnt:green:front",
166 +static void __init ubnt_unifi_setup(void)
168 + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
169 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
171 + ath79_register_m25p80(NULL);
173 + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
175 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
176 + ath79_register_eth(0);
178 + ap91_pci_init(ee, NULL);
180 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_leds_gpio),
181 + ubnt_unifi_leds_gpio);
183 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
184 + ARRAY_SIZE(ubnt_xm_gpio_keys),
185 + ubnt_xm_gpio_keys);
188 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI, "UBNT-UF", "Ubiquiti UniFi",
192 +#define UBNT_UNIFIOD_PRI_PHYMASK BIT(4)
193 +#define UBNT_UNIFIOD_2ND_PHYMASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
195 +static void __init ubnt_unifi_outdoor_setup(void)
197 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
198 + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
199 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
201 + ath79_register_m25p80(NULL);
203 + ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
204 + UBNT_UNIFIOD_2ND_PHYMASK));
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);
211 + ap91_pci_init(ee, NULL);
213 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_leds_gpio),
214 + ubnt_unifi_outdoor_leds_gpio);
217 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR, "UBNT-U20",
218 + "Ubiquiti UniFiAP Outdoor",
219 + ubnt_unifi_outdoor_setup);
221 +static struct gpio_led ubnt_uap_pro_gpio_leds[] __initdata = {
223 + .name = "ubnt:white:dome",
226 + .name = "ubnt:blue:dome",
231 +static struct gpio_keys_button uap_pro_gpio_keys[] __initdata = {
235 + .code = KEY_RESTART,
236 + .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
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,
250 +static struct ar8327_platform_data uap_pro_ar8327_data = {
251 + .pad0_cfg = &uap_pro_ar8327_pad0_cfg,
254 + .speed = AR8327_PORT_SPEED_1000,
261 +static struct mdio_board_info uap_pro_mdio0_info[] = {
263 + .bus_id = "ag71xx-mdio.0",
265 + .platform_data = &uap_pro_ar8327_data,
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
274 +static void __init ubnt_uap_pro_setup(void)
276 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
278 + ath79_register_m25p80(NULL);
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);
286 + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
287 + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
289 + ath79_register_mdio(0, 0x0);
290 + mdiobus_register_board_info(uap_pro_mdio0_info,
291 + ARRAY_SIZE(uap_pro_mdio0_info));
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);
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);
305 +MIPS_MACHINE(ATH79_MACH_UBNT_UAP_PRO, "UAP-PRO", "Ubiquiti UniFi AP Pro",
306 + ubnt_uap_pro_setup);
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.
313 config ATH79_MACH_UBNT_XM
314 - bool "Ubiquiti Networks XM (rev 1.0) board"
315 + bool "Ubiquiti Networks XM/UniFi boards"
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
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 */