ar71xx: add kernel support for the Allnet ALL0258N board
authorGabor Juhos <juhosg@openwrt.org>
Mon, 24 Oct 2011 21:49:21 +0000 (21:49 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Mon, 24 Oct 2011 21:49:21 +0000 (21:49 +0000)
This patchs adds support for the Allnet ALL0258N outdoor AP/bridge.
The ALL0258N is based on the AR7240 SoC paired with an AR9285 radio,
it got 8MB of NOR and 32MB SDRAM.

Signed-off-by: Daniel Golle <dgolle@allnet.de>
SVN-Revision: 28564

target/linux/ar71xx/base-files/lib/ar71xx.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-all0258n.c [new file with mode: 0644]
target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h

index d099d39df3a7f5552ebd85794f211bd01e027008..51ff62b524a58e9d8173d81700fdbc787e77a26a 100755 (executable)
@@ -10,6 +10,9 @@ ar71xx_board_name() {
        machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
 
        case "$machine" in
        machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
 
        case "$machine" in
+       *ALL0258N)
+               name="all0258n"
+               ;;
        *AP121)
                name="ap121"
                ;;
        *AP121)
                name="ap121"
                ;;
index 731b87d74469ceedb30666326da16530691295b1..94d4d4a4fcb124a1d62d92ec7d023c4837ee7a54 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_DEV_PB42_PCI=y
 CONFIG_AR71XX_DEV_PB9X_PCI=y
 CONFIG_AR71XX_DEV_USB=y
+CONFIG_AR71XX_MACH_ALL0258N=y
 CONFIG_AR71XX_MACH_AP121=y
 CONFIG_AR71XX_MACH_AP81=y
 CONFIG_AR71XX_MACH_AP83=y
 CONFIG_AR71XX_MACH_AP121=y
 CONFIG_AR71XX_MACH_AP81=y
 CONFIG_AR71XX_MACH_AP83=y
index 71e47c2f358c7a74461b4397b3576d92077d3172..d9ea47e0c06bc48164451abd8c1a2a95725918c1 100644 (file)
@@ -1,6 +1,13 @@
 if ATHEROS_AR71XX
 
 menu "Atheros AR71xx machine selection"
 if ATHEROS_AR71XX
 
 menu "Atheros AR71xx machine selection"
+config AR71XX_MACH_ALL0258N
+       bool "Allnet ALL0258N support"
+       select SOC_AR724X
+       select AR71XX_DEV_M25P80
+       select AR71XX_DEV_AP91_PCI if PCI
+       select AR71XX_DEV_GPIO_BUTTONS
+       select AR71XX_DEV_LEDS_GPIO
 
 config AR71XX_MACH_AP81
        bool "Atheros AP81 board support"
 
 config AR71XX_MACH_AP81
        bool "Atheros AP81 board support"
