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/pci.h>
14 #include <linux/platform_device.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
17 #include <linux/input.h>
18 #include <linux/ath9k_platform.h>
20 #include <asm/mips_machine.h>
21 #include <asm/mach-ar71xx/ar71xx.h>
22 #include <asm/mach-ar71xx/pci.h>
26 #define UBNT_RS_GPIO_LED_RF 2
27 #define UBNT_RS_GPIO_SW4 8
29 #define UBNT_LS_SR71_GPIO_LED_D25 0
30 #define UBNT_LS_SR71_GPIO_LED_D26 1
31 #define UBNT_LS_SR71_GPIO_LED_D24 2
32 #define UBNT_LS_SR71_GPIO_LED_D23 4
33 #define UBNT_LS_SR71_GPIO_LED_D22 5
34 #define UBNT_LS_SR71_GPIO_LED_D27 6
35 #define UBNT_LS_SR71_GPIO_LED_D28 7
37 #define UBNT_BULLET_M_GPIO_LED_L1 0
38 #define UBNT_BULLET_M_GPIO_LED_L2 1
39 #define UBNT_BULLET_M_GPIO_LED_L3 11
40 #define UBNT_BULLET_M_GPIO_LED_L4 7
41 #define UBNT_BULLET_M_GPIO_BTN_RESET 12
43 #define UBNT_BUTTONS_POLL_INTERVAL 20
45 static struct spi_board_info ubnt_spi_info[] = {
49 .max_speed_hz = 25000000,
54 static struct ar71xx_pci_irq ubnt_pci_irqs[] __initdata = {
58 .irq = AR71XX_PCI_IRQ_DEV0,
62 .irq = AR71XX_PCI_IRQ_DEV1,
66 .irq = AR71XX_PCI_IRQ_DEV2,
70 static struct gpio_led ubnt_rs_leds_gpio[] __initdata = {
72 .name = "ubnt:green:rf",
73 .gpio = UBNT_RS_GPIO_LED_RF,
78 static struct gpio_led ubnt_ls_sr71_leds_gpio[] __initdata = {
80 .name = "ubnt:green:d22",
81 .gpio = UBNT_LS_SR71_GPIO_LED_D22,
84 .name = "ubnt:green:d23",
85 .gpio = UBNT_LS_SR71_GPIO_LED_D23,
88 .name = "ubnt:green:d24",
89 .gpio = UBNT_LS_SR71_GPIO_LED_D24,
92 .name = "ubnt:red:d25",
93 .gpio = UBNT_LS_SR71_GPIO_LED_D25,
96 .name = "ubnt:red:d26",
97 .gpio = UBNT_LS_SR71_GPIO_LED_D26,
100 .name = "ubnt:green:d27",
101 .gpio = UBNT_LS_SR71_GPIO_LED_D27,
104 .name = "ubnt:green:d28",
105 .gpio = UBNT_LS_SR71_GPIO_LED_D28,
110 static struct gpio_led ubnt_bullet_m_leds_gpio[] __initdata = {
112 .name = "ubnt:red:link1",
113 .gpio = UBNT_BULLET_M_GPIO_LED_L1,
116 .name = "ubnt:orange:link2",
117 .gpio = UBNT_BULLET_M_GPIO_LED_L2,
120 .name = "ubnt:green:link3",
121 .gpio = UBNT_BULLET_M_GPIO_LED_L3,
124 .name = "ubnt:green:link4",
125 .gpio = UBNT_BULLET_M_GPIO_LED_L4,
130 static struct gpio_button ubnt_gpio_buttons[] __initdata = {
136 .gpio = UBNT_RS_GPIO_SW4,
141 static struct gpio_button ubnt_bullet_m_gpio_buttons[] __initdata = {
147 .gpio = UBNT_BULLET_M_GPIO_BTN_RESET,
152 static void __init ubnt_generic_setup(void)
154 ar71xx_add_device_spi(NULL, ubnt_spi_info,
155 ARRAY_SIZE(ubnt_spi_info));
157 ar71xx_add_device_gpio_buttons(-1, UBNT_BUTTONS_POLL_INTERVAL,
158 ARRAY_SIZE(ubnt_gpio_buttons),
161 ar71xx_pci_init(ARRAY_SIZE(ubnt_pci_irqs), ubnt_pci_irqs);
164 #define UBNT_RS_WAN_PHYMASK (1 << 20)
165 #define UBNT_RS_LAN_PHYMASK ((1 << 16) | (1 << 17) | (1 << 18) | (1 << 19))
167 #define UBNT_RSPRO_WAN_PHYMASK (1 << 4)
168 #define UBNT_RSPRO_LAN_PHYMASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3))
170 static void __init ubnt_rs_setup(void)
172 ubnt_generic_setup();
174 ar71xx_add_device_mdio(~(UBNT_RS_WAN_PHYMASK | UBNT_RS_LAN_PHYMASK));
176 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
177 ar71xx_eth0_data.phy_mask = UBNT_RS_WAN_PHYMASK;
179 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
180 ar71xx_eth1_data.phy_mask = UBNT_RS_LAN_PHYMASK;
182 ar71xx_eth1_data.speed = SPEED_100;
183 ar71xx_eth1_data.duplex = DUPLEX_FULL;
185 ar71xx_add_device_eth(0);
186 ar71xx_add_device_eth(1);
188 ar71xx_add_device_usb();
190 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio),
194 MIPS_MACHINE(AR71XX_MACH_UBNT_RS, "Ubiquiti RouterStation", ubnt_rs_setup);
196 static void __init ubnt_rspro_setup(void)
198 ubnt_generic_setup();
200 ar71xx_add_device_mdio(~(UBNT_RSPRO_WAN_PHYMASK | UBNT_RSPRO_LAN_PHYMASK));
202 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
203 ar71xx_eth0_data.phy_mask = UBNT_RSPRO_WAN_PHYMASK;
205 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
206 ar71xx_eth1_data.phy_mask = UBNT_RSPRO_LAN_PHYMASK;
208 ar71xx_eth1_data.speed = SPEED_1000;
209 ar71xx_eth1_data.duplex = DUPLEX_FULL;
211 ar71xx_add_device_eth(0);
212 ar71xx_add_device_eth(1);
214 ar71xx_add_device_usb();
216 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio),
220 MIPS_MACHINE(AR71XX_MACH_UBNT_RSPRO, "Ubiquiti RouterStation Pro",
223 static void __init ubnt_lsx_setup(void)
225 ubnt_generic_setup();
228 MIPS_MACHINE(AR71XX_MACH_UBNT_LSX, "Ubiquiti LSX", ubnt_lsx_setup);
230 #define UBNT_LSSR71_PHY_MASK (1 << 1)
232 static void __init ubnt_lssr71_setup(void)
234 ubnt_generic_setup();
236 ar71xx_add_device_mdio(~UBNT_LSSR71_PHY_MASK);
238 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
239 ar71xx_eth0_data.phy_mask = UBNT_LSSR71_PHY_MASK;
241 ar71xx_add_device_eth(0);
243 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_ls_sr71_leds_gpio),
244 ubnt_ls_sr71_leds_gpio);
247 MIPS_MACHINE(AR71XX_MACH_UBNT_LSSR71, "Ubiquiti LS-SR71", ubnt_lssr71_setup);
250 static struct ar71xx_pci_irq ubnt_bullet_m_pci_irqs[] __initdata = {
254 .irq = AR71XX_PCI_IRQ_DEV0,
258 static struct ath9k_platform_data ubnt_bullet_m_wmac_data;
260 static int ubmnt_bullet_m_pci_plat_dev_init(struct pci_dev *dev)
262 dev->dev.platform_data = &ubnt_bullet_m_wmac_data;
266 static void __init ubnt_bullet_m_pci_init(void)
268 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
270 memcpy(ubnt_bullet_m_wmac_data.eeprom_data, ee,
271 sizeof(ubnt_bullet_m_wmac_data.eeprom_data));
273 ar71xx_pci_plat_dev_init = ubmnt_bullet_m_pci_plat_dev_init;
275 ar71xx_pci_init(ARRAY_SIZE(ubnt_bullet_m_pci_irqs),
276 ubnt_bullet_m_pci_irqs);
279 static inline void ubnt_bullet_m_pci_init(void) { };
280 #endif /* CONFIG_PCI */
282 static void __init ubnt_bullet_m_setup(void)
284 u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
286 ar71xx_set_mac_base(mac);
287 ar71xx_add_device_spi(NULL, ubnt_spi_info,
288 ARRAY_SIZE(ubnt_spi_info));
290 ar71xx_add_device_mdio(~0);
292 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
293 ar71xx_eth0_data.phy_mask = 0;
295 ar71xx_eth0_data.speed = SPEED_100;
296 ar71xx_eth0_data.duplex = DUPLEX_FULL;
298 ar71xx_add_device_eth(0);
300 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_bullet_m_leds_gpio),
301 ubnt_bullet_m_leds_gpio);
303 ar71xx_add_device_gpio_buttons(-1, UBNT_BUTTONS_POLL_INTERVAL,
304 ARRAY_SIZE(ubnt_bullet_m_gpio_buttons),
305 ubnt_bullet_m_gpio_buttons);
307 ubnt_bullet_m_pci_init();
310 MIPS_MACHINE(AR71XX_MACH_UBNT_BULLET_M, "Ubiquiti Bullet M", ubnt_bullet_m_setup);