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 <linux/platform_device.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/flash.h>
16 #include <linux/input.h>
18 #include <asm/mips_machine.h>
19 #include <asm/mach-ar71xx/ar71xx.h>
20 #include <asm/mach-ar71xx/pci.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_BULLET_M_GPIO_LED_L1 0
36 #define UBNT_BULLET_M_GPIO_LED_L2 1
37 #define UBNT_BULLET_M_GPIO_LED_L3 11
38 #define UBNT_BULLET_M_GPIO_LED_L4 7
39 #define UBNT_BULLET_M_GPIO_BTN_RESET 12
41 #define UBNT_BUTTONS_POLL_INTERVAL 20
43 static struct spi_board_info ubnt_spi_info
[] = {
47 .max_speed_hz
= 25000000,
52 static struct ar71xx_pci_irq ubnt_pci_irqs
[] __initdata
= {
56 .irq
= AR71XX_PCI_IRQ_DEV0
,
60 .irq
= AR71XX_PCI_IRQ_DEV1
,
64 .irq
= AR71XX_PCI_IRQ_DEV2
,
68 static struct gpio_led ubnt_rs_leds_gpio
[] __initdata
= {
70 .name
= "ubnt:green:rf",
71 .gpio
= UBNT_RS_GPIO_LED_RF
,
76 static struct gpio_led ubnt_ls_sr71_leds_gpio
[] __initdata
= {
78 .name
= "ubnt:green:d22",
79 .gpio
= UBNT_LS_SR71_GPIO_LED_D22
,
82 .name
= "ubnt:green:d23",
83 .gpio
= UBNT_LS_SR71_GPIO_LED_D23
,
86 .name
= "ubnt:green:d24",
87 .gpio
= UBNT_LS_SR71_GPIO_LED_D24
,
90 .name
= "ubnt:red:d25",
91 .gpio
= UBNT_LS_SR71_GPIO_LED_D25
,
94 .name
= "ubnt:red:d26",
95 .gpio
= UBNT_LS_SR71_GPIO_LED_D26
,
98 .name
= "ubnt:green:d27",
99 .gpio
= UBNT_LS_SR71_GPIO_LED_D27
,
102 .name
= "ubnt:green:d28",
103 .gpio
= UBNT_LS_SR71_GPIO_LED_D28
,
108 static struct gpio_led ubnt_bullet_m_leds_gpio
[] __initdata
= {
110 .name
= "ubnt:red:link1",
111 .gpio
= UBNT_BULLET_M_GPIO_LED_L1
,
114 .name
= "ubnt:orange:link2",
115 .gpio
= UBNT_BULLET_M_GPIO_LED_L2
,
118 .name
= "ubnt:green:link3",
119 .gpio
= UBNT_BULLET_M_GPIO_LED_L3
,
122 .name
= "ubnt:green:link4",
123 .gpio
= UBNT_BULLET_M_GPIO_LED_L4
,
128 static struct gpio_button ubnt_gpio_buttons
[] __initdata
= {
134 .gpio
= UBNT_RS_GPIO_SW4
,
139 static struct gpio_button ubnt_bullet_m_gpio_buttons
[] __initdata
= {
145 .gpio
= UBNT_BULLET_M_GPIO_BTN_RESET
,
150 static void __init
ubnt_generic_setup(void)
152 ar71xx_add_device_spi(NULL
, ubnt_spi_info
,
153 ARRAY_SIZE(ubnt_spi_info
));
155 ar71xx_add_device_gpio_buttons(-1, UBNT_BUTTONS_POLL_INTERVAL
,
156 ARRAY_SIZE(ubnt_gpio_buttons
),
159 ar71xx_pci_init(ARRAY_SIZE(ubnt_pci_irqs
), ubnt_pci_irqs
);
162 #define UBNT_RS_WAN_PHYMASK (1 << 20)
163 #define UBNT_RS_LAN_PHYMASK ((1 << 16) | (1 << 17) | (1 << 18) | (1 << 19))
165 #define UBNT_RSPRO_WAN_PHYMASK (1 << 4)
166 #define UBNT_RSPRO_LAN_PHYMASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3))
168 static void __init
ubnt_rs_setup(void)
170 ubnt_generic_setup();
172 ar71xx_add_device_mdio(~(UBNT_RS_WAN_PHYMASK
| UBNT_RS_LAN_PHYMASK
));
174 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
175 ar71xx_eth0_data
.phy_mask
= UBNT_RS_WAN_PHYMASK
;
177 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RMII
;
178 ar71xx_eth1_data
.phy_mask
= UBNT_RS_LAN_PHYMASK
;
180 ar71xx_eth1_data
.speed
= SPEED_100
;
181 ar71xx_eth1_data
.duplex
= DUPLEX_FULL
;
183 ar71xx_add_device_eth(0);
184 ar71xx_add_device_eth(1);
186 ar71xx_add_device_usb();
188 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio
),
192 MIPS_MACHINE(AR71XX_MACH_UBNT_RS
, "Ubiquiti RouterStation", ubnt_rs_setup
);
194 static void __init
ubnt_rspro_setup(void)
196 ubnt_generic_setup();
198 ar71xx_add_device_mdio(~(UBNT_RSPRO_WAN_PHYMASK
| UBNT_RSPRO_LAN_PHYMASK
));
200 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
201 ar71xx_eth0_data
.phy_mask
= UBNT_RSPRO_WAN_PHYMASK
;
203 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
204 ar71xx_eth1_data
.phy_mask
= UBNT_RSPRO_LAN_PHYMASK
;
206 ar71xx_eth1_data
.speed
= SPEED_1000
;
207 ar71xx_eth1_data
.duplex
= DUPLEX_FULL
;
209 ar71xx_add_device_eth(0);
210 ar71xx_add_device_eth(1);
212 ar71xx_add_device_usb();
214 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio
),
218 MIPS_MACHINE(AR71XX_MACH_UBNT_RSPRO
, "Ubiquiti RouterStation Pro",
221 static void __init
ubnt_lsx_setup(void)
223 ubnt_generic_setup();
226 MIPS_MACHINE(AR71XX_MACH_UBNT_LSX
, "Ubiquiti LSX", ubnt_lsx_setup
);
228 #define UBNT_LSSR71_PHY_MASK (1 << 1)
230 static void __init
ubnt_lssr71_setup(void)
232 ubnt_generic_setup();
234 ar71xx_add_device_mdio(~UBNT_LSSR71_PHY_MASK
);
236 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
237 ar71xx_eth0_data
.phy_mask
= UBNT_LSSR71_PHY_MASK
;
239 ar71xx_add_device_eth(0);
241 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_ls_sr71_leds_gpio
),
242 ubnt_ls_sr71_leds_gpio
);
245 MIPS_MACHINE(AR71XX_MACH_UBNT_LSSR71
, "Ubiquiti LS-SR71", ubnt_lssr71_setup
);
247 static void __init
ubnt_bullet_m_setup(void)
249 ar71xx_add_device_spi(NULL
, ubnt_spi_info
,
250 ARRAY_SIZE(ubnt_spi_info
));
252 ar71xx_add_device_mdio(~0);
254 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
255 ar71xx_eth0_data
.phy_mask
= 0;
257 ar71xx_eth0_data
.speed
= SPEED_100
;
258 ar71xx_eth0_data
.duplex
= DUPLEX_FULL
;
260 ar71xx_add_device_eth(0);
262 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_bullet_m_leds_gpio
),
263 ubnt_bullet_m_leds_gpio
);
265 ar71xx_add_device_gpio_buttons(-1, UBNT_BUTTONS_POLL_INTERVAL
,
266 ARRAY_SIZE(ubnt_bullet_m_gpio_buttons
),
267 ubnt_bullet_m_gpio_buttons
);
270 MIPS_MACHINE(AR71XX_MACH_UBNT_BULLET_M
, "Ubiquiti Bullet M", ubnt_bullet_m_setup
);