ar71xx: remove more unnecessary includes
[librecmc/librecmc.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 <asm/mips_machine.h>
14 #include <asm/mach-ar71xx/ar71xx.h>
15
16 #include "devices.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"
22
23 #define UBNT_RS_GPIO_LED_RF     2
24 #define UBNT_RS_GPIO_SW4        8
25
26 #define UBNT_LS_SR71_GPIO_LED_D25       0
27 #define UBNT_LS_SR71_GPIO_LED_D26       1
28 #define UBNT_LS_SR71_GPIO_LED_D24       2
29 #define UBNT_LS_SR71_GPIO_LED_D23       4
30 #define UBNT_LS_SR71_GPIO_LED_D22       5
31 #define UBNT_LS_SR71_GPIO_LED_D27       6
32 #define UBNT_LS_SR71_GPIO_LED_D28       7
33
34 #define UBNT_M_GPIO_LED_L1      0
35 #define UBNT_M_GPIO_LED_L2      1
36 #define UBNT_M_GPIO_LED_L3      11
37 #define UBNT_M_GPIO_LED_L4      7
38 #define UBNT_M_GPIO_BTN_RESET   12
39
40 #define UBNT_BUTTONS_POLL_INTERVAL      20
41
42 static struct gpio_led ubnt_rs_leds_gpio[] __initdata = {
43         {
44                 .name           = "ubnt:green:rf",
45                 .gpio           = UBNT_RS_GPIO_LED_RF,
46                 .active_low     = 0,
47         }
48 };
49
50 static struct gpio_led ubnt_ls_sr71_leds_gpio[] __initdata = {
51         {
52                 .name           = "ubnt:green:d22",
53                 .gpio           = UBNT_LS_SR71_GPIO_LED_D22,
54                 .active_low     = 0,
55         }, {
56                 .name           = "ubnt:green:d23",
57                 .gpio           = UBNT_LS_SR71_GPIO_LED_D23,
58                 .active_low     = 0,
59         }, {
60                 .name           = "ubnt:green:d24",
61                 .gpio           = UBNT_LS_SR71_GPIO_LED_D24,
62                 .active_low     = 0,
63         }, {
64                 .name           = "ubnt:red:d25",
65                 .gpio           = UBNT_LS_SR71_GPIO_LED_D25,
66                 .active_low     = 0,
67         }, {
68                 .name           = "ubnt:red:d26",
69                 .gpio           = UBNT_LS_SR71_GPIO_LED_D26,
70                 .active_low     = 0,
71         }, {
72                 .name           = "ubnt:green:d27",
73                 .gpio           = UBNT_LS_SR71_GPIO_LED_D27,
74                 .active_low     = 0,
75         }, {
76                 .name           = "ubnt:green:d28",
77                 .gpio           = UBNT_LS_SR71_GPIO_LED_D28,
78                 .active_low     = 0,
79         }
80 };
81
82 static struct gpio_led ubnt_m_leds_gpio[] __initdata = {
83         {
84                 .name           = "ubnt:red:link1",
85                 .gpio           = UBNT_M_GPIO_LED_L1,
86                 .active_low     = 0,
87         }, {
88                 .name           = "ubnt:orange:link2",
89                 .gpio           = UBNT_M_GPIO_LED_L2,
90                 .active_low     = 0,
91         }, {
92                 .name           = "ubnt:green:link3",
93                 .gpio           = UBNT_M_GPIO_LED_L3,
94                 .active_low     = 0,
95         }, {
96                 .name           = "ubnt:green:link4",
97                 .gpio           = UBNT_M_GPIO_LED_L4,
98                 .active_low     = 0,
99         }
100 };
101
102 static struct gpio_button ubnt_gpio_buttons[] __initdata = {
103         {
104                 .desc           = "sw4",
105                 .type           = EV_KEY,
106                 .code           = BTN_0,
107                 .threshold      = 5,
108                 .gpio           = UBNT_RS_GPIO_SW4,
109                 .active_low     = 1,
110         }
111 };
112
113 static struct gpio_button ubnt_m_gpio_buttons[] __initdata = {
114         {
115                 .desc           = "reset",
116                 .type           = EV_KEY,
117                 .code           = BTN_0,
118                 .threshold      = 5,
119                 .gpio           = UBNT_M_GPIO_BTN_RESET,
120                 .active_low     = 1,
121         }
122 };
123
124 static void __init ubnt_generic_setup(void)
125 {
126         ar71xx_add_device_m25p80(NULL);
127
128         ar71xx_add_device_gpio_buttons(-1, UBNT_BUTTONS_POLL_INTERVAL,
129                                         ARRAY_SIZE(ubnt_gpio_buttons),
130                                         ubnt_gpio_buttons);
131
132         pb42_pci_init();
133 }
134
135 #define UBNT_RS_WAN_PHYMASK     (1 << 20)
136 #define UBNT_RS_LAN_PHYMASK     ((1 << 16) | (1 << 17) | (1 << 18) | (1 << 19))
137
138 #define UBNT_RSPRO_WAN_PHYMASK  (1 << 4)
139 #define UBNT_RSPRO_LAN_PHYMASK  ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3))
140
141 static void __init ubnt_rs_setup(void)
142 {
143         ubnt_generic_setup();
144
145         ar71xx_add_device_mdio(~(UBNT_RS_WAN_PHYMASK | UBNT_RS_LAN_PHYMASK));
146
147         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
148         ar71xx_eth0_data.phy_mask = UBNT_RS_WAN_PHYMASK;
149
150         ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
151         ar71xx_eth1_data.phy_mask = UBNT_RS_LAN_PHYMASK;
152
153         ar71xx_eth1_data.speed = SPEED_100;
154         ar71xx_eth1_data.duplex = DUPLEX_FULL;
155
156         ar71xx_add_device_eth(0);
157         ar71xx_add_device_eth(1);
158
159         ar71xx_add_device_usb();
160
161         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio),
162                                         ubnt_rs_leds_gpio);
163 }
164
165 MIPS_MACHINE(AR71XX_MACH_UBNT_RS, "Ubiquiti RouterStation", ubnt_rs_setup);
166
167 static void __init ubnt_rspro_setup(void)
168 {
169         ubnt_generic_setup();
170
171         ar71xx_add_device_mdio(~(UBNT_RSPRO_WAN_PHYMASK | UBNT_RSPRO_LAN_PHYMASK));
172
173         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
174         ar71xx_eth0_data.phy_mask = UBNT_RSPRO_WAN_PHYMASK;
175
176         ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
177         ar71xx_eth1_data.phy_mask = UBNT_RSPRO_LAN_PHYMASK;
178
179         ar71xx_eth1_data.speed = SPEED_1000;
180         ar71xx_eth1_data.duplex = DUPLEX_FULL;
181
182         ar71xx_add_device_eth(0);
183         ar71xx_add_device_eth(1);
184
185         ar71xx_add_device_usb();
186
187         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio),
188                                         ubnt_rs_leds_gpio);
189 }
190
191 MIPS_MACHINE(AR71XX_MACH_UBNT_RSPRO, "Ubiquiti RouterStation Pro",
192              ubnt_rspro_setup);
193
194 static void __init ubnt_lsx_setup(void)
195 {
196         ubnt_generic_setup();
197 }
198
199 MIPS_MACHINE(AR71XX_MACH_UBNT_LSX, "Ubiquiti LSX", ubnt_lsx_setup);
200
201 #define UBNT_LSSR71_PHY_MASK    (1 << 1)
202
203 static void __init ubnt_lssr71_setup(void)
204 {
205         ubnt_generic_setup();
206
207         ar71xx_add_device_mdio(~UBNT_LSSR71_PHY_MASK);
208
209         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
210         ar71xx_eth0_data.phy_mask = UBNT_LSSR71_PHY_MASK;
211
212         ar71xx_add_device_eth(0);
213
214         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_ls_sr71_leds_gpio),
215                                         ubnt_ls_sr71_leds_gpio);
216 }
217
218 MIPS_MACHINE(AR71XX_MACH_UBNT_LSSR71, "Ubiquiti LS-SR71", ubnt_lssr71_setup);
219
220 static void __init ubnt_m_setup(void)
221 {
222         u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
223         u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
224
225         ar71xx_set_mac_base(mac);
226
227         ar71xx_add_device_m25p80(NULL);
228
229         ar71xx_add_device_mdio(~0);
230
231         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
232         ar71xx_eth0_data.phy_mask = 0;
233         ar71xx_eth0_data.speed = SPEED_100;
234         ar71xx_eth0_data.duplex = DUPLEX_FULL;
235         ar71xx_eth0_data.fifo_cfg1 = 0x0010ffff;
236         ar71xx_eth0_data.fifo_cfg2 = 0x015500aa;
237         ar71xx_eth0_data.fifo_cfg3 = 0x01f00140;
238
239         ar71xx_add_device_eth(0);
240
241         ap91_pci_init(ee, NULL);
242
243         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_m_leds_gpio),
244                                         ubnt_m_leds_gpio);
245
246         ar71xx_add_device_gpio_buttons(-1, UBNT_BUTTONS_POLL_INTERVAL,
247                                         ARRAY_SIZE(ubnt_m_gpio_buttons),
248                                         ubnt_m_gpio_buttons);
249 }
250
251 static void __init ubnt_rocket_m_setup(void)
252 {
253         ubnt_m_setup();
254         ar71xx_add_device_usb();
255 }
256
257 MIPS_MACHINE(AR71XX_MACH_UBNT_BULLET_M, "Ubiquiti Bullet M", ubnt_m_setup);
258 MIPS_MACHINE(AR71XX_MACH_UBNT_ROCKET_M, "Ubiquiti Rocket M", ubnt_rocket_m_setup);
259
260 /* TODO detect the second ethernet port and use one
261    init function for all Ubiquiti MIMO series products */
262 static void __init ubnt_nano_m_setup(void)
263 {
264         ubnt_m_setup();
265
266         ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
267         ar71xx_eth1_data.phy_mask = 0;
268         ar71xx_eth1_data.speed = SPEED_1000;
269         ar71xx_eth1_data.duplex = DUPLEX_FULL;
270         ar71xx_eth1_data.fifo_cfg1 = 0x0010ffff;
271         ar71xx_eth1_data.fifo_cfg2 = 0x015500aa;
272         ar71xx_eth1_data.fifo_cfg3 = 0x01f00140;
273
274         ar71xx_add_device_eth(1);
275 }
276
277 MIPS_MACHINE(AR71XX_MACH_UBNT_NANO_M, "Ubiquiti Nanostation M", ubnt_nano_m_setup);