ipq40xx: add support for MikroTik hAP ac3
authorRobert Marko <robimarko@gmail.com>
Sat, 9 Oct 2021 18:13:25 +0000 (20:13 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 28 Nov 2021 16:19:52 +0000 (17:19 +0100)
This adds support for the MikroTik RouterBOARD RBD53iG-5HacD2HnD
(hAP ac³), a  indoor dual band, dual-radio 802.11ac
wireless AP with external omnidirectional antennae, USB port, five
10/100/1000 Mbps Ethernet ports and PoE passthrough.

See https://mikrotik.com/product/hap_ac3 for more info.

Specifications:
 - SoC: Qualcomm Atheros IPQ4019
 - RAM: 256 MB
 - Storage: 16 MB NOR + 128 MB NAND
 - Wireless:
   · Built-in IPQ4019 (SoC) 802.11b/g/n 2x2:2, 3 dBi antennae
   · Built-in IPQ4019 (SoC) 802.11a/n/ac 2x2:2, 5.5 dBi antennae
 - Ethernet: Built-in IPQ4019 (SoC, QCA8075) , 5x 1000/100/10 port,
             passive PoE in, PoE passtrough on port 5
- 1x USB Type A port

Installation:
1. Boot the initramfs image via TFTP
2. Run "cat /proc/mtd" and look for "ubi" partition mtd device number, ex. "mtd1"
3. Use ubiformat to remove MikroTik specific UBI volumes
* Detach the UBI partition by running: "ubidetach -d 0"
* Format the partition by running: "ubiformat /dev/mtdN -y"
Replace mtdN with the correct mtd index from step 2.
3. Flash the sysupgrade image using "sysupgrade -n"

Signed-off-by: Robert Marko <robimarko@gmail.com>
Tested-by: Mark Birss <markbirss@gmail.com>
Tested-by: Michael Büchler <michael.buechler@posteo.net>
Tested-by: Alex Tomkins <tomkins@darkzone.net>
package/firmware/ipq-wifi/Makefile
package/firmware/ipq-wifi/board-mikrotik_hap-ac3.qca4019 [new file with mode: 0644]
target/linux/ipq40xx/base-files/etc/board.d/01_leds
target/linux/ipq40xx/base-files/etc/board.d/02_network
target/linux/ipq40xx/base-files/etc/board.d/03_gpio_switches
target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
target/linux/ipq40xx/base-files/lib/upgrade/platform.sh
target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-hap-ac3.dts [new file with mode: 0644]
target/linux/ipq40xx/image/mikrotik.mk
target/linux/ipq40xx/patches-5.10/901-arm-boot-add-dts-files.patch
target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch

index da0949b887bc0487b65ca35f0d55823f826d9da0..6835363cb6df59c4e1510d0961eb54ae1dc797a3 100644 (file)
@@ -44,6 +44,7 @@ ALLWIFIBOARDS:= \
        linksys_mr8300-v0 \
        luma_wrtq-329acn \
        mikrotik_hap-ac2 \
+       mikrotik_hap-ac3 \
        mikrotik_sxtsq-5-ac \
        mobipromo_cm520-79f \
        nec_wg2600hp3 \
@@ -130,6 +131,7 @@ $(eval $(call generate-ipq-wifi-package,linksys_ea8300,Linksys EA8300))
 $(eval $(call generate-ipq-wifi-package,linksys_mr8300-v0,Linksys MR8300))
 $(eval $(call generate-ipq-wifi-package,luma_wrtq-329acn,Luma WRTQ-329ACN))
 $(eval $(call generate-ipq-wifi-package,mikrotik_hap-ac2,Mikrotik hAP ac2))
+$(eval $(call generate-ipq-wifi-package,mikrotik_hap-ac3,Mikrotik hAP ac3))
 $(eval $(call generate-ipq-wifi-package,mikrotik_sxtsq-5-ac,MikroTik SXTsq 5 ac))
 $(eval $(call generate-ipq-wifi-package,mobipromo_cm520-79f,MobiPromo CM520-79F))
 $(eval $(call generate-ipq-wifi-package,nec_wg2600hp3,NEC Platforms WG2600HP3))
diff --git a/package/firmware/ipq-wifi/board-mikrotik_hap-ac3.qca4019 b/package/firmware/ipq-wifi/board-mikrotik_hap-ac3.qca4019
new file mode 100644 (file)
index 0000000..a97a202
Binary files /dev/null and b/package/firmware/ipq-wifi/board-mikrotik_hap-ac3.qca4019 differ
index b2545f41e179e3e0cd80d8a2eb32b4bee430fa38..8942ad20005bd24c168bcf76460dbcd0d7a25fee 100644 (file)
@@ -45,6 +45,14 @@ engenius,ens620ext)
        ucidef_set_led_netdev "lan1" "LAN1" "green:lan1" "eth0"
        ucidef_set_led_netdev "lan2" "LAN2" "green:lan2" "eth1"
        ;;
