From: Roger Pueyo Centelles <roger.pueyo@guifi.net>
Date: Thu, 21 Dec 2017 14:53:05 +0000 (+0100)
Subject: ar71xx: add support for MikroTik RouterBOARD 921GS-5HPacD r2 (mANTBox 15s)
X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=82626cc145610b8b6485d650693629ef0b943505;p=openwrt%2Fstaging%2Fldir.git

ar71xx: add support for MikroTik RouterBOARD 921GS-5HPacD r2 (mANTBox 15s)

This patch adds support for the MikroTik RouterBOARD 921GS-5HPacD r2
(mANTBox 15s), an outdoor sector antenna with a built-in 802.11ac
wireless router. Additionally, it adds a new profile for devices with
>= 128 MB NAND flash and 802.11ac to the ar71xx/mikrotik subtarget.

See https://mikrotik.com/product/RB921GS-5HPacD-15S for more info.

Specifications:
 - SoC: Qualcomm Atheros QCA9558 (720 MHz)
 - RAM: 128 MB
 - Storage: 128 MB NAND
 - Wireless: external QCA9822 802.11a/ac 2x2:2
 - Ethernet: 1x 1000/100/10 Mbps, integrated, via AR8031 PHY, passive PoE in
 - SFP: 1x host

Working:
 - Board/system detection
 - NAND storage detection
 - Wireless
 - Ethernet
 - 1x user LED
 - Reset button
 - Sysupgrade

Untested:
 - SFP cage (probably not working)

Installation:
 - Boot initramfs image via TFTP and then flash sysupgrade image

Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
---

diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network
index 255585a9e8..fb61792bf4 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -97,6 +97,7 @@ ar71xx_setup_interfaces()
 	rb-911g-5hpnd|\
 	rb-912uag-2hpnd|\
 	rb-912uag-5hpnd|\
+	rb-921gs-5hpacd-r2|\
 	rb-lhg-5nd|\
 	rb-mapl-2nd|\
 	rb-sxt2n|\
diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index 6a0a59f610..ec5f7a3e28 100644
--- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -132,6 +132,7 @@ case "$FIRMWARE" in
 		ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
 		;;
 	rb-911g-5hpacd|\
+	rb-921gs-5hpacd-r2|\
 	rb-962uigs-5hact2hnt)
 		ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
 		;;
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 285fa68357..b5440230a5 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -944,6 +944,9 @@ ar71xx_board_detect() {
 	*"RouterBOARD 912UAG-5HPnD")
 		name="rb-912uag-5hpnd"
 		;;
+	*"RouterBOARD 921GS-5HPacD r2")
+		name="rb-921gs-5hpacd-r2"
+		;;
 	*"RouterBOARD 941-2nD")
 		name="rb-941-2nd"
 		;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index e3c48c9eef..ecf6820a2b 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -512,6 +512,7 @@ platform_check_image() {
 	rb-911g-5hpacd|\
 	rb-912uag-2hpnd|\
 	rb-912uag-5hpnd|\
+	rb-921gs-5hpacd-r2|\
 	rb-951g-2hnd|\
 	rb-951ui-2hnd|\
 	rb-2011l|\
@@ -697,6 +698,7 @@ platform_pre_upgrade() {
 	rb-911g-5hpnd|\
 	rb-912uag-2hpnd|\
 	rb-912uag-5hpnd|\
+	rb-921gs-5hpacd-r2|\
 	rb-951g-2hnd|\
 	rb-951ui-2hnd|\
 	rb-2011il|\
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-rb922.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-rb922.c
index 1159838747..2f54d029f6 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-rb922.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-rb922.c
@@ -276,9 +276,16 @@ static void __init rb922gs_setup(void)
 	ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
 	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
 	ath79_eth0_data.phy_mask = BIT(RB922_PHY_ADDR);
-	ath79_eth0_pll_data.pll_10 = 0x81001313;
-	ath79_eth0_pll_data.pll_100 = 0x81000101;
-	ath79_eth0_pll_data.pll_1000 = 0x8f000000;
+	if (strcmp(info->board_name, "921GS-5HPacD r2") == 0) {
+		ath79_eth0_pll_data.pll_10 = 0xa0001313;
+		ath79_eth0_pll_data.pll_100 = 0xa0000101;
+		ath79_eth0_pll_data.pll_1000 = 0x8f000000;
+	}
+	else {
+		ath79_eth0_pll_data.pll_10 = 0x81001313;
+		ath79_eth0_pll_data.pll_100 = 0x81000101;
+		ath79_eth0_pll_data.pll_1000 = 0x8f000000;
+	}
 
 	ath79_register_eth(0);
 
diff --git a/target/linux/ar71xx/image/mikrotik.mk b/target/linux/ar71xx/image/mikrotik.mk
index 8f190875c5..fd6ca27938 100644
--- a/target/linux/ar71xx/image/mikrotik.mk
+++ b/target/linux/ar71xx/image/mikrotik.mk
@@ -24,6 +24,15 @@ define Device/nand-large
 endef
 TARGET_DEVICES += nand-large
 
+define Device/nand-large-ac
+  $(Device/mikrotik)
+  DEVICE_TITLE := MikroTik RouterBoard (>= 128 MB NAND, 802.11ac)
+  DEVICE_PACKAGES += kmod-ath10k ath10k-firmware-qca988x
+  KERNEL := kernel-bin | kernel2minor -s 2048 -e -c
+  SUPPORTED_DEVICES := rb-921gs-5hpacd-r2
+endef
+TARGET_DEVICES += nand-large-ac
+
 define Device/rb-nor-flash-16M
   DEVICE_TITLE := MikroTik RouterBoard (16 MB SPI NOR)
   DEVICE_PACKAGES := rbcfg rssileds -nand-utils kmod-ledtrig-gpio