[LEDE-DEV] [PATCH 6/9] ar71xx: add support for Anonabox Pro

Zoltan HERPAI wigyori at uid0.hu
Sun Oct 22 13:21:24 PDT 2017


From: August Germar <august at anonabox.com>

Chipset is a 650mhz Atheros with 128mb ram.
Variation of QCA9531 SoC with two Ethernet ports
and a 802.11n 2.4 GHz radio.

Signed-off-by: August Germar <august at anonabox.com>
[with review by Daniel Engberg]
Reviewed-by: Zoltan HERPAI <wigyori at uid0.hu>
---
 target/linux/ar71xx/base-files/lib/ar71xx.sh       |   3 +
 .../ar71xx/base-files/lib/upgrade/platform.sh      |   1 +
 target/linux/ar71xx/config-4.9                     |   1 +
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |  11 +++
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
 .../files/arch/mips/ath79/mach-anonabox-pro.c      | 110 +++++++++++++++++++++
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
 target/linux/ar71xx/image/legacy-devices.mk        |   6 ++
 target/linux/ar71xx/image/legacy.mk                |   2 +
 9 files changed, 136 insertions(+)
 create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-anonabox-pro.c

diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index f89c009..bdba81b 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -687,6 +687,9 @@ ar71xx_board_detect() {
 	*"HiWiFi HC6361")
 		name="hiwifi-hc6361"
 		;;
+	*"ANONABOX_PRO")
+		name="anonabox-pro"
+		;;
 	*"Hornet-UB")
 		local size="$(mtd_get_part_size 'firmware')"
 
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 3d6d9ed..a60e44c 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -310,6 +310,7 @@ platform_check_image() {
 		;;
 	alfa-ap96|\
 	alfa-nx|\
+	anonabox-pro|\
 	ap121-mini|\
 	ap121|\
 	ap135-020|\
diff --git a/target/linux/ar71xx/config-4.9 b/target/linux/ar71xx/config-4.9
index 84b2a0b..285c638 100644
--- a/target/linux/ar71xx/config-4.9
+++ b/target/linux/ar71xx/config-4.9
@@ -36,6 +36,7 @@ CONFIG_ATH79_MACH_ALFA_AP96=y
 CONFIG_ATH79_MACH_ALFA_NX=y
 CONFIG_ATH79_MACH_ALL0258N=y
 CONFIG_ATH79_MACH_ALL0315N=y
+CONFIG_ATH79_MACH_ANONABOX_PRO=y
 CONFIG_ATH79_MACH_ANTMINER_S1=y
 CONFIG_ATH79_MACH_ANTMINER_S3=y
 CONFIG_ATH79_MACH_ANTROUTER_R1=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index 5cb4f7e..ac77aed 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -124,6 +124,17 @@ config ATH79_MACH_ALL0315N
 	select ATH79_DEV_LEDS_GPIO
 	select ATH79_DEV_M25P80
 
+config ATH79_MACH_ANONABOX_PRO
+	bool "Anonabox Pro board"
+	select SOC_QCA953X
+	select ATH79_DEV_GPIO_BUTTONS
+	select ATH79_DEV_LEDS_GPIO
+	select ATH79_DEV_SPI
+	select ATH79_DEV_USB
+	select ATH79_DEV_WMAC
+	select ATH79_DEV_ETH
+	select ATH79_DEV_M25P80
+
 config ATH79_MACH_ANTMINER_S1
 	bool "Bitmain Antminer S1 support"
 	select SOC_AR933X
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
index 7d12282..e6f0cae 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_ATH79_MACH_ALFA_AP96)		+= mach-alfa-ap96.o
 obj-$(CONFIG_ATH79_MACH_ALFA_NX)		+= mach-alfa-nx.o
 obj-$(CONFIG_ATH79_MACH_ALL0258N)		+= mach-all0258n.o
 obj-$(CONFIG_ATH79_MACH_ALL0315N)		+= mach-all0315n.o
+obj-$(CONFIG_ATH79_MACH_ANONABOX_PRO)		+= mach-anonabox-pro.o
 obj-$(CONFIG_ATH79_MACH_ANTMINER_S1)		+= mach-antminer-s1.o
 obj-$(CONFIG_ATH79_MACH_ANTMINER_S3)		+= mach-antminer-s3.o
 obj-$(CONFIG_ATH79_MACH_ANTROUTER_R1)		+= mach-antrouter-r1.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-anonabox-pro.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-anonabox-pro.c