+mikrotik,hap-ac3)
+       ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
+       ucidef_set_led_switch "lan1" "LAN1" "green:lan1" "switch0" "0x10"
+       ucidef_set_led_switch "lan2" "LAN2" "green:lan2" "switch0" "0x08"
+       ucidef_set_led_switch "lan3" "LAN3" "green:lan3" "switch0" "0x04"
+       ucidef_set_led_switch "lan4" "LAN4" "green:lan4" "switch0" "0x02"
+       ucidef_set_led_gpio "poe" "POE" "red:poe" "452" "0"
+       ;;
 mikrotik,sxtsq-5-ac)
        ucidef_set_rssimon "wlan0" "200000" "1"
        ucidef_set_led_rssi "rssilow" "rssilow" "green:rssilow" "wlan0" "1" "100"
index 5d123109a2f88c9049a239e364a767c4f475aac8..7ccdf97a60ff28b64efe2ddf6cd4814dfaec4528 100644 (file)
@@ -50,6 +50,7 @@ ipq40xx_setup_interfaces()
                ;;
        asus,rt-ac58u|\
        mikrotik,hap-ac2|\
+       mikrotik,hap-ac3|\
        p2w,r619ac-64m|\
        p2w,r619ac-128m|\
        zyxel,nbg6617)
@@ -182,7 +183,8 @@ ipq40xx_setup_macs()
                wan_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
                lan_mac=$(macaddr_add "$wan_mac" 1)
                ;;
-       mikrotik,hap-ac2)
+       mikrotik,hap-ac2|\
+       mikrotik,hap-ac3)
                wan_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base)
                lan_mac=$(macaddr_add $wan_mac 1)
                label_mac="$wan_mac"
index 9029eb3a828610daf32db3382b6052cd3b6e0f59..4036e5356f75ca75b55aa38ef914c905ae4afea9 100644 (file)
@@ -18,6 +18,9 @@ cilab,meshpoint-one)
 compex,wpj428)
        ucidef_add_gpio_switch "sim_card_select" "SIM card select" "3" "0"
        ;;
+mikrotik,hap-ac3)
+       ucidef_add_gpio_switch "poe_passtrough" "PoE Passthrough" "452" "0"
+       ;;
 esac
 
 board_config_flush
index f90c5580153324b51ad1a052b87b3a1007462790..1e1b44592428082fe08ff49812007fdd2c2e8216 100644 (file)
@@ -149,7 +149,8 @@ case "$FIRMWARE" in
                caldata_valid "202f" || caldata_extract "ART" 0x1000 0x2f20
                ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) 2)
                ;;
-       mikrotik,hap-ac2)
+       mikrotik,hap-ac2 |\
+       mikrotik,hap-ac3)
                wlan_data="/sys/firmware/mikrotik/hard_config/wlan_data"
                ( [ -f "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data" 0x0 0x2f20 ) || \
                ( [ -d "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data/data_0" 0x0 0x2f20 )
@@ -266,7 +267,8 @@ case "$FIRMWARE" in
                caldata_valid "202f" || caldata_extract "ART" 0x5000 0x2f20
                ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) 3)
                ;;
