ar71xx: preliminary Ubiquiti Bullet M support
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-ubnt.c
1 /*
2 * Ubiquiti RouterStation support
3 *
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>
7 *
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.
11 */
12
13 #include <linux/platform_device.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/flash.h>
16 #include <linux/input.h>
17
18 #include <asm/mips_machine.h>
19 #include <asm/mach-ar71xx/ar71xx.h>
20 #include <asm/mach-ar71xx/pci.h>
21
22 #include "devices.h"
23
24 #define UBNT_RS_GPIO_LED_RF 2
25 #define UBNT_RS_GPIO_SW4 8
26
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
34
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
40 #define UBNT_BUTTONS_POLL_INTERVAL 20
41
42 static struct spi_board_info ubnt_spi_info[] = {
43 {
44 .bus_num = 0,
45 .chip_select = 0,
46 .max_speed_hz = 25000000,
47 .modalias = "m25p80",
48 }
49 };
50
51 static struct ar71xx_pci_irq ubnt_pci_irqs[] __initdata = {
52 {
53 .slot = 0,
54 .pin = 1,
55 .irq = AR71XX_PCI_IRQ_DEV0,
56 }, {
57 .slot = 1,
58 .pin = 1,
59 .irq = AR71XX_PCI_IRQ_DEV1,
60 }, {
61 .slot = 2,
62 .pin = 1,
63 .irq = AR71XX_PCI_IRQ_DEV2,
64 }
65 };
66
67 static struct gpio_led ubnt_rs_leds_gpio[] __initdata = {
68 {
69 .name = "ubnt:green:rf",
70 .gpio = UBNT_RS_GPIO_LED_RF,
71 .active_low = 0,
72 }
73 };
74
75 static struct gpio_led ubnt_ls_sr71_leds_gpio[] __initdata = {
76 {
77 .name = "ubnt:green:d22",
78 .gpio = UBNT_LS_SR71_GPIO_LED_D22,
79 .active_low = 0,
80 }, {
81 .name = "ubnt:green:d23",
82 .gpio = UBNT_LS_SR71_GPIO_LED_D23,
83 .active_low = 0,
84 }, {
85 .name = "ubnt:green:d24",
86 .gpio = UBNT_LS_SR71_GPIO_LED_D24,
87 .active_low = 0,
88 }, {
89 .name = "ubnt:red:d25",
90 .gpio = UBNT_LS_SR71_GPIO_LED_D25,
91 .active_low = 0,
92 }, {
93 .name = "ubnt:red:d26",
94 .gpio = UBNT_LS_SR71_GPIO_LED_D26,
95 .active_low = 0,
96 }, {
97 .name = "ubnt:green:d27",
98 .gpio = UBNT_LS_SR71_GPIO_LED_D27,
99 .active_low = 0,
100 }, {
101 .name = "ubnt:green:d28",
102 .gpio = UBNT_LS_SR71_GPIO_LED_D28,
103 .active_low = 0,
104 }
105 };
106
107 static struct gpio_led ubnt_bullet_m_leds_gpio[] __initdata = {
108 {
109 .name = "ubnt:red:link1",
110 .gpio = UBNT_BULLET_M_GPIO_LED_L1,
111 .active_low = 0,
112 }, {
113 .name = "ubnt:orange:link2",
114 .gpio = UBNT_BULLET_M_GPIO_LED_L2,
115 .active_low = 0,
116 }, {
117 .name = "ubnt:green:link3",
118 .gpio = UBNT_BULLET_M_GPIO_LED_L3,
119 .active_low = 0,
120 }, {
121 .name = "ubnt:green:link4",
122 .gpio = UBNT_BULLET_M_GPIO_LED_L4,
123 .active_low = 0,
124 }
125 };
126
127 static struct gpio_button ubnt_gpio_buttons[] __initdata = {
128 {
129 .desc = "sw4",
130 .type = EV_KEY,
131 .code = BTN_0,
132 .threshold = 5,
133 .gpio = UBNT_RS_GPIO_SW4,
134 .active_low = 1,
135 }
136 };
137
138 static void __init ubnt_generic_setup(void)
139 {
140 ar71xx_add_device_spi(NULL, ubnt_spi_info,
141 ARRAY_SIZE(ubnt_spi_info));
142
143 ar71xx_add_device_gpio_buttons(-1, UBNT_BUTTONS_POLL_INTERVAL,
144 ARRAY_SIZE(ubnt_gpio_buttons),
145 ubnt_gpio_buttons);
146
147 ar71xx_pci_init(ARRAY_SIZE(ubnt_pci_irqs), ubnt_pci_irqs);
148 }
149
150 #define UBNT_RS_WAN_PHYMASK (1 << 20)
151 #define UBNT_RS_LAN_PHYMASK ((1 << 16) | (1 << 17) | (1 << 18) | (1 << 19))
152
153 #define UBNT_RSPRO_WAN_PHYMASK (1 << 4)
154 #define UBNT_RSPRO_LAN_PHYMASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3))
155
156 static void __init ubnt_rs_setup(void)
157 {
158 ubnt_generic_setup();
159
160 ar71xx_add_device_mdio(~(UBNT_RS_WAN_PHYMASK | UBNT_RS_LAN_PHYMASK));
161
162 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
163 ar71xx_eth0_data.phy_mask = UBNT_RS_WAN_PHYMASK;
164
165 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
166 ar71xx_eth1_data.phy_mask = UBNT_RS_LAN_PHYMASK;
167
168 ar71xx_eth1_data.speed = SPEED_100;
169 ar71xx_eth1_data.duplex = DUPLEX_FULL;
170
171 ar71xx_add_device_eth(0);
172 ar71xx_add_device_eth(1);
173
174 ar71xx_add_device_usb();
175
176 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio),
177 ubnt_rs_leds_gpio);
178 }
179
180 MIPS_MACHINE(AR71XX_MACH_UBNT_RS, "Ubiquiti RouterStation", ubnt_rs_setup);
181
182 static void __init ubnt_rspro_setup(void)
183 {
184 ubnt_generic_setup();
185
186 ar71xx_add_device_mdio(~(UBNT_RSPRO_WAN_PHYMASK | UBNT_RSPRO_LAN_PHYMASK));
187
188 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
189 ar71xx_eth0_data.phy_mask = UBNT_RSPRO_WAN_PHYMASK;
190
191 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
192 ar71xx_eth1_data.phy_mask = UBNT_RSPRO_LAN_PHYMASK;
193
194 ar71xx_eth1_data.speed = SPEED_1000;
195 ar71xx_eth1_data.duplex = DUPLEX_FULL;
196
197 ar71xx_add_device_eth(0);
198 ar71xx_add_device_eth(1);
199
200 ar71xx_add_device_usb();
201
202 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio),
203 ubnt_rs_leds_gpio);
204 }
205
206 MIPS_MACHINE(AR71XX_MACH_UBNT_RSPRO, "Ubiquiti RouterStation Pro",
207 ubnt_rspro_setup);
208
209 static void __init ubnt_lsx_setup(void)
210 {
211 ubnt_generic_setup();
212 }
213
214 MIPS_MACHINE(AR71XX_MACH_UBNT_LSX, "Ubiquiti LSX", ubnt_lsx_setup);
215
216 #define UBNT_LSSR71_PHY_MASK (1 << 1)
217
218 static void __init ubnt_lssr71_setup(void)
219 {
220 ubnt_generic_setup();
221
222 ar71xx_add_device_mdio(~UBNT_LSSR71_PHY_MASK);
223
224 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
225 ar71xx_eth0_data.phy_mask = UBNT_LSSR71_PHY_MASK;
226
227 ar71xx_add_device_eth(0);
228
229 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_ls_sr71_leds_gpio),
230 ubnt_ls_sr71_leds_gpio);
231 }
232
233 MIPS_MACHINE(AR71XX_MACH_UBNT_LSSR71, "Ubiquiti LS-SR71", ubnt_lssr71_setup);
234
235 static void __init ubnt_bullet_m_setup(void)
236 {
237 ar71xx_add_device_spi(NULL, ubnt_spi_info,
238 ARRAY_SIZE(ubnt_spi_info));
239
240 ar71xx_add_device_mdio(~0);
241
242 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
243 ar71xx_eth0_data.phy_mask = 0;
244
245 ar71xx_eth0_data.speed = SPEED_100;
246 ar71xx_eth0_data.duplex = DUPLEX_FULL;
247
248 ar71xx_add_device_eth(0);
249
250 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_bullet_m_leds_gpio),
251 ubnt_bullet_m_leds_gpio);
252 }
253
254 MIPS_MACHINE(AR71XX_MACH_UBNT_BULLET_M, "Ubiquiti Bullet M", ubnt_bullet_m_setup);
This page took 0.061635 seconds and 5 git commands to generate.