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,246 @@ 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);
216 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
217 + ARRAY_SIZE(ubnt_xm_gpio_keys),
218 + ubnt_xm_gpio_keys);
221 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR, "UBNT-U20",
222 + "Ubiquiti UniFiAP Outdoor",
223 + ubnt_unifi_outdoor_setup);
225 +static struct gpio_led ubnt_uap_pro_gpio_leds[] __initdata = {
227 + .name = "ubnt:white:dome",
230 + .name = "ubnt:blue:dome",
235 +static struct gpio_keys_button uap_pro_gpio_keys[] __initdata = {
239 + .code = KEY_RESTART,
240 + .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
246 +static struct ar8327_pad_cfg uap_pro_ar8327_pad0_cfg = {
247 + .mode = AR8327_PAD_MAC_RGMII,
248 + .txclk_delay_en = true,
249 + .rxclk_delay_en = true,
250 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
251 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
254 +static struct ar8327_platform_data uap_pro_ar8327_data = {
255 + .pad0_cfg = &uap_pro_ar8327_pad0_cfg,
258 + .speed = AR8327_PORT_SPEED_1000,
265 +static struct mdio_board_info uap_pro_mdio0_info[] = {
267 + .bus_id = "ag71xx-mdio.0",
269 + .platform_data = &uap_pro_ar8327_data,
273 +#define UAP_PRO_MAC0_OFFSET 0x0000
274 +#define UAP_PRO_MAC1_OFFSET 0x0006
275 +#define UAP_PRO_WMAC_CALDATA_OFFSET 0x1000
276 +#define UAP_PRO_PCI_CALDATA_OFFSET 0x5000
278 +static void __init ubnt_uap_pro_setup(void)
280 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
282 + ath79_register_m25p80(NULL);
284 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_uap_pro_gpio_leds),
285 + ubnt_uap_pro_gpio_leds);
286 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
287 + ARRAY_SIZE(uap_pro_gpio_keys),
288 + uap_pro_gpio_keys);
290 + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
291 + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
293 + ath79_register_mdio(0, 0x0);
294 + mdiobus_register_board_info(uap_pro_mdio0_info,
295 + ARRAY_SIZE(uap_pro_mdio0_info));
297 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
298 + ath79_init_mac(ath79_eth0_data.mac_addr,
299 + eeprom + UAP_PRO_MAC0_OFFSET, 0);
301 + /* GMAC0 is connected to an AR8327 switch */
302 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
303 + ath79_eth0_data.phy_mask = BIT(0);
304 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
305 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
306 + ath79_register_eth(0);
309 +MIPS_MACHINE(ATH79_MACH_UBNT_UAP_PRO, "UAP-PRO", "Ubiquiti UniFi AP Pro",
310 + ubnt_uap_pro_setup);
312 --- a/arch/mips/ath79/Kconfig
313 +++ b/arch/mips/ath79/Kconfig
314 @@ -68,12 +68,16 @@ config ATH79_MACH_PB44
315 Atheros PB44 reference board.
317 config ATH79_MACH_UBNT_XM
318 - bool "Ubiquiti Networks XM (rev 1.0) board"
319 + bool "Ubiquiti Networks XM/UniFi boards"
322 select ATH79_DEV_AP9X_PCI if PCI
323 + select ATH79_DEV_ETH
324 select ATH79_DEV_GPIO_BUTTONS
325 select ATH79_DEV_LEDS_GPIO
326 select ATH79_DEV_M25P80
327 + select ATH79_DEV_USB
328 + select ATH79_DEV_WMAC
330 Say 'Y' here if you want your kernel to support the
331 Ubiquiti Networks XM (rev 1.0) board.
332 --- a/arch/mips/ath79/machtypes.h
333 +++ b/arch/mips/ath79/machtypes.h
334 @@ -22,6 +22,13 @@ enum ath79_mach_type {
335 ATH79_MACH_AP81, /* Atheros AP81 reference board */
336 ATH79_MACH_DB120, /* Atheros DB120 reference board */
337 ATH79_MACH_PB44, /* Atheros PB44 reference board */
338 + ATH79_MACH_UBNT_AIRROUTER, /* Ubiquiti AirRouter */
339 + ATH79_MACH_UBNT_BULLET_M, /* Ubiquiti Bullet M */
340 + ATH79_MACH_UBNT_NANO_M, /* Ubiquiti NanoStation M */
341 + ATH79_MACH_UBNT_ROCKET_M, /* Ubiquiti Rocket M */
342 + ATH79_MACH_UBNT_UAP_PRO, /* Ubiquiti UniFi AP Pro */
343 + ATH79_MACH_UBNT_UNIFI, /* Ubiquiti Unifi */
344 + ATH79_MACH_UBNT_UNIFI_OUTDOOR, /* Ubiquiti UnifiAP Outdoor */
345 ATH79_MACH_UBNT_XM, /* Ubiquiti Networks XM board rev 1.0 */