-       mikrotik,hap-ac2|\
+       mikrotik,hap-ac2 |\
+       mikrotik,hap-ac3 |\
        mikrotik,sxtsq-5-ac)
                wlan_data="/sys/firmware/mikrotik/hard_config/wlan_data"
                ( [ -f "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data" 0x8000 0x2f20 ) || \
index 605b1e78819e1c0aaa21b6d3996871ca9d758f80..02833ebc3d54a2bbaf6f930985ef317a76a6e55a 100644 (file)
@@ -55,6 +55,24 @@ zyxel_do_upgrade() {
        fi
 }
 
+platform_do_upgrade_mikrotik_nand() {
+       local fw_mtd=$(find_mtd_part kernel)
+       fw_mtd="${fw_mtd/block/}"
+       [ -n "$fw_mtd" ] || return
+
+       local board_dir=$(tar tf "$1" | grep -m 1 '^sysupgrade-.*/$')
+       board_dir=${board_dir%/}
+       [ -n "$board_dir" ] || return
+
+       local kernel_len=$(tar xf "$1" ${board_dir}/kernel -O | wc -c)
+       [ -n "$kernel_len" ] || return
+
+       tar xf "$1" ${board_dir}/kernel -O | ubiformat "$fw_mtd" -y -S $kernel_len -f -
+
+       CI_KERNPART="none"
+       nand_do_upgrade "$1"
+}
+
 platform_do_upgrade() {
        case "$(board_name)" in
        8dev,jalapeno |\
@@ -119,6 +137,9 @@ platform_do_upgrade() {
                [ "$(rootfs_type)" = "tmpfs" ] && mtd erase firmware
                default_do_upgrade "$1"
                ;;
+       mikrotik,hap-ac3)
+               platform_do_upgrade_mikrotik_nand "$1"
+               ;;
        netgear,rbr50 |\
        netgear,rbs50 |\
        netgear,srr60 |\
diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-hap-ac3.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-hap-ac3.dts
new file mode 100644 (file)
index 0000000..9aa58ff
--- /dev/null
@@ -0,0 +1,328 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/* Copyright (c) 2021, Robert Marko <robimarko@gmail.com> */
+
+#include "qcom-ipq4019.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/soc/qcom,tcsr.h>
+
+/ {
+       model = "MikroTik hAP ac3";
+       compatible = "mikrotik,hap-ac3";
+
+       memory {
+               device_type = "memory";
+               reg = <0x80000000 0x10000000>;
+       };
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+       };
+
+       aliases {
+               led-boot = &led_status_blue;
+               led-failsafe = &led_status_red;
+               led-running = &led_status_blue;
+               led-upgrade = &led_status_red;
+       };
+
+       soc {
+               rng@22000 {
+                       status = "okay";
+               };
+
+               counter@4a1000 {
+                       compatible = "qcom,qca-gcnt";
+                       reg = <0x4a1000 0x4>;
+               };
+
+               tcsr@1949000 {
+                       compatible = "qcom,tcsr";
+                       reg = <0x1949000 0x100>;
+                       qcom,wifi_glb_cfg = <TCSR_WIFI_GLB_CFG>;
+               };
+
+               tcsr@194b000 {
+                       /* select hostmode */
+                       compatible = "qcom,tcsr";
+                       reg = <0x194b000 0x100>;
+                       qcom,usb-hsphy-mode-select = <TCSR_USB_HSPHY_HOST_MODE>;
+                       status = "okay";
+               };
+
+               ess_tcsr@1953000 {
+                       compatible = "qcom,tcsr";
+                       reg = <0x1953000 0x1000>;
+                       qcom,ess-interface-select = <TCSR_ESS_PSGMII>;
+               };
+
+               tcsr@1957000 {
+                       compatible = "qcom,tcsr";
+                       reg = <0x1957000 0x100>;
+                       qcom,wifi_noc_memtype_m0_m2 = <TCSR_WIFI_NOC_MEMTYPE_M0_M2>;
+               };
+
+               usb2: usb2@60f8800 {
+                       status = "okay";
+               };
+
+               crypto@8e3a000 {
+                       status = "okay";
+               };
+
+               watchdog@b017000 {
+                       status = "okay";
+               };
+
+               ess-switch@c000000 {
+                       status = "okay";
+               };
+
+               edma@c080000 {
+                       status = "okay";
+               };
+       };
+
+       keys {
+               compatible = "gpio-keys";
+
+               reset {
+                       label = "reset";
+                       gpios = <&tlmm 5 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+               };
+
+               mode {
+                       label = "mode";
+                       gpios = <&tlmm 4 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RFKILL>;
+               };
+
+               led {
+                       label = "led";
+                       gpios = <&tlmm 42 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_WPS_BUTTON>;
+               };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_status_blue: status-blue {
+                       label = "blue:status";
+                       gpios = <&tlmm 0 GPIO_ACTIVE_HIGH>;
+               };
+
+               led_status_red: status-red {
+                       label = "red:status";
+                       gpios = <&tlmm 1 GPIO_ACTIVE_HIGH>;
+                       panic-indicator;
+               };
+
+               led_status_green: status-green {
+                       label = "green:status";
+                       gpios = <&tlmm 3 GPIO_ACTIVE_HIGH>;
+               };
+
+               wlan {
+                       label = "green:wlan";
+                       gpios = <&tlmm 23 GPIO_ACTIVE_HIGH>;
+               };
+
+               ethernet {
+                       label = "green:ethernet";
+                       gpios = <&tlmm 22 GPIO_ACTIVE_HIGH>;
+               };
+
+               wan {
+                       label = "green:wan";
+                       gpios = <&tlmm 28 GPIO_ACTIVE_HIGH>;
+               };
+
+               lan1 {
+                       label = "green:lan1";
+                       gpios = <&tlmm 29 GPIO_ACTIVE_HIGH>;
+               };
+
+               lan2 {
+                       label = "green:lan2";
+                       gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>;
+               };
+
+               lan3 {
+                       label = "green:lan3";
+                       gpios = <&tlmm 31 GPIO_ACTIVE_HIGH>;
+               };
+
+               lan4 {
+                       label = "green:lan4";
+                       gpios = <&tlmm 32 GPIO_ACTIVE_HIGH>;
+               };
+
+               poe {
+                       label = "red:poe";
+                       gpios = <&tlmm 36 GPIO_ACTIVE_HIGH>;
+               };
+       };
+};
+
+&tlmm {
+       serial_pins: serial_pinmux {
+               mux {
+                       pins = "gpio16", "gpio17";
+                       function = "blsp_uart0";
+                       bias-disable;
+               };
+       };
+
+       spi_0_pins: spi_0_pinmux {
+               pin {
+                       function = "blsp_spi0";
+                       pins = "gpio13", "gpio14", "gpio15";
+                       drive-strength = <12>;
+                       bias-disable;
+               };
+
+               pin_cs {
+                       function = "gpio";
+                       pins = "gpio12";
+                       drive-strength = <2>;
+                       bias-disable;
+                       output-high;
+               };
+       };
+
+       nand_pins: nand_pins {
+               pullups {
+                       pins = "gpio53", "gpio58", "gpio59";
+                       function = "qpic";
+                       bias-pull-up;
+               };
+
+               pulldowns {
+                       pins = "gpio55", "gpio56", "gpio57", "gpio60",
+                                  "gpio62", "gpio63", "gpio64", "gpio65",
+                                  "gpio66", "gpio67", "gpio68", "gpio69";
+                       function = "qpic";
+                       bias-pull-down;
+               };
+       };
+
+       enable-usb-power {
+               gpio-hog;
+               gpios = <44 GPIO_ACTIVE_HIGH>;
+               output-high;
+               line-name = "enable USB power";
+       };
+};
+
+&blsp_dma {
+       status = "okay";
+};
+
+&blsp1_spi1 {
+       status = "okay";
+
+       pinctrl-0 = <&spi_0_pins>;
+       pinctrl-names = "default";
+       cs-gpios = <&tlmm 12 GPIO_ACTIVE_HIGH>;
+
+       flash@0 {
+               reg = <0>;
+               compatible = "jedec,spi-nor";
+               spi-max-frequency = <40000000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "Qualcomm";
+                               reg = <0x0 0x80000>;
+                               read-only;
+                       };
+
+                       partition@80000 {
+                               compatible = "mikrotik,routerboot-partitions";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+                               label = "RouterBoot";
+                               reg = <0x80000 0x80000>;
+                               read-only;
+
+                               hard_config {
+                                       read-only;
+                                       size = <0x2000>;
+                               };
+
+                               dtb_config {
+                                       read-only;
+                               };
+
+                               soft_config {
+                               };
+                       };
+               };
+       };
+};
+
+&qpic_bam {
+       status = "okay";
+};
+
+&nand {
+       status = "okay";
+
+       pinctrl-0 = <&nand_pins>;
+       pinctrl-names = "default";
+
+       nand@0 {
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "kernel";
+                               reg = <0x0 0xa00000>;
+                       };
+
+                       partition@a00000 {
+                               label = "ubi";
+                               reg = <0xa00000 0x7600000>;
+                       };
+               };
+       };
+};
+
+&blsp1_uart1 {
+       status = "okay";
+
+       pinctrl-0 = <&serial_pins>;
+       pinctrl-names = "default";
+};
+
+&cryptobam {
+       status = "okay";
+};
+
+&usb2_hs_phy {
+       status = "okay";
+};
+
+&mdio {
+       status = "okay";
+};
+
+&wifi0 {
+       status = "okay";
+
+       qcom,ath10k-calibration-variant = "MikroTik-hAP-ac3";
+};
+
+&wifi1 {
+       status = "okay";
+
+       qcom,ath10k-calibration-variant = "MikroTik-hAP-ac3";
+};
index 31497608bed9c7c4aaf087b8d48e09a05613fa33..bfff58597f9dc3c0c2aff270a62636caa9a583b5 100644 (file)
@@ -10,6 +10,16 @@ define Device/mikrotik_nor
                check-size | append-metadata
 endef
 
