ipq807x: add support for TP-Link EAP660 HD v1
authorGeorge Witt <george.witt@nltsproject.org>
Mon, 5 Aug 2024 21:29:37 +0000 (16:29 -0500)
committerRobert Marko <robimarko@gmail.com>
Sun, 8 Sep 2024 10:01:19 +0000 (12:01 +0200)
Specifications:
* SoC: Qualcomm IPQ8072A (64-bit Quad-core Arm Cortex-A53 @ 2200MHz)
* Memory: 2x ESMT M15T4G16256A-DEBG2G (1 GiB DDR3-1866 13-13-13)
* Serial Port: 3v3 TTL 115200n8
* Wi-Fi: QCN5054 (4x4 5 GHz 802.11ax)
* Wi-Fi: QCN5024 (4x4 2.4 GHz 802.11b/g/n/ax)
* Ethernet: QCA8081 (10/100/1000/2.5GBASE-T)
* Flash: Winbond W29N01HZSINF (128 MiB)
* LEDs: 1x Blue Status (GPIO 42 Active High)
* Buttons: 1x Reset (GPIO 50 Active Low)

Installation Instructions (Serial+TFTP):
1. Solder 4 pin header to JP1 and bridge pads of R58 and R62.
2. Connect 3V3 TTL port to TX, RX, and GND, which are positions 1, 2,
   and 3 respectively. Be sure to crossover TX and RX.
3. Copy RAM firmware image
   openwrt-qualcommax-ipq807x-tplink_eap660hd-v1-initramfs-uImage.itb
   to TFTP server root, available at 192.168.10.1.
4. Connect PoE ethernet cable to the RJ45 port and hold Ctrl+B in the
   serial console (115200 baud) until autoboot is halted.
5. Run the following commands in the U-boot prompt:
   # tftpboot 0x44000000 openwrt-qualcommax-ipq807x-tplink_eap660hd-v1-initramfs-uImage.itb
   # bootm
   You may need to type Ctrl+C and Enter before running these commands
   to clear invisible characters from the buffer.
6. Run the following command in a terminal to copy the sysupgrade image
   to be installed (check IP address):
   $ scp openwrt-qualcommax-ipq807x-tplink_eap660hd-v1-squashfs-sysupgrade.bin root@192.168.1.1:/tmp/
7. Activate the OpenWrt serial console and run the following commands:
   # cd /tmp
   # sysupgrade -n openwrt-qualcommax-ipq807x-tplink_eap660hd-v1-squashfs-sysupgrade.bin
8. The AP will reboot and OpenWrt will be successfully installed.

Signed-off-by: George Witt <george.witt@nltsproject.org>
Link: https://github.com/openwrt/openwrt/pull/15832
Signed-off-by: Robert Marko <robimarko@gmail.com>
package/boot/uboot-envtools/files/qualcommax_ipq807x
package/firmware/ipq-wifi/Makefile
target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8072-eap660hd-v1.dts [new file with mode: 0644]
target/linux/qualcommax/image/ipq807x.mk
target/linux/qualcommax/ipq807x/base-files/etc/board.d/02_network
target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/firmware/11-ath11k-caldata
target/linux/qualcommax/ipq807x/base-files/lib/preinit/09_mount_factory_data [new file with mode: 0644]
target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh

index 852e05f29a191bf0ab682907561333b83505c7bc..f5fb07a4db0bf03a60d636775c1fb99a95209849 100644 (file)
@@ -38,7 +38,8 @@ linksys,mx8500)
                ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x40000" "0x20000" "2"
        ;;
 netgear,sxr80|\
-netgear,sxs80)
+netgear,sxs80|\
+tplink,eap660hd-v1)
        idx="$(find_mtd_index 0:appsblenv)"
        [ -n "$idx" ] && \
                ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x40000" "0x20000"
index fb5b18cb3dd86c317658c237a80d671842d64a96..1c95983964f4a3d4579b282d084212a55ebf1598 100644 (file)
@@ -52,6 +52,7 @@ ALLWIFIBOARDS:= \
        qnap_301w \
        redmi_ax6 \
        spectrum_sax1v1k \
+       tplink_eap660hd-v1 \
        wallys_dr40x9 \
        xiaomi_ax3600 \
        xiaomi_ax9000 \
@@ -177,6 +178,7 @@ $(eval $(call generate-ipq-wifi-package,qnap_301w,QNAP 301w))
 $(eval $(call generate-ipq-wifi-package,prpl_haze,prpl Haze))
 $(eval $(call generate-ipq-wifi-package,redmi_ax6,Redmi AX6))
 $(eval $(call generate-ipq-wifi-package,spectrum_sax1v1k,Spectrum SAX1V1K))
+$(eval $(call generate-ipq-wifi-package,tplink_eap660hd-v1,TP-Link EAP660 HD v1))
 $(eval $(call generate-ipq-wifi-package,wallys_dr40x9,Wallys DR40X9))
 $(eval $(call generate-ipq-wifi-package,xiaomi_ax3600,Xiaomi AX3600))
 $(eval $(call generate-ipq-wifi-package,xiaomi_ax9000,Xiaomi AX9000))
diff --git a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8072-eap660hd-v1.dts b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8072-eap660hd-v1.dts
new file mode 100644 (file)
index 0000000..500847c
--- /dev/null
@@ -0,0 +1,131 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause
+
+/dts-v1/;
+
+#include "ipq8074.dtsi"
+#include "ipq8074-hk-cpu.dtsi"
+#include "ipq8074-ess.dtsi"
+#include <dt-bindings/leds/common.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+       model = "TP-Link EAP660 HD v1";
+       compatible = "tplink,eap660hd-v1", "qcom,ipq8074";
+
+       aliases {
+               serial0 = &blsp1_uart5;
+               led-boot = &led_status_blue;
+               led-failsafe = &led_status_blue;
+               led-running = &led_status_blue;
+               led-upgrade = &led_status_blue;
+       };
+
+       chosen {
+               stdout-path = "serial0,115200n8";
+               bootargs-append = " root=/dev/ubiblock0_1";
+       };
+
+       keys {
+               compatible = "gpio-keys";
+
+               reset {
+                       label = "reset";
+                       gpios = <&tlmm 50 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+               };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_status_blue: status-blue {
+                       function = LED_FUNCTION_STATUS;
+                       gpios = <&tlmm 42 GPIO_ACTIVE_HIGH>;
+                       color = <LED_COLOR_ID_BLUE>;
+               };
+       };
+};
+
+&blsp1_uart5 {
+       status = "okay";
+};
+
+&tlmm {
+       mdio_pins: mdio-pins {
+               mdc {
+                       pins = "gpio68";
+                       function = "mdc";
+                       drive-strength = <8>;
+                       bias-pull-up;
+               };
+
+               mdio {
+                       pins = "gpio69";
+                       function = "mdio";
+                       drive-strength = <8>;
+                       bias-pull-up;
+               };
+       };
+};
+
+&mdio {
+       status = "okay";
+       pinctrl-0 = <&mdio_pins>;
+       pinctrl-names = "default";
+       reset-gpios = <&tlmm 25 GPIO_ACTIVE_LOW>;
+       
+       qca8081_28: ethernet-phy@28 {
+               compatible = "ethernet-phy-ieee802.3-c22";
+               reg = <28>;
+       };
+};
+
+&dp5 {
+       status = "okay";
+       phy-mode = "sgmii";
+       phy-handle = <&qca8081_28>;
+       label = "lan";
+};
+
+&switch {
+       status = "okay";
+       switch_lan_bmp = <ESS_PORT5>;
+       switch_mac_mode1 = <MAC_MODE_SGMII_PLUS>;
+
+       qcom,port_phyinfo {
+               port@5 {
+                       phy_address = <28>;
+                       port_id = <5>;
+                       port_mac_sel = "QGMAC_PORT";
+               };
+       };
+};
+
+&edma {
+       status = "okay";
+};
+
+&qpic_bam {
+       status = "okay";
+};
+
+&qpic_nand {
+       status = "okay";
+
+       nand@0 {
+               reg = <0>;
+               nand-ecc-strength = <4>;
+               nand-ecc-step-size = <512>;
+               nand-bus-width = <8>;
+
+               partitions {
+                       compatible = "qcom,smem-part";
+               };
+       };
+};
+
+&wifi {
+       status = "okay";
+       qcom,ath11k-calibration-variant = "TP-Link-EAP660-HD-v1";
+};
index 8caa6a322c8f30835783463effcb5f0058a8cf41..b62734334d2600f6dd68903cc9569a0d11ae48da 100644 (file)
@@ -344,6 +344,20 @@ define Device/spectrum_sax1v1k
 endef
 TARGET_DEVICES += spectrum_sax1v1k
 
+define Device/tplink_eap660hd-v1
+       $(call Device/FitImage)
+       $(call Device/UbiFit)
+       DEVICE_VENDOR := TP-Link
+       DEVICE_MODEL := EAP660 HD
+       DEVICE_VARIANT := v1
+       BLOCKSIZE := 128k
+       PAGESIZE := 2048
+       SOC := ipq8072
+       DEVICE_PACKAGES := ipq-wifi-tplink_eap660hd-v1
+       TPLINK_SUPPORT_STRING := SupportList:\r\nEAP660 HD(TP-Link|UN|AX3600-D):1.0\r\n
+endef
+TARGET_DEVICES += tplink_eap660hd-v1
+
 define Device/xiaomi_ax3600
        $(call Device/FitImage)
        $(call Device/UbiFit)
index f87dbdd2bea0e14067f699f767a3fab6b89c4e68..437581d001127a6a7f0a2eb6d64cdd06db69b533 100644 (file)
@@ -60,6 +60,9 @@ ipq807x_setup_interfaces()
        qnap,301w)
                ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 10g-2" "10g-1"
                ;;
+       tplink,eap660hd-v1)
+               ucidef_set_interface_lan "lan" "dhcp"
+               ;;
        zyxel,nbg7815)
                ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 10g" "wan"
                ;;
@@ -89,6 +92,10 @@ ipq807x_setup_macs()
                        lan_mac=$(macaddr_add $label_mac 1)
                        wan_mac=$label_mac
                ;;
+               tplink,eap660hd-v1)
+                       label_mac=$(get_mac_binary /tmp/factory_data/default-mac 0)
+                       lan_mac=$label_mac
+               ;;
        esac
 
        [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
index e413801ef94c53d60eba705025123ebe6a4d3f60..2e741f044841c6759ad5e2129b367942d4eedcf0 100644 (file)
@@ -80,6 +80,13 @@ case "$FIRMWARE" in
        spectrum,sax1v1k)
                caldata_extract_mmc "0:ART" 0x1000 0x20000
                ;;
+       tplink,eap660hd-v1)
+               caldata_from_file "/tmp/factory_data/radio" 0 0x20000
+               label_mac=$(get_mac_binary /tmp/factory_data/default-mac 0)
+               ath11k_patch_mac $label_mac 1
+               ath11k_patch_mac $(macaddr_add $label_mac 1) 0
+               ath11k_set_macflag
+               ;;
        zbtlink,zbt-z800ax)
                caldata_extract "0:art" 0x1000 0x20000
                label_mac=$(get_mac_label)
diff --git a/target/linux/qualcommax/ipq807x/base-files/lib/preinit/09_mount_factory_data b/target/linux/qualcommax/ipq807x/base-files/lib/preinit/09_mount_factory_data
new file mode 100644 (file)
index 0000000..59fde52
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+preinit_mount_factory_data() {
+       local mtd_path
+
+       . /lib/functions.sh
+       . /lib/functions/system.sh
+
+       case $(board_name) in
+       tplink,eap660hd-v1)
+               mtd_path=$(find_mtd_chardev "factory_data")
+               ubiattach --dev-path="$mtd_path" --devn=1
+               mkdir /tmp/factory_data
+               mount -o ro,noatime -t ubifs ubi1:ubi_factory_data /tmp/factory_data
+               ;;
+       esac
+}
+
+boot_hook_add preinit_main preinit_mount_factory_data
index f78a4b04f1d08808c08b9697908757b2f054e02e..92ef5fef2cec77ac72e61c21b1a0d3495f5b5294 100644 (file)
@@ -35,6 +35,79 @@ asus_initial_setup() {
        ubirmvol /dev/ubi0 -N jffs2
 }
 
+remove_oem_ubi_volume() {
+       local oem_volume_name="$1"
+       local oem_ubivol
+       local mtdnum
+       local ubidev
+
+       mtdnum=$(find_mtd_index "$CI_UBIPART")
+       if [ ! "$mtdnum" ]; then
+               return
+       fi
+
+       ubidev=$(nand_find_ubi "$CI_UBIPART")
+       if [ ! "$ubidev" ]; then
+               ubiattach --mtdn="$mtdnum"
+               ubidev=$(nand_find_ubi "$CI_UBIPART")
+       fi
+
+       if [ "$ubidev" ]; then
+               oem_ubivol=$(nand_find_volume "$ubidev" "$oem_volume_name")
+               [ "$oem_ubivol" ] && ubirmvol "/dev/$ubidev" --name="$oem_volume_name"
+       fi
+}
+
+tplink_get_boot_part() {
+       local cur_boot_part
+       local args
+
+       # Try to find rootfs from kernel arguments
+       read -r args < /proc/cmdline
+       for arg in $args; do
+               local ubi_mtd_arg=${arg#ubi.mtd=}
+               case "$ubi_mtd_arg" in
+               rootfs|rootfs_1)
+                       echo "$ubi_mtd_arg"
+                       return
+               ;;
+               esac
+       done
+
+       # Fallback to u-boot env (e.g. when running initramfs)
+       cur_boot_part="$(/usr/sbin/fw_printenv -n tp_boot_idx)"
+       case $cur_boot_part in
+       1)
+               echo rootfs_1
+               ;;
+       0|*)
+               echo rootfs
+               ;;
+       esac
+}
+
+tplink_do_upgrade() {
+       local new_boot_part
+
+       case $(tplink_get_boot_part) in
+       rootfs)
+               CI_UBIPART="rootfs_1"
+               new_boot_part=1
+       ;;
+       rootfs_1)
+               CI_UBIPART="rootfs"
+               new_boot_part=0
+       ;;
+       esac
+
+       fw_setenv -s - <<-EOF
+               tp_boot_idx $new_boot_part
+       EOF
+
+       remove_oem_ubi_volume ubi_rootfs
+       nand_do_upgrade "$1"
+}
+
 platform_check_image() {
        return 0;
 }
@@ -117,6 +190,9 @@ platform_do_upgrade() {
                rootfsname="rootfs"
                mmc_do_upgrade "$1"
                ;;
+       tplink,eap660hd-v1)
+               tplink_do_upgrade "$1"
+               ;;
        redmi,ax6|\
        xiaomi,ax3600|\
        xiaomi,ax9000)