2 * Ubiquiti RouterStation support
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 * Copyright (C) 2008 Ubiquiti <support@ubnt.com>
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.
13 #include <asm/mach-ar71xx/ar71xx.h>
17 #include "dev-m25p80.h"
18 #include "dev-ap91-pci.h"
19 #include "dev-gpio-buttons.h"
20 #include "dev-pb42-pci.h"
21 #include "dev-leds-gpio.h"
24 #define UBNT_RS_GPIO_LED_RF 2
25 #define UBNT_RS_GPIO_SW4 8
27 #define UBNT_LS_SR71_GPIO_LED_D25 0
28 #define UBNT_LS_SR71_GPIO_LED_D26 1
29 #define UBNT_LS_SR71_GPIO_LED_D24 2
30 #define UBNT_LS_SR71_GPIO_LED_D23 4
31 #define UBNT_LS_SR71_GPIO_LED_D22 5
32 #define UBNT_LS_SR71_GPIO_LED_D27 6
33 #define UBNT_LS_SR71_GPIO_LED_D28 7
35 #define UBNT_M_GPIO_LED_L1 0
36 #define UBNT_M_GPIO_LED_L2 1
37 #define UBNT_M_GPIO_LED_L3 11
38 #define UBNT_M_GPIO_LED_L4 7
39 #define UBNT_M_GPIO_BTN_RESET 12
41 #define UBNT_KEYS_POLL_INTERVAL 20 /* msecs */
42 #define UBNT_KEYS_DEBOUNCE_INTERVAL (3 * UBNT_KEYS_POLL_INTERVAL)
44 static struct gpio_led ubnt_rs_leds_gpio
[] __initdata
= {
46 .name
= "ubnt:green:rf",
47 .gpio
= UBNT_RS_GPIO_LED_RF
,
52 static struct gpio_led ubnt_ls_sr71_leds_gpio
[] __initdata
= {
54 .name
= "ubnt:green:d22",
55 .gpio
= UBNT_LS_SR71_GPIO_LED_D22
,
58 .name
= "ubnt:green:d23",
59 .gpio
= UBNT_LS_SR71_GPIO_LED_D23
,
62 .name
= "ubnt:green:d24",
63 .gpio
= UBNT_LS_SR71_GPIO_LED_D24
,
66 .name
= "ubnt:red:d25",
67 .gpio
= UBNT_LS_SR71_GPIO_LED_D25
,
70 .name
= "ubnt:red:d26",
71 .gpio
= UBNT_LS_SR71_GPIO_LED_D26
,
74 .name
= "ubnt:green:d27",
75 .gpio
= UBNT_LS_SR71_GPIO_LED_D27
,
78 .name
= "ubnt:green:d28",
79 .gpio
= UBNT_LS_SR71_GPIO_LED_D28
,
84 static struct gpio_led ubnt_m_leds_gpio
[] __initdata
= {
86 .name
= "ubnt:red:link1",
87 .gpio
= UBNT_M_GPIO_LED_L1
,
90 .name
= "ubnt:orange:link2",
91 .gpio
= UBNT_M_GPIO_LED_L2
,
94 .name
= "ubnt:green:link3",
95 .gpio
= UBNT_M_GPIO_LED_L3
,
98 .name
= "ubnt:green:link4",
99 .gpio
= UBNT_M_GPIO_LED_L4
,
104 static struct gpio_keys_button ubnt_gpio_keys
[] __initdata
= {
109 .debounce_interval
= UBNT_KEYS_DEBOUNCE_INTERVAL
,
110 .gpio
= UBNT_RS_GPIO_SW4
,
115 static struct gpio_keys_button ubnt_m_gpio_keys
[] __initdata
= {
120 .debounce_interval
= UBNT_KEYS_DEBOUNCE_INTERVAL
,
121 .gpio
= UBNT_M_GPIO_BTN_RESET
,
126 static const char *ubnt_part_probes
[] = {
131 static struct flash_platform_data ubnt_flash_data
= {
132 .part_probes
= ubnt_part_probes
,
135 static void __init
ubnt_generic_setup(void)
137 ar71xx_add_device_m25p80(&ubnt_flash_data
);
139 ar71xx_register_gpio_keys_polled(-1, UBNT_KEYS_POLL_INTERVAL
,
140 ARRAY_SIZE(ubnt_gpio_keys
),
147 * There is Secondary MAC address duplicate problem with some UBNT HW batches.
148 * Do not increase Secondary MAC address by 1 but do workaround
149 * with 'Locally Administrated' bit.
151 static void __init
ubnt_init_secondary_mac(unsigned char *mac_base
)
153 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
, mac_base
, 0);
154 ar71xx_eth1_data
.mac_addr
[0] |= 0x02;
157 #define UBNT_RS_WAN_PHYMASK BIT(20)
158 #define UBNT_RS_LAN_PHYMASK (BIT(16) | BIT(17) | BIT(18) | BIT(19))
160 static void __init
ubnt_rs_setup(void)
162 ubnt_generic_setup();
164 ar71xx_add_device_mdio(0, ~(UBNT_RS_WAN_PHYMASK
| UBNT_RS_LAN_PHYMASK
));
166 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, ar71xx_mac_base
, 0);
167 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
168 ar71xx_eth0_data
.phy_mask
= UBNT_RS_WAN_PHYMASK
;
170 ubnt_init_secondary_mac(ar71xx_mac_base
);
171 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RMII
;
172 ar71xx_eth1_data
.speed
= SPEED_100
;
173 ar71xx_eth1_data
.duplex
= DUPLEX_FULL
;
175 ar71xx_add_device_eth(0);
176 ar71xx_add_device_eth(1);
178 ar71xx_add_device_usb();
180 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio
),
184 MIPS_MACHINE(AR71XX_MACH_UBNT_RS
, "UBNT-RS", "Ubiquiti RouterStation",
187 #define UBNT_RSPRO_WAN_PHYMASK BIT(4)
188 #define UBNT_RSPRO_LAN_PHYMASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
190 static void __init
ubnt_rspro_setup(void)
192 ubnt_generic_setup();
194 ar71xx_add_device_mdio(0, ~(UBNT_RSPRO_WAN_PHYMASK
|
195 UBNT_RSPRO_LAN_PHYMASK
));
197 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, ar71xx_mac_base
, 0);
198 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
199 ar71xx_eth0_data
.phy_mask
= UBNT_RSPRO_WAN_PHYMASK
;
201 ubnt_init_secondary_mac(ar71xx_mac_base
);
202 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
203 ar71xx_eth1_data
.phy_mask
= UBNT_RSPRO_LAN_PHYMASK
;
204 ar71xx_eth1_data
.speed
= SPEED_1000
;
205 ar71xx_eth1_data
.duplex
= DUPLEX_FULL
;
207 ar71xx_add_device_eth(0);
208 ar71xx_add_device_eth(1);
210 ar71xx_add_device_usb();
212 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio
),
216 MIPS_MACHINE(AR71XX_MACH_UBNT_RSPRO
, "UBNT-RSPRO", "Ubiquiti RouterStation Pro",
219 static void __init
ubnt_lsx_setup(void)
221 ubnt_generic_setup();
224 MIPS_MACHINE(AR71XX_MACH_UBNT_LSX
, "UBNT-LSX", "Ubiquiti LSX", ubnt_lsx_setup
);
226 #define UBNT_LSSR71_PHY_MASK BIT(1)
228 static void __init
ubnt_lssr71_setup(void)
230 ubnt_generic_setup();
232 ar71xx_add_device_mdio(0, ~UBNT_LSSR71_PHY_MASK
);
234 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, ar71xx_mac_base
, 0);
235 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
236 ar71xx_eth0_data
.phy_mask
= UBNT_LSSR71_PHY_MASK
;
238 ar71xx_add_device_eth(0);
240 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_ls_sr71_leds_gpio
),
241 ubnt_ls_sr71_leds_gpio
);
244 MIPS_MACHINE(AR71XX_MACH_UBNT_LSSR71
, "UBNT-LS-SR71", "Ubiquiti LS-SR71",
247 #define UBNT_M_WAN_PHYMASK BIT(4)
249 static void __init
ubnt_m_setup(void)
251 u8
*mac1
= (u8
*) KSEG1ADDR(0x1fff0000);
252 u8
*mac2
= (u8
*) KSEG1ADDR(0x1fff0000 + ETH_ALEN
);
253 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
255 ar71xx_add_device_m25p80(NULL
);
257 ar71xx_add_device_mdio(0, ~UBNT_M_WAN_PHYMASK
);
259 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac1
, 0);
260 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
, mac2
, 0);
261 ar71xx_add_device_eth(0);
263 ap91_pci_init(ee
, NULL
);
265 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_m_leds_gpio
),
268 ar71xx_register_gpio_keys_polled(-1, UBNT_KEYS_POLL_INTERVAL
,
269 ARRAY_SIZE(ubnt_m_gpio_keys
),
273 static void __init
ubnt_rocket_m_setup(void)
276 ar71xx_add_device_usb();
279 MIPS_MACHINE(AR71XX_MACH_UBNT_BULLET_M
, "UBNT-BM", "Ubiquiti Bullet M",
281 MIPS_MACHINE(AR71XX_MACH_UBNT_ROCKET_M
, "UBNT-RM", "Ubiquiti Rocket M",
282 ubnt_rocket_m_setup
);
284 /* TODO detect the second ethernet port and use one
285 init function for all Ubiquiti MIMO series products */
286 static void __init
ubnt_nano_m_setup(void)
289 ar71xx_add_device_eth(1);
292 MIPS_MACHINE(AR71XX_MACH_UBNT_NANO_M
, "UBNT-NM", "Ubiquiti Nanostation M",
295 static struct gpio_led ubnt_airrouter_leds_gpio
[] __initdata
= {
297 .name
= "ubnt:green:globe",
303 static void __init
ubnt_airrouter_setup(void)
305 u8
*mac1
= (u8
*) KSEG1ADDR(0x1fff0000);
306 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
308 ar71xx_add_device_m25p80(NULL
);
309 ar71xx_add_device_mdio(0, ~UBNT_M_WAN_PHYMASK
);
311 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac1
, 0);
312 ubnt_init_secondary_mac(mac1
);
314 ar71xx_add_device_eth(1);
315 ar71xx_add_device_eth(0);
316 ar71xx_add_device_usb();
318 ap91_pci_init(ee
, NULL
);
319 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_airrouter_leds_gpio
),
320 ubnt_airrouter_leds_gpio
);
323 MIPS_MACHINE(AR71XX_MACH_UBNT_AIRROUTER
, "UBNT-AR", "Ubiquiti AirRouter",
324 ubnt_airrouter_setup
);
326 static struct gpio_led ubnt_unifi_leds_gpio
[] __initdata
= {
328 .name
= "ubnt:orange:dome",
332 .name
= "ubnt:green:dome",
338 static void __init
ubnt_unifi_setup(void)
340 u8
*mac
= (u8
*) KSEG1ADDR(0x1fff0000);
341 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
343 ar71xx_add_device_m25p80(NULL
);
345 ar71xx_add_device_mdio(0, ~UBNT_M_WAN_PHYMASK
);
347 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac
, 0);
348 ar71xx_add_device_eth(0);
350 ap91_pci_init(ee
, NULL
);
352 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_leds_gpio
),
353 ubnt_unifi_leds_gpio
);
356 MIPS_MACHINE(AR71XX_MACH_UBNT_UNIFI
, "UBNT-UF", "Ubiquiti UniFi",