2 * Ubiquiti RouterStation support
4 * Copyright (C) 2008-2012 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-ath79/ath79.h>
16 #include "dev-gpio-buttons.h"
17 #include "dev-leds-gpio.h"
18 #include "dev-m25p80.h"
20 #include "machtypes.h"
23 #define UBNT_RS_GPIO_LED_RF 2
24 #define UBNT_RS_GPIO_SW4 8
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
34 #define UBNT_KEYS_POLL_INTERVAL 20 /* msecs */
35 #define UBNT_KEYS_DEBOUNCE_INTERVAL (3 * UBNT_KEYS_POLL_INTERVAL)
37 static struct gpio_led ubnt_rs_leds_gpio
[] __initdata
= {
39 .name
= "ubnt:green:rf",
40 .gpio
= UBNT_RS_GPIO_LED_RF
,
45 static struct gpio_led ubnt_ls_sr71_leds_gpio
[] __initdata
= {
47 .name
= "ubnt:green:d22",
48 .gpio
= UBNT_LS_SR71_GPIO_LED_D22
,
51 .name
= "ubnt:green:d23",
52 .gpio
= UBNT_LS_SR71_GPIO_LED_D23
,
55 .name
= "ubnt:green:d24",
56 .gpio
= UBNT_LS_SR71_GPIO_LED_D24
,
59 .name
= "ubnt:red:d25",
60 .gpio
= UBNT_LS_SR71_GPIO_LED_D25
,
63 .name
= "ubnt:red:d26",
64 .gpio
= UBNT_LS_SR71_GPIO_LED_D26
,
67 .name
= "ubnt:green:d27",
68 .gpio
= UBNT_LS_SR71_GPIO_LED_D27
,
71 .name
= "ubnt:green:d28",
72 .gpio
= UBNT_LS_SR71_GPIO_LED_D28
,
77 static struct gpio_keys_button ubnt_gpio_keys
[] __initdata
= {
82 .debounce_interval
= UBNT_KEYS_DEBOUNCE_INTERVAL
,
83 .gpio
= UBNT_RS_GPIO_SW4
,
88 static const char *ubnt_part_probes
[] = {
93 static struct flash_platform_data ubnt_flash_data
= {
94 .part_probes
= ubnt_part_probes
,
97 static void __init
ubnt_generic_setup(void)
99 ath79_register_m25p80(&ubnt_flash_data
);
101 ath79_register_gpio_keys_polled(-1, UBNT_KEYS_POLL_INTERVAL
,
102 ARRAY_SIZE(ubnt_gpio_keys
),
104 ath79_register_pci();
107 #define UBNT_RS_WAN_PHYMASK BIT(20)
108 #define UBNT_RS_LAN_PHYMASK (BIT(16) | BIT(17) | BIT(18) | BIT(19))
110 static void __init
ubnt_rs_setup(void)
112 ubnt_generic_setup();
114 ath79_register_mdio(0, ~(UBNT_RS_WAN_PHYMASK
| UBNT_RS_LAN_PHYMASK
));
116 ath79_init_mac(ath79_eth0_data
.mac_addr
, ath79_mac_base
, 0);
117 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
118 ath79_eth0_data
.phy_mask
= UBNT_RS_WAN_PHYMASK
;
121 * There is Secondary MAC address duplicate problem with some
122 * UBNT HW batches. Do not increase Secondary MAC address by 1
123 * but do workaround with 'Locally Administrated' bit.
125 ath79_init_local_mac(ath79_eth1_data
.mac_addr
, ath79_mac_base
);
126 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RMII
;
127 ath79_eth1_data
.speed
= SPEED_100
;
128 ath79_eth1_data
.duplex
= DUPLEX_FULL
;
130 ath79_register_eth(0);
131 ath79_register_eth(1);
133 ath79_register_usb();
135 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio
),
139 MIPS_MACHINE(ATH79_MACH_UBNT_RS
, "UBNT-RS", "Ubiquiti RouterStation",
142 #define UBNT_RSPRO_WAN_PHYMASK BIT(4)
143 #define UBNT_RSPRO_LAN_PHYMASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
145 static void __init
ubnt_rspro_setup(void)
147 ubnt_generic_setup();
149 ath79_register_mdio(0, ~(UBNT_RSPRO_WAN_PHYMASK
|
150 UBNT_RSPRO_LAN_PHYMASK
));
152 ath79_init_mac(ath79_eth0_data
.mac_addr
, ath79_mac_base
, 0);
153 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
154 ath79_eth0_data
.phy_mask
= UBNT_RSPRO_WAN_PHYMASK
;
157 * There is Secondary MAC address duplicate problem with some
158 * UBNT HW batches. Do not increase Secondary MAC address by 1
159 * but do workaround with 'Locally Administrated' bit.
161 ath79_init_local_mac(ath79_eth1_data
.mac_addr
, ath79_mac_base
);
162 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
163 ath79_eth1_data
.phy_mask
= UBNT_RSPRO_LAN_PHYMASK
;
164 ath79_eth1_data
.speed
= SPEED_1000
;
165 ath79_eth1_data
.duplex
= DUPLEX_FULL
;
167 ath79_register_eth(0);
168 ath79_register_eth(1);
170 ath79_register_usb();
172 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio
),
176 MIPS_MACHINE(ATH79_MACH_UBNT_RSPRO
, "UBNT-RSPRO", "Ubiquiti RouterStation Pro",
179 static void __init
ubnt_lsx_setup(void)
181 ubnt_generic_setup();
184 MIPS_MACHINE(ATH79_MACH_UBNT_LSX
, "UBNT-LSX", "Ubiquiti LSX", ubnt_lsx_setup
);
186 #define UBNT_LSSR71_PHY_MASK BIT(1)
188 static void __init
ubnt_lssr71_setup(void)
190 ubnt_generic_setup();
192 ath79_register_mdio(0, ~UBNT_LSSR71_PHY_MASK
);
194 ath79_init_mac(ath79_eth0_data
.mac_addr
, ath79_mac_base
, 0);
195 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
196 ath79_eth0_data
.phy_mask
= UBNT_LSSR71_PHY_MASK
;
198 ath79_register_eth(0);
200 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_ls_sr71_leds_gpio
),
201 ubnt_ls_sr71_leds_gpio
);
204 MIPS_MACHINE(ATH79_MACH_UBNT_LSSR71
, "UBNT-LS-SR71", "Ubiquiti LS-SR71",