ar71xx: add kernel support for the UniFi AP Pro
[openwrt.git] / target / linux / ar71xx / patches-3.6 / 608-MIPS-ath79-ubnt-xm-add-more-boards.patch
index 4b880e9..65576b6 100644 (file)
@@ -1,12 +1,16 @@
 --- a/arch/mips/ath79/mach-ubnt-xm.c
 +++ b/arch/mips/ath79/mach-ubnt-xm.c
-@@ -13,15 +13,17 @@
+@@ -12,16 +12,22 @@
  #include <linux/init.h>
  #include <linux/pci.h>
++#include <linux/platform_device.h>
  #include <linux/ath9k_platform.h>
 +#include <linux/etherdevice.h>
++#include <linux/ar8216_platform.h>
  
  #include <asm/mach-ath79/irq.h>
++#include <asm/mach-ath79/ar71xx_regs.h>
  
  #include "dev-ap9x-pci.h"
 +#include "dev-eth.h"
  #include "dev-leds-gpio.h"
  #include "dev-m25p80.h"
 +#include "dev-usb.h"
++#include "dev-wmac.h"
  #include "machtypes.h"
 -#include "pci.h"
  
  #define UBNT_XM_GPIO_LED_L1           0
  #define UBNT_XM_GPIO_LED_L2           1
-@@ -37,19 +39,19 @@
+@@ -37,19 +43,19 @@
  
  static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
        {
@@ -43,7 +48,7 @@
                .gpio           = UBNT_XM_GPIO_LED_L4,
                .active_low     = 0,
        },
-@@ -66,9 +68,13 @@ static struct gpio_keys_button ubnt_xm_g
+@@ -66,9 +72,13 @@ static struct gpio_keys_button ubnt_xm_g
        }
  };
  
@@ -57,7 +62,7 @@
  
        ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
                                 ubnt_xm_leds_gpio);
-@@ -79,9 +85,155 @@ static void __init ubnt_xm_init(void)
+@@ -79,9 +89,242 @@ static void __init ubnt_xm_init(void)
  
        ath79_register_m25p80(NULL);
        ap91_pci_init(eeprom, NULL);
 +      }
 +};
 +
-+
 +static void __init ubnt_unifi_setup(void)
 +{
 +      u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR, "UBNT-U20",
 +           "Ubiquiti UniFiAP Outdoor",
 +           ubnt_unifi_outdoor_setup);
