ar71xx: add support for the ALFA Network N2/N5 boards
authorGabor Juhos <juhosg@openwrt.org>
Sun, 1 Jan 2012 19:30:25 +0000 (19:30 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Sun, 1 Jan 2012 19:30:25 +0000 (19:30 +0000)
SVN-Revision: 29635

target/linux/ar71xx/base-files/etc/diag.sh
target/linux/ar71xx/base-files/etc/uci-defaults/leds
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-nx.c [new file with mode: 0644]
target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h

index 6c40f62e839c497b3b44b866a798a40974c48069..feed265602eec2549d41af084900b80b9a3845f6 100755 (executable)
@@ -30,6 +30,9 @@ status_led_off() {
 
 get_status_led() {
        case $(ar71xx_board_name) in
+       alfa-nx)
+               status_led="alfa:green:led_8"
+               ;;
        ap81)
                status_led="ap81:green:status"
                ;;
index 0fdab7b2a4c9cad66d0ec501a6ce692d30500375..c637279faba12f455c3761b9e9323e79819db760 100755 (executable)
@@ -101,6 +101,11 @@ EOF
 board=$(ar71xx_board_name)
 
 case "$board" in
+alfa-nx)
+       set_led_netdev "wan" "WAN" "alfa:green:led_2" "eth0"
+       set_led_netdev "lan" "LAN" "alfa:green:led_3" "eth1"
+       ;;
+
 rb750)
        set_led_default "act" "act" "rb750:green:act" "1"
        set_led_netdev "port1" "port1" "rb750:green:port1" "eth1"
index 48139642e0b6221b3de3d6ae2c89f5c1421ed06e..ba556c10757f85cbec39075d5185e65e55c28467 100755 (executable)
@@ -114,6 +114,7 @@ wp543)
        ucidef_set_interface_lan "eth0"
        ;;
 
+alfa-nx |\
 ap83 |\
 jwap003 |\
 pb42 |\
index ee242a43c4fcb430dbf756bec0c7a49dd301745b..b259b678658e4a1d0563b9e7b475b391a22a0ca5 100755 (executable)
@@ -118,6 +118,9 @@ ar71xx_board_detect() {
        *"AirRouter")
                name="airrouter"
                ;;
+       *"ALFA Network N2/N5")
+               name="alfa-nx"
+               ;;
        *ALL0258N)
                name="all0258n"
                ;;
