From 8e68a5d788194c8f96b3a5280164384292ba758e Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Fri, 28 Oct 2022 11:43:33 +0800 Subject: [PATCH] ipq60xx: add CMIOT-AX18/ZN-M2 support --- .../ipq60xx/base-files/etc/board.d/01_leds | 25 +++ .../ipq60xx/base-files/etc/board.d/02_network | 4 + .../etc/hotplug.d/firmware/11-ath11k-caldata | 46 +++- .../base-files/lib/upgrade/platform.sh | 22 ++ .../arch/arm64/boot/dts/qcom/ipq6018-ax18.dts | 67 ++++++ .../arm64/boot/dts/qcom/ipq6018-cmiot.dtsi | 200 ++++++++++++++++++ .../arch/arm64/boot/dts/qcom/ipq6018-m2.dts | 66 ++++++ target/linux/ipq60xx/image/generic.mk | 24 +++ ...1000-arm64-dts-add-OpenWrt-DTS-files.patch | 4 +- 9 files changed, 453 insertions(+), 5 deletions(-) create mode 100644 target/linux/ipq60xx/base-files/etc/board.d/01_leds create mode 100644 target/linux/ipq60xx/base-files/lib/upgrade/platform.sh create mode 100644 target/linux/ipq60xx/files/arch/arm64/boot/dts/qcom/ipq6018-ax18.dts create mode 100644 target/linux/ipq60xx/files/arch/arm64/boot/dts/qcom/ipq6018-cmiot.dtsi create mode 100644 target/linux/ipq60xx/files/arch/arm64/boot/dts/qcom/ipq6018-m2.dts diff --git a/target/linux/ipq60xx/base-files/etc/board.d/01_leds b/target/linux/ipq60xx/base-files/etc/board.d/01_leds new file mode 100644 index 000000000..9f1cec67c --- /dev/null +++ b/target/linux/ipq60xx/base-files/etc/board.d/01_leds @@ -0,0 +1,25 @@ +#!/bin/sh +# +# Copyright (C) 2015 OpenWrt.org +# + +. /lib/functions/uci-defaults.sh + +board_config_update + +board=$(board_name) + +case "$board" in +cmiot,ax18|\ +zn,m2) + ucidef_set_led_netdev "wan" "WAN" "blue:wan" "eth0" + ucidef_set_led_netdev "wlan2g" "WLAN2G" "blue:wlan2g" "wlan1" + ucidef_set_led_netdev "wlan5g" "WLAN5G" "blue:wlan5g" "wlan0" + ;; +*) + ;; +esac + +board_config_flush + +exit 0 \ No newline at end of file diff --git a/target/linux/ipq60xx/base-files/etc/board.d/02_network b/target/linux/ipq60xx/base-files/etc/board.d/02_network index 3378049b6..d981a61a8 100644 --- a/target/linux/ipq60xx/base-files/etc/board.d/02_network +++ b/target/linux/ipq60xx/base-files/etc/board.d/02_network @@ -6,6 +6,10 @@ setup_network() local macaddr case $(board_name) in + cmiot,ax18|\ + zn,m2) + ucidef_set_interfaces_lan_wan "eth1 eth2 eth3" "eth0" + ;; linksys,mr7350) ucidef_set_interfaces_lan_wan "eth0 eth1 eth2 eth3" "eth4" ;; diff --git a/target/linux/ipq60xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata b/target/linux/ipq60xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata index 13d033edb..deef9ddb0 100644 --- a/target/linux/ipq60xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata +++ b/target/linux/ipq60xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata @@ -3,11 +3,35 @@ [ -e /lib/firmware/$FIRMWARE ] && exit 0 . /lib/functions/caldata.sh +. /lib/functions/system.sh + +board=$(board_name) + +ath11k_generate_macs() { + case "$board" in + linksys,mr7350) + eth=$(mtd_get_mac_ascii devinfo hw_mac_addr) + ;; + *) + eth=$(cat /sys/class/net/eth0/address) + ;; + esac + + touch /lib/firmware/ath11k-macs + mac1=$(macaddr_add $eth 2) + mac2=$(macaddr_add $eth 3) + mac3=$(macaddr_add $eth 4) + echo -ne \\x${mac1//:/\\x} >> /lib/firmware/ath11k-macs + echo -ne \\x${mac2//:/\\x} >> /lib/firmware/ath11k-macs + echo -ne \\x${mac3//:/\\x} >> /lib/firmware/ath11k-macs +} case "$FIRMWARE" in "ath11k/IPQ6018/hw1.0/cal-ahb-c000000.wifi.bin") - case $(board_name) in - linksys,mr7350) + case "$board" in + cmiot,ax18|\ + linksys,mr|\ + zn,m2) caldata_extract "0:art" 0x1000 0x10000 ;; tplink,eap610-outdoor) @@ -15,8 +39,22 @@ case "$FIRMWARE" in cp /tmp/factory_data/radio "/lib/firmware/$FIRMWARE" ;; *) - caldata_die "Don't know how to read caldata for $(board_name)" - ;; + caldata_die "Don't know how to read caldata for $board" + ;; esac ;; + +ath11k-macs) + case "$board" in + cmiot,ax18|\ + linksys,mr7350|\ + zn,m2) + ath11k_generate_macs + ;; + esac + ;; + +*) + exit 1 + ;; esac diff --git a/target/linux/ipq60xx/base-files/lib/upgrade/platform.sh b/target/linux/ipq60xx/base-files/lib/upgrade/platform.sh new file mode 100644 index 000000000..b442736e1 --- /dev/null +++ b/target/linux/ipq60xx/base-files/lib/upgrade/platform.sh @@ -0,0 +1,22 @@ + +PART_NAME=firmware +REQUIRE_IMAGE_METADATA=1 + +RAMFS_COPY_BIN='fw_printenv fw_setenv' +RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' + +platform_check_image() { + return 0; +} + +platform_do_upgrade() { + case "$(board_name)" in + cmiot,ax18|\ + zn,m2) + nand_do_upgrade "$1" + ;; + *) + default_do_upgrade "$1" + ;; + esac +} \ No newline at end of file diff --git a/target/linux/ipq60xx/files/arch/arm64/boot/dts/qcom/ipq6018-ax18.dts b/target/linux/ipq60xx/files/arch/arm64/boot/dts/qcom/ipq6018-ax18.dts new file mode 100644 index 000000000..bf902da82 --- /dev/null +++ b/target/linux/ipq60xx/files/arch/arm64/boot/dts/qcom/ipq6018-ax18.dts @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: (GPL-2.0+) + +/dts-v1/; + +#include "ipq6018-cmiot.dtsi" + +/ { + model = "CMIOT AX18"; + compatible = "cmiot,ax18", "qcom,ipq6018"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&leds_pins>; + pinctrl-names = "default"; + + led_power: power { + label = "ax18:blue:power"; + gpio = <&tlmm 73 GPIO_ACTIVE_HIGH>; + }; + + wan { + label = "ax18:blue:wan"; + gpio = <&tlmm 74 GPIO_ACTIVE_HIGH>; + }; + + wlan2g { + label = "ax18:blue:wlan2g"; + gpio = <&tlmm 37 GPIO_ACTIVE_HIGH>; + }; + + wlan5g { + label = "ax18:blue:wlan5g"; + gpio = <&tlmm 35 GPIO_ACTIVE_HIGH>; + }; + + wps { + label = "ax18:red:wps"; + gpio = <&tlmm 69 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&tlmm { + leds_pins: leds_pins { + mux_0 { + pins = "gpio35", "gpio37", + "gpio69", "gpio74"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + mux_1 { + pins = "gpio73"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; diff --git a/target/linux/ipq60xx/files/arch/arm64/boot/dts/qcom/ipq6018-cmiot.dtsi b/target/linux/ipq60xx/files/arch/arm64/boot/dts/qcom/ipq6018-cmiot.dtsi new file mode 100644 index 000000000..de514efab --- /dev/null +++ b/target/linux/ipq60xx/files/arch/arm64/boot/dts/qcom/ipq6018-cmiot.dtsi @@ -0,0 +1,200 @@ +// SPDX-License-Identifier: (GPL-2.0+) + +/dts-v1/; + +#include "ipq6018.dtsi" +#include "ipq6018-upstreamable.dtsi" +#include "ipq6018-ess.dtsi" + +#include +#include + +/ { + qcom,msm-id = <0x192 0x0>; + + aliases { + serial0 = &blsp1_uart3; + + /* Aliases as required by u-boot to patch MAC addresses */ + ethernet0 = &dp1; + ethernet1 = &dp2; + ethernet2 = &dp3; + ethernet3 = &dp4; + }; + + chosen { + bootargs-append = " root=/dev/ubiblock0_1 swiotlb=1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 60 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&tlmm 9 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + button_pins: button_pins { + wps_button { + pins = "gpio9"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + reset_button { + pins = "gpio60"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&soc { + dp1: dp@1 { + compatible = "qcom,nss-dp"; + reg = <0x0 0x3a001000 0x0 0x200>; + qcom,mactype = <0>; + qcom,id = <5>; + local-mac-address = [000000000000]; + phy-handle = <&phy_0>; + phy-mode = "sgmii"; + }; + + dp2: dp2 { + compatible = "qcom,nss-dp"; + reg = <0x0 0x3a001200 0x0 0x200>; + qcom,mactype = <0>; + qcom,id = <1>; + local-mac-address = [000000000000]; + phy-handle = <&phy_1>; + phy-mode = "sgmii"; + }; + + dp3: dp3 { + compatible = "qcom,nss-dp"; + reg = <0x0 0x3a001400 0x0 0x200>; + qcom,mactype = <0>; + qcom,id = <2>; + local-mac-address = [000000000000]; + phy-handle = <&phy_2>; + phy-mode = "sgmii"; + }; + + dp4: dp4 { + compatible = "qcom,nss-dp"; + reg = <0x0 0x3a001600 0x0 0x200>; + qcom,mactype = <0>; + qcom,id = <4>; + local-mac-address = [000000000000]; + phy-handle = <&phy_3>; + phy-mode = "sgmii"; + }; +}; + +&edma { + status = "okay"; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 75 GPIO_ACTIVE_LOW>; + + phy_0: ethernet-phy@0 { + reg = <4>; + }; + + phy_1: ethernet-phy@1 { + reg = <0>; + }; + + phy_2: ethernet-phy@2 { + reg = <1>; + }; + + phy_3: ethernet-phy@3 { + reg = <3>; + }; +}; + +&switch { + status = "okay"; + + switch_mac_mode = <0x0>; /* mac mode for uniphy instance0*/ + switch_mac_mode1 = <0xff>; /* mac mode for uniphy instance1*/ + switch_mac_mode2 = <0xff>; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@0 { + port_id = <0x01>; + phy_address = <0x00>; + }; + port@1 { + port_id = <0x02>; + phy_address = <0x01>; + }; + port@2 { + port_id = <0x04>; + phy_address = <0x03>; + }; + port@3 { + port_id = <0x05>; + phy_address = <0x04>; + }; + }; +}; + +&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>; + }; +}; + +&wifi { + status = "okay"; +}; diff --git a/target/linux/ipq60xx/files/arch/arm64/boot/dts/qcom/ipq6018-m2.dts b/target/linux/ipq60xx/files/arch/arm64/boot/dts/qcom/ipq6018-m2.dts new file mode 100644 index 000000000..16cc4137e --- /dev/null +++ b/target/linux/ipq60xx/files/arch/arm64/boot/dts/qcom/ipq6018-m2.dts @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: (GPL-2.0+) + +/dts-v1/; + +#include "ipq6018-cmiot.dtsi" + +/ { + model = "ZN M2"; + compatible = "zn,m2", "qcom,ipq6018"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&leds_pins>; + pinctrl-names = "default"; + + led_power: power { + label = "m2:blue:power"; + gpio = <&tlmm 58 GPIO_ACTIVE_HIGH>; + }; + + mesh { + label = "m2:blue:mesh"; + gpio = <&tlmm 73 GPIO_ACTIVE_HIGH>; + }; + + lan { + label = "m2:blue:lan"; + gpio = <&tlmm 74 GPIO_ACTIVE_HIGH>; + }; + + wan { + label = "m2:blue:wan"; + gpio = <&tlmm 37 GPIO_ACTIVE_HIGH>; + }; + + wlan5g { + label = "m2:blue:wlan5g"; + gpio = <&tlmm 35 GPIO_ACTIVE_HIGH>; + }; + + wlan2g { + label = "m2:blue:wlan2g"; + gpio = <&tlmm 70 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&tlmm { + leds_pins: leds_pins { + mux { + pins = "gpio35", "gpio37", + "gpio58", "gpio70", + "gpio73", "gpio74"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + }; +}; diff --git a/target/linux/ipq60xx/image/generic.mk b/target/linux/ipq60xx/image/generic.mk index b2ad5f2a8..22f30911d 100644 --- a/target/linux/ipq60xx/image/generic.mk +++ b/target/linux/ipq60xx/image/generic.mk @@ -23,6 +23,18 @@ define Device/UbiFit IMAGE/nand-sysupgrade.bin := sysupgrade-tar | append-metadata endef +define Device/cmiot_ax18 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := CMIOT + DEVICE_MODEL := AX18 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@cp03-c1 + SOC := ipq6018 +endef +TARGET_DEVICES += cmiot_ax18 + define Device/mr7350 $(call Device/FitImage) DEVICE_VENDOR := Linksys @@ -51,3 +63,15 @@ define Device/eap610-outdoor IMAGE/nand-factory.ubi := append-ubi | qsdk-ipq-factory-nand endef TARGET_DEVICES += eap610-outdoor + +define Device/zn_m2 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := ZN + DEVICE_MODEL := M2 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@cp03-c1 + SOC := ipq6018 +endef +TARGET_DEVICES += zn_m2 diff --git a/target/linux/ipq60xx/patches-5.15/1000-arm64-dts-add-OpenWrt-DTS-files.patch b/target/linux/ipq60xx/patches-5.15/1000-arm64-dts-add-OpenWrt-DTS-files.patch index dc124d4f1..b868bfeda 100644 --- a/target/linux/ipq60xx/patches-5.15/1000-arm64-dts-add-OpenWrt-DTS-files.patch +++ b/target/linux/ipq60xx/patches-5.15/1000-arm64-dts-add-OpenWrt-DTS-files.patch @@ -16,12 +16,14 @@ diff --git a/arch/arm64/boot/dts/qcom/Makefile b/arch/arm64/boot/dts/qcom/Makefi index 70516508be56..27a7e3f98465 100644 --- a/arch/arm64/boot/dts/qcom/Makefile +++ b/arch/arm64/boot/dts/qcom/Makefile -@@ -4,6 +4,8 @@ dtb-$(CONFIG_ARCH_QCOM) += apq8094-sony-xperia-kitakami-karin_windy.dtb +@@ -4,6 +4,10 @@ dtb-$(CONFIG_ARCH_QCOM) += apq8094-sony-xperia-kitakami-karin_windy.dtb dtb-$(CONFIG_ARCH_QCOM) += apq8096-db820c.dtb dtb-$(CONFIG_ARCH_QCOM) += apq8096-ifc6640.dtb dtb-$(CONFIG_ARCH_QCOM) += ipq6018-cp01-c1.dtb +dtb-$(CONFIG_ARCH_QCOM) += ipq6018-eap610-outdoor.dtb +dtb-$(CONFIG_ARCH_QCOM) += ipq6018-mr7350.dtb ++dtb-$(CONFIG_ARCH_QCOM) += ipq6018-ax18.dtb ++dtb-$(CONFIG_ARCH_QCOM) += ipq6018-m2.dtb dtb-$(CONFIG_ARCH_QCOM) += ipq8074-hk01.dtb dtb-$(CONFIG_ARCH_QCOM) += ipq8074-hk10-c1.dtb dtb-$(CONFIG_ARCH_QCOM) += ipq8074-hk10-c2.dtb