++
++static struct gpio_led ubnt_uap_pro_gpio_leds[] __initdata = {
++      {
++              .name           = "ubnt:white:dome",
++              .gpio           = 12,
++      }, {
++              .name           = "ubnt:blue:dome",
++              .gpio           = 13,
++      }
++};
++
++static struct gpio_keys_button uap_pro_gpio_keys[] __initdata = {
++      {
++              .desc                   = "reset",
++              .type                   = EV_KEY,
++              .code                   = KEY_RESTART,
++              .debounce_interval      = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
++              .gpio                   = 17,
++              .active_low             = 1,
++      }
++};
++
++static struct ar8327_pad_cfg uap_pro_ar8327_pad0_cfg = {
++      .mode = AR8327_PAD_MAC_RGMII,
++      .txclk_delay_en = true,
++      .rxclk_delay_en = true,
++      .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
++      .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
++};
++
++static struct ar8327_platform_data uap_pro_ar8327_data = {
++      .pad0_cfg = &uap_pro_ar8327_pad0_cfg,
++      .cpuport_cfg = {
++              .force_link = 1,
++              .speed = AR8327_PORT_SPEED_1000,
++              .duplex = 1,
++              .txpause = 1,
++              .rxpause = 1,
++      },
++};
++
++static struct mdio_board_info uap_pro_mdio0_info[] = {
++      {
++              .bus_id = "ag71xx-mdio.0",
++              .phy_addr = 0,
++              .platform_data = &uap_pro_ar8327_data,
++      },
++};
++
++#define UAP_PRO_MAC0_OFFSET           0x0000
++#define UAP_PRO_MAC1_OFFSET           0x0006
++#define UAP_PRO_WMAC_CALDATA_OFFSET   0x1000
++#define UAP_PRO_PCI_CALDATA_OFFSET    0x5000
++
++static void __init ubnt_uap_pro_setup(void)
++{
++      u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
++
++      ath79_register_m25p80(NULL);
++
++      ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_uap_pro_gpio_leds),
++                               ubnt_uap_pro_gpio_leds);
++      ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
++                                        ARRAY_SIZE(uap_pro_gpio_keys),
++                                        uap_pro_gpio_keys);
++
++      ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
++      ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
++
++      ath79_register_mdio(0, 0x0);
++      mdiobus_register_board_info(uap_pro_mdio0_info,
++                                  ARRAY_SIZE(uap_pro_mdio0_info));
++
++      ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
++      ath79_init_mac(ath79_eth0_data.mac_addr,
++                     eeprom + UAP_PRO_MAC0_OFFSET, 0);
++
++      /* GMAC0 is connected to an AR8327 switch */
++      ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
++      ath79_eth0_data.phy_mask = BIT(0);
++      ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
++      ath79_eth0_pll_data.pll_1000 = 0x06000000;
++      ath79_register_eth(0);
++}
++
++MIPS_MACHINE(ATH79_MACH_UBNT_UAP_PRO, "UAP-PRO", "Ubiquiti UniFi AP Pro",
++           ubnt_uap_pro_setup);
++
 --- a/arch/mips/ath79/Kconfig
 +++ b/arch/mips/ath79/Kconfig
-@@ -71,9 +71,11 @@ config ATH79_MACH_UBNT_XM
-       bool "Ubiquiti Networks XM (rev 1.0) board"
+@@ -68,12 +68,16 @@ config ATH79_MACH_PB44
+         Atheros PB44 reference board.
+ config ATH79_MACH_UBNT_XM
+-      bool "Ubiquiti Networks XM (rev 1.0) board"
++      bool "Ubiquiti Networks XM/UniFi boards"
        select SOC_AR724X
++      select SOC_AR934X
        select ATH79_DEV_AP9X_PCI if PCI
 +      select ATH79_DEV_ETH
        select ATH79_DEV_GPIO_BUTTONS
        select ATH79_DEV_LEDS_GPIO
        select ATH79_DEV_M25P80
 +      select ATH79_DEV_USB
++      select ATH79_DEV_WMAC
        help
          Say 'Y' here if you want your kernel to support the
          Ubiquiti Networks XM (rev 1.0) board.
 --- a/arch/mips/ath79/machtypes.h
 +++ b/arch/mips/ath79/machtypes.h
-@@ -22,6 +22,12 @@ enum ath79_mach_type {
+@@ -22,6 +22,13 @@ enum ath79_mach_type {
        ATH79_MACH_AP81,                /* Atheros AP81 reference board */
        ATH79_MACH_DB120,               /* Atheros DB120 reference board */
        ATH79_MACH_PB44,                /* Atheros PB44 reference board */
 +      ATH79_MACH_UBNT_BULLET_M,       /* Ubiquiti Bullet M */
 +      ATH79_MACH_UBNT_NANO_M,         /* Ubiquiti NanoStation M */
 +      ATH79_MACH_UBNT_ROCKET_M,       /* Ubiquiti Rocket M */
++      ATH79_MACH_UBNT_UAP_PRO,        /* Ubiquiti UniFi AP Pro */
 +      ATH79_MACH_UBNT_UNIFI,          /* Ubiquiti Unifi */
 +      ATH79_MACH_UBNT_UNIFI_OUTDOOR,  /* Ubiquiti UnifiAP Outdoor */
        ATH79_MACH_UBNT_XM,             /* Ubiquiti Networks XM board rev 1.0 */