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_BUTTONS_POLL_INTERVAL 20
43 static struct gpio_led ubnt_rs_leds_gpio
[] __initdata
= {
45 .name
= "ubnt:green:rf",
46 .gpio
= UBNT_RS_GPIO_LED_RF
,
51 static struct gpio_led ubnt_ls_sr71_leds_gpio
[] __initdata
= {
53 .name
= "ubnt:green:d22",
54 .gpio
= UBNT_LS_SR71_GPIO_LED_D22
,
57 .name
= "ubnt:green:d23",
58 .gpio
= UBNT_LS_SR71_GPIO_LED_D23
,
61 .name
= "ubnt:green:d24",
62 .gpio
= UBNT_LS_SR71_GPIO_LED_D24
,
65 .name
= "ubnt:red:d25",
66 .gpio
= UBNT_LS_SR71_GPIO_LED_D25
,
69 .name
= "ubnt:red:d26",
70 .gpio
= UBNT_LS_SR71_GPIO_LED_D26
,
73 .name
= "ubnt:green:d27",
74 .gpio
= UBNT_LS_SR71_GPIO_LED_D27
,
77 .name
= "ubnt:green:d28",
78 .gpio
= UBNT_LS_SR71_GPIO_LED_D28
,
83 static struct gpio_led ubnt_m_leds_gpio
[] __initdata
= {
85 .name
= "ubnt:red:link1",
86 .gpio
= UBNT_M_GPIO_LED_L1
,
89 .name
= "ubnt:orange:link2",
90 .gpio
= UBNT_M_GPIO_LED_L2
,
93 .name
= "ubnt:green:link3",
94 .gpio
= UBNT_M_GPIO_LED_L3
,
97 .name
= "ubnt:green:link4",
98 .gpio
= UBNT_M_GPIO_LED_L4
,
103 static struct gpio_button ubnt_gpio_buttons
[] __initdata
= {
109 .gpio
= UBNT_RS_GPIO_SW4
,
114 static struct gpio_button ubnt_m_gpio_buttons
[] __initdata
= {
120 .gpio
= UBNT_M_GPIO_BTN_RESET
,
125 static void __init
ubnt_generic_setup(void)
127 ar71xx_add_device_m25p80(NULL
);
129 ar71xx_add_device_gpio_buttons(-1, UBNT_BUTTONS_POLL_INTERVAL
,
130 ARRAY_SIZE(ubnt_gpio_buttons
),
136 #define UBNT_RS_WAN_PHYMASK (1 << 20)
137 #define UBNT_RS_LAN_PHYMASK ((1 << 16) | (1 << 17) | (1 << 18) | (1 << 19))
139 static void __init
ubnt_rs_setup(void)
141 ubnt_generic_setup();
143 ar71xx_add_device_mdio(~(UBNT_RS_WAN_PHYMASK
| UBNT_RS_LAN_PHYMASK
));
145 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, ar71xx_mac_base
, 0);
146 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
147 ar71xx_eth0_data
.phy_mask
= UBNT_RS_WAN_PHYMASK
;
149 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
, ar71xx_mac_base
, 1);
150 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RMII
;
151 ar71xx_eth1_data
.speed
= SPEED_100
;
152 ar71xx_eth1_data
.duplex
= DUPLEX_FULL
;
154 ar71xx_add_device_eth(0);
155 ar71xx_add_device_eth(1);
157 ar71xx_add_device_usb();
159 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio
),
163 MIPS_MACHINE(AR71XX_MACH_UBNT_RS
, "UBNT-RS", "Ubiquiti RouterStation",
166 #define UBNT_RSPRO_WAN_PHYMASK (1 << 4)
167 #define UBNT_RSPRO_LAN_PHYMASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3))
169 static void __init
ubnt_rspro_setup(void)
171 ubnt_generic_setup();
173 ar71xx_add_device_mdio(~(UBNT_RSPRO_WAN_PHYMASK
|
174 UBNT_RSPRO_LAN_PHYMASK
));
176 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, ar71xx_mac_base
, 0);
177 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
178 ar71xx_eth0_data
.phy_mask
= UBNT_RSPRO_WAN_PHYMASK
;
180 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
, ar71xx_mac_base
, 1);
181 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
182 ar71xx_eth1_data
.phy_mask
= UBNT_RSPRO_LAN_PHYMASK
;
183 ar71xx_eth1_data
.speed
= SPEED_1000
;
184 ar71xx_eth1_data
.duplex
= DUPLEX_FULL
;
186 ar71xx_add_device_eth(0);
187 ar71xx_add_device_eth(1);
189 ar71xx_add_device_usb();
191 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio
),
195 MIPS_MACHINE(AR71XX_MACH_UBNT_RSPRO
, "UBNT-RSPRO", "Ubiquiti RouterStation Pro",
198 static void __init
ubnt_lsx_setup(void)
200 ubnt_generic_setup();
203 MIPS_MACHINE(AR71XX_MACH_UBNT_LSX
, "UBNT-LSX", "Ubiquiti LSX", ubnt_lsx_setup
);
205 #define UBNT_LSSR71_PHY_MASK (1 << 1)
207 static void __init
ubnt_lssr71_setup(void)
209 ubnt_generic_setup();
211 ar71xx_add_device_mdio(~UBNT_LSSR71_PHY_MASK
);
213 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, ar71xx_mac_base
, 0);
214 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
215 ar71xx_eth0_data
.phy_mask
= UBNT_LSSR71_PHY_MASK
;
217 ar71xx_add_device_eth(0);
219 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_ls_sr71_leds_gpio
),
220 ubnt_ls_sr71_leds_gpio
);
223 MIPS_MACHINE(AR71XX_MACH_UBNT_LSSR71
, "UBNT-LS-SR71", "Ubiquiti LS-SR71",
226 static void __init
ubnt_m_setup(void)
228 u8
*mac
= (u8
*) KSEG1ADDR(0x1fff0000);
229 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
231 ar71xx_add_device_m25p80(NULL
);
233 ar71xx_add_device_mdio(~0);
235 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac
, 0);
236 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
, mac
, 1);
237 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
238 ar71xx_eth0_data
.speed
= SPEED_100
;
239 ar71xx_eth0_data
.duplex
= DUPLEX_FULL
;
240 ar71xx_eth0_data
.fifo_cfg1
= 0x0010ffff;
241 ar71xx_eth0_data
.fifo_cfg2
= 0x015500aa;
242 ar71xx_eth0_data
.fifo_cfg3
= 0x01f00140;
244 ar71xx_add_device_eth(0);
246 ap91_pci_init(ee
, NULL
);
248 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_m_leds_gpio
),
251 ar71xx_add_device_gpio_buttons(-1, UBNT_BUTTONS_POLL_INTERVAL
,
252 ARRAY_SIZE(ubnt_m_gpio_buttons
),
253 ubnt_m_gpio_buttons
);
256 static void __init
ubnt_rocket_m_setup(void)
259 ar71xx_add_device_usb();
262 MIPS_MACHINE(AR71XX_MACH_UBNT_BULLET_M
, "UBNT-BM", "Ubiquiti Bullet M",
264 MIPS_MACHINE(AR71XX_MACH_UBNT_ROCKET_M
, "UBNT-RM", "Ubiquiti Rocket M",
265 ubnt_rocket_m_setup
);
267 /* TODO detect the second ethernet port and use one
268 init function for all Ubiquiti MIMO series products */
269 static void __init
ubnt_nano_m_setup(void)
273 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RMII
;
274 ar71xx_eth1_data
.speed
= SPEED_1000
;
275 ar71xx_eth1_data
.duplex
= DUPLEX_FULL
;
276 ar71xx_eth1_data
.fifo_cfg1
= 0x0010ffff;
277 ar71xx_eth1_data
.fifo_cfg2
= 0x015500aa;
278 ar71xx_eth1_data
.fifo_cfg3
= 0x01f00140;
280 ar71xx_add_device_eth(1);
283 MIPS_MACHINE(AR71XX_MACH_UBNT_NANO_M
, "UBNT-NM", "Ubiquiti Nanostation M",
286 static struct gpio_led ubnt_unifi_leds_gpio
[] __initdata
= {
288 .name
= "ubnt:orange:dome",
292 .name
= "ubnt:green:dome",
298 static void __init
ubnt_unifi_setup(void)
300 u8
*mac
= (u8
*) KSEG1ADDR(0x1fff0000);
301 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
303 ar71xx_add_device_m25p80(NULL
);
305 ar71xx_add_device_mdio(~0);
307 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac
, 0);
308 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
309 ar71xx_eth0_data
.speed
= SPEED_100
;
310 ar71xx_eth0_data
.duplex
= DUPLEX_FULL
;
312 ar71xx_add_device_eth(0);
314 ap91_pci_init(ee
, NULL
);
316 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_leds_gpio
),
317 ubnt_unifi_leds_gpio
);
320 MIPS_MACHINE(AR71XX_MACH_UBNT_UNIFI
, "UBNT-XM", "Ubiquiti UniFi",