ar71xx: refactor ubnt xw board setup
[openwrt.git] / target / linux / ar71xx / patches-3.10 / 616-MIPS-ath79-ubnt-xw.patch
1 Index: linux-3.10.49/arch/mips/ath79/mach-ubnt-xm.c
2 ===================================================================
3 --- linux-3.10.49.orig/arch/mips/ath79/mach-ubnt-xm.c   2014-08-15 22:55:37.890080659 +0200
4 +++ linux-3.10.49/arch/mips/ath79/mach-ubnt-xm.c        2014-08-15 22:58:31.061570912 +0200
5 @@ -332,3 +332,67 @@
6  MIPS_MACHINE(ATH79_MACH_UBNT_UAP_PRO, "UAP-PRO", "Ubiquiti UniFi AP Pro",
7              ubnt_uap_pro_setup);
8  
9 +#define UBNT_XW_GPIO_LED_L1            11
10 +#define UBNT_XW_GPIO_LED_L2            16
11 +#define UBNT_XW_GPIO_LED_L3            13
12 +#define UBNT_XW_GPIO_LED_L4            14
13 +
14 +static struct gpio_led ubnt_xw_leds_gpio[] __initdata = {
15 +       {
16 +               .name           = "ubnt:red:link1",
17 +               .gpio           = UBNT_XW_GPIO_LED_L1,
18 +               .active_low     = 1,
19 +       }, {
20 +               .name           = "ubnt:orange:link2",
21 +               .gpio           = UBNT_XW_GPIO_LED_L2,
22 +               .active_low     = 1,
23 +       }, {
24 +               .name           = "ubnt:green:link3",
25 +               .gpio           = UBNT_XW_GPIO_LED_L3,
26 +               .active_low     = 1,
27 +       }, {
28 +               .name           = "ubnt:green:link4",
29 +               .gpio           = UBNT_XW_GPIO_LED_L4,
30 +               .active_low     = 1,
31 +       },
32 +};
33 +
34 +static void __init ubnt_xw_init(void)
35 +{
36 +       u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
37 +
38 +       ath79_register_m25p80(NULL);
39 +
40 +       ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xw_leds_gpio),
41 +                                ubnt_xw_leds_gpio);
42 +       ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
43 +                                        ARRAY_SIZE(ubnt_xm_gpio_keys),
44 +                                        ubnt_xm_gpio_keys);
45 +
46 +       ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
47 +       ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
48 +
49 +
50 +       ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_MII_GMAC0 | AR934X_ETH_CFG_MII_GMAC0_SLAVE);
51 +       ath79_init_mac(ath79_eth0_data.mac_addr,
52 +                      eeprom + UAP_PRO_MAC0_OFFSET, 0);
53 +
54 +       ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
55 +       ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
56 +}
57 +
58 +static void __init ubnt_nano_m_xw_setup(void)
59 +{
60 +       ubnt_xw_init();
61 +
62 +       /* GMAC0 is connected to an AR8326 switch */
63 +       ath79_register_mdio(0, ~(BIT(0) | BIT(1) | BIT(5)));
64 +       ath79_eth0_data.phy_mask = (BIT(0) | BIT(1) | BIT(5));
65 +       ath79_eth0_data.speed = SPEED_100;
66 +       ath79_eth0_data.duplex = DUPLEX_FULL;
67 +       ath79_register_eth(0);
68 +}
69 +
70 +MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M_XW, "UBNT-NM-XW", "Ubiquiti Nanostation M XW",
71 +            ubnt_nano_m_xw_setup);
72 +
73 --- a/arch/mips/ath79/machtypes.h
74 +++ b/arch/mips/ath79/machtypes.h
75 @@ -121,9 +121,10 @@ enum ath79_mach_type {
76         ATH79_MACH_TL_WR941ND,          /* TP-LINK TL-WR941ND */
77         ATH79_MACH_UBNT_AIRROUTER,      /* Ubiquiti AirRouter */
78         ATH79_MACH_UBNT_BULLET_M,       /* Ubiquiti Bullet M */
79         ATH79_MACH_UBNT_LSSR71,         /* Ubiquiti LS-SR71 */
80         ATH79_MACH_UBNT_LSX,            /* Ubiquiti LSX */
81         ATH79_MACH_UBNT_NANO_M,         /* Ubiquiti NanoStation M */
82 +       ATH79_MACH_UBNT_NANO_M_XW,      /* Ubiquiti NanoStation M XW */
83         ATH79_MACH_UBNT_ROCKET_M,       /* Ubiquiti Rocket M */
84         ATH79_MACH_UBNT_RSPRO,          /* Ubiquiti RouterStation Pro */
85         ATH79_MACH_UBNT_RS,             /* Ubiquiti RouterStation */