diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/network b/target/linux/ar71xx/base-files/etc/uci-defaults/network index d51660368..38c7214a0 100755 --- a/target/linux/ar71xx/base-files/etc/uci-defaults/network +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/network @@ -111,6 +111,7 @@ wp543) ucidef_set_interface_lan "eth0" ;; +alfa-ap96 |\ alfa-nx |\ ap83 |\ jwap003 |\ diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 218f93422..cc0b0b4d3 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -124,6 +124,9 @@ ar71xx_board_detect() { *"AirRouter") name="airrouter" ;; + *"ALFA Network AP96") + name="alfa-ap96" + ;; *"ALFA Network N2/N5") name="alfa-nx" ;; @@ -142,7 +145,7 @@ ar71xx_board_detect() { *AP83) name="ap83" ;; - *AP96) + *"Atheros AP96") name="ap96" ;; *AW-NR580) diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index c2bfa08db..14af3bfc3 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -77,6 +77,7 @@ platform_check_image() { platform_check_image_all0258n "$1" && return 0 return 1 ;; + alfa-ap96 | \ alfa-nx | \ ap121 | \ ap121-mini | \ diff --git a/target/linux/ar71xx/config-2.6.39 b/target/linux/ar71xx/config-2.6.39 index 8cc92aba3..14b628790 100644 --- a/target/linux/ar71xx/config-2.6.39 +++ b/target/linux/ar71xx/config-2.6.39 @@ -13,6 +13,7 @@ CONFIG_AR71XX_DEV_M25P80=y CONFIG_AR71XX_DEV_PB42_PCI=y CONFIG_AR71XX_DEV_PB9X_PCI=y CONFIG_AR71XX_DEV_USB=y +CONFIG_AR71XX_MACH_ALFA_AP96=y CONFIG_AR71XX_MACH_ALFA_NX=y CONFIG_AR71XX_MACH_ALL0258N=y CONFIG_AR71XX_MACH_AP121=y diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig b/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig index 90c7b69a6..8979fdf82 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig @@ -1,6 +1,13 @@ if ATHEROS_AR71XX menu "Atheros AR71xx machine selection" +config AR71XX_MACH_ALFA_AP96 + bool "ALFA Network AP96 board support" + select SOC_AR71XX + select AR71XX_DEV_PB42_PCI if PCI + select AR71XX_DEV_GPIO_BUTTONS + select AR71XX_DEV_USB + config AR71XX_MACH_HORNET_UB bool "Alfa Networks Hornet-UB board support" select SOC_AR933X diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile b/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile index 0cb277e82..42c268026 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile @@ -28,6 +28,7 @@ obj-$(CONFIG_AR71XX_DEV_USB) += dev-usb.o obj-$(CONFIG_AR71XX_NVRAM) += nvram.o obj-$(CONFIG_AR71XX_PCI_ATH9K_FIXUP) += pci-ath9k-fixup.o +obj-$(CONFIG_AR71XX_MACH_ALFA_AP96) += mach-alfa-ap96.o obj-$(CONFIG_AR71XX_MACH_ALFA_NX) += mach-alfa-nx.o obj-$(CONFIG_AR71XX_MACH_ALL0258N) += mach-all0258n.o obj-$(CONFIG_AR71XX_MACH_AP121) += mach-ap121.o diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-alfa-ap96.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-alfa-ap96.c new file mode 100644 index 000000000..f22db50a5 --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-alfa-ap96.c @@ -0,0 +1,156 @@ +/* + * ALFA Network AP96 board support + * + * Copyright (C) 2012 Gabor Juhos + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "machtype.h" +#include "devices.h" +#include "dev-pb42-pci.h" +#include "dev-gpio-buttons.h" +#include "dev-usb.h" + +#define ALFA_AP96_GPIO_MICROSD_CS 0 +#define ALFA_AP96_GPIO_RTC_CS 1 +#define ALFA_AP96_GPIO_PCIE_RESET 2 +#define ALFA_AP96_GPIO_SIM_DETECT 3 +#define ALFA_AP96_GPIO_MICROSD_CD 4 +#define ALFA_AP96_GPIO_PCIE_W_DISABLE 5 + +#define ALFA_AP96_GPIO_BUTTON_RESET 11 + +#define ALFA_AP96_KEYS_POLL_INTERVAL 20 /* msecs */ +#define ALFA_AP96_KEYS_DEBOUNCE_INTERVAL (3 * ALFA_AP96_KEYS_POLL_INTERVAL) + +static struct gpio_keys_button alfa_ap96_gpio_keys[] __initdata = { + { + .desc = "Reset button", + .type = EV_KEY, + .code = KEY_RESTART, + .debounce_interval = ALFA_AP96_KEYS_DEBOUNCE_INTERVAL, + .gpio = ALFA_AP96_GPIO_BUTTON_RESET, + .active_low = 1, + } +}; + +static int alfa_ap96_mmc_get_cd(struct device *dev) +{ + return !gpio_get_value(ALFA_AP96_GPIO_MICROSD_CD); +} + +static struct mmc_spi_platform_data alfa_ap96_mmc_data = { + .get_cd = alfa_ap96_mmc_get_cd, + .caps = MMC_CAP_NEEDS_POLL, + .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, +}; + +static struct spi_board_info alfa_ap96_spi_info[] = { + { + .bus_num = 0, + .chip_select = 0, + .max_speed_hz = 25000000, + .modalias = "m25p80", + }, { + .bus_num = 0, + .chip_select = 1, + .max_speed_hz = 25000000, + .modalias = "mmc_spi", + .platform_data = &alfa_ap96_mmc_data, + .controller_data = (void *) ALFA_AP96_GPIO_MICROSD_CS, + }, { + .bus_num = 0, + .chip_select = 2, + .max_speed_hz = 6250000, + .modalias = "rtc-pcf2123", + .controller_data = (void *) ALFA_AP96_GPIO_RTC_CS, + }, +}; + +static struct resource alfa_ap96_spi_resources[] = { + [0] = { + .start = AR71XX_SPI_BASE, + .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1, + .flags = IORESOURCE_MEM, + }, +}; + +static struct ar71xx_spi_platform_data alfa_ap96_spi_data = { + .bus_num = 0, + .num_chipselect = 3, +}; + +static struct platform_device alfa_ap96_spi_device = { + .name = "pb44-spi", + .id = -1, + .resource = alfa_ap96_spi_resources, + .num_resources = ARRAY_SIZE(alfa_ap96_spi_resources), + .dev = { + .platform_data = &alfa_ap96_spi_data, + }, +}; + +static void __init alfa_ap96_gpio_setup(void) +{ + ar71xx_gpio_function_disable(AR71XX_GPIO_FUNC_SPI_CS1_EN | + AR71XX_GPIO_FUNC_SPI_CS2_EN); + + gpio_request(ALFA_AP96_GPIO_MICROSD_CD, "microSD CD"); + gpio_direction_input(ALFA_AP96_GPIO_MICROSD_CD); + gpio_request(ALFA_AP96_GPIO_PCIE_RESET, "PCIe reset"); + gpio_direction_output(ALFA_AP96_GPIO_PCIE_RESET, 1); + gpio_request(ALFA_AP96_GPIO_PCIE_W_DISABLE, "PCIe write disable"); + gpio_direction_output(ALFA_AP96_GPIO_PCIE_W_DISABLE, 1); +} + +#define ALFA_AP96_WAN_PHYMASK BIT(4) +#define ALFA_AP96_LAN_PHYMASK BIT(5) +#define ALFA_AP96_MDIO_PHYMASK (ALFA_AP96_LAN_PHYMASK | ALFA_AP96_WAN_PHYMASK) + +static void __init alfa_ap96_init(void) +{ + alfa_ap96_gpio_setup(); + + ar71xx_add_device_mdio(0, ~ALFA_AP96_MDIO_PHYMASK); + + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 0); + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; + ar71xx_eth0_data.phy_mask = ALFA_AP96_WAN_PHYMASK; + ar71xx_eth1_pll_data.pll_1000 = 0x110000; + + ar71xx_add_device_eth(0); + + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, ar71xx_mac_base, 1); + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; + ar71xx_eth1_data.phy_mask = ALFA_AP96_LAN_PHYMASK; + ar71xx_eth1_pll_data.pll_1000 = 0x110000; + + ar71xx_add_device_eth(1); + + pb42_pci_init(); + + spi_register_board_info(alfa_ap96_spi_info, + ARRAY_SIZE(alfa_ap96_spi_info)); + platform_device_register(&alfa_ap96_spi_device); + + ar71xx_register_gpio_keys_polled(-1, ALFA_AP96_KEYS_POLL_INTERVAL, + ARRAY_SIZE(alfa_ap96_gpio_keys), + alfa_ap96_gpio_keys); + ar71xx_add_device_usb(); +} + +MIPS_MACHINE(AR71XX_MACH_ALFA_AP96, "ALFA-AP96", "ALFA Network AP96", + alfa_ap96_init); diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h b/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h index a2aa0359f..522b0acde 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h @@ -16,6 +16,7 @@ enum ar71xx_mach_type { AR71XX_MACH_GENERIC = 0, + AR71XX_MACH_ALFA_AP96, /* ALFA Network AP96 board */ AR71XX_MACH_ALFA_NX, /* ALFA Network N2/N5 board */ AR71XX_MACH_ALL0258N, /* Allnet ALL0258N */ AR71XX_MACH_AP121, /* Atheros AP121 */