From acc2592fe686cbe63bd2061f9c52bd229ce745f1 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Sun, 15 Jun 2025 22:03:36 +0800 Subject: [PATCH] qualcommax: sync ipq50xx with upstream source --- .../arch/arm64/boot/dts/qcom/ipq5018-ess.dtsi | 2 + .../arm64/boot/dts/qcom/ipq5018-gl-b3000.dts | 516 +++++++++--------- .../arm64/boot/dts/qcom/ipq5018-mr5500.dts | 379 +++++++++++++ .../arm64/boot/dts/qcom/ipq5018-mx-base.dtsi | 6 - .../arm64/boot/dts/qcom/ipq5018-mx2000.dts | 16 +- .../arm64/boot/dts/qcom/ipq5018-mx5500.dts | 21 +- .../arm64/boot/dts/qcom/ipq5018-spnmx56.dts | 235 ++++++++ target/linux/qualcommax/image/ipq50xx.mk | 57 +- .../ipq50xx/base-files/etc/board.d/02_network | 12 +- .../etc/hotplug.d/firmware/11-ath11k-caldata | 28 +- .../ipq50xx/base-files/etc/init.d/bootcount | 4 +- .../base-files/lib/upgrade/platform.sh | 80 ++- 12 files changed, 1019 insertions(+), 337 deletions(-) create mode 100644 target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mr5500.dts create mode 100644 target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-spnmx56.dts diff --git a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-ess.dtsi b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-ess.dtsi index a42b7bbea..384d7e36f 100644 --- a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-ess.dtsi +++ b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-ess.dtsi @@ -59,10 +59,12 @@ resets = <&gcc GCC_GMAC0_BCR>, <&gcc GCC_GMAC1_BCR>, <&gcc GCC_UNIPHY_BCR>, + <&gcc GCC_UNIPHY_AHB_ARES>, <&gcc GCC_UNIPHY_SOFT_RESET>; reset-names = "gmac0_bcr_rst", "gmac1_bcr_rst", "uniphy_bcr_rst", + "uniphy1_ahb_rst", "uniphy1_soft_rst"; status = "disabled"; diff --git a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-gl-b3000.dts b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-gl-b3000.dts index 4ddfa2644..9bb1fabe8 100644 --- a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-gl-b3000.dts +++ b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-gl-b3000.dts @@ -1,31 +1,31 @@ -// SPDX-License-Identifier: (GPL-2.0+) +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT /dts-v1/; + #include "ipq5018.dtsi" #include "ipq5018-ess.dtsi" + #include #include +#include / { - #address-cells = <0x2>; - #size-cells = <0x2>; model = "GL.iNet GL-B3000"; compatible = "glinet,gl-b3000", "qcom,ipq5018"; - interrupt-parent = <&intc>; aliases { ethernet1 = &dp2; label-mac-device = &dp2; + led-boot = &led_system_blue; + led-failsafe = &led_status_white; + led-running = &led_status_white; + led-upgrade = &led_system_blue; serial0 = &blsp1_uart1; - led-boot = &led_blue; - led-failsafe = &led_blue; - led-running = &led_blue; - led-upgrade = &led_white; }; chosen { + bootargs-append = " root=/dev/ubiblock0_1 swiotlb=1 coherent_pool=2M"; stdout-path = "serial0:115200n8"; - bootargs-append = " root=/dev/ubiblock0_1"; }; keys { @@ -35,8 +35,8 @@ reset { label = "reset"; - linux,code = ; gpios = <&tlmm 27 GPIO_ACTIVE_LOW>; + linux,code = ; }; }; @@ -45,23 +45,20 @@ pinctrl-0 = <&leds_pins>; pinctrl-names = "default"; - led_blue: status_blue { - label = "blue:status"; + led_system_blue: led_system_blue { + color = ; + function = LED_FUNCTION_POWER; gpio = <&tlmm 24 GPIO_ACTIVE_HIGH>; }; - led_white: status_white { - label = "white:status"; + led_status_white: led_status_white { + color = ; + function = LED_FUNCTION_POWER; gpio = <&tlmm 23 GPIO_ACTIVE_HIGH>; }; }; reserved-memory { - tz_appps@4a400000 { - no-map; - reg = <0x0 0x4a400000 0x0 0x400000>; - }; - q6_mem_regions: q6_mem_regions@4b000000 { no-map; reg = <0x0 0x4b000000 0x0 0x3000000>; @@ -69,6 +66,118 @@ }; }; +&switch { + status = "okay"; + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy -> QCA8337 Phy2 + port@0 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + // MAC1 ---SGMII---> QCA8337 SerDes + port@1 { + port_id = <2>; + forced-speed = <1000>; + forced-duplex = <1>; + }; + }; +}; + +// MAC1 ---SGMII---> QCA8337 SerDes +&dp2 { + status = "okay"; + nvmem-cells = <&macaddr_dp2>; + nvmem-cell-names = "mac-address"; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&mdio0 { + status = "okay"; +}; + +&mdio1 { + status = "okay"; + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + // QCA8337 Phy0 -> WAN + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + // QCA8337 Phy1 -> LAN1 + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + // QCA8337 Phy3 -> LAN2 + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + // QCA8337 switch + switch0: ethernet-switch@17 { + compatible = "qca,qca8337"; + reg = <17>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + switch0cpu: port@0 { + reg = <0>; + label = "cpu"; + phy-mode = "sgmii"; + ethernet = <&dp2>; + qca,sgmii-enable-pll; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + + // QCA8337 Phy0 -> WAN + port@1 { + reg = <1>; + label = "wan"; + phy-handle = <&qca8337_0>; + }; + + // QCA8337 Phy1 -> LAN1 + port@2 { + reg = <2>; + label = "lan1"; + phy-handle = <&qca8337_1>; + + nvmem-cells = <&macaddr_dp2 2>; + nvmem-cell-names = "mac-address"; + }; + + // QCA8337 Phy3 -> LAN2 + port@3 { + reg = <3>; + label = "lan2"; + phy-handle = <&qca8337_2>; + + nvmem-cells = <&macaddr_dp2 2>; + nvmem-cell-names = "mac-address"; + }; + }; + }; +}; + &sleep_clk { clock-frequency = <32000>; }; @@ -78,7 +187,7 @@ }; &blsp1_uart1 { - pinctrl-0 = <&blsp0_uart_pins>; + pinctrl-0 = <&serial_0_pins>; pinctrl-names = "default"; status = "okay"; }; @@ -91,184 +200,12 @@ status = "okay"; }; -&dp1 { - status = "okay"; -}; - -&dp2 { - phy-mode = "sgmii"; - status = "okay"; - - fixed-link { - speed = <1000>; - full-duplex; - }; -}; - -&ge_phy { - status = "okay"; -}; - -&mdio0 { - status = "okay"; -}; - -&mdio1 { - pinctrl-0 = <&mdio1_pins>; - pinctrl-names = "default"; - reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; - status = "okay"; - - // QCA8337 Phy0 -> WAN - qca8337_0: ethernet-phy@0 { - reg = <0>; - }; - // QCA8337 Phy1 -> LAN1 - qca8337_1: ethernet-phy@1 { - reg = <1>; - }; - // QCA8337 Phy3 -> LAN2 - qca8337_2: ethernet-phy@2 { - reg = <2>; - }; - // QCA8337 Phy2 -> IPQ5018 GE Phy - qca8337_3: ethernet-phy@3 { - reg = <3>; - }; - // QCA8337 switch - switch0: ethernet-switch@17 { - compatible = "qca,qca8337"; - reg = <17>; - #address-cells = <1>; - #size-cells = <0>; - switch_cpu_bmp = <0x40>; /* cpu port bitmap */ - switch_lan_bmp = <0x0c>; /* lan port bitmap */ - switch_wan_bmp = <0x02>; /* wan port bitmap */ - - ports { - #address-cells = <1>; - #size-cells = <0>; - - switch0cpu: port@0 { - reg = <0>; - label = "cpu"; - phy-mode = "sgmii"; - ethernet = <&dp2>; - qca,sgmii-enable-pll; - fixed-link { - speed = <1000>; - full-duplex; - }; - }; - // QCA8337 Phy0 -> WAN - port@1 { - reg = <1>; - label = "wan"; - phy-handle = <&qca8337_0>; - port_id = <1>; - phy_address = <0>; - }; - - // QCA8337 Phy1 -> LAN1 - port@2 { - reg = <2>; - label = "lan1"; - phy-handle = <&qca8337_1>; - port_id = <2>; - phy_address = <1>; - }; - // QCA8337 Phy3 -> LAN2 - port@3 { - reg = <3>; - label = "lan2"; - phy-handle = <&qca8337_2>; - port_id = <3>; - phy_address = <2>; - }; - }; - }; -}; - &prng { status = "okay"; }; -&q6v5_wcss { +&qfprom { status = "okay"; - memory-region = <&q6_mem_regions>; - firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt", - "ath11k/IPQ5018/hw1.0/m3_fw.mdt", - "ath11k/qcn6122/hw1.0/m3_fw.mdt"; - - boot-args = - ; - - // IPQ5018 - q6_wcss_pd1: pd-1 { - firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt"; - 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"; - - 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"; - }; - - // QCN6102 5G - q6_wcss_pd3: pd-3 { - firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt"; - interrupts-extended = - <&wcss_smp2p_in 24 0>, - <&wcss_smp2p_in 25 0>, - <&wcss_smp2p_in 28 0>, - <&wcss_smp2p_in 27 0>; - interrupt-names = - "fatal", - "ready", - "spawn-ack", - "stop-ack"; - qcom,smem-states = - <&wcss_smp2p_out 24>, - <&wcss_smp2p_out 25>, - <&wcss_smp2p_out 26>; - qcom,smem-state-names = - "shutdown", - "stop", - "spawn"; - }; }; &qpic_bam { @@ -282,69 +219,40 @@ nand@0 { compatible = "spi-nand"; + reg = <0>; #address-cells = <1>; #size-cells = <1>; - reg = <0>; nand-ecc-engine = <&qpic_nand>; - nand-ecc-strength = <4>; - nand-ecc-step-size = <512>; nand-bus-width = <8>; partitions { compatible = "qcom,smem-part"; - }; - }; -}; -&switch { - switch_mac_mode = ; - status = "okay"; + partition-0-art { + compatible = "fixed-partitions"; + label = "0:ART"; + read-only; + #address-cells = <1>; + #size-cells = <1>; - qcom,port_phyinfo { - // MAC0 -> GE Phy -> QCA8337 Phy2 - port@0 { - port_id = <1>; - mdiobus = <&mdio0>; - phy_address = <7>; - phy_dac = <0x10 0x10>; - }; - // MAC1 ---SGMII---> QCA8337 SerDes - port@1 { - port_id = <2>; - forced-speed = <1000>; - forced-duplex = <1>; + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_dp2: macaddr@0 { + compatible = "mac-base"; + #nvmem-cell-cells = <1>; + reg = <0x0 0x6>; + }; + }; + }; }; }; }; &tlmm { - blsp0_uart_pins: uart_pins { - blsp0_uart_rx_tx { - pins = "gpio20", "gpio21"; - function = "blsp0_uart0"; - bias-disable; - }; - }; - - button_pins: button_pins { - mux { - pins = "gpio27"; - function = "gpio"; - drive-strength = <8>; - bias-pull-up; - }; - }; - - leds_pins: leds_pins { - mux { - pins = "gpio23", "gpio24"; - function = "gpio"; - drive-strength = <8>; - bias-pull-down; - }; - }; - mdio1_pins: mdio-state { mdc-pins { pins = "gpio36"; @@ -352,6 +260,7 @@ drive-strength = <8>; bias-pull-up; }; + mdio-pins { pins = "gpio37"; function = "mdio"; @@ -360,6 +269,20 @@ }; }; + leds_pins: leds-pins { + pins = "gpio23", "gpio24"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + button_pins: button-pins { + pins = "gpio27"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + qpic_pins: qpic-state { clock-pins { pins = "gpio9"; @@ -367,12 +290,14 @@ drive-strength = <8>; bias-disable; }; + cs-pins { pins = "gpio8"; function = "qspi_cs"; drive-strength = <8>; bias-disable; }; + data-pins { pins = "gpio4", "gpio5", "gpio6", "gpio7"; function = "qspi_data"; @@ -380,23 +305,124 @@ bias-disable; }; }; + + serial_0_pins: uart0-state { + pins = "gpio20", "gpio21"; + function = "blsp0_uart0"; + drive-strength = <8>; + bias-disable; + }; +}; + +&tsens { + status = "okay"; +}; + +&q6v5_wcss { + status = "okay"; + + memory-region = <&q6_mem_regions>; + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt", + "ath11k/IPQ5018/hw1.0/m3_fw.mdt", + "ath11k/QCN6122/hw1.0/m3_fw.mdt"; + + /* B3000 currently doesn't support passing bootargs */ + /*boot-args = < */ + /* type: 0x1 PCIE0 */ + /* length: 4 */ + /* PD id: 3 */ + /* reset GPIO: 15 */ + /* reserved: 0 0>; */ + + // IPQ5018 + q6_wcss_pd1: pd-1 { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt"; + + 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"; + + // qcom,halt-regs = <&tcsr_q6_block 0xa000 0xd000 0x0>; + interrupts-extended = + <&wcss_smp2p_in 8 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 9 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 12 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 11 IRQ_TYPE_NONE>; + 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"; + }; + + // QCN6102 5G + q6_wcss_pd3: pd-3 { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt"; + + interrupts-extended = + <&wcss_smp2p_in 24 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 25 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 28 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 27 IRQ_TYPE_NONE>; + interrupt-names = + "fatal", + "ready", + "spawn-ack", + "stop-ack"; + + qcom,smem-states = + <&wcss_smp2p_out 24>, + <&wcss_smp2p_out 25>, + <&wcss_smp2p_out 26>; + qcom,smem-state-names = + "shutdown", + "stop", + "spawn"; + }; }; &wifi0 { + // IPQ5018 + status = "okay"; + qcom,rproc = <&q6_wcss_pd1>; qcom,userpd-subsys-name = "q6v5_wcss_userpd1"; qcom,ath11k-calibration-variant = "GL-iNet-GL-B3000"; - qcom,ath11k-fw-memory-mode = <2>; + qcom,ath11k-fw-memory-mode = <1>; qcom,bdf-addr = <0x4c400000>; - status = "okay"; }; &wifi1 { + // QCN6102 5G + status = "okay"; + qcom,rproc = <&q6_wcss_pd3>; qcom,userpd-subsys-name = "q6v5_wcss_userpd3"; qcom,ath11k-calibration-variant = "GL-iNet-GL-B3000"; - qcom,ath11k-fw-memory-mode = <2>; + qcom,ath11k-fw-memory-mode = <1>; qcom,bdf-addr = <0x4d100000>; qcom,m3-dump-addr = <0x4df00000>; - status = "okay"; }; diff --git a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mr5500.dts b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mr5500.dts new file mode 100644 index 000000000..a92a60482 --- /dev/null +++ b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mr5500.dts @@ -0,0 +1,379 @@ +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-mx-base.dtsi" + +/ { + model = "Linksys MR5500"; + compatible = "linksys,mr5500", "qcom,ipq5018"; + + gpio-leds { + compatible = "gpio-leds"; + + usb { + color = ; + function = LED_FUNCTION_USB; + gpios = <&tlmm 19 GPIO_ACTIVE_HIGH>; + trigger-sources = <&usb_port1>; + linux,default-trigger = "usbport"; + }; + }; + + regulator_fixed_5p0: regulator-s0500 { + compatible = "regulator-fixed"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <500000>; + regulator-name = "fixed_5p0"; + gpio = <&tlmm 17 GPIO_ACTIVE_LOW>; + }; +}; + +/* + * =============================================================== + * _______________________ _______________________ + * | IPQ5018 | | QCA8337 | + * | +------+ +--------+ | | +--------+ +------+ | + * | | MAC0 |---| GE Phy | | | | Phy0 |---| MAC1 | | + * | +------+ +--------+ | | +--------+ +------+ | + * | +------+ +--------+ | | +--------+ +------+ | + * | | MAC1 |---| Uniphy |-+-SGMII-+-| SerDes |---| MAC6 | | + * | +------+ +--------+ | | +--------+ +------+ | + * |_______________________| |_______________________| + * + * =============================================================== + */ + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy + port@0 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + // MAC1 ---SGMII---> QCA8337 SerDes + port@1 { + port_id = <2>; + forced-speed = <1000>; + forced-duplex = <1>; + }; + }; +}; + +// MAC1 ---SGMII---> QCA8337 SerDes +&dp2 { + status = "okay"; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&mdio0 { + status = "okay"; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + switch1: ethernet-switch@17 { + compatible = "qca,qca8337"; + reg = <17>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + label = "lan1"; + phy-handle = <&qca8337_0>; + phy-mode = "internal"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@2 { + reg = <2>; + label = "lan2"; + phy-handle = <&qca8337_1>; + phy-mode = "internal"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@3 { + reg = <3>; + label = "lan3"; + phy-handle = <&qca8337_2>; + phy-mode = "internal"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@4 { + reg = <4>; + label = "lan4"; + phy-handle = <&qca8337_3>; + phy-mode = "internal"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@5 { + reg = <5>; + label = "wan"; + phy-handle = <&qca8337_4>; + phy-mode = "internal"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + }; + }; + + port@6 { + reg = <6>; + label = "cpu"; + phy-mode = "sgmii"; + ethernet = <&dp2>; + qca,sgmii-enable-pll; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + // QCA8337 Phy0 -> LAN1 + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + // QCA8337 Phy1 -> LAN2 + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + // QCA8337 Phy2 -> LAN3 + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + // QCA8337 Phy3 -> LAN4 + qca8337_3: ethernet-phy@3 { + reg = <3>; + }; + + // QCA8337 Phy4 -> WAN + qca8337_4: ethernet-phy@4 { + reg = <4>; + }; + }; + }; +}; + +&usbphy0 { + status = "okay"; + + vdd-supply = <®ulator_fixed_5p0>; +}; + +&usb { + status = "okay"; + + vbus-supply = <®ulator_fixed_5p0>; +}; + +&usb_dwc { + #address-cells = <1>; + #size-cells = <0>; + dr_mode = "host"; + + usb_port1: port@1 { + reg = <1>; + #trigger-source-cells = <0>; + }; +}; + +&pcie0_phy { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + perst-gpios = <&tlmm 15 GPIO_ACTIVE_LOW>; + + pcie@0 { + wifi@0,0 { + status = "okay"; + + /* QCN9074: ath11k lacks DT compatible for PCI cards */ + compatible = "pci17cb,1104"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath11k-calibration-variant = "Linksys-MR5500"; + }; + }; +}; + +&q6v5_wcss { + status = "okay"; + + memory-region = <&q6_mem_regions>; + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt", + "ath11k/IPQ5018/hw1.0/m3_fw.mdt"; + + // IPQ5018 + q6_wcss_pd1: pd-1 { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt"; + + 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"; + + 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"; + }; +}; + +&wifi0 { + // IPQ5018 + qcom,rproc = <&q6_wcss_pd1>; + qcom,ath11k-calibration-variant = "Linksys-MR5500"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4c400000>; + + status = "okay"; +}; diff --git a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx-base.dtsi b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx-base.dtsi index 57fe5c53a..27d023692 100644 --- a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx-base.dtsi +++ b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx-base.dtsi @@ -6,10 +6,7 @@ #include / { - aliases { - ethernet0 = &dp1; - ethernet1 = &dp2; led-boot = &led_system_blue; led-failsafe = &led_system_red; led-running = &led_system_blue; @@ -132,9 +129,6 @@ #size-cells = <1>; nand-ecc-engine = <&qpic_nand>; - - nand-ecc-strength = <8>; - nand-ecc-step-size = <512>; nand-bus-width = <8>; partitions { diff --git a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx2000.dts b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx2000.dts index db045d9a5..e254f0343 100644 --- a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx2000.dts +++ b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx2000.dts @@ -48,7 +48,6 @@ // MAC1 ---SGMII---> QCA8337 SerDes &dp2 { status = "okay"; - phy-mode = "sgmii"; fixed-link { speed = <1000>; @@ -60,13 +59,6 @@ status = "okay"; }; -/* IPQ5018 GE Phy -> Not connected - * needs to be enabled for QSDK to identify the IPQ5018 dummy switch - */ -&ge_phy { - status = "okay"; -}; - &mdio1 { status = "okay"; @@ -155,8 +147,8 @@ memory-region = <&q6_mem_regions>; firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt", - "ath11k/IPQ5018/hw1.0/m3_fw.mdt", - "ath11k/QCN6122/hw1.0/m3_fw.mdt"; + "ath11k/IPQ5018/hw1.0/m3_fw.mdt", + "ath11k/QCN6122/hw1.0/m3_fw.mdt"; /* The QCN6102 radio should map to UPD ID 2. Without */ /* bootargs, the firmware will expect it to be on UPD ID 3 */ @@ -243,7 +235,7 @@ // IPQ5018 qcom,rproc = <&q6_wcss_pd1>; qcom,ath11k-calibration-variant = "Linksys-MX2000"; - qcom,ath11k-fw-memory-mode = <2>; + qcom,ath11k-fw-memory-mode = <1>; qcom,bdf-addr = <0x4c400000>; status = "okay"; @@ -254,7 +246,7 @@ qcom,rproc = <&q6_wcss_pd2>; qcom,userpd-subsys-name = "q6v5_wcss_userpd2"; qcom,ath11k-calibration-variant = "Linksys-MX2000"; - qcom,ath11k-fw-memory-mode = <2>; + qcom,ath11k-fw-memory-mode = <1>; qcom,bdf-addr = <0x4d100000>; qcom,m3-dump-addr = <0x4df00000>; diff --git a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx5500.dts b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx5500.dts index 43672d3b5..f7a6936b3 100644 --- a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx5500.dts +++ b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-mx5500.dts @@ -48,7 +48,6 @@ // MAC1 ---SGMII---> QCA8337 SerDes &dp2 { status = "okay"; - phy-mode = "sgmii"; fixed-link { speed = <1000>; @@ -60,13 +59,6 @@ status = "okay"; }; -/* IPQ5018 GE Phy -> Not connected - * needs to be enabled for QSDK to identify the IPQ5018 dummy switch - */ -&ge_phy { - status = "okay"; -}; - &mdio1 { status = "okay"; @@ -159,13 +151,8 @@ perst-gpios = <&tlmm 15 GPIO_ACTIVE_LOW>; - bridge@0,0 { - reg = <0x00000000 0 0 0 0>; - #address-cells = <3>; - #size-cells = <2>; - ranges; - - wifi@1,0 { + pcie@0 { + wifi@0,0 { status = "okay"; /* QCN9074: ath11k lacks DT compatible for PCI cards */ @@ -182,7 +169,7 @@ memory-region = <&q6_mem_regions>; firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt", - "ath11k/IPQ5018/hw1.0/m3_fw.mdt"; + "ath11k/IPQ5018/hw1.0/m3_fw.mdt"; // IPQ5018 q6_wcss_pd1: pd-1 { @@ -233,7 +220,7 @@ // IPQ5018 qcom,rproc = <&q6_wcss_pd1>; qcom,ath11k-calibration-variant = "Linksys-MX5500"; - qcom,ath11k-fw-memory-mode = <2>; + qcom,ath11k-fw-memory-mode = <1>; qcom,bdf-addr = <0x4c400000>; status = "okay"; diff --git a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-spnmx56.dts b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-spnmx56.dts new file mode 100644 index 000000000..dc287ce5f --- /dev/null +++ b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-spnmx56.dts @@ -0,0 +1,235 @@ +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-mx-base.dtsi" + +/ { + model = "Linksys SPNMX56"; + compatible = "linksys,spnmx56", "qcom,ipq5018"; +}; + +/* +* ================================================================= +* _______________________ _______________________ +* | IPQ5018 | | QCA8337 | +* | +------+ +--------+ | | +--------+ +------+ | +* | | MAC0 |---| GE Phy |-+--- MDI ---+ | Phy4 |---| MAC5 | | +* | +------+ +--------+ | | +--------+ +------+ | +* | | |_______________________| +* | | _______________________ +* | | | QCA8081 | +* | +------+ +--------+ | | +--------+ +------+ | +* | | MAC1 |---| Uniphy |-+-- SGMII+--+ | Phy |---| MAC | | +* | +------+ +--------+ | | +--------+ +------+ | +* |_______________________| |_______________________| +* +* ================================================================= +*/ + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy --- MDI --- QCA8337 Switch + port@0 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + phy_dac = <0x10 0x10>; + }; + + // MAC1 -> Uniphy --- SGMII --- QCA8081 + port@1 { + port_id = <2>; + mdiobus = <&mdio1>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +// MAC0 -> GE Phy +&dp1 { + status = "okay"; +}; + +// MAC1 ---SGMII---> QCA8081 +&dp2 { + status = "okay"; + + label = "wan"; + phy-handle = <&qca8081>; +}; + +&mdio0 { + status = "okay"; +}; + +// IPQ5018 GE Phy -> QCA8337 PHY4 +&ge_phy { + qcom,dac-preset-short-cable; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + // Not connected + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + // QCA8337 Phy1 -> LAN1 + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + // QCA8337 Phy2 -> LAN2 + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + // QCA8337 Phy3 -> LAN3 + qca8337_3: ethernet-phy@3 { + reg = <3>; + }; + + // QCA8337 Phy4 -> MDI -> IPQ5018 GE PHY + qca8337_4: ethernet-phy@4 { + reg = <4>; + }; + + // QCA8081 Phy -> WAN + qca8081: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 24 GPIO_ACTIVE_LOW>; + }; + + // QCA8337 switch + switch1: ethernet-switch@17 { + compatible = "qca,qca8337"; + reg = <17>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@2 { + reg = <2>; + label = "lan3"; + phy-handle = <&qca8337_1>; + }; + + port@3 { + reg = <3>; + label = "lan2"; + phy-handle = <&qca8337_2>; + }; + + port@4 { + reg = <4>; + label = "lan1"; + phy-handle = <&qca8337_3>; + }; + + port@5 { + reg = <5>; + phy-handle = <&qca8337_4>; + phy-mode = "gmii"; + ethernet = <&dp1>; + }; + }; + }; +}; + +&pcie0_phy { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + perst-gpios = <&tlmm 15 GPIO_ACTIVE_LOW>; + + pcie@0 { + wifi@0,0 { + status = "okay"; + + /* QCN9074: ath11k lacks DT compatible for PCI cards */ + compatible = "pci17cb,1104"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath11k-calibration-variant = "Linksys-SPNMX56"; + }; + }; +}; + +&q6v5_wcss { + status = "okay"; + + memory-region = <&q6_mem_regions>; + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt", + "ath11k/IPQ5018/hw1.0/m3_fw.mdt"; + + // IPQ5018 + q6_wcss_pd1: pd-1 { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt"; + + 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"; + + 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"; + }; +}; + +&wifi0 { + // IPQ5018 + qcom,rproc = <&q6_wcss_pd1>; + qcom,ath11k-calibration-variant = "Linksys-SPNMX56"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4c400000>; + + status = "okay"; +}; diff --git a/target/linux/qualcommax/image/ipq50xx.mk b/target/linux/qualcommax/image/ipq50xx.mk index 2de1b7669..661f18cd4 100644 --- a/target/linux/qualcommax/image/ipq50xx.mk +++ b/target/linux/qualcommax/image/ipq50xx.mk @@ -5,29 +5,21 @@ define Device/EmmcImage IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-to 64k | sysupgrade-tar rootfs=$$$$@ | append-metadata endef -define Device/cmcc_rax3000q - $(call Device/FitImage) - $(call Device/UbiFit) - SOC := ipq5018 - DEVICE_VENDOR := CMCC - DEVICE_MODEL := RAX3000Q - BLOCKSIZE := 128k - PAGESIZE := 2048 - DEVICE_DTS_CONFIG := config@mp02.1 - DEVICE_PACKAGES := ath11k-firmware-qcn6122 ipq-wifi-cmcc_rax3000q -endef -TARGET_DEVICES += cmcc_rax3000q - define Device/glinet_gl-b3000 - $(call Device/FitImage) - $(call Device/UbiFit) - SOC := ipq5018 - DEVICE_VENDOR := GL.iNET - DEVICE_MODEL := GL-B3000 - BLOCKSIZE := 128k - PAGESIZE := 2048 - DEVICE_DTS_CONFIG := config@mp03.5-c1 - DEVICE_PACKAGES := ath11k-firmware-qcn6122 ipq-wifi-gl-b3000 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := GL.iNet + DEVICE_MODEL := GL-B3000 + SOC := ipq5018 + KERNEL_IN_UBI := 1 + BLOCKSIZE := 128k + PAGESIZE := 2048 + NAND_SIZE := 128m + DEVICE_DTS_CONFIG := config@mp03.5-c1 + SUPPORTED_DEVICES += b3000 + DEVICE_PACKAGES := \ + ath11k-firmware-qcn6122 \ + ipq-wifi-glinet_gl-b3000 endef TARGET_DEVICES += glinet_gl-b3000 @@ -57,6 +49,17 @@ define Device/linksys_ipq50xx_mx_base append-ubi | linksys-image type=$$$$(DEVICE_MODEL) endef +define Device/linksys_mr5500 + $(call Device/linksys_ipq50xx_mx_base) + DEVICE_MODEL := MR5500 + DEVICE_DTS_CONFIG := config@mp03.1 + DEVICE_PACKAGES := kmod-ath11k-pci \ + ath11k-firmware-qcn9074 \ + ipq-wifi-linksys_mr5500 \ + kmod-usb-ledtrig-usbport +endef +TARGET_DEVICES += linksys_mr5500 + define Device/linksys_mx2000 $(call Device/linksys_ipq50xx_mx_base) DEVICE_MODEL := MX2000 @@ -75,3 +78,13 @@ define Device/linksys_mx5500 ipq-wifi-linksys_mx5500 endef TARGET_DEVICES += linksys_mx5500 + +define Device/linksys_spnmx56 + $(call Device/linksys_ipq50xx_mx_base) + DEVICE_MODEL := SPNMX56 + DEVICE_DTS_CONFIG := config@mp03.1 + DEVICE_PACKAGES := kmod-ath11k-pci \ + ath11k-firmware-qcn9074 \ + ipq-wifi-linksys_spnmx56 +endef +TARGET_DEVICES += linksys_spnmx56 diff --git a/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/02_network b/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/02_network index 0beda336f..ef881c940 100644 --- a/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/02_network +++ b/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/02_network @@ -10,12 +10,15 @@ ipq50xx_setup_interfaces() glinet,gl-b3000) ucidef_set_interfaces_lan_wan "lan1 lan2" "wan" ;; - cmcc,rax3000q|\ jdcloud,re-cs-03|\ linksys,mx2000|\ - linksys,mx5500) + linksys,mx5500|\ + linksys,spnmx56) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" ;; + linksys,mr5500) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan" + ;; esac } @@ -27,12 +30,13 @@ ipq50xx_setup_macs() local label_mac="" case "$board" in + linksys,mr5500|\ linksys,mx2000|\ - linksys,mx5500) + linksys,mx5500|\ + linksys,spnmx56) label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr) lan_mac=$label_mac wan_mac=$label_mac - ucidef_set_network_device_mac eth0 $label_mac ;; esac diff --git a/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata b/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata index e815bc17f..890525190 100644 --- a/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata +++ b/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata @@ -9,18 +9,15 @@ board=$(board_name) case "$FIRMWARE" in "ath11k/IPQ5018/hw1.0/cal-ahb-c000000.wifi.bin") case "$board" in - cmcc,rax3000q|\ glinet,gl-b3000) - caldata_extract "0:ART" 0x1000 0x20000 - addr=$(mtd_get_mac_binary "0:ART" 0x6) - ath11k_patch_mac $(macaddr_add $addr 3) 0 + caldata_extract "0:art" 0x1000 0x20000 + ath11k_patch_mac $(macaddr_add $(get_mac_label_dt) 3) 0 ath11k_set_macflag ;; - jdcloud,re-cs-03) - caldata_extract_mmc "0:ART" 0x1000 0x20000 - ;; + linksys,mr5500|\ linksys,mx2000|\ - linksys,mx5500) + linksys,mx5500|\ + linksys,spnmx56) caldata_extract "0:ART" 0x1000 0x20000 label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr) ath11k_patch_mac $(macaddr_add $label_mac 1) 0 @@ -31,16 +28,11 @@ case "$FIRMWARE" in ;; "ath11k/QCN6122/hw1.0/cal-ahb-b00a040.wifi1.bin") case "$board" in - cmcc,rax3000q|\ glinet,gl-b3000) - caldata_extract "0:ART" 0x26800 0x20000 - addr=$(mtd_get_mac_binary "0:ART" 0x6) - ath11k_patch_mac $(macaddr_add $addr 4) 0 + caldata_extract "0:art" 0x26800 0x20000 + ath11k_patch_mac $(macaddr_add $(get_mac_label_dt) 4) 0 ath11k_set_macflag ;; - jdcloud,re-cs-03) - caldata_extract_mmc "0:ART" 0x26800 0x20000 - ;; linksys,mx2000) caldata_extract "0:ART" 0x26800 0x20000 label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr) @@ -50,9 +42,11 @@ case "$FIRMWARE" in ;; esac ;; -"ath11k/QCN9074/hw1.0/cal-pci-0001:01:00.0.bin") +"ath11k/QCN9074/hw1.0/cal-pci-0000:01:00.0.bin") case "$board" in - linksys,mx5500) + linksys,mr5500|\ + linksys,mx5500|\ + linksys,spnmx56) caldata_extract "0:ART" 0x26800 0x20000 label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr) ath11k_patch_mac $(macaddr_add $label_mac 2) 0 diff --git a/target/linux/qualcommax/ipq50xx/base-files/etc/init.d/bootcount b/target/linux/qualcommax/ipq50xx/base-files/etc/init.d/bootcount index b570428ae..0e573a140 100755 --- a/target/linux/qualcommax/ipq50xx/base-files/etc/init.d/bootcount +++ b/target/linux/qualcommax/ipq50xx/base-files/etc/init.d/bootcount @@ -4,8 +4,10 @@ START=99 boot() { case $(board_name) in + linksys,mr5500|\ linksys,mx2000|\ - linksys,mx5500) + linksys,mx5500|\ + linksys,spnmx56) mtd resetbc s_env || true ;; esac diff --git a/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh b/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh index cb5ae74e7..23733a009 100644 --- a/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh @@ -1,9 +1,70 @@ PART_NAME=firmware REQUIRE_IMAGE_METADATA=1 -RAMFS_COPY_BIN='fw_printenv fw_setenv head' +RAMFS_COPY_BIN='dumpimage fw_printenv fw_setenv head seq' RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' +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 +} + +linksys_mx_pre_upgrade() { + local setenv_script="/tmp/fw_env_upgrade" + + CI_UBIPART="rootfs" + boot_part="$(fw_printenv -n boot_part)" + if [ -n "$UPGRADE_OPT_USE_CURR_PART" ]; then + if [ "$boot_part" -eq "2" ]; then + CI_KERNPART="alt_kernel" + CI_UBIPART="alt_rootfs" + fi + else + if [ "$boot_part" -eq "1" ]; then + echo "boot_part 2" >> $setenv_script + CI_KERNPART="alt_kernel" + CI_UBIPART="alt_rootfs" + else + echo "boot_part 1" >> $setenv_script + fi + fi + + boot_part_ready="$(fw_printenv -n boot_part_ready)" + if [ "$boot_part_ready" -ne "3" ]; then + echo "boot_part_ready 3" >> $setenv_script + fi + + auto_recovery="$(fw_printenv -n auto_recovery)" + if [ "$auto_recovery" != "yes" ]; then + echo "auto_recovery yes" >> $setenv_script + fi + + if [ -f "$setenv_script" ]; then + fw_setenv -s $setenv_script || { + echo "failed to update U-Boot environment" + return 1 + } + fi +} + platform_check_image() { return 0; } @@ -18,19 +79,12 @@ platform_do_upgrade() { CI_ROOTPART="rootfs" emmc_do_upgrade "$1" ;; + linksys,mr5500|\ linksys,mx2000|\ - linksys,mx5500) - 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 + linksys,mx5500|\ + linksys,spnmx56) + linksys_mx_pre_upgrade "$1" + remove_oem_ubi_volume squashfs nand_do_upgrade "$1" ;; *)