From 28783931f18e08f6b75efd793207d3812476e34f Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Sat, 10 Jun 2023 16:42:30 +0800 Subject: [PATCH] mediatek: remove stock layout for 360 t7 The factory bootloader doesn't allow to boot with 3rd-party firmware, so this "stock" layout is mostly useless. Signed-off-by: Tianling Shen (cherry picked from commit 7944d7a3da2c47b2e78a32ccdd81d65da1c55b43) --- .../uboot-envtools/files/mediatek_filogic | 3 +- .../mediatek/dts/mt7981b-livinet-zr-3020.dts | 111 +++++----- .../dts/mt7981b-qihoo-360-t7-stock.dts | 26 --- .../dts/mt7981b-qihoo-360-t7-ubootmod.dts | 16 -- ....dtsi => mt7981b-qihoo-360t7-ubootmod.dts} | 202 ++++++++++-------- .../filogic/base-files/etc/board.d/02_network | 13 +- .../etc/hotplug.d/ieee80211/11_fix_wifi_mac | 8 +- target/linux/mediatek/image/filogic.mk | 56 ++--- 8 files changed, 195 insertions(+), 240 deletions(-) delete mode 100644 target/linux/mediatek/dts/mt7981b-qihoo-360-t7-stock.dts delete mode 100644 target/linux/mediatek/dts/mt7981b-qihoo-360-t7-ubootmod.dts rename target/linux/mediatek/dts/{mt7981b-qihoo-360-t7.dtsi => mt7981b-qihoo-360t7-ubootmod.dts} (88%) diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic index d1098f5215..ed645d5896 100644 --- a/package/boot/uboot-envtools/files/mediatek_filogic +++ b/package/boot/uboot-envtools/files/mediatek_filogic @@ -38,8 +38,7 @@ bananapi,bpi-r3) esac ;; livinet,zr-3020|\ -qihoo,360-t7-stock|\ -qihoo,360-t7-ubootmod) +qihoo,360t7-ubootmod) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" "1" ;; xiaomi,redmi-router-ax6000|\ diff --git a/target/linux/mediatek/dts/mt7981b-livinet-zr-3020.dts b/target/linux/mediatek/dts/mt7981b-livinet-zr-3020.dts index 44a159e4d3..751d0923cb 100644 --- a/target/linux/mediatek/dts/mt7981b-livinet-zr-3020.dts +++ b/target/linux/mediatek/dts/mt7981b-livinet-zr-3020.dts @@ -4,6 +4,9 @@ */ /dts-v1/; +#include +#include + #include "mt7981.dtsi" / { @@ -83,14 +86,6 @@ }; }; -&uart0 { - status = "okay"; -}; - -&watchdog { - status = "okay"; -}; - ð { status = "okay"; @@ -111,10 +106,9 @@ }; &mdio_bus { - switch0: switch@0 { + switch: switch@0 { compatible = "mediatek,mt7531"; reg = <31>; - dsa,member = <0 0>; reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>; interrupt-controller; #interrupt-cells = <1>; @@ -123,48 +117,6 @@ }; }; -&switch0 { - ports { - #address-cells = <1>; - #size-cells = <0>; - - port@0 { - reg = <0>; - label = "wan"; - - nvmem-cells = <&macaddr_config_50787>; - nvmem-cell-names = "mac-address-ascii"; - }; - - port@2 { - reg = <2>; - label = "lan1"; - }; - - port@3 { - reg = <3>; - label = "lan2"; - }; - - port@4 { - reg = <4>; - label = "lan3"; - }; - - port@6 { - reg = <6>; - ethernet = <&gmac0>; - phy-mode = "2500base-x"; - - fixed-link { - speed = <2500>; - full-duplex; - pause; - }; - }; - }; -}; - &spi0 { pinctrl-names = "default"; pinctrl-0 = <&spi0_flash_pins>; @@ -227,6 +179,7 @@ partition@6680000 { label = "config2"; reg = <0x6680000 0x100000>; + read-only; compatible = "nvmem-cells"; #address-cells = <1>; @@ -248,6 +201,48 @@ }; }; +&switch { + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "wan"; + + nvmem-cells = <&macaddr_config_50787>; + nvmem-cell-names = "mac-address-ascii"; + }; + + port@2 { + reg = <2>; + label = "lan1"; + }; + + port@3 { + reg = <3>; + label = "lan2"; + }; + + port@4 { + reg = <4>; + label = "lan3"; + }; + + port@6 { + reg = <6>; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + }; +}; + &pio { i2c_pins: i2c-pins-g0 { mux { @@ -318,11 +313,19 @@ }; }; +&uart0 { + status = "okay"; +}; + +&watchdog { + status = "okay"; +}; + &wifi { + status = "okay"; + mediatek,mtd-eeprom = <&factory 0x0>; nvmem-cells = <&macaddr_config_5068a>; nvmem-cell-names = "mac-address-ascii"; - - status = "okay"; }; diff --git a/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-stock.dts b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-stock.dts deleted file mode 100644 index 46af2ba8a5..0000000000 --- a/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-stock.dts +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT - -/dts-v1/; -#include "mt7981b-qihoo-360-t7.dtsi" - -/ { - model = "Qihoo 360 T7 (stock layout)"; - compatible = "qihoo,360-t7-stock", "mediatek,mt7981"; -}; - -&partitions { - partition@580000 { - label = "ubi"; - reg = <0x580000 0x2400000>; - }; - - partition@2980000 { - label = "firmware-1"; - reg = <0x2980000 0x2400000>; - }; - - partition@4D80000 { - label = "plugin"; - reg = <0x4d80000 0x2400000>; - }; -}; diff --git a/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-ubootmod.dts b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-ubootmod.dts deleted file mode 100644 index cba370cf0c..0000000000 --- a/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-ubootmod.dts +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT - -/dts-v1/; -#include "mt7981b-qihoo-360-t7.dtsi" - -/ { - model = "Qihoo 360 T7 (modified U-Boot layout)"; - compatible = "qihoo,360-t7-ubootmod", "mediatek,mt7981"; -}; - -&partitions { - partition@580000 { - label = "ubi"; - reg = <0x580000 0x6c00000>; - }; -}; diff --git a/target/linux/mediatek/dts/mt7981b-qihoo-360-t7.dtsi b/target/linux/mediatek/dts/mt7981b-qihoo-360t7-ubootmod.dts similarity index 88% rename from target/linux/mediatek/dts/mt7981b-qihoo-360-t7.dtsi rename to target/linux/mediatek/dts/mt7981b-qihoo-360t7-ubootmod.dts index 3136068ddc..9a24783aa5 100644 --- a/target/linux/mediatek/dts/mt7981b-qihoo-360-t7.dtsi +++ b/target/linux/mediatek/dts/mt7981b-qihoo-360t7-ubootmod.dts @@ -1,9 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT /dts-v1/; +#include +#include + #include "mt7981.dtsi" / { + model = "Qihoo 360T7 (modified U-Boot layout)"; + compatible = "qihoo,360t7-ubootmod", "mediatek,mt7981"; + + aliases { led-boot = &red_led; led-failsafe = &red_led; @@ -47,14 +54,6 @@ }; }; -&uart0 { - status = "okay"; -}; - -&watchdog { - status = "okay"; -}; - ð { pinctrl-names = "default"; pinctrl-0 = <&mdio_pins>; @@ -78,10 +77,9 @@ }; &mdio_bus { - switch0: switch@0 { + switch: switch@0 { compatible = "mediatek,mt7531"; reg = <31>; - dsa,member = <0 0>; reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>; interrupt-controller; #interrupt-cells = <1>; @@ -90,7 +88,92 @@ }; }; -&switch0 { +&spi0 { + pinctrl-names = "default"; + pinctrl-0 = <&spi0_flash_pins>; + status = "okay"; + + spi_nand: flash@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "spi-nand"; + reg = <0>; + spi-max-frequency = <52000000>; + + spi-cal-enable; + spi-cal-mode = "read-data"; + spi-cal-datalen = <7>; + spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4E 0x41 0x4E 0x44>; + spi-cal-addrlen = <5>; + spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>; + + spi-tx-buswidth = <4>; + spi-rx-buswidth = <4>; + mediatek,nmbm; + mediatek,bmt-max-ratio = <1>; + mediatek,bmt-max-reserved-blocks = <64>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "BL2"; + reg = <0x00000 0x100000>; + }; + + partition@100000 { + label = "u-boot-env"; + reg = <0x100000 0x80000>; + }; + + factory: partition@180000 { + label = "Factory"; + reg = <0x180000 0x200000>; + }; + + partition@380000 { + label = "FIP"; + reg = <0x380000 0x200000>; + }; + + partition@580000 { + label = "ubi"; + reg = <0x580000 0x6c00000>; + }; + + partition@7180000 { + label = "stock-config"; + reg = <0x7180000 0x100000>; + read-only; + }; + + partition@7280000 { + label = "stock-factory"; + reg = <0x7280000 0x80000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_14: macaddr@14 { + reg = <0x14 0x11>; + }; + + }; + + partition@7300000 { + label = "stock-log"; + reg = <0x7300000 0x400000>; + read-only; + }; + }; + }; +}; + +&switch { ports { #address-cells = <1>; #size-cells = <0>; @@ -133,83 +216,6 @@ }; }; -&spi0 { - pinctrl-names = "default"; - pinctrl-0 = <&spi0_flash_pins>; - status = "okay"; - - spi_nand: flash@0 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "spi-nand"; - reg = <0>; - spi-max-frequency = <52000000>; - - spi-cal-enable; - spi-cal-mode = "read-data"; - spi-cal-datalen = <7>; - spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4E 0x41 0x4E 0x44>; - spi-cal-addrlen = <5>; - spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>; - - spi-tx-buswidth = <4>; - spi-rx-buswidth = <4>; - mediatek,nmbm; - mediatek,bmt-max-ratio = <1>; - mediatek,bmt-max-reserved-blocks = <64>; - - partitions: partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "BL2"; - reg = <0x00 0x100000>; - }; - - partition@100000 { - label = "u-boot-env"; - reg = <0x100000 0x80000>; - }; - - factory: partition@180000 { - label = "Factory"; - reg = <0x180000 0x200000>; - }; - - partition@380000 { - label = "FIP"; - reg = <0x380000 0x200000>; - }; - - partition@7180000 { - label = "stock-config"; - reg = <0x7180000 0x100000>; - }; - - partition@7280000 { - label = "stock-factory"; - reg = <0x7280000 0x80000>; - - compatible = "nvmem-cells"; - #address-cells = <1>; - #size-cells = <1>; - - macaddr_factory_14: macaddr@14 { - reg = <0x14 0x11>; - }; - - }; - - partition@7300000 { - label = "stock-log"; - reg = <0x7300000 0x400000>; - }; - }; - }; -}; - &pio { spi0_flash_pins: spi0-pins { mux { @@ -219,24 +225,32 @@ conf-pu { pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP"; - drive-strength = ; - bias-pull-up = ; + drive-strength = <8>; + bias-pull-up = <103>; }; conf-pd { pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO"; - drive-strength = ; - bias-pull-down = ; + drive-strength = <8>; + bias-pull-down = <103>; }; }; }; +&uart0 { + status = "okay"; +}; + +&watchdog { + status = "okay"; +}; + &wifi { + status = "okay"; + mediatek,mtd-eeprom = <&factory 0x0>; nvmem-cells = <&macaddr_factory_14>; nvmem-cell-names = "mac-address-ascii"; mac-address-increment = <2>; - - status = "okay"; }; diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network index fcd0319716..cadf691784 100644 --- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network @@ -14,17 +14,15 @@ mediatek_setup_interfaces() bananapi,bpi-r3) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 sfp2" "eth1 wan" ;; - cudy,wr3000-v1) + cudy,wr3000-v1|\ + livinet,zr-3020|\ + qihoo,360t7|\ + qihoo,360t7-ubootmod) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" ;; glinet,gl-mt3000) ucidef_set_interfaces_lan_wan eth1 eth0 ;; - livinet,zr-3020|\ - qihoo,360-t7-stock|\ - qihoo,360-t7-ubootmod) - ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" wan - ;; mediatek,mt7986a-rfb) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan6" "eth1 wan" ;; @@ -34,9 +32,6 @@ mediatek_setup_interfaces() mediatek,mt7988a-dsa-10g-spim-snand) ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3" "eth1 eth2" ;; - qihoo,360t7) - ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" wan - ;; tplink,tl-xdr4288|\ tplink,tl-xdr6088) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan5" eth1 diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac index 7235230fe2..c9f4b96dcc 100644 --- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac +++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac @@ -36,12 +36,8 @@ case "$board" in addr=$(mtd_get_mac_ascii config2 wifi5gmac) [ "$PHYNBR" = "1" ] && echo $macaddr > /sys${DEVPATH}/macaddress ;; - qihoo,360-t7-stock|\ - qihoo,360-t7-ubootmod) - addr=$(macaddr_add $(cat /sys/class/net/eth0/address) 2) - [ "$PHYNBR" = "1" ] && macaddr_setbit $addr 6 > /sys${DEVPATH}/macaddress - ;; - qihoo,360t7) + qihoo,360t7|\ + qihoo,360t7-ubootmod) addr=$(mtd_get_mac_ascii factory lanMac) [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index 28dc64586b..8a38b8fe3c 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -255,41 +255,9 @@ define Device/mediatek_mt7988a-rfb-nand endef TARGET_DEVICES += mediatek_mt7988a-rfb-nand -define Device/qihoo_360-t7-common - DEVICE_VENDOR := Qihoo - DEVICE_DTS_DIR := ../dts - DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware - UBINIZE_OPTS := -E 5 - BLOCKSIZE := 128k - PAGESIZE := 2048 - IMAGE_SIZE := 65536k - KERNEL_IN_UBI := 1 - IMAGES += factory.bin - IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE) - IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata - KERNEL = kernel-bin | lzma | \ - fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb - KERNEL_INITRAMFS = kernel-bin | lzma | \ - fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd -endef - -define Device/qihoo_360-t7-stock - DEVICE_MODEL := 360 T7 (stock layout) - DEVICE_DTS := mt7981b-qihoo-360-t7-stock - $(call Device/qihoo_360-t7-common) -endef -TARGET_DEVICES += qihoo_360-t7-stock - -define Device/qihoo_360-t7-ubootmod - DEVICE_MODEL := 360 T7 (modified U-Boot layout) - DEVICE_DTS := mt7981b-qihoo-360-t7-ubootmod - $(call Device/qihoo_360-t7-common) -endef -TARGET_DEVICES += qihoo_360-t7-ubootmod - define Device/qihoo_360t7 DEVICE_VENDOR := Qihoo - DEVICE_MODEL := 360 T7 (OpenWrt U-Boot layout) + DEVICE_MODEL := 360T7 (OpenWrt U-Boot layout) DEVICE_DTS := mt7981b-qihoo-360t7 DEVICE_DTS_DIR := ../dts UBINIZE_OPTS := -E 5 @@ -311,6 +279,28 @@ define Device/qihoo_360t7 endef TARGET_DEVICES += qihoo_360t7 +define Device/qihoo_360t7-ubootmod + DEVICE_VENDOR := Qihoo + DEVICE_MODEL := 360T7 (modified U-Boot layout) + DEVICE_DTS := mt7981b-qihoo-360t7-ubootmod + DEVICE_DTS_DIR := ../dts + DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware + SUPPORTED_DEVICES += qihoo,360-t7-ubootmod + UBINIZE_OPTS := -E 5 + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 65536k + KERNEL_IN_UBI := 1 + IMAGES += factory.bin + IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE) + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + KERNEL = kernel-bin | lzma | \ + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb + KERNEL_INITRAMFS = kernel-bin | lzma | \ + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd +endef +TARGET_DEVICES += qihoo_360t7-ubootmod + define Device/tplink_tl-xdr-common DEVICE_VENDOR := TP-Link DEVICE_DTS_DIR := ../dts