index 055282840ab056be32024f9795ac5eac8b075eee..ec0d03b68437ce0789a6db508e163e7a29054bb4 100755 (executable)
@@ -77,6 +77,7 @@ platform_check_image() {
                platform_check_image_all0258n "$1" && return 0
                return 1
                ;;
+       alfa-nx | \
        ap121 | \
        ap121-mini | \
        ap96 | \
index 78eb0ef1b66c6697dd03b1122d9c1b251d4e5491..2a232ddb049d2de0d3805199ca9d2e844547cf2d 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_NX=y
 CONFIG_AR71XX_MACH_ALL0258N=y
 CONFIG_AR71XX_MACH_AP121=y
 CONFIG_AR71XX_MACH_AP81=y
index 52d8313da302fd9739f9df28e18db9bcbabe6777..c2ccf8121ec644578af5c4afdda637c2171068d3 100644 (file)
@@ -10,6 +10,14 @@ config AR71XX_MACH_HORNET_UB
        select AR71XX_DEV_USB
        select AR71XX_DEV_AR9XXX_WMAC
 
+config AR71XX_MACH_ALFA_NX
+       bool "ALFA Network N2/N5 board support"
+       select SOC_AR724X
+       select AR71XX_DEV_AP91_PCI if PCI
+       select AR71XX_DEV_M25P80
+       select AR71XX_DEV_GPIO_BUTTONS
+       select AR71XX_DEV_LEDS_GPIO
+
 config AR71XX_MACH_ALL0258N
        bool "Allnet ALL0258N support"
        select SOC_AR724X
index 9300d7a500458ac83297c65843e4c0e6c33d41c0..9d086811f589a0ca868710beb9c026b3d3ff0b75 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_NX)      += mach-alfa-nx.o
 obj-$(CONFIG_AR71XX_MACH_ALL0258N)     += mach-all0258n.o
 obj-$(CONFIG_AR71XX_MACH_AP121)                += mach-ap121.o
 obj-$(CONFIG_AR71XX_MACH_AP81)         += mach-ap81.o
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-alfa-nx.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-alfa-nx.c
new file mode 100644 (file)
index 0000000..6e28080
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ *  ALFA Network N2/N5 board support
+ *
+ *  Copyright (C) 2011 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/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/mach-ar71xx/ar71xx.h>
+
+#include "machtype.h"
+#include "devices.h"
+#include "dev-m25p80.h"
+#include "dev-ap91-pci.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+
+#define ALFA_NX_GPIO_LED_2             17
+#define ALFA_NX_GPIO_LED_3             16
+#define ALFA_NX_GPIO_LED_5             12
+#define ALFA_NX_GPIO_LED_6             8
+#define ALFA_NX_GPIO_LED_7             6
+#define ALFA_NX_GPIO_LED_8             7
+
+#define ALFA_NX_GPIO_BTN_RESET         11
+
+#define ALFA_NX_KEYS_POLL_INTERVAL     20      /* msecs */
+#define ALFA_NX_KEYS_DEBOUNCE_INTERVAL (3 * ALFA_NX_KEYS_POLL_INTERVAL)
+
+#define ALFA_NX_MAC0_OFFSET            0
+#define ALFA_NX_MAC1_OFFSET            6
+#define ALFA_NX_CALDATA_OFFSET         0x1000
+
+#ifdef CONFIG_MTD_PARTITIONS
+static struct mtd_partition alfa_nx_partitions[] = {
+       {
+               .name           = "u-boot",
+               .offset         = 0,
+               .size           = 0x040000,
+               .mask_flags     = MTD_WRITEABLE,
+       }, {
+               .name           = "u-boot-env",
+               .offset         = 0x040000,
+               .size           = 0x010000,
+               .mask_flags     = MTD_WRITEABLE,
+       }, {
+               .name           = "rootfs",
+               .offset         = 0x050000,
+               .size           = 0x600000,
+       }, {
+               .name           = "kernel",
+               .offset         = 0x650000,
+               .size           = 0x190000,
+       }, {
+               .name           = "nvram",
+               .offset         = 0x7e0000,
+               .size           = 0x010000,
+               .mask_flags     = MTD_WRITEABLE,
+       }, {
+               .name           = "art",
+               .offset         = 0x7f0000,
+               .size           = 0x010000,
+               .mask_flags     = MTD_WRITEABLE,
+       }, {
+               .name           = "firmware",
+               .offset         = 0x050000,
+               .size           = 0x780000,
+       }
+};
+#endif /* CONFIG_MTD_PARTITIONS */
+
+static struct flash_platform_data alfa_nx_flash_data = {
+#ifdef CONFIG_MTD_PARTITIONS
+       .parts          = alfa_nx_partitions,
+       .nr_parts       = ARRAY_SIZE(alfa_nx_partitions),
+#endif
+};
+
+static struct gpio_keys_button alfa_nx_gpio_keys[] __initdata = {
+       {
+               .desc           = "Reset button",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = ALFA_NX_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = ALFA_NX_GPIO_BTN_RESET,
+               .active_low     = 1,
+       }
+};
+
+static struct gpio_led alfa_nx_leds_gpio[] __initdata = {
+       {
+               .name           = "alfa:green:led_2",
+               .gpio           = ALFA_NX_GPIO_LED_2,
+               .active_low     = 1,
+       }, {
+               .name           = "alfa:green:led_3",
+               .gpio           = ALFA_NX_GPIO_LED_3,
+               .active_low     = 1,
+       }, {
+               .name           = "alfa:red:led_5",
+               .gpio           = ALFA_NX_GPIO_LED_5,
+               .active_low     = 1,
+       }, {
+               .name           = "alfa:amber:led_6",
+               .gpio           = ALFA_NX_GPIO_LED_6,
+               .active_low     = 1,
+       }, {
+               .name           = "alfa:green:led_7",
+               .gpio           = ALFA_NX_GPIO_LED_7,
+               .active_low     = 1,
+       }, {
+               .name           = "alfa:green:led_8",
+               .gpio           = ALFA_NX_GPIO_LED_8,
+               .active_low     = 1,
+       }
+};
+
+static void __init alfa_nx_setup(void)
+{
+       u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
+
+       ar71xx_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
+                                  AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
+                                  AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
+                                  AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
+                                  AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
+                                  AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
+
+       ar71xx_add_device_m25p80(&alfa_nx_flash_data);
+
+       ar71xx_add_device_leds_gpio(0, ARRAY_SIZE(alfa_nx_leds_gpio),
+                                       alfa_nx_leds_gpio);
+
+       ar71xx_register_gpio_keys_polled(-1, ALFA_NX_KEYS_POLL_INTERVAL,
+                                        ARRAY_SIZE(alfa_nx_gpio_keys),
+                                        alfa_nx_gpio_keys);
+
+       ar71xx_add_device_mdio(0, 0x0);
+
+       ar71xx_init_mac(ar71xx_eth0_data.mac_addr,
+                       art + ALFA_NX_MAC0_OFFSET, 0);
+       ar71xx_init_mac(ar71xx_eth1_data.mac_addr,
+                       art + ALFA_NX_MAC1_OFFSET, 0);
+
+       /* WAN port */
+       ar71xx_add_device_eth(0);
+       /* LAN port */
+       ar71xx_add_device_eth(1);
+
+       ap91_pci_init(art + ALFA_NX_CALDATA_OFFSET, NULL);
+}
+
+MIPS_MACHINE(AR71XX_MACH_ALFA_NX, "ALFA-NX", "ALFA Network N2/N5",
+            alfa_nx_setup);
index 00eee5160223e7a28c798867636ec16cde02eedb..cac9d55f779f5df6478e7091f8e11f32a781c357 100644 (file)
@@ -16,6 +16,7 @@
 
 enum ar71xx_mach_type {
        AR71XX_MACH_GENERIC = 0,
+       AR71XX_MACH_ALFA_NX,    /* ALFA Network N2/N5 board */
        AR71XX_MACH_ALL0258N,   /* Allnet ALL0258N */
        AR71XX_MACH_AP121,      /* Atheros AP121 */
        AR71XX_MACH_AP121_MINI, /* Atheros AP121-MINI */