From 6284f585efa0401b565d706e7a290510dc4a9a97 Mon Sep 17 00:00:00 2001 From: nbd Date: Tue, 17 Jul 2012 11:35:36 -0400 Subject: [PATCH 120/123] 608-MIPS-ath79-ubnt-xm-add-more-boards Import of the above patch from openwrt trunk, as of this commit: ---------- commit c1d79f64eed0a7ac36b5b9bca52275b397bec424 Author: nbd Date: Mon Jul 16 16:26:51 2012 +0000 uboot-ar71xx: fix compile on recent mac os x versions git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32750 3c298f89-4303-0410-b956-a3cf2f4a3e73 ---------- Path to patch in the repo is: target/linux/ar71xx/patches-3.3 Repo is: git://nbd.name/openwrt.git Signed-off-by: Paul Gortmaker --- arch/mips/ath79/Kconfig | 2 + arch/mips/ath79/mach-ubnt-xm.c | 119 ++++++++++++++++++++++++++++++++++++++-- arch/mips/ath79/machtypes.h | 5 ++ 3 files changed, 121 insertions(+), 5 deletions(-) diff --git a/arch/mips/ath79/Kconfig b/arch/mips/ath79/Kconfig index ff02412..e4385c5 100644 --- a/arch/mips/ath79/Kconfig +++ b/arch/mips/ath79/Kconfig @@ -53,9 +53,11 @@ config ATH79_MACH_UBNT_XM bool "Ubiquiti Networks XM (rev 1.0) board" select SOC_AR724X 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 help Say 'Y' here if you want your kernel to support the Ubiquiti Networks XM (rev 1.0) board. diff --git a/arch/mips/ath79/mach-ubnt-xm.c b/arch/mips/ath79/mach-ubnt-xm.c index f12dfa1..25648f5 100644 --- a/arch/mips/ath79/mach-ubnt-xm.c +++ b/arch/mips/ath79/mach-ubnt-xm.c @@ -13,15 +13,17 @@ #include #include #include +#include #include #include "dev-ap9x-pci.h" +#include "dev-eth.h" #include "dev-gpio-buttons.h" #include "dev-leds-gpio.h" #include "dev-m25p80.h" +#include "dev-usb.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 @@ static struct gpio_led ubnt_xm_leds_gpio[] __initdata = { { - .name = "ubnt-xm:red:link1", + .name = "ubnt:red:link1", .gpio = UBNT_XM_GPIO_LED_L1, .active_low = 0, }, { - .name = "ubnt-xm:orange:link2", + .name = "ubnt:orange:link2", .gpio = UBNT_XM_GPIO_LED_L2, .active_low = 0, }, { - .name = "ubnt-xm:green:link3", + .name = "ubnt:green:link3", .gpio = UBNT_XM_GPIO_LED_L3, .active_low = 0, }, { - .name = "ubnt-xm:green:link4", + .name = "ubnt:green:link4", .gpio = UBNT_XM_GPIO_LED_L4, .active_low = 0, }, @@ -66,9 +68,13 @@ static struct gpio_keys_button ubnt_xm_gpio_keys[] __initdata = { } }; +#define UBNT_M_WAN_PHYMASK BIT(4) + static void __init ubnt_xm_init(void) { u8 *eeprom = (u8 *) KSEG1ADDR(UBNT_XM_EEPROM_ADDR); + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000); + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN); ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio), ubnt_xm_leds_gpio); @@ -79,9 +85,112 @@ static void __init ubnt_xm_init(void) ath79_register_m25p80(NULL); ap91_pci_init(eeprom, NULL); + + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK); + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0); + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0); + ath79_register_eth(0); } MIPS_MACHINE(ATH79_MACH_UBNT_XM, "UBNT-XM", "Ubiquiti Networks XM (rev 1.0) board", ubnt_xm_init); + +MIPS_MACHINE(ATH79_MACH_UBNT_BULLET_M, "UBNT-BM", "Ubiquiti Bullet M", + ubnt_xm_init); + +static void __init ubnt_rocket_m_setup(void) +{ + ubnt_xm_init(); + ath79_register_usb(); +} + +MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M, "UBNT-RM", "Ubiquiti Rocket M", + ubnt_rocket_m_setup); + +static void __init ubnt_nano_m_setup(void) +{ + ubnt_xm_init(); + ath79_register_eth(1); +} + +MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M, "UBNT-NM", "Ubiquiti Nanostation M", + ubnt_nano_m_setup); + +static struct gpio_led ubnt_airrouter_leds_gpio[] __initdata = { + { + .name = "ubnt:green:globe", + .gpio = 0, + .active_low = 1, + }, { + .name = "ubnt:green:power", + .gpio = 11, + .active_low = 1, + .default_state = LEDS_GPIO_DEFSTATE_ON, + } +}; + +static void __init ubnt_airrouter_setup(void) +{ + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000); + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); + + ath79_register_m25p80(NULL); + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK); + + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0); + ath79_init_local_mac(ath79_eth1_data.mac_addr, mac1); + + ath79_register_eth(1); + ath79_register_eth(0); + ath79_register_usb(); + + ap91_pci_init(ee, NULL); + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airrouter_leds_gpio), + ubnt_airrouter_leds_gpio); + + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL, + ARRAY_SIZE(ubnt_xm_gpio_keys), + ubnt_xm_gpio_keys); +} + +MIPS_MACHINE(ATH79_MACH_UBNT_AIRROUTER, "UBNT-AR", "Ubiquiti AirRouter", + ubnt_airrouter_setup); + +static struct gpio_led ubnt_unifi_leds_gpio[] __initdata = { + { + .name = "ubnt:orange:dome", + .gpio = 1, + .active_low = 0, + }, { + .name = "ubnt:green:dome", + .gpio = 0, + .active_low = 0, + } +}; + +static void __init ubnt_unifi_setup(void) +{ + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000); + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); + + ath79_register_m25p80(NULL); + + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK); + + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0); + ath79_register_eth(0); + + ap91_pci_init(ee, NULL); + + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_leds_gpio), + ubnt_unifi_leds_gpio); + + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL, + ARRAY_SIZE(ubnt_xm_gpio_keys), + ubnt_xm_gpio_keys); +} + +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI, "UBNT-UF", "Ubiquiti UniFi", + ubnt_unifi_setup); diff --git a/arch/mips/ath79/machtypes.h b/arch/mips/ath79/machtypes.h index af92e5c..ebf0143 100644 --- a/arch/mips/ath79/machtypes.h +++ b/arch/mips/ath79/machtypes.h @@ -20,6 +20,11 @@ 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_AIRROUTER, /* Ubiquiti AirRouter */ + 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_UNIFI, /* Ubiquiti Unifi */ ATH79_MACH_UBNT_XM, /* Ubiquiti Networks XM board rev 1.0 */ }; -- 1.7.9.7