ar71xx: add inital support for the ALFA Network AP96 board
authorGabor Juhos <juhosg@openwrt.org>
Wed, 4 Jan 2012 21:13:54 +0000 (21:13 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Wed, 4 Jan 2012 21:13:54 +0000 (21:13 +0000)
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.

SVN-Revision: 29662

target/linux/ar71xx/base-files/etc/uci-defaults/network
target/linux/ar71xx/base-files/lib/ar71xx.sh
target/linux/ar71xx/base-files/lib/upgrade/platform.sh
target/linux/ar71xx/config-2.6.39
target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig
target/linux/ar71xx/files/arch/mips/ar71xx/Makefile
target/linux/ar71xx/files/arch/mips/ar71xx/mach-alfa-ap96.c [new file with mode: 0644]
target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h

index d51660368c413db29f7fa354c7da3b94e5daabbc..38c7214a071d5d6ab998ced18ccfd4669b6d752f 100755 (executable)
@@ -111,6 +111,7 @@ wp543)
        ucidef_set_interface_lan "eth0"
        ;;
 
+alfa-ap96 |\
 alfa-nx |\
 ap83 |\
 jwap003 |\
index 218f934229d69344aac4eca799a4fe7547aeeea4..cc0b0b4d32ecc4388327113e827f1640f1eeec41 100755 (executable)
@@ -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)
index c2bfa08dbbe432c4f0fc7f7c93125955b77fdb7d..14af3bfc36d13eaaf82cff6146ba8af61cd90ec4 100755 (executable)
@@ -77,6 +77,7 @@ platform_check_image() {
                platform_check_image_all0258n "$1" && return 0
                return 1
                ;;
+       alfa-ap96 | \
        alfa-nx | \
        ap121 | \
        ap121-mini | \
index 8cc92aba3ef283e035a00010acac950502e2812b..14b62879045f42c33d2025f130b3d92137719925 100644 (file)
@@ -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
index 90c7b69a6d1dc728a8fd08c6d45d25f569cce15c..8979fdf8269cc7894dd5112872a48e0be7e2ef94 100644 (file)
@@ -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
index 0cb277e828227347bb5c08ff99cc22f3283961e1..42c268026b275a04e45c8f7d7fb6f1ddfca67135 100644 (file)
@@ -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 (file)
index 0000000..f22db50
--- /dev/null
@@ -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);
index a2aa0359f74d84c6829627e7f9e7640c9b3276b1..522b0acdeffa832645d9dc48ac6fa886d5356885 100644 (file)
@@ -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 */