index 6c872f2c1464009f366519468d52c7729fe08873..aab38537e44772a6978a24485351b08073aa5382 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_NVRAM)             += nvram.o
 obj-$(CONFIG_AR71XX_PCI_ATH9K_FIXUP)   += pci-ath9k-fixup.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
 obj-$(CONFIG_AR71XX_MACH_AP83)         += mach-ap83.o
 obj-$(CONFIG_AR71XX_MACH_AP121)                += mach-ap121.o
 obj-$(CONFIG_AR71XX_MACH_AP81)         += mach-ap81.o
 obj-$(CONFIG_AR71XX_MACH_AP83)         += mach-ap83.o
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-all0258n.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-all0258n.c
new file mode 100644 (file)
index 0000000..7c383f5
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ *  Allnet ALL0258N support
+ *
+ *  Copyright (C) 2011 Daniel Golle <dgolle@allnet.de>
+ *
+ *  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 <linux/platform_device.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"
+
+/* found via /sys/gpio/... try and error */
+#define ALL0258N_GPIO_BTN_RESET                1
+#define ALL0258N_GPIO_LED_RSSIHIGH     13
+#define ALL0258N_GPIO_LED_RSSIMEDIUM   15
+#define ALL0258N_GPIO_LED_RSSILOW      14
+
+/* defaults taken from others machs */
+#define ALL0258N_KEYS_POLL_INTERVAL    20      /* msecs */
+#define ALL0258N_KEYS_DEBOUNCE_INTERVAL (3 * ALL0258N_KEYS_POLL_INTERVAL)
+
+/* showed up in the original firmware's bootlog */
+#define ALL0258N_LAN_PHYMASK BIT(4)
+#define ALL0258N_SEC_PHYMASK BIT(3)
+
+/*
+ * from U-Boot bootargs of original firmware:
+ * mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),320k(custom),1024k(kernel),4928k(rootfs),1536k(failsafe),64k(ART)
+ * we use a more OpenWrt-friendly layout now:
+ * mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),896k(kernel),5376k(rootfs),1536k(failsafe),64k(ART)
+ */
+#ifdef CONFIG_MTD_PARTITIONS
+static struct mtd_partition all0258n_partitions[] = {
+       {
+               .name           = "u-boot",
+               .offset         = 0,
+               .size           = 0x040000,
+               .mask_flags     = MTD_WRITEABLE,
+       }, {
+               .name           = "u-boot-env",
+               .offset         = 0x040000,
+               .size           = 0x010000,
+       }, {
+               .name           = "kernel",
+               .offset         = 0x050000,
+               .size           = 0x0E0000,
+       }, {
+               .name           = "rootfs",
+               .offset         = 0x130000,
+               .size           = 0x540000,
+       }, {
+               .name           = "failsafe",
+               .offset         = 0x670000,
+               .size           = 0x180000,
+       }, {
+               .name           = "firmware",
+               .offset         = 0x050000,
+               .size           = 0x630000,
+       }, {
+               .name           = "art",
+               .offset         = 0x7F0000,
+               .size           = 0x010000,
+               .mask_flags     = MTD_WRITEABLE,
+       }
+};
+#endif /* CONFIG_MTD_PARTITIONS */
+
+static struct flash_platform_data all0258n_flash_data = {
+#ifdef CONFIG_MTD_PARTITIONS
+       .parts          = all0258n_partitions,
+       .nr_parts       = ARRAY_SIZE(all0258n_partitions),
+#endif
+};
+
+static struct gpio_led all0258n_leds_gpio[] __initdata = {
+       {
+               .name           = "all0258n:green:rssihigh",
+               .gpio           = ALL0258N_GPIO_LED_RSSIHIGH,
+               .active_low     = 1,
+       }, {
+               .name           = "all0258n:yellow:rssimedium",
+               .gpio           = ALL0258N_GPIO_LED_RSSIMEDIUM,
+               .active_low     = 1,
+       }, {
+               .name           = "all0258n:red:rssilow",
+               .gpio           = ALL0258N_GPIO_LED_RSSILOW,
+               .active_low     = 1,
+       }
+};
+
+static struct gpio_keys_button all0258n_gpio_keys[] __initdata = {
+       {
+               .desc           = "reset",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = ALL0258N_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = ALL0258N_GPIO_BTN_RESET,
+               .active_low     = 1,
+       }
+};
+
+static void __init all0258n_setup(void)
+{
+       u8 *mac = (u8 *) KSEG1ADDR(0x1f7f0000);
+       u8 *ee =  (u8 *) KSEG1ADDR(0x1f7f1000);
+
+       ar71xx_add_device_m25p80(&all0258n_flash_data);
+
+       ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(all0258n_leds_gpio),
+                                       all0258n_leds_gpio);
+
+       ar71xx_register_gpio_keys_polled(-1, ALL0258N_KEYS_POLL_INTERVAL,
+                                        ARRAY_SIZE(all0258n_gpio_keys),
+                                        all0258n_gpio_keys);
+
+       ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
+       ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 0);
+
+       ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
+       ar71xx_eth0_data.phy_mask = ALL0258N_LAN_PHYMASK;
+
+       ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
+       ar71xx_eth1_data.phy_mask = ALL0258N_SEC_PHYMASK;
+       ar71xx_eth1_data.has_ar7240_switch = 1;
+
+       ar71xx_add_device_mdio(0x0);
+
+       ar71xx_add_device_eth(0);
+       ar71xx_add_device_eth(1);
+
+       ap91_pci_init(ee, mac);
+}
+
+MIPS_MACHINE(AR71XX_MACH_ALL0258N, "ALL0258N", "Allnet ALL0258N",
+            all0258n_setup);
index fa8d5cbd83f3cf91cdf3707f2118ddfdfe5dd8f9..6f16e7bebed4d2ae1110d602d20bd07334b14780 100644 (file)
@@ -16,6 +16,7 @@
 
 enum ar71xx_mach_type {
        AR71XX_MACH_GENERIC = 0,
 
 enum ar71xx_mach_type {
        AR71XX_MACH_GENERIC = 0,
+       AR71XX_MACH_ALL0258N,   /* Allnet ALL0258N */
        AR71XX_MACH_AP121,      /* Atheros AP121 */
        AR71XX_MACH_AP121_MINI, /* Atheros AP121-MINI */
        AR71XX_MACH_AP81,       /* Atheros AP81 */
        AR71XX_MACH_AP121,      /* Atheros AP121 */
        AR71XX_MACH_AP121_MINI, /* Atheros AP121-MINI */
        AR71XX_MACH_AP81,       /* Atheros AP81 */