diff --git a/package/boot/uboot-envtools/files/ipq50xx b/package/boot/uboot-envtools/files/ipq50xx index 73083b078e..97e70f2c0e 100644 --- a/package/boot/uboot-envtools/files/ipq50xx +++ b/package/boot/uboot-envtools/files/ipq50xx @@ -9,7 +9,8 @@ touch /etc/config/ubootenv board=$(board_name) case "$board" in - redmi,ax3000) + redmi,ax3000|\ + xiaomi,cr881x) ubootenv_add_uci_config "/dev/mtd10" "0x0" "0x10000" "0x20000" ;; esac diff --git a/package/firmware/ipq-wifi/Makefile b/package/firmware/ipq-wifi/Makefile index e5e99137d1..35ca2d15b5 100644 --- a/package/firmware/ipq-wifi/Makefile +++ b/package/firmware/ipq-wifi/Makefile @@ -41,6 +41,7 @@ ALLWIFIBOARDS:= \ wallys_dr40x9 \ xiaomi_ax3600 \ xiaomi_ax9000 \ + xiaomi_cr881x \ zte_mf289f \ zte_mf287 \ zte_mf287plus \ @@ -135,6 +136,7 @@ $(eval $(call generate-ipq-wifi-package,redmi_ax6,Redmi AX6)) $(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)) +$(eval $(call generate-ipq-wifi-package,xiaomi_cr881x,Xiaomi CR881x)) $(eval $(call generate-ipq-wifi-package,zte_mf289f,ZTE MF289F)) $(eval $(call generate-ipq-wifi-package,zte_mf287,ZTE MF287)) $(eval $(call generate-ipq-wifi-package,zte_mf287plus,ZTE MF287Plus)) diff --git a/package/firmware/ipq-wifi/src/board-xiaomi_cr881x.ipq5018 b/package/firmware/ipq-wifi/src/board-xiaomi_cr881x.ipq5018 new file mode 100644 index 0000000000..c5689ca647 Binary files /dev/null and b/package/firmware/ipq-wifi/src/board-xiaomi_cr881x.ipq5018 differ diff --git a/package/firmware/ipq-wifi/src/board-xiaomi_cr881x.qcn6122 b/package/firmware/ipq-wifi/src/board-xiaomi_cr881x.qcn6122 new file mode 100644 index 0000000000..2489f93c64 Binary files /dev/null and b/package/firmware/ipq-wifi/src/board-xiaomi_cr881x.qcn6122 differ diff --git a/target/linux/ipq50xx/base-files/etc/board.d/01_leds b/target/linux/ipq50xx/base-files/etc/board.d/01_leds index 137a1e0c6c..626aa15b3d 100755 --- a/target/linux/ipq50xx/base-files/etc/board.d/01_leds +++ b/target/linux/ipq50xx/base-files/etc/board.d/01_leds @@ -22,6 +22,9 @@ case $board in redmi,ax3000) ucidef_set_led_switch "wan" "WAN" "blue:internet" "switch1" "$( bits 4 )" ;; + xiaomi,cr881x) + ucidef_set_led_switch "wan" "WAN" "blue:internet" "switch0" "$( bits 3 )" + ;; esac board_config_flush diff --git a/target/linux/ipq50xx/base-files/etc/board.d/02_network b/target/linux/ipq50xx/base-files/etc/board.d/02_network index 4d46bf642e..8f604b15ce 100755 --- a/target/linux/ipq50xx/base-files/etc/board.d/02_network +++ b/target/linux/ipq50xx/base-files/etc/board.d/02_network @@ -12,6 +12,12 @@ ipq50xx_setup_interfaces() "1:lan:1" "2:lan:2" "3:lan:3" \ "4:wan" ;; + xiaomi,cr881x) + ucidef_add_switch "switch0" \ + "8u@eth1" "4u@eth0" \ + "0:lan:1" "1:lan:2" "2:lan:3" \ + "3:wan" + ;; esac } diff --git a/target/linux/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata b/target/linux/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata index 32f8e7a69d..8e92d95284 100644 --- a/target/linux/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata +++ b/target/linux/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata @@ -9,14 +9,16 @@ board=$(board_name) case "$FIRMWARE" in "ath11k/IPQ5018/hw1.0/caldata.bin") case "$board" in - redmi,ax3000) + redmi,ax3000|\ + xiaomi,cr881x) caldata_extract "0:ART" 0x1000 0x20000 ;; esac ;; "ath11k/qcn6122/hw1.0/caldata_1.bin") case "$board" in - redmi,ax3000) + redmi,ax3000|\ + xiaomi,cr881x) caldata_extract "0:ART" 0x26800 0x20000 ;; esac diff --git a/target/linux/ipq50xx/base-files/etc/init.d/uboot_env b/target/linux/ipq50xx/base-files/etc/init.d/uboot_env index 18c7f4d0b3..52997f9bba 100755 --- a/target/linux/ipq50xx/base-files/etc/init.d/uboot_env +++ b/target/linux/ipq50xx/base-files/etc/init.d/uboot_env @@ -6,7 +6,8 @@ START=99 boot() { case $(board_name) in - redmi,ax3000) + redmi,ax3000|\ + xiaomi,cr881x) fw_printenv >/dev/null || return 0 local flag_ota_reboot="$(fw_printenv flag_ota_reboot | cut -d'=' -f2)" diff --git a/target/linux/ipq50xx/base-files/lib/upgrade/platform.sh b/target/linux/ipq50xx/base-files/lib/upgrade/platform.sh index d1900f138a..19ceb64888 100644 --- a/target/linux/ipq50xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ipq50xx/base-files/lib/upgrade/platform.sh @@ -6,7 +6,8 @@ RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' platform_check_image() { local board=$(board_name) case $board in - redmi,ax3000) + redmi,ax3000|\ + xiaomi,cr881x) mi_dualboot_check_image "$1" return $? ;; @@ -20,7 +21,8 @@ platform_check_image() { platform_do_upgrade() { local board=$(board_name) case $board in - redmi,ax3000) + redmi,ax3000|\ + xiaomi,cr881x) mi_dualboot_do_upgrade "$1" ;; *) diff --git a/target/linux/ipq50xx/config-5.15 b/target/linux/ipq50xx/config-5.15 index 7bd06a0786..8252d778cc 100644 --- a/target/linux/ipq50xx/config-5.15 +++ b/target/linux/ipq50xx/config-5.15 @@ -1296,6 +1296,7 @@ CONFIG_ARCH_IPQ50XX=y CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT=y # CONFIG_MTD_UBI_GLUEBI is not set CONFIG_MDIO_IPQ4019=y +CONFIG_YT9215_PHY=y CONFIG_BRIDGE_VLAN_FILTERING=y CONFIG_LEDS_GPIO=y CONFIG_SWCONFIG_LEDS=y diff --git a/target/linux/ipq50xx/dts/ipq5018-cr881x.dts b/target/linux/ipq50xx/dts/ipq5018-cr881x.dts new file mode 100644 index 0000000000..179512d8b4 --- /dev/null +++ b/target/linux/ipq50xx/dts/ipq5018-cr881x.dts @@ -0,0 +1,511 @@ +// SPDX-License-Identifier: (GPL-2.0+) + +/dts-v1/; + +#include "ipq5018.dtsi" +#include +#include + +/ { + model = "Xiaomi CR881x"; + compatible = "xiaomi,cr881x", "qcom,ipq5018"; + + #address-cells = <2>; + #size-cells = <2>; + interrupt-parent = <&intc>; + + aliases { + serial0 = &blsp1_uart1; + + ethernet0 = &mac0; + ethernet1 = &mac1; + + led-boot = &led_system_blue; + led-failsafe = &led_system_red; + led-running = &led_system_blue; + led-upgrade = &led_system_red; + }; + + chosen { + // Override the root parameter from u-boot + // Increase coherent_pool size for WiFi + bootargs-append = " root=/dev/ubiblock0_1 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; + + reserved-memory { + // Not sure why but without this, WiFi will crash + tz_apps@4a400000 { + no-map; + // The size is incorrent, but it works + reg = <0x0 0x4a400000 0x0 0x700000>; + }; + + q6_mem_regions: q6_mem_regions@4b000000 { + no-map; + // reg = <0x0 0x4b000000 0x0 0x3b00000>; + reg = <0x0 0x4b000000 0x0 0x3000000>; + }; + }; + + thermal-zones { + status = "ok"; + }; +}; + +&tlmm { + blsp_uart0_pins: blsp_uart0_pins { + pins = + "gpio20", // RX + "gpio21"; // TX + function = "blsp0_uart0"; + drive-strength = <8>; + bias-disable; + }; + + qspi_nand_pins: qspi_nand_pins { + clock { + pins = "gpio9"; + function = "qspi_clk"; + drive-strength = <8>; + bias-disable; + }; + + cs { + pins = "gpio8"; + function = "qspi_cs"; + drive-strength = <8>; + bias-disable; + }; + + data0 { + pins = "gpio7"; + function = "qspi0"; + drive-strength = <8>; + bias-disable; + }; + + data1 { + pins = "gpio6"; + function = "qspi1"; + drive-strength = <8>; + bias-disable; + }; + + data2 { + pins = "gpio5"; + function = "qspi2"; + drive-strength = <8>; + bias-disable; + }; + + data3 { + pins = "gpio4"; + function = "qspi3"; + drive-strength = <8>; + bias-disable; + }; + }; + + mdio1_pins: mdio1_pins { + mdc { + pins = "gpio36"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio37"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + leds_pins: leds_pins { + led_system_blue { + pins = "gpio24"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + led_system_red { + pins = "gpio25"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + led_internet_blue { + pins = "gpio26"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + led_internet_red { + pins = "gpio27"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + }; + + button_pins: button_pins { + button_reset { + pins = "gpio38"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + button_mesh { + pins = "gpio28"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart1 { + pinctrl-0 = <&blsp_uart0_pins>; + pinctrl-names = "default"; + status = "ok"; +}; + +&qpic_bam { + status = "ok"; +}; + +&nand { + pinctrl-0 = <&qspi_nand_pins>; + pinctrl-names = "default"; + status = "ok"; +}; + +&soc { + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&leds_pins>; + pinctrl-names = "default"; + + led_system_blue: led_system_blue { + label = "blue:system"; + gpio = <&tlmm 24 GPIO_ACTIVE_HIGH>; + default-state = "on"; + }; + + led_system_red: led_system_red { + label = "red:system"; + gpio = <&tlmm 25 GPIO_ACTIVE_HIGH>; + }; + + led_internet_blue: led_internet_blue { + label = "blue:internet"; + gpio = <&tlmm 26 GPIO_ACTIVE_HIGH>; + }; + + led_internet_red: led_internet_red { + label = "red:internet"; + gpio = <&tlmm 27 GPIO_ACTIVE_HIGH>; + }; + }; + + button { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + button_reset { + label = "reset"; + gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; + linux,input-type = ; + linux,code = ; + debounce-interval = <60>; + }; + + button_mesh { + label = "mesh"; + gpios = <&tlmm 28 GPIO_ACTIVE_LOW>; + linux,input-type = ; + linux,code = ; + debounce-interval = <60>; + }; + }; + + ess-instance { + num_devices = <1>; + + // Dummy switch, to describe how the external ports connects to the MAC + // For example, some chips have PSGMII ports which combine 5 MAC into + // 1 external port. + // For IPQ50xx, this is used to choose SGMII or SGMII-plus + ess-switch@0x39c00000 { + compatible = "qcom,ess-switch-ipq50xx"; + device_id = <0>; + + cmnblk_clk = "internal_96MHz"; + + // MAC1 Mode + switch_mac_mode = <0xc>; // PORT_WRAPPER_SGMII_PLUS + // switch_mac_mode = <0xf>; // PORT_WRAPPER_SGMII_CHANNEL0 + + qcom,port_phyinfo { + // MAC0 -> GE Phy -> YT9215 Phy4 + port@0 { + port_id = <1>; + + mdiobus = <&mdio0>; + phy_address = <7>; + + phy_dac = <0x10 0x10>; + }; + + // MAC1 ---SGMII---> YT9215 SerDes + port@1 { + port_id = <2>; + + forced-speed = <2500>; + forced-duplex = <1>; + }; + }; + }; + }; + + // MAC0 -> GE Phy + mac0: dp1 { + compatible = "qcom,nss-dp"; + device_type = "network"; + qcom,id = <1>; + + reg = <0x39C00000 0x10000>; + interrupts = ; + clocks = <&gcc GCC_SNOC_GMAC0_AXI_CLK>; + clock-names = "nss-snoc-gmac-axi-clk"; + + qcom,mactype = <2>; // GMAC_HAL_TYPE_SYN_GMAC + local-mac-address = [000000000000]; + phy-handle = <&ge_phy>; + phy-mode = "internal"; + }; + + // MAC1 ---SGMII---> YT9215 SerDes + mac1: dp2 { + compatible = "qcom,nss-dp"; + device_type = "network"; + qcom,id = <2>; + + reg = <0x39D00000 0x10000>; + interrupts = ; + clocks = <&gcc GCC_SNOC_GMAC1_AXI_CLK>; + clock-names = "nss-snoc-gmac-axi-clk"; + + qcom,mactype = <2>; // GMAC_HAL_TYPE_SYN_GMAC + local-mac-address = [000000000000]; + phy-mode = "2500base-x"; + }; +}; + +&mdio0 { + status = "ok"; + + resets = <&gcc GCC_GEPHY_MDC_SW_ARES>; + reset-names = "phy"; + + // IPQ5018 GE Phy -> YT9215 Phy4 + ge_phy: ethernet-phy@0 { + reg = <7>; + }; +}; + +&mdio1 { + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + status = "ok"; + + // Motorcomm YT9215 + yt9215: switch@1d { + compatible = "motorcomm,yt9215-smi"; + reg = <29>; + switchid = <0>; + + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + reset-assert-us = <10000>; /* 10ms */ + reset-deassert-us = <50000>; /* 50ms */ + + ports { + // MAC0 -> Phy0 -> LAN1 + port@0 { + reg = <0>; + }; + + // MAC1 -> Phy1 -> LAN2 + port@1 { + reg = <1>; + }; + + // MAC2 -> Phy2 -> LAN3 + port@2 { + reg = <2>; + }; + + // MAC3 -> Phy3 -> WAN + port@3 { + reg = <3>; + }; + + // MAC4 -> Phy4 -> IPQ5018 GE Phy + port@4 { + reg = <4>; + }; + + // MAC8 ---SGMII+---> IPQ5018 MAC1 + port@8 { + reg = <8>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + }; + }; + }; + }; +}; + +&q6v5_wcss { + memory-region = <&q6_mem_regions>; + + qcom,rproc = <&q6v5_wcss>; + firmware = "IPQ5018/q6_fw.mdt"; + + qcom,bootargs_smem = <507>; + boot-args = ; + + status = "ok"; + + // IPQ5018 + q6_wcss_pd1: remoteproc_pd1@4ab000 { + compatible = "qcom,ipq5018-wcss-ahb-mpd"; + + resets = + <&gcc GCC_WCSSAON_RESET>, + <&gcc GCC_WCSS_BCR>, + <&gcc GCC_CE_BCR>; + reset-names = + "wcss_aon_reset", + "wcss_reset", + "ce_reset"; + + clocks = + <&gcc GCC_WCSS_AHB_S_CLK>, + <&gcc GCC_WCSS_ACMT_CLK>, + <&gcc GCC_WCSS_AXI_M_CLK>; + clock-names = + "gcc_wcss_ahb_s_clk", + "gcc_wcss_acmt_clk", + "gcc_wcss_axi_m_clk"; + + reg = <0x4ab000 0x20>; + reg-names = "rmb"; + + // qcom,halt-regs = <&tcsr_q6_block 0xa000 0xd000 0x0>; + + interrupts-extended = + <&wcss_smp2p_in 8 0>, + <&wcss_smp2p_in 9 0>, + <&wcss_smp2p_in 12 0>, + <&wcss_smp2p_in 11 0>; + interrupt-names = + "fatal", + "ready", + "spawn-ack", + "stop-ack"; + + qcom,smem-states = + <&wcss_smp2p_out 8>, + <&wcss_smp2p_out 9>, + <&wcss_smp2p_out 10>; + qcom,smem-state-names = + "shutdown", + "stop", + "spawn"; + + firmware = "IPQ5018/q6_fw.mdt"; + m3_firmware = "IPQ5018/m3_fw.mdt"; + }; + + // QCN6102 + q6_wcss_pd2: remoteproc_pd2 { + compatible = "qcom,ipq5018-wcss-pcie-mpd"; + + interrupts-extended = + <&wcss_smp2p_in 16 0>, + <&wcss_smp2p_in 17 0>, + <&wcss_smp2p_in 20 0>, + <&wcss_smp2p_in 19 0>; + interrupt-names = + "fatal", + "ready", + "spawn-ack", + "stop-ack"; + + qcom,smem-states = + <&wcss_smp2p_out 16>, + <&wcss_smp2p_out 17>, + <&wcss_smp2p_out 18>; + qcom,smem-state-names = + "shutdown", + "stop", + "spawn"; + + firmware = "IPQ5018/q6_fw.mdt"; + m3_firmware = "qcn6122/m3_fw.mdt"; + }; +}; + +&wifi0 { + // IPQ5018 + qcom,multipd_arch; + qcom,rproc = <&q6_wcss_pd1>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd1"; + + qcom,board_id = <0x23>; + + // qcom,ath11k-fw-memory-mode = <0>; + // qcom,bdf-addr = <0x4c400000>; + // qcom,caldb-addr = <0x4d200000>; + // qcom,m3-dump-addr = <0x4d400000>; + + qcom,ath11k-fw-memory-mode = <2>; + qcom,bdf-addr = <0x4c400000>; + + status = "ok"; +}; + +&wifi1 { + // QCN6102 + qcom,multipd_arch; + qcom,rproc = <&q6_wcss_pd2>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd2"; + + qcom,board_id = <0x60>; + + // qcom,ath11k-fw-memory-mode = <0>; + // qcom,bdf-addr = <0x4d500000>; + // qcom,caldb-addr = <0x4e500000>; + // qcom,m3-dump-addr = <0x4ea00000>; + + qcom,ath11k-fw-memory-mode = <2>; + qcom,bdf-addr = <0x4d100000>; + qcom,m3-dump-addr = <0x4df00000>; + + status = "ok"; +}; diff --git a/target/linux/ipq50xx/image/Makefile b/target/linux/ipq50xx/image/Makefile index adaaca5bd1..0615756fe6 100644 --- a/target/linux/ipq50xx/image/Makefile +++ b/target/linux/ipq50xx/image/Makefile @@ -54,4 +54,21 @@ define Device/redmi_ax3000 endef TARGET_DEVICES += redmi_ax3000 +define Device/xiaomi_cr881x + $(call Device/FitImage) + $(call Device/UbiFit) + SOC := ipq5018 + DEVICE_VENDOR := Xiaomi + DEVICE_MODEL := CR881x + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@mp03.3 + IMAGES := nand-factory.ubi + DEVICE_PACKAGES := \ + ath11k-firmware-ipq5018 \ + ath11k-firmware-qcn6122 \ + ipq-wifi-xiaomi_cr881x +endef +TARGET_DEVICES += xiaomi_cr881x + $(eval $(call BuildImage)) diff --git a/target/linux/ipq50xx/patches/421-mtd-rawnand-winbond-add-support-for-W25N01GW.patch b/target/linux/ipq50xx/patches/421-mtd-rawnand-winbond-add-support-for-W25N01GW.patch new file mode 100644 index 0000000000..d9e88e4838 --- /dev/null +++ b/target/linux/ipq50xx/patches/421-mtd-rawnand-winbond-add-support-for-W25N01GW.patch @@ -0,0 +1,26 @@ +From 41d22a684adaaa54f379cd087a73aaa1859415fc Mon Sep 17 00:00:00 2001 +From: hzy +Date: Thu, 13 Jun 2024 22:09:57 +0800 +Subject: [PATCH 1/1] mtd: rawnand: winbond: add support for W25N01GW + +--- + drivers/mtd/nand/raw/nand_ids.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/mtd/nand/raw/nand_ids.c b/drivers/mtd/nand/raw/nand_ids.c +index fd64d9f..0f1ef87 100644 +--- a/drivers/mtd/nand/raw/nand_ids.c ++++ b/drivers/mtd/nand/raw/nand_ids.c +@@ -74,6 +74,9 @@ struct nand_flash_dev nand_flash_ids[] = { + {"GD5F1GQ5REYIH SPI NAND 1G 1.8V", + { .id = {0xc8, 0x21} }, + SZ_2K, SZ_128, SZ_128K, 0, 2, 64, NAND_ECC_INFO(4, SZ_512) }, ++ {"W25N01GW SPI NAND 1.8V 1G-BIT", ++ { .id = {0xef, 0xba} }, ++ SZ_2K, SZ_128, SZ_128K, 0, 2, 64, NAND_ECC_INFO(4, SZ_512) }, + {"W25N01JW SPI NAND 1.8V 1G-BIT", + { .id = {0xef, 0xbc} }, + SZ_2K, SZ_128, SZ_128K, 0, 2, 64, NAND_ECC_INFO(4, SZ_512) }, +-- +2.40.1 +