diff --git a/patches-mt798x-7.6.6.1/4010-support-Qihoo-360T7.patch b/patches-mt798x-7.6.6.1/4010-support-Qihoo-360T7.patch new file mode 100644 index 0000000..2a2894c --- /dev/null +++ b/patches-mt798x-7.6.6.1/4010-support-Qihoo-360T7.patch @@ -0,0 +1,482 @@ +From c96d75cce852adf3106112c33b920ed8e52baa35 Mon Sep 17 00:00:00 2001 +From: fujr +Date: Tue, 28 Feb 2023 05:22:15 +0800 +Subject: [PATCH 2/2] Add support for qihoo 360T7 + +--- + .../boot/dts/mediatek/mt7981-360-t7-108M.dts | 61 +++++ + .../boot/dts/mediatek/mt7981-360-t7-base.dtsi | 242 ++++++++++++++++++ + target/linux/mediatek/image/mt7981.mk | 35 +++ + .../mt7981/base-files/etc/board.d/01_leds | 6 + + .../mt7981/base-files/etc/board.d/02_network | 59 +++++ + 5 files changed, 403 insertions(+) + create mode 100644 target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-360-t7-108M.dts + create mode 100644 target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-360-t7-base.dtsi + +diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-360-t7-108M.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-360-t7-108M.dts +new file mode 100644 +index 0000000000..c1749442e3 +--- /dev/null ++++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-360-t7-108M.dts +@@ -0,0 +1,61 @@ ++/dts-v1/; ++#include "mt7981-360-t7-base.dtsi" ++ ++/ { ++ nmbm_spim_nand { ++ compatible = "generic,nmbm"; ++ ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ lower-mtd-device = <&spi_nand>; ++ forced-create; ++ ++ 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>; ++ }; ++ ++ 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>; ++ }; ++ ++ partition@7280000 { ++ label = "stock-factory"; ++ reg = <0x7280000 0x80000>; ++ }; ++ ++ partition@7300000 { ++ label = "stock-log"; ++ reg = <0x7300000 0x400000>; ++ }; ++ }; ++ }; ++}; ++ +diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-360-t7-base.dtsi b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-360-t7-base.dtsi +new file mode 100644 +index 0000000000..271dc68f57 +--- /dev/null ++++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-360-t7-base.dtsi +@@ -0,0 +1,242 @@ ++/dts-v1/; ++#include "mt7981.dtsi" ++ ++/ { ++ model = "360 T7"; ++ compatible = "360,t7", "mediatek,mt7981"; ++ ++ aliases { ++ led-boot = &red_led; ++ led-failsafe = &red_led; ++ led-running = &green_led; ++ led-upgrade = &green_led; ++ }; ++ ++ ++ gl-hw { ++ compatible = "gl-hw-info"; ++ model = "mt3000"; ++ wan = "eth1"; ++ lan = "eth0"; ++ temperature = "/sys/devices/virtual/thermal/thermal_zone0/temp"; ++ switch-button = "gpio-455"; ++ reset-button = "gpio-456"; ++ radio = "mt798111 mt798112"; ++ cfg-partition = "/dev/mtd7"; ++ flash_size = <128>; ++ dfs; ++ factory_data { ++ device_mac = "stock-factory", "0xb0"; ++ device_ddns = "stock-factory", "0xc0"; ++ device_sn_bak = "stock-factory", "0xd0"; ++ device_sn = "stock-factory", "0xe0"; ++ country_code = "stock-factory", "0x7a"; ++ }; ++ }; ++ ++ ++ chosen { ++ bootargs = "console=ttyS0,115200n1 loglevel=8 \ ++ earlycon=uart8250,mmio32,0x11002000"; ++ }; ++ ++ memory { ++ reg = <0 0x40000000 0 0x10000000>; ++ }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ ++ green_led: green { ++ label = "360t7:green"; ++ gpios = <&pio 7 GPIO_ACTIVE_LOW>; ++ }; ++ ++ red_led: red { ++ label = "360t7:red"; ++ gpios = <&pio 3 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++ ++ gpio-keys { ++ compatible = "gpio-keys"; ++ reset { ++ label = "reset"; ++ linux,code = ; ++ gpios = <&pio 1 GPIO_ACTIVE_LOW>; ++ }; ++ ++ wps { ++ label = "wps"; ++ linux,code = ; ++ gpios = <&pio 0 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++ ++ gsw: gsw@0 { ++ compatible = "mediatek,mt753x"; ++ mediatek,ethsys = <ðsys>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++}; ++ ++&uart0 { ++ status = "okay"; ++}; ++ ++&watchdog { ++ status = "okay"; ++}; ++ ++ð { ++ status = "okay"; ++ ++ gmac0: mac@0 { ++ compatible = "mediatek,eth-mac"; ++ reg = <0>; ++ phy-mode = "2500base-x"; ++ ++ fixed-link { ++ speed = <2500>; ++ full-duplex; ++ pause; ++ }; ++ }; ++ ++ gmac1: mac@1 { ++ compatible = "mediatek,eth-mac"; ++ reg = <1>; ++ phy-mode = "2500base-x"; ++ ++ fixed-link { ++ speed = <2500>; ++ full-duplex; ++ pause; ++ }; ++ }; ++ mdio: mdio-bus { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ ++}; ++ ++&gsw { ++ mediatek,mdio = <&mdio>; ++ mediatek,mdio_master_pinmux = <0>; ++ reset-gpios = <&pio 39 0>; ++ interrupt-parent = <&pio>; ++ interrupts = <38 IRQ_TYPE_LEVEL_HIGH>; ++ status = "okay"; ++ ++ port5: port@5 { ++ compatible = "mediatek,mt753x-port"; ++ reg = <5>; ++ phy-mode = "sgmii"; ++ ++ fixed-link { ++ speed = <2500>; ++ full-duplex; ++ }; ++ }; ++ ++ port6: port@6 { ++ compatible = "mediatek,mt753x-port"; ++ mediatek,ssc-on; ++ reg = <6>; ++ phy-mode = "sgmii"; ++ ++ fixed-link { ++ speed = <2500>; ++ full-duplex; ++ }; ++ }; ++}; ++ ++&hnat { ++ mtketh-wan = "eth0"; ++ mtketh-lan = "eth1"; ++ mtketh-ppd = "eth1"; ++ mtketh-max-gmac = <2>; ++ status = "okay"; ++}; ++ ++&spi0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&spi0_flash_pins>; ++ status = "okay"; ++ ++ spi_nand: spi_nand@0 { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ compatible = "spi-nand"; ++ reg = <0>; ++ spi-max-frequency = <52000000>; ++ spi-tx-buswidth = <4>; ++ spi-rx-buswidth = <4>; ++ spi-cal-enable; ++ spi-cal-mode = "read-data"; ++ spi-cal-datalen = <7>; ++ spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4E 0x41 0x4E 0x44>; /* 'SPINAND' */ ++ spi-cal-addrlen = <5>; ++ spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>; ++ }; ++}; ++ ++&pio { ++ pwm0_pin: pwm0-pin-g0 { ++ mux { ++ function = "pwm"; ++ groups = "pwm0_0"; ++ }; ++ }; ++ ++ pwm1_pin: pwm1-pin-g0 { ++ mux { ++ function = "pwm"; ++ groups = "pwm1_0"; ++ }; ++ }; ++ ++ pwm2_pin: pwm2-pin { ++ mux { ++ function = "pwm"; ++ groups = "pwm2"; ++ }; ++ }; ++ ++ spi0_flash_pins: spi0-pins { ++ mux { ++ function = "spi"; ++ groups = "spi0", "spi0_wp_hold"; ++ }; ++ ++ conf-pu { ++ pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP"; ++ drive-strength = ; ++ bias-pull-up = ; ++ }; ++ ++ conf-pd { ++ pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO"; ++ drive-strength = ; ++ bias-pull-down = ; ++ }; ++ }; ++ ++ uart1_pins: uart1-pins-g1 { ++ mux { ++ function = "uart"; ++ groups = "uart1_1"; ++ }; ++ }; ++ ++ uart2_pins: uart2-pins-g1 { ++ mux { ++ function = "uart"; ++ groups = "uart2_1"; ++ }; ++ }; ++}; ++ +diff --git a/target/linux/mediatek/image/mt7981.mk b/target/linux/mediatek/image/mt7981.mk +index b7f1f6d437..7a436bb61d 100755 +--- a/target/linux/mediatek/image/mt7981.mk ++++ b/target/linux/mediatek/image/mt7981.mk +@@ -222,3 +222,38 @@ define Device/glinet_gl-mt2500 + IMAGE/sysupgrade.bin := sysupgrade-tar | append-gl-metadata + endef + TARGET_DEVICES += glinet_gl-mt2500 ++ ++define Device/mt7981-360-t7 ++ DEVICE_VENDOR := GL.iNet ++ DEVICE_MODEL := 360 T7 ++ DEVICE_DTS := mt7981-360-t7 ++ DEVICE_DTS_DIR := $(DTS_DIR)/mediatek ++ SUPPORTED_DEVICES := 360,t7 ++ UBINIZE_OPTS := -E 5 ++ BLOCKSIZE := 128k ++ PAGESIZE := 2048 ++ IMAGE_SIZE := 36864k ++ KERNEL_IN_UBI := 1 ++ IMAGES += factory.bin ++ IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE) ++ IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata ++endef ++TARGET_DEVICES += mt7981-360-t7 ++ ++define Device/mt7981-360-t7-108M ++ DEVICE_VENDOR := GL.iNet ++ DEVICE_MODEL := 360 T7 (with 108M ubi) ++ DEVICE_DTS := mt7981-360-t7-108M ++ DEVICE_DTS_DIR := $(DTS_DIR)/mediatek ++ SUPPORTED_DEVICES := 360,t7 ++ UBINIZE_OPTS := -E 5 ++ BLOCKSIZE := 128k ++ PAGESIZE := 2048 ++ IMAGE_SIZE := 110592k ++ KERNEL_IN_UBI := 1 ++ IMAGES += factory.bin ++ IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE) ++ IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata ++endef ++TARGET_DEVICES += mt7981-360-t7-108M ++ +diff --git a/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds b/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds +index 43905e604d..779ac123b1 100755 +--- a/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds ++++ b/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds +@@ -13,6 +13,12 @@ glinet,x3000-emmc) + ucidef_set_led_default "power" "POWER" "power" "1" + ;; + esac ++case "$(board_name)" in ++*360,t7*) ++ ucidef_set_led_default "green" "GREEN" "360t7:green" "1" ++ ucidef_set_led_default "red" "RED" "360t7:red" "0" ++ ;; ++esac + + board_config_flush + +diff --git a/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network +index c2a22e425b..936ea35aea 100755 +--- a/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network ++++ b/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network +@@ -28,18 +28,63 @@ mediatek_setup_interfaces() + *mt2500*) + ucidef_set_interfaces_lan_wan eth1 eth0 + ;; ++ *360,t7*) ++ ucidef_set_interfaces_lan_wan "eth0" "eth1" ++ ucidef_add_switch "switch0" \ ++ "0:lan" "1:lan" "2:lan" "3:wan" "6u@eth0" "5u@eth1" ++ ;; + *) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" eth1 + ;; + esac + } + ++mtk_facrory_write_mac() ++{ ++ local part_name=$1 ++ local offset=$2 ++ local macaddr=$3 #aa:bb:cc:dd:ee:ff ++ local data="" ++ ++ part=$(find_mtd_part $part_name) ++ if [ -n "$part" ] && [ -n "$macaddr" ]; then ++ local i=1 ++ for x in ${macaddr//:/ }; do ++ [ $i -gt 6 ] && break ++ data=${data}"\x${x}" ++ i=$((i+1)) ++ done ++ dd if=$part of=/tmp/Factory.backup ++ printf "${data}" | dd conv=notrunc of=/tmp/Factory.backup bs=1 seek=$((${offset})) ++ mtd write /tmp/Factory.backup $part_name ++ rm -rf /tmp/Factory.backup ++ fi ++} ++ ++mtk_factory_get_byte() ++{ ++ local part_name=$1 ++ local offset=$2 ++ local len=$3 ++ ++ part=$(find_mtd_part $part_name) ++ if [ -n "$part" ]; then ++ hexdump -n $len -s $offset -e ''`expr ${len} - 1`'/1 "%02x-" "%02x"' $part ++ fi ++} ++ ++ + mediatek_setup_macs() + { + local board="$1" + local part_name="Factory" + local lan_mac="" + local wan_mac="" ++ local lan_mac_offset="0x2A" ++ local wan_mac_offset="0x24" ++ ++ lan_mac=$(mtd_get_mac_binary $part_name $lan_mac_offset) ++ wan_mac=$(mtd_get_mac_binary $part_name $wan_mac_offset) + + case $board in + *mt3000*) +@@ -55,6 +100,20 @@ mediatek_setup_macs() + wan_mac=$(get_mac_binary /dev/mmcblk0p3 0x0a) + lan_mac=$(macaddr_add "$wan_mac" 1) + ;; ++ *360,t7*) ++ local part=$(find_mtd_part "stock-factory") ++ if [ -n "$part" ]; then ++ local factoryMac="$(dd if=$part bs=1 count=200 2>/dev/null |grep "^lanMac=")" ++ if [ -n "$factoryMac" ]; then ++ lan_mac="${factoryMac#lanMac=}" ++ wan_mac="$(macaddr_add $lan_mac 0x1)" ++ if [ "$(mtk_factory_get_byte "Factory" 4 2)" = "00-0c" ]; then ++ local wifi_mac="$(macaddr_add $lan_mac 0x2)" ++ mtk_facrory_write_mac "Factory" 4 $wifi_mac ++ fi ++ fi ++ fi ++ ;; + esac + + [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac" +-- +2.25.1 +