new file mode 100644
index 0000000..3fc4c39
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-anonabox-pro.c
@@ -0,0 +1,110 @@
+/*
+ * AnonaBox QCA9531 board support
+ *
+ * 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. 
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/ath9k_platform.h>
+#include <linux/ar8216_platform.h>
+
+#include <asm/mach-ath79/ar71xx_regs.h>
+
+#include "common.h"
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-m25p80.h"
+#include "dev-spi.h"
+#include "dev-usb.h"
+#include "dev-wmac.h"
+#include "machtypes.h"
+
+#define ANONABOX_PRO_GPIO_LED_STATUS              14
+
+#define ANONABOX_PRO_GPIO_BTN_RST                 17
+
+#define ANONABOX_PRO_KEYS_POLL_INTERVAL           20    /* msecs */
+#define ANONABOX_PRO_KEYS_DEBOUNCE_INTERVAL       (3 * ANONABOX_PRO_KEYS_POLL_INTERVAL)
+
+#define ANONABOX_PRO_MAC0_OFFSET                  0
+#define ANONABOX_PRO_MAC1_OFFSET                  6
+#define ANONABOX_PRO_WMAC_CALDATA_OFFSET          0x1000
+
+static struct gpio_led anonabox_pro_leds_gpio[] __initdata = {
+        {
+                .name           = "anonabox_pro:green:status",
+                .gpio           = ANONABOX_PRO_GPIO_LED_STATUS,
+                .active_low     = 1,
+        },
+};
+
+static struct gpio_keys_button anonabox_pro_gpio_keys[] __initdata = {
+        {
+                .desc           = "reset button",
+                .type           = EV_KEY,
+                .code           = KEY_RESTART,
+                .debounce_interval = ANONABOX_PRO_KEYS_DEBOUNCE_INTERVAL,
+                .gpio           = ANONABOX_PRO_GPIO_BTN_RST,
+                .active_low     = 1,
+        },
+};
+
+static void __init anonabox_pro_gpio_led_setup(void)
+{
+        ath79_register_leds_gpio(-1, ARRAY_SIZE(anonabox_pro_leds_gpio),
+                anonabox_pro_leds_gpio);
+        ath79_register_gpio_keys_polled(-1, ANONABOX_PRO_KEYS_POLL_INTERVAL,
+                ARRAY_SIZE(anonabox_pro_gpio_keys),
+                anonabox_pro_gpio_keys);
+}
+
+static void __init anonabox_pro_setup(void)
+{
+        u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
+
+        ath79_register_m25p80(NULL);
+
+        anonabox_pro_gpio_led_setup();
+
+        ath79_register_usb();
+
+        ath79_register_wmac(art + ANONABOX_PRO_WMAC_CALDATA_OFFSET, NULL);
+
+        ath79_register_mdio(0, 0x0);
+        ath79_register_mdio(1, 0x0);
+
+        ath79_init_mac(ath79_eth0_data.mac_addr, art + ANONABOX_PRO_MAC0_OFFSET, 0);
+        ath79_init_mac(ath79_eth1_data.mac_addr, art + ANONABOX_PRO_MAC1_OFFSET, 0);
+
+        /* WAN port */
+        ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+        ath79_eth0_data.speed = SPEED_100;
+        ath79_eth0_data.duplex = DUPLEX_FULL;
+        ath79_eth0_data.phy_mask = BIT(4);
+        ath79_register_eth(0);
+
+        /* LAN ports */
+        ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
+        ath79_eth1_data.speed = SPEED_1000;
+        ath79_eth1_data.duplex = DUPLEX_FULL;
+        ath79_switch_data.phy_poll_mask |= BIT(4);
+        ath79_switch_data.phy4_mii_en = 1;
+        ath79_register_eth(1);
+}
+
+MIPS_MACHINE(ATH79_MACH_ANONABOX_PRO, "ANONABOX_PRO", "Anonabox QCA9531",
+        anonabox_pro_setup);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
index 01472b6..bdf0167 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
@@ -26,6 +26,7 @@ enum ath79_mach_type {
 	ATH79_MACH_ALL0258N,			/* Allnet ALL0258N */
 	ATH79_MACH_ALL0305,			/* Allnet ALL0305 */
 	ATH79_MACH_ALL0315N,			/* Allnet ALL0315N */
+	ATH79_MACH_ANONABOX_PRO,		/* AnonaBox Pro */
 	ATH79_MACH_ANTMINER_S1,			/* Antminer S1 */
 	ATH79_MACH_ANTMINER_S3,			/* Antminer S3 */
 	ATH79_MACH_ANTROUTER_R1,		/* Antrouter R1 */
diff --git a/target/linux/ar71xx/image/legacy-devices.mk b/target/linux/ar71xx/image/legacy-devices.mk
index e418282..0bbadc0 100644
--- a/target/linux/ar71xx/image/legacy-devices.mk
+++ b/target/linux/ar71xx/image/legacy-devices.mk
@@ -55,6 +55,12 @@ define LegacyDevice/ALL0315N
 endef
 LEGACY_DEVICES += ALL0315N
 
+define LegacyDevice/ANONABOX_PRO
+  DEVICE_TITLE := AnonaBox Pro board
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-ledtrig-usbdev
+endef
+LEGACY_DEVICES += ANONABOX_PRO
+
 define LegacyDevice/AP121_8M
   DEVICE_TITLE := Atheros AP121 reference board (8MB flash)
   DEVICE_PACKAGES := kmod-usb-core kmod-usb2
diff --git a/target/linux/ar71xx/image/legacy.mk b/target/linux/ar71xx/image/legacy.mk
index 701116b..62d261e 100644
--- a/target/linux/ar71xx/image/legacy.mk
+++ b/target/linux/ar71xx/image/legacy.mk
@@ -227,6 +227,7 @@ alfa_mtdlayout_8M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs)
 alfa_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,15936k(firmware),64k(nvram),64k(art)ro
 all0258n_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),6272k(firmware),1536k(failsafe),64k(art)ro
 all0315n_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env),13568k(firmware),2048k(failsafe),256k(art)ro
