ar71xx: rb2011: apply patch to file
[openwrt.git] / target / linux / ar71xx / patches-3.14 / 616-MIPS-ath79-ubnt-xw.patch
1 --- a/arch/mips/ath79/mach-ubnt-xm.c
2 +++ b/arch/mips/ath79/mach-ubnt-xm.c
3 @@ -186,6 +186,19 @@ static struct gpio_led ubnt_unifi_outdoo
4         }
5  };
6  
7 +static struct gpio_led ubnt_unifi_outdoor_plus_leds_gpio[] __initdata = {
8 +       {
9 +               .name           = "ubnt:white:front",
10 +               .gpio           = 1,
11 +               .active_low     = 0,
12 +       }, {
13 +               .name           = "ubnt:blue:front",
14 +               .gpio           = 0,
15 +               .active_low     = 0,
16 +       }
17 +};
18 +
19 +
20  static void __init ubnt_unifi_setup(void)
21  {
22         u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
23 @@ -245,6 +258,38 @@ MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDO
24              "Ubiquiti UniFiAP Outdoor",
25              ubnt_unifi_outdoor_setup);
26  
27 +
28 +static void __init ubnt_unifi_outdoor_plus_setup(void)
29 +{
30 +       u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
31 +       u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
32 +       u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
33 +
34 +       ath79_register_m25p80(NULL);
35 +
36 +       ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
37 +                                UBNT_UNIFIOD_2ND_PHYMASK));
38 +
39 +       ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
40 +       ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
41 +       ath79_register_eth(0);
42 +       ath79_register_eth(1);
43 +
44 +       ap91_pci_init(ee, NULL);
45 +
46 +       ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_plus_leds_gpio),
47 +                                ubnt_unifi_outdoor_plus_leds_gpio);
48 +
49 +       ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
50 +                                        ARRAY_SIZE(ubnt_xm_gpio_keys),
51 +                                        ubnt_xm_gpio_keys);
52 +}
53 +
54 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR_PLUS, "UBNT-UOP",
55 +            "Ubiquiti UniFiAP Outdoor+",
56 +            ubnt_unifi_outdoor_plus_setup);
57 +
58 +
59  static struct gpio_led ubnt_uap_pro_gpio_leds[] __initdata = {
60         {
61                 .name           = "ubnt:white:dome",
62 @@ -332,3 +377,78 @@ static void __init ubnt_uap_pro_setup(vo
63  MIPS_MACHINE(ATH79_MACH_UBNT_UAP_PRO, "UAP-PRO", "Ubiquiti UniFi AP Pro",
64              ubnt_uap_pro_setup);
65  
66 +#define UBNT_XW_GPIO_LED_L1            11
67 +#define UBNT_XW_GPIO_LED_L2            16
68 +#define UBNT_XW_GPIO_LED_L3            13
69 +#define UBNT_XW_GPIO_LED_L4            14
70 +
71 +static struct gpio_led ubnt_xw_leds_gpio[] __initdata = {
72 +       {
73 +               .name           = "ubnt:red:link1",
74 +               .gpio           = UBNT_XW_GPIO_LED_L1,
75 +               .active_low     = 1,
76 +       }, {
77 +               .name           = "ubnt:orange:link2",
78 +               .gpio           = UBNT_XW_GPIO_LED_L2,
79 +               .active_low     = 1,
80 +       }, {
81 +               .name           = "ubnt:green:link3",
82 +               .gpio           = UBNT_XW_GPIO_LED_L3,
83 +               .active_low     = 1,
84 +       }, {
85 +               .name           = "ubnt:green:link4",
86 +               .gpio           = UBNT_XW_GPIO_LED_L4,
87 +               .active_low     = 1,
88 +       },
89 +};
90 +
91 +static void __init ubnt_xw_init(void)
92 +{
93 +       u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
94 +
95 +       ath79_register_m25p80(NULL);
96 +
97 +       ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xw_leds_gpio),
98 +                                ubnt_xw_leds_gpio);
99 +       ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
100 +                                        ARRAY_SIZE(ubnt_xm_gpio_keys),
101 +                                        ubnt_xm_gpio_keys);
102 +
103 +       ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
104 +       ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
105 +
106 +
107 +       ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_MII_GMAC0 | AR934X_ETH_CFG_MII_GMAC0_SLAVE);
108 +       ath79_init_mac(ath79_eth0_data.mac_addr,
109 +                      eeprom + UAP_PRO_MAC0_OFFSET, 0);
110 +
111 +       ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
112 +       ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
113 +}
114 +
115 +static void __init ubnt_nano_m_xw_setup(void)
116 +{
117 +       ubnt_xw_init();
118 +
119 +       /* GMAC0 is connected to an AR8326 switch */
120 +       ath79_register_mdio(0, ~(BIT(0) | BIT(1) | BIT(5)));
121 +       ath79_eth0_data.phy_mask = (BIT(0) | BIT(1) | BIT(5));
122 +       ath79_eth0_data.speed = SPEED_100;
123 +       ath79_eth0_data.duplex = DUPLEX_FULL;
124 +       ath79_register_eth(0);
125 +}
126 +
127 +static void __init ubnt_loco_m_xw_setup(void)
128 +{
129 +       ubnt_xw_init();
130 +
131 +       ath79_register_mdio(0, ~BIT(1));
132 +       ath79_eth0_data.phy_mask = BIT(1);
133 +       ath79_register_eth(0);
134 +}
135 +
136 +MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M_XW, "UBNT-NM-XW", "Ubiquiti Nanostation M XW",
137 +            ubnt_nano_m_xw_setup);
138 +
139 +MIPS_MACHINE(ATH79_MACH_UBNT_LOCO_M_XW, "UBNT-LOCO-XW", "Ubiquiti Loco M XW",
140 +            ubnt_loco_m_xw_setup);