diff options
author | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2012-01-04 21:13:54 +0000 |
---|---|---|
committer | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2012-01-04 21:13:54 +0000 |
commit | b8e2e95b70dd175be2743d4d95eb85f04f6b3b97 (patch) | |
tree | af768a94ed18e2eefb806e8ac9134a4ed81bc9aa /target/linux/ar71xx/files/arch | |
parent | 3d14a486be2901c17ae0250a081c4f9ab30feb0a (diff) |
ar71xx: add inital support for the ALFA Network AP96 board
The microSD slot and the Real Time Clock is not working yet.
The miniPCIe interface is not tested due to the lack of a
suitable card.
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@29662 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ar71xx/files/arch')
4 files changed, 165 insertions, 0 deletions
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 <juhosg@openwrt.org> + * + * 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 <linux/init.h> +#include <linux/bitops.h> +#include <linux/gpio.h> +#include <linux/platform_device.h> +#include <linux/mmc/host.h> +#include <linux/spi/spi.h> +#include <linux/spi/mmc_spi.h> + +#include <asm/mach-ar71xx/ar71xx.h> + +#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 */ |