+anonabox_pro_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14528k(rootfs),1472k(kernel),64k(art)ro,16000k at 0x50000(firmware)
 ap96_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs),1728k(kernel),64k(art)ro,7872k at 0x40000(firmware)
 ap121_mtdlayout_8M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs),1600k(kernel),64k(nvram),64k(art)ro,7744k at 0x50000(firmware)
 ap121_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,10944k(rootfs),4992k(kernel),64k(nvram),64k(art)ro,15936k at 0x50000(firmware)
@@ -882,6 +883,7 @@ $(eval $(call SingleProfile,AthLzma,64k,ALFAAP120C,alfa-ap120c,ALFA-AP120C,ttyS0
 $(eval $(call SingleProfile,AthLzma,64k,ALFAAP96,alfa-ap96,ALFA-AP96,ttyS0,115200,$$(alfa_ap96_mtdlayout),RKuImage))
 $(eval $(call SingleProfile,AthLzma,64k,ALL0258N,all0258n,ALL0258N,ttyS0,115200,$$(all0258n_mtdlayout),KRuImage,65536))
 $(eval $(call SingleProfile,AthLzma,256k,ALL0315N,all0315n,ALL0315N,ttyS0,115200,$$(all0315n_mtdlayout),KRuImage,262144))
+$(eval $(call SingleProfile,AthLzma,64k,ANONABOX_PRO,anonabox-pro-16M,ANONABOX_PRO,ttyS0,115200,$$(anonabox_pro_mtdlayout_16M),RKuImage))
 $(eval $(call SingleProfile,AthLzma,64k,AP121_8M,ap121-8M,AP121,ttyATH0,115200,$$(ap121_mtdlayout_8M),RKuImage))
 $(eval $(call SingleProfile,AthLzma,64k,AP121_16M,ap121-16M,AP121,ttyATH0,115200,$$(ap121_mtdlayout_16M),RKuImage))
 $(eval $(call SingleProfile,AthLzma,64k,AP132,ap132,AP132,ttyS0,115200,$$(ap132_mtdlayout),KRuImage))
-- 
1.9.1




More information about the Lede-dev mailing list