+define Device/mikrotik_nand
+       DEVICE_VENDOR := MikroTik
+       KERNEL_NAME := vmlinux
+       KERNEL_INITRAMFS := kernel-bin | append-dtb-elf
+       KERNEL := kernel-bin | append-dtb-elf | package-kernel-ubifs | \
+               ubinize-kernel
+       IMAGES := nand-sysupgrade.bin
+       IMAGE/nand-sysupgrade.bin := sysupgrade-tar | append-metadata
+endef
+
 define Device/mikrotik_hap-ac2
        $(call Device/mikrotik_nor)
        DEVICE_MODEL := hAP ac2
@@ -19,6 +29,17 @@ define Device/mikrotik_hap-ac2
 endef
 TARGET_DEVICES += mikrotik_hap-ac2
 
+define Device/mikrotik_hap-ac3
+       $(call Device/mikrotik_nand)
+       DEVICE_MODEL := hAP ac3
+       SOC := qcom-ipq4019
+       BLOCKSIZE := 128k
+       PAGESIZE := 2048
+       KERNEL_UBIFS_OPTS = -m $$(PAGESIZE) -e 124KiB -c $$(PAGESIZE) -x none
+       DEVICE_PACKAGES := kmod-ledtrig-gpio ipq-wifi-mikrotik_hap-ac3
+endef
+TARGET_DEVICES += mikrotik_hap-ac3
+
 define Device/mikrotik_sxtsq-5-ac
        $(call Device/mikrotik_nor)
        DEVICE_MODEL := SXTsq 5 ac (RBSXTsqG-5acD)
index 436f5a74f55d718f97a6b4ad8c5612ce84416a25..69ba9e4a431f3851836ce078c3854d4211971a29 100644 (file)
@@ -10,7 +10,7 @@ Signed-off-by: John Crispin <john@phrozen.org>
 
 --- a/arch/arm/boot/dts/Makefile
 +++ b/arch/arm/boot/dts/Makefile
-@@ -902,11 +902,67 @@ dtb-$(CONFIG_ARCH_QCOM) += \
+@@ -902,11 +902,68 @@ dtb-$(CONFIG_ARCH_QCOM) += \
        qcom-apq8074-dragonboard.dtb \
        qcom-apq8084-ifc6540.dtb \
        qcom-apq8084-mtp.dtb \
@@ -55,6 +55,7 @@ Signed-off-by: John Crispin <john@phrozen.org>
 +      qcom-ipq4019-fritzrepeater-1200.dtb \
 +      qcom-ipq4019-fritzrepeater-3000.dtb \
 +      qcom-ipq4019-habanero-dvk.dtb \
++      qcom-ipq4019-hap-ac3.dtb \
 +      qcom-ipq4019-map-ac2200.dtb \
 +      qcom-ipq4019-mr8300.dtb \
 +      qcom-ipq4019-pa2200.dtb \
index bb63c1c4fb490a388d48258336c2920aca95ae30..0846c6668c91fc799ec8545489b72d40efea8ea3 100644 (file)
@@ -10,7 +10,7 @@ Signed-off-by: John Crispin <john@phrozen.org>
 
 --- a/arch/arm/boot/dts/Makefile
 +++ b/arch/arm/boot/dts/Makefile
-@@ -837,11 +837,65 @@ dtb-$(CONFIG_ARCH_QCOM) += \
+@@ -837,11 +837,66 @@ dtb-$(CONFIG_ARCH_QCOM) += \
        qcom-apq8074-dragonboard.dtb \
        qcom-apq8084-ifc6540.dtb \
        qcom-apq8084-mtp.dtb \
@@ -52,6 +52,7 @@ Signed-off-by: John Crispin <john@phrozen.org>
 +      qcom-ipq4019-fritzbox-7530.dtb \
 +      qcom-ipq4019-fritzrepeater-1200.dtb \
 +      qcom-ipq4019-fritzrepeater-3000.dtb \
++      qcom-ipq4019-hap-ac3.dtb \
 +      qcom-ipq4019-map-ac2200.dtb \
 +      qcom-ipq4019-mr8300.dtb \
 +      qcom-ipq4019-e2600ac-c1.dtb \