ar71xx: merge unifi outdoor patch into the ubnt-xm one
[openwrt.git] / target / linux / ar71xx / patches-3.3 / 608-MIPS-ath79-ubnt-xm-add-more-boards.patch
1 --- a/arch/mips/ath79/mach-ubnt-xm.c
2 +++ b/arch/mips/ath79/mach-ubnt-xm.c
3 @@ -13,15 +13,17 @@
4  #include <linux/init.h>
5  #include <linux/pci.h>
6  #include <linux/ath9k_platform.h>
7 +#include <linux/etherdevice.h>
8  
9  #include <asm/mach-ath79/irq.h>
10  
11  #include "dev-ap9x-pci.h"
12 +#include "dev-eth.h"
13  #include "dev-gpio-buttons.h"
14  #include "dev-leds-gpio.h"
15  #include "dev-m25p80.h"
16 +#include "dev-usb.h"
17  #include "machtypes.h"
18 -#include "pci.h"
19  
20  #define UBNT_XM_GPIO_LED_L1            0
21  #define UBNT_XM_GPIO_LED_L2            1
22 @@ -37,19 +39,19 @@
23  
24  static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
25         {
26 -               .name           = "ubnt-xm:red:link1",
27 +               .name           = "ubnt:red:link1",
28                 .gpio           = UBNT_XM_GPIO_LED_L1,
29                 .active_low     = 0,
30         }, {
31 -               .name           = "ubnt-xm:orange:link2",
32 +               .name           = "ubnt:orange:link2",
33                 .gpio           = UBNT_XM_GPIO_LED_L2,
34                 .active_low     = 0,
35         }, {
36 -               .name           = "ubnt-xm:green:link3",
37 +               .name           = "ubnt:green:link3",
38                 .gpio           = UBNT_XM_GPIO_LED_L3,
39                 .active_low     = 0,
40         }, {
41 -               .name           = "ubnt-xm:green:link4",
42 +               .name           = "ubnt:green:link4",
43                 .gpio           = UBNT_XM_GPIO_LED_L4,
44                 .active_low     = 0,
45         },
46 @@ -66,9 +68,13 @@ static struct gpio_keys_button ubnt_xm_g
47         }
48  };
49  
50 +#define UBNT_M_WAN_PHYMASK     BIT(4)
51 +
52  static void __init ubnt_xm_init(void)
53  {
54         u8 *eeprom = (u8 *) KSEG1ADDR(UBNT_XM_EEPROM_ADDR);
55 +       u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
56 +       u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
57  
58         ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
59                                  ubnt_xm_leds_gpio);
60 @@ -79,9 +85,155 @@ static void __init ubnt_xm_init(void)
61  
62         ath79_register_m25p80(NULL);
63         ap91_pci_init(eeprom, NULL);
64 +
65 +       ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
66 +       ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
67 +       ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
68 +       ath79_register_eth(0);
69  }
70  
71  MIPS_MACHINE(ATH79_MACH_UBNT_XM,
72              "UBNT-XM",
73              "Ubiquiti Networks XM (rev 1.0) board",
74              ubnt_xm_init);
75 +
76 +MIPS_MACHINE(ATH79_MACH_UBNT_BULLET_M, "UBNT-BM", "Ubiquiti Bullet M",
77 +            ubnt_xm_init);
78 +
79 +static void __init ubnt_rocket_m_setup(void)
80 +{
81 +       ubnt_xm_init();
82 +       ath79_register_usb();
83 +}
84 +
85 +MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M, "UBNT-RM", "Ubiquiti Rocket M",
86 +            ubnt_rocket_m_setup);
87 +
88 +static void __init ubnt_nano_m_setup(void)
89 +{
90 +       ubnt_xm_init();
91 +       ath79_register_eth(1);
92 +}
93 +
94 +MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M, "UBNT-NM", "Ubiquiti Nanostation M",
95 +            ubnt_nano_m_setup);
96 +
97 +static struct gpio_led ubnt_airrouter_leds_gpio[] __initdata = {
98 +       {
99 +               .name           = "ubnt:green:globe",
100 +               .gpio           = 0,
101 +               .active_low     = 1,
102 +       }, {
103 +               .name           = "ubnt:green:power",
104 +               .gpio           = 11,
105 +               .active_low     = 1,
106 +               .default_state  = LEDS_GPIO_DEFSTATE_ON,
107 +       }
108 +};
109 +
110 +static void __init ubnt_airrouter_setup(void)
111 +{
112 +       u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
113 +       u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
114 +
115 +       ath79_register_m25p80(NULL);
116 +       ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
117 +
118 +       ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
119 +       ath79_init_local_mac(ath79_eth1_data.mac_addr, mac1);
120 +
121 +       ath79_register_eth(1);
122 +       ath79_register_eth(0);
123 +       ath79_register_usb();
124 +
125 +       ap91_pci_init(ee, NULL);
126 +       ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airrouter_leds_gpio),
127 +                                ubnt_airrouter_leds_gpio);
128 +
129 +       ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
130 +                                        ARRAY_SIZE(ubnt_xm_gpio_keys),
131 +                                        ubnt_xm_gpio_keys);
132 +}
133 +
134 +MIPS_MACHINE(ATH79_MACH_UBNT_AIRROUTER, "UBNT-AR", "Ubiquiti AirRouter",
135 +            ubnt_airrouter_setup);
136 +
137 +static struct gpio_led ubnt_unifi_leds_gpio[] __initdata = {
138 +       {
139 +               .name           = "ubnt:orange:dome",
140 +               .gpio           = 1,
141 +               .active_low     = 0,
142 +       }, {
143 +               .name           = "ubnt:green:dome",
144 +               .gpio           = 0,
145 +               .active_low     = 0,
146 +       }
147 +};
148 +
149 +static struct gpio_led ubnt_unifi_outdoor_leds_gpio[] __initdata = {
150 +       {
151 +               .name           = "ubnt:orange:front",
152 +               .gpio           = 1,
153 +               .active_low     = 0,
154 +       }, {
155 +               .name           = "ubnt:green:front",
156 +               .gpio           = 0,
157 +               .active_low     = 0,
158 +       }
159 +};
160 +
161 +
162 +static void __init ubnt_unifi_setup(void)
163 +{
164 +       u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
165 +       u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
166 +
167 +       ath79_register_m25p80(NULL);
168 +
169 +       ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
170 +
171 +       ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
172 +       ath79_register_eth(0);
173 +
174 +       ap91_pci_init(ee, NULL);
175 +
176 +       ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_leds_gpio),
177 +                                ubnt_unifi_leds_gpio);
178 +
179 +       ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
180 +                                        ARRAY_SIZE(ubnt_xm_gpio_keys),
181 +                                        ubnt_xm_gpio_keys);
182 +}
183 +
184 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI, "UBNT-UF", "Ubiquiti UniFi",
185 +            ubnt_unifi_setup);
186 +
187 +
188 +#define UBNT_UNIFIOD_PRI_PHYMASK       BIT(4)
189 +#define UBNT_UNIFIOD_2ND_PHYMASK       (BIT(0) | BIT(1) | BIT(2) | BIT(3))
190 +
191 +static void __init ubnt_unifi_outdoor_setup(void)
192 +{
193 +       u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
194 +       u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
195 +       u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
196 +
197 +       ath79_register_m25p80(NULL);
198 +
199 +       ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
200 +                                UBNT_UNIFIOD_2ND_PHYMASK));
201 +
202 +       ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
203 +       ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
204 +       ath79_register_eth(0);
205 +       ath79_register_eth(1);
206 +
207 +       ap91_pci_init(ee, NULL);
208 +
209 +       ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_leds_gpio),
210 +                                ubnt_unifi_outdoor_leds_gpio);
211 +}
212 +
213 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR, "UBNT-U20",
214 +            "Ubiquiti UniFiAP Outdoor",
215 +            ubnt_unifi_outdoor_setup);
216 --- a/arch/mips/ath79/Kconfig
217 +++ b/arch/mips/ath79/Kconfig
218 @@ -71,9 +71,11 @@ config ATH79_MACH_UBNT_XM
219         bool "Ubiquiti Networks XM (rev 1.0) board"
220         select SOC_AR724X
221         select ATH79_DEV_AP9X_PCI if PCI
222 +       select ATH79_DEV_ETH
223         select ATH79_DEV_GPIO_BUTTONS
224         select ATH79_DEV_LEDS_GPIO
225         select ATH79_DEV_M25P80
226 +       select ATH79_DEV_USB
227         help
228           Say 'Y' here if you want your kernel to support the
229           Ubiquiti Networks XM (rev 1.0) board.
230 --- a/arch/mips/ath79/machtypes.h
231 +++ b/arch/mips/ath79/machtypes.h
232 @@ -22,6 +22,12 @@ enum ath79_mach_type {
233         ATH79_MACH_AP81,                /* Atheros AP81 reference board */
234         ATH79_MACH_DB120,               /* Atheros DB120 reference board */
235         ATH79_MACH_PB44,                /* Atheros PB44 reference board */
236 +       ATH79_MACH_UBNT_AIRROUTER,      /* Ubiquiti AirRouter */
237 +       ATH79_MACH_UBNT_BULLET_M,       /* Ubiquiti Bullet M */
238 +       ATH79_MACH_UBNT_NANO_M,         /* Ubiquiti NanoStation M */
239 +       ATH79_MACH_UBNT_ROCKET_M,       /* Ubiquiti Rocket M */
240 +       ATH79_MACH_UBNT_UNIFI,          /* Ubiquiti Unifi */
241 +       ATH79_MACH_UBNT_UNIFI_OUTDOOR,  /* Ubiquiti UnifiAP Outdoor */
242         ATH79_MACH_UBNT_XM,             /* Ubiquiti Networks XM board rev 1.0 */
243  };
244