ipq807x: add support for Linksys MX4200 V1 and V2
authorMohammad Sayful Islam <sayf.mohammad01@gmail.com>
Wed, 3 Jan 2024 07:54:16 +0000 (07:54 +0000)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 6 Jan 2024 15:13:23 +0000 (16:13 +0100)
Linksys MX4200 is a 802.11ax Tri-band router/AP.
Specifications:
* CPU: Qualcomm IPQ8174 Quad core Cortex-A53 1.4GHz
* RAM: 512MB of DDR3
* Storage: 512Mb NAND
* Ethernet: 4x1G RJ45 ports (QCA8075)
* WLAN:
* 2.4GHz: Qualcomm QCN5024 2x2 802.11b/g/n/ax 574 Mbps PHY rate
* 5GHz: Qualcomm QCN5054 2x2@80MHz or 2x2@160MHz 802.11a/b/g/n/ac/ax 2402 PHY rate
* 5GHz: Qualcomm QCN5054 4x4@80MHz or 2x2@160MHz 802.11a/b/g/n/ac/ax 2402 PHY rate
* LED-s:
* RGB system led

* Buttons: 1x Soft reset 1x WPS
* Power: 12V DC Jack

Installation instructions:
Open Linksys Web UI - http://192.168.1.1/ca or http://10.65.1.1/ca depending on your setup.
Login with your admin password. The default password can be found on a sticker under the device.
To enter into the support mode, click on the “CA” link and the bottom of the page.
Open the “Connectivity” menu and upload the squash-factory image with the “Choose file” button.
Click start. Ignore all the prompts and warnings by click “yes” in all the popups.
The Wifi radios are turned off by default. To configure the router, you will need to connect your computer to the LAN port of the device.
Then you would need to write openwrt to the other partition for it to work
- First Check booted partition
fw_printenv -n boot_part

- Then install Openwrt to the other partition if booted in slot 1:
mtd -r -e alt_kernel -n write openwrt-qualcommax-ipq807x-linksys_mx4200v(X)-squashfs-factory.bin alt_kernel

- If in slot 2:
mtd -r -e kernel -n write openwrt-qualcommax-ipq807x-linksys_mx4200v(X)-squashfs-factory.bin kernel

Replace (X) with your model version either 1 or 2

Signed-off-by: Mohammad Sayful Islam <sayf.mohammad01@gmail.com>
Reviewed-by: Robert Marko <robimarko@gmail.com>
package/boot/uboot-envtools/files/qualcommax_ipq807x
package/firmware/ipq-wifi/Makefile
package/system/mtd/src/Makefile
target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8174-mx4200.dtsi [new file with mode: 0644]
target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8174-mx4200v1.dts [new file with mode: 0644]
target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8174-mx4200v2.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/etc/init.d/bootcount
target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh

index 761d5dfcc9fe51a9e9b5b34c56eebc8174a589c8..bcedfd9adc91ce88ef1e787dd051db7e5e177bfe 100644 (file)
@@ -29,6 +29,12 @@ edimax,cax1800)
        [ -n "$idx" ] && \
                ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x20000"
        ;;
+linksys,mx4200v1|\
+linksys,mx4200v2)
+       idx="$(find_mtd_index u_env)"
+       [ -n "$idx" ] && \
+               ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x40000" "0x20000" "2"
+       ;;
 redmi,ax6|\
 xiaomi,ax3600|\
 xiaomi,ax9000)
index ef1a456403a71bd7eb23108ef7c57b5182d3c641..189b8e9ec94a00d563b0b99750d8c47e6d90ee15 100644 (file)
@@ -34,6 +34,7 @@ ALLWIFIBOARDS:= \
        dynalink_dl-wrx36 \
        edgecore_eap102 \
        edimax_cax1800 \
+        linksys_mx4200 \
        netgear_rax120v2 \
        netgear_wax218 \
        netgear_wax620 \
@@ -83,7 +84,7 @@ define ipq-wifi-install-one
     $(call ipq-wifi-install-one-to,$(1),$(2),QCA9984/hw1.0),\
   $(if $(filter $(suffix $(1)),.QCA99X0 .qca99x0),\
     $(call ipq-wifi-install-one-to,$(1),$(2),QCA99X0/hw2.0),\
-  $(if $(filter $(suffix $(1)),.IPQ8074 .ipq8074),\
+  $(if $(filter $(suffix $(1)),.IPQ8074 .ipq8074 .ipq8174),\
     $(call ipq-wifi-install-ath11-one-to,$(1),$(2),IPQ8074/hw2.0),\
   $(if $(filter $(suffix $(1)),.QCN9074 .qcn9074),\
     $(call ipq-wifi-install-ath11-one-to,$(1),$(2),QCN9074/hw1.0),\
@@ -144,6 +145,7 @@ $(eval $(call generate-ipq-wifi-package,compex_wpq873,Compex WPQ-873))
 $(eval $(call generate-ipq-wifi-package,dynalink_dl-wrx36,Dynalink DL-WRX36))
 $(eval $(call generate-ipq-wifi-package,edgecore_eap102,Edgecore EAP102))
 $(eval $(call generate-ipq-wifi-package,edimax_cax1800,Edimax CAX1800))
+$(eval $(call generate-ipq-wifi-package,linksys_mx4200,Linksys MX4200))
 $(eval $(call generate-ipq-wifi-package,netgear_rax120v2,Netgear RAX120v2))
 $(eval $(call generate-ipq-wifi-package,netgear_wax218,Netgear WAX218))
 $(eval $(call generate-ipq-wifi-package,netgear_wax620,Netgear WAX620))
index e204ecb221d5992206eb3bc4f17da1d5a657d709..a1277a67396f3e88de6a1884998b600bbffbea15 100644 (file)
@@ -20,6 +20,7 @@ obj.mvebu = linksys_bootcount.o
 obj.kirkwood = linksys_bootcount.o
 obj.ipq806x = linksys_bootcount.o
 obj.ipq40xx = linksys_bootcount.o
+obj.qualcommax = linksys_bootcount.o
 
 ifdef FIS_SUPPORT
   obj += fis.o
diff --git a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8174-mx4200.dtsi b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8174-mx4200.dtsi
new file mode 100644 (file)
index 0000000..ef67742
--- /dev/null
@@ -0,0 +1,440 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/* Copyright (c) 2023, Mohammad Sayful Islam <Sayf.mohammad01@gmail.com> */
+
+#include "ipq8074.dtsi"
+#include "ipq8074-ac-cpu.dtsi"
+#include "ipq8074-ess.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
+
+/ {
+
+       aliases {
+               serial0 = &blsp1_uart5;
+               serial1 = &blsp1_uart3;
+               /*
+                * Aliases as required by u-boot
+                * to patch MAC addresses
+                */
+               ethernet1 = &dp2;
+               ethernet2 = &dp3;
+               ethernet3 = &dp4;
+               ethernet4 = &dp5;
+               led-boot = &led_system_blue;
+               led-running = &led_system_blue;
+               led-failsafe = &led_system_red;
+               led-upgrade = &led_system_green;
+       };
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+               bootargs-append = " root=/dev/ubiblock0_0";
+       };
+
+       keys {
+               compatible = "gpio-keys";
+               pinctrl-0 = <&button_pins>;
+               pinctrl-names = "default";
+
+               reset-button {
+                       label = "reset";
+                       gpios = <&tlmm 52 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+               };
+
+               wps-button {
+                       label = "wps";
+                       gpios = <&tlmm 67 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_WPS_BUTTON>;
+               };
+       };
+};
+
+&tlmm {
+       button_pins: button-state {
+               pins = "gpio52", "gpio67";
+               function = "gpio";
+               drive-strength = <8>;
+               bias-pull-up;
+       };
+
+       mdio_pins: mdio-state {
+               mdc-pins {
+                       pins = "gpio68";
+                       function = "mdc";
+                       drive-strength = <8>;
+                       bias-pull-up;
+               };
+
+               mdio-pins {
+                       pins = "gpio69";
+                       function = "mdio";
+                       drive-strength = <8>;
+                       bias-pull-up;
+               };
+       };
+
+       iot_pins: iot-state {
+               recovery-pins {
+                       pins = "gpio22";
+                       function = "gpio";
+                       input;
+               };
+
+               reset-pins {
+                       pins = "gpio21";
+                       function = "gpio";
+                       bias-pull-up;
+               };
+       };
+};
+
+&blsp1_uart3 {
+       status = "okay";
+
+       pinctrl-0 = <&hsuart_pins &iot_pins>;
+       pinctrl-names = "default";
+
+       /* Silicon Labs EFR32MG21 IoT */
+};
+
+&blsp1_uart5 {
+       status = "okay";
+};
+
+&prng {
+       status = "okay";
+};
+
+&cryptobam {
+       status = "okay";
+};
+
+&crypto {
+       status = "okay";
+};
+
+&qpic_bam {
+       status = "okay";
+};
+
+&qpic_nand {
+       status = "okay";
+
+       /*
+        * Bootloader will find the NAND DT node by the compatible and
+        * then "fixup" it by adding the partitions from the SMEM table
+        * using the legacy bindings thus making it impossible for us
+        * to change the partition table or utilize NVMEM for calibration.
+        * So add a dummy partitions node that bootloader will populate
+        * and set it as disabled so the kernel ignores it instead of
+        * printing warnings due to the broken way bootloader adds the
+        * partitions.
+        */
+       partitions {
+               status = "disabled";
+       };
+
+       nand@0 {
+               reg = <0>;
+               nand-ecc-strength = <4>;
+               nand-ecc-step-size = <512>;
+               nand-bus-width = <8>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "0:sbl1";
+                               reg = <0x0 0x100000>;
+                               read-only;
+                       };
+
+                       partition@100000 {
+                               label = "0:mibib";
+                               reg = <0x100000 0x100000>;
+                               read-only;
+                       };
+
+                       partition@200000 {
+                               label = "0:bootconfig";
+                               reg = <0x200000 0x80000>;
+                               read-only;
+                       };
+
+                       partition@280000 {
+                               label = "0:bootconfig1";
+                               reg = <0x280000 0x80000>;
+                               read-only;
+                       };
+
+                       partition@300000 {
+                               label = "0:qsee";
+                               reg = <0x300000 0x300000>;
+                               read-only;
+                       };
+
+                       partition@600000 {
+                               label = "0:qsee_1";
+                               reg = <0x600000 0x300000>;
+                               read-only;
+                       };
+
+                       partition@900000 {
+                               label = "0:devcfg";
+                               reg = <0x900000 0x80000>;
+                               read-only;
+                       };
+
+                       partition@980000 {
+                               label = "0:devcfg_1";
+                               reg = <0x980000 0x80000>;
+                               read-only;
+                       };
+
+                       partition@a00000 {
+                               label = "0:apdp";
+                               reg = <0xa00000 0x80000>;
+                               read-only;
+                       };
+
+                       partition@a80000 {
+                               label = "0:apdp_1";
+                               reg = <0xa80000 0x80000>;
+                               read-only;
+                       };
+
+                       partition@b00000 {
+                               label = "0:rpm";
+                               reg = <0xb00000 0x80000>;
+                               read-only;
+                       };
+
+                       partition@b80000 {
+                               label = "0:rpm_1";
+                               reg = <0xb80000 0x80000>;
+                               read-only;
+                       };
+
+                       partition@c00000 {
+                               label = "0:cdt";
+                               reg = <0xc00000 0x80000>;
+                               read-only;
+                       };
+
+                       partition@c80000 {
+                               label = "0:cdt_1";
+                               reg = <0xc80000 0x80000>;
+                               read-only;
+                       };
+
+                       partition@d00000 {
+                               label = "0:appsblenv";
+                               reg = <0xd00000 0x80000>;
+                       };
+
+                       partition@d80000 {
+                               label = "0:appsbl";
+                               reg = <0xd80000 0x100000>;
+                               read-only;
+                       };
+
+                       partition@e80000 {
+                               label = "0:appsbl_1";
+                               reg = <0xe80000 0x100000>;
+                               read-only;
+                       };
+
+                       partition@f80000 {
+                               label = "0:art";
+                               reg = <0xf80000 0x80000>;
+                               read-only;
+                       };
+
+                       partition@1000000 {
+                               label = "u_env";
+                               reg = <0x1000000 0x40000>;
+                       };
+
+                       partition@1040000 {
+                               label = "s_env";
+                               reg = <0x1040000 0x20000>;
+                       };
+
+                       partition@1060000 {
+                               label = "devinfo";
+                               reg = <0x1060000 0x20000>;
+                               read-only;
+                       };
+
+                       partition@1080000 {
+                               label = "kernel";
+                               reg = <0x1080000 0x9600000>;
+                       };
+
+                       partition@1680000 {
+                               label = "rootfs";
+                               reg = <0x1680000 0x9000000>;
+                       };
+
+                       partition@a680000 {
+                               label = "alt_kernel";
+                               reg = <0xa680000 0x9600000>;
+                       };
+
+                       partition@ac80000 {
+                               label = "alt_rootfs";
+                               reg = <0xac80000 0x9000000>;
+                       };
+                       partition@13c80000 {
+                               label = "sysdiag";
+                               reg = <0x13c80000 0x200000>;
+                               read-only;
+                       };
+                       partition@13e80000 {
+                               label = "0:ethphyfw";
+                               reg = <0x13e80000 0x80000>;
+                               read-only;
+                       };
+                       partition@13f00000 {
+                               label = "syscfg";
+                               reg = <0x13f00000 0xb800000>;
+                               read-only;
+                       };
+                       partition@1f700000 {
+                               label = "0:wififw";
+                               reg = <0x1f700000 0x900000>;
+                               read-only;
+                       };
+               };
+       };
+};
+
+&blsp1_i2c2 {
+       status = "okay";
+
+       led-controller@62 {
+               compatible = "nxp,pca9633";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               reg = <0x62>;
+               nxp,hw-blink;
+
+               led_system_red: led@0 {
+                       reg = <0>;
+                       color = <LED_COLOR_ID_RED>;
+                       function = LED_FUNCTION_STATUS;
+               };
+
+               led_system_green: led@1 {
+                       reg = <1>;
+                       color = <LED_COLOR_ID_GREEN>;
+                       function = LED_FUNCTION_STATUS;
+               };
+
+               led_system_blue: led@2 {
+                       reg = <2>;
+                       color = <LED_COLOR_ID_BLUE>;
+                       function = LED_FUNCTION_STATUS;
+               };
+       };
+};
+
+&mdio {
+       status = "okay";
+
+       pinctrl-0 = <&mdio_pins>;
+       pinctrl-names = "default";
+       reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>;
+
+       qca8075_1: ethernet-phy@1 {
+               compatible = "ethernet-phy-ieee802.3-c22";
+               reg = <1>;
+       };
+
+       qca8075_2: ethernet-phy@2 {
+               compatible = "ethernet-phy-ieee802.3-c22";
+               reg = <2>;
+       };
+
+       qca8075_3: ethernet-phy@3 {
+               compatible = "ethernet-phy-ieee802.3-c22";
+               reg = <3>;
+       };
+
+       qca8075_4: ethernet-phy@4 {
+               compatible = "ethernet-phy-ieee802.3-c22";
+               reg = <4>;
+       };
+};
+
+&switch {
+       status = "okay";
+
+       switch_lan_bmp = <(ESS_PORT3 | ESS_PORT4 | ESS_PORT5)>; /* lan port bitmap */
+       switch_wan_bmp = <ESS_PORT2>; /* wan port bitmap */
+       switch_mac_mode = <MAC_MODE_PSGMII>; /* mac mode for uniphy instance0*/
+
+       qcom,port_phyinfo {
+               port@2 {
+                       port_id = <2>;
+                       phy_address = <1>;
+               };
+               port@3 {
+                       port_id = <3>;
+                       phy_address = <2>;
+               };
+               port@4 {
+                       port_id = <4>;
+                       phy_address = <3>;
+               };
+               port@5 {
+                       port_id = <5>;
+                       phy_address = <4>;
+               };
+       };
+};
+
+&edma {
+       status = "okay";
+};
+
+&dp2 {
+       status = "okay";
+       phy-handle = <&qca8075_1>;
+       label = "wan";
+};
+
+&dp3 {
+       status = "okay";
+       phy-handle = <&qca8075_2>;
+       label = "lan1";
+};
+
+&dp4 {
+       status = "okay";
+       phy-handle = <&qca8075_3>;
+       label = "lan2";
+};
+
+&dp5 {
+       status = "okay";
+       phy-handle = <&qca8075_4>;
+       label = "lan3";
+};
+
+&ssphy_0 {
+       status = "okay";
+};
+
+&qusb_phy_0 {
+       status = "okay";
+};
+
+&usb_0 {
+       status = "okay";
+};
+
diff --git a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8174-mx4200v1.dts b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8174-mx4200v1.dts
new file mode 100644 (file)
index 0000000..4bc1b8c
--- /dev/null
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/* Copyright (c) 2023, Mohammad Sayful Islam <Sayf.mohammad01@gmail.com> */
+
+/dts-v1/;
+
+#include "ipq8074-512m.dtsi"
+#include "ipq8174-mx4200.dtsi"
+
+/ {
+       model = "Linksys MX4200v1";
+       compatible = "linksys,mx4200v1", "qcom,ipq8074";
+};
+  
+&wifi {
+       status = "okay";
+
+        qcom,ath11k-calibration-variant = "Linksys-MX4200v1";
+       qcom,ath11k-fw-memory-mode = <1>;
+};
diff --git a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8174-mx4200v2.dts b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8174-mx4200v2.dts
new file mode 100644 (file)
index 0000000..44e1b72
--- /dev/null
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/* Copyright (c) 2023, Mohammad Sayful Islam <Sayf.mohammad01@gmail.com> */
+
+/dts-v1/;
+
+#include "ipq8174-mx4200.dtsi"
+
+/ {
+       model = "Linksys MX4200v2";
+       compatible = "linksys,mx4200v2", "qcom,ipq8074";
+};
+
+&wifi {
+       status = "okay";
+
+       qcom,ath11k-calibration-variant = "Linksys-MX4200v2";
+};
index d8416d10fbcc78e1e92205dd82fc8809b535a14b..5beff11309fd9a0ff1841f713a8510d64c627909 100644 (file)
@@ -115,6 +115,31 @@ define Device/edimax_cax1800
 endef
 TARGET_DEVICES += edimax_cax1800
 
+define Device/linksys_mx4200v1
+       $(call Device/FitImage)
+       $(call Device/UbiFit)
+       DEVICE_VENDOR := Linksys
+        DEVICE_MODEL := MX4200
+        DEVICE_VARIANT := v1
+       BLOCKSIZE := 128k
+       PAGESIZE := 2048
+        KERNEL_SIZE := 6144k
+       IMAGE_SIZE := 147456k
+       NAND_SIZE := 512m
+       KERNEL_IN_UBI :=
+       SOC := ipq8174
+       IMAGES += factory.bin
+       IMAGE/factory.bin  := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | linksys-image type=MX4200
+       DEVICE_PACKAGES := kmod-leds-pca963x ipq-wifi-linksys_mx4200 kmod-bluetooth
+endef
+TARGET_DEVICES += linksys_mx4200v1
+
+define Device/linksys_mx4200v2
+       $(call Device/linksys_mx4200v1)
+        DEVICE_VARIANT := v2
+endef
+TARGET_DEVICES += linksys_mx4200v2
+
 define Device/netgear_rax120v2
        $(call Device/FitImage)
        $(call Device/UbiFit)
index 5da17db3fa9344a1f1c949de087843505f47b23f..ff9069091f792bfcbb1113015837aace418ab724 100644 (file)
@@ -18,6 +18,8 @@ ipq807x_setup_interfaces()
                ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
                ;;
        compex,wpq873|\
+        linksys,mx4200v1|\
+        linksys,mx4200v2|\
        redmi,ax6|\
        xiaomi,ax3600)
                ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
index ac1405739d4e306e20c2b8885392806f271f6a61..85d107079ee50b5af16ee017e30ee4f78ea17e54 100644 (file)
@@ -15,6 +15,8 @@ case "$FIRMWARE" in
        dynalink,dl-wrx36|\
        edgecore,eap102|\
        edimax,cax1800|\
+       linksys,mx4200v1|\
+       linksys,mx4200v2|\
        netgear,rax120v2|\
        netgear,wax218|\
        netgear,wax620|\
index 84f826b3b846baaec988e448452447aa5024dfc0..f5f6c909e9b42427a971e44c821131f61b464740 100755 (executable)
@@ -10,5 +10,9 @@ boot() {
                # Unset changed flag after sysupgrade complete
                fw_setenv changed
        ;;
+       linksys,mx4200v1|\
+       linksys,mx4200v2)
+               mtd resetbc s_env || true
+       ;;
        esac
 }
index 67fd0f540226b786f9502d740df86d4cad0ad355..78842e1c4d30357663b94e2c38925ca76f063d0a 100644 (file)
@@ -73,6 +73,21 @@ platform_do_upgrade() {
                fw_setenv upgrade_available 1
                nand_do_upgrade "$1"
                ;;
+       linksys,mx4200v1|\
+       linksys,mx4200v2)
+               boot_part="$(fw_printenv -n boot_part)"
+               if [ "$boot_part" -eq "1" ]; then
+                       fw_setenv boot_part 2
+                       CI_KERNPART="alt_kernel"
+                       CI_UBIPART="alt_rootfs"
+               else
+                       fw_setenv boot_part 1
+                       CI_UBIPART="rootfs"
+               fi
+               fw_setenv boot_part_ready 3
+               fw_setenv auto_recovery yes
+               nand_do_upgrade "$1"
+               ;;
        prpl,haze|\
        qnap,301w)
                kernelname="0:HLOS"