From b0360ffa94838457e6da7a692572c21fd1ff1335 Mon Sep 17 00:00:00 2001 From: hanwckf Date: Tue, 1 Aug 2023 02:10:06 +0800 Subject: [PATCH] mediatek: add support for H3C NX30 Pro --- defconfig/mt7981-ax3000.config | 2 + package/boot/uboot-envtools/files/mediatek | 1 + target/linux/mediatek/base-files/sbin/smp.sh | 1 + .../boot/dts/mediatek/mt7981-h3c-nx30pro.dts | 237 ++++++++++++++++++ target/linux/mediatek/image/mt7981.mk | 17 ++ .../mt7981/base-files/etc/board.d/01_leds | 4 + .../mt7981/base-files/etc/board.d/02_network | 15 +- .../mt7981/base-files/lib/upgrade/platform.sh | 2 + 8 files changed, 275 insertions(+), 4 deletions(-) create mode 100644 target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-h3c-nx30pro.dts diff --git a/defconfig/mt7981-ax3000.config b/defconfig/mt7981-ax3000.config index 5e668b6b94..c9f807512a 100644 --- a/defconfig/mt7981-ax3000.config +++ b/defconfig/mt7981-ax3000.config @@ -5,6 +5,8 @@ CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_cetron_ct3003=y CONFIG_TARGET_DEVICE_PACKAGES_mediatek_mt7981_DEVICE_cetron_ct3003="" CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_cmcc_rax3000m=y CONFIG_TARGET_DEVICE_PACKAGES_mediatek_mt7981_DEVICE_cmcc_rax3000m="" +CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_h3c_nx30pro=y +CONFIG_TARGET_DEVICE_PACKAGES_mediatek_mt7981_DEVICE_h3c_nx30pro="" CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_jcg_q30=y CONFIG_TARGET_DEVICE_PACKAGES_mediatek_mt7981_DEVICE_jcg_q30="" CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_livinet_zr-3020=y diff --git a/package/boot/uboot-envtools/files/mediatek b/package/boot/uboot-envtools/files/mediatek index 8f84e1e89c..d04261c699 100644 --- a/package/boot/uboot-envtools/files/mediatek +++ b/package/boot/uboot-envtools/files/mediatek @@ -17,6 +17,7 @@ case "$board" in livinet,zr-3020*) ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x20000" "0x20000" "1" ;; +h3c,nx30pro |\ cmcc,rax3000m) ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x80000" "0x20000" "4" ;; diff --git a/target/linux/mediatek/base-files/sbin/smp.sh b/target/linux/mediatek/base-files/sbin/smp.sh index cf02de632f..ed1bba9c5d 100755 --- a/target/linux/mediatek/base-files/sbin/smp.sh +++ b/target/linux/mediatek/base-files/sbin/smp.sh @@ -721,6 +721,7 @@ setup_model() *360,t7* |\ xiaomi,mi-router-wr30u* |\ *rax3000m* |\ + h3c,nx30pro |\ *7981*) MT7981_whnat $num_of_wifi ;; diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-h3c-nx30pro.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-h3c-nx30pro.dts new file mode 100644 index 0000000000..426251d38a --- /dev/null +++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-h3c-nx30pro.dts @@ -0,0 +1,237 @@ +/dts-v1/; +#include "mt7981.dtsi" + +/ { + model = "H3C NX30PRO"; + compatible = "h3c,nx30pro", "mediatek,mt7981"; + + aliases { + led-boot = &red_led; + led-failsafe = &red_led; + led-running = &green_led; + led-upgrade = &green_led; + }; + + 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 = "nx30pro:green"; + gpios = <&pio 4 GPIO_ACTIVE_LOW>; + }; + + red_led: red { + label = "nx30pro:red"; + gpios = <&pio 5 GPIO_ACTIVE_LOW>; + }; + }; + + gpio-keys { + compatible = "gpio-keys"; + reset { + label = "reset"; + linux,code = ; + gpios = <&pio 1 GPIO_ACTIVE_LOW>; + }; + + mesh { + label = "mesh"; + gpios = <&pio 0 GPIO_ACTIVE_LOW>; + linux,code = ; + linux,input-type = ; + }; + }; + + gsw: gsw@0 { + compatible = "mediatek,mt753x"; + mediatek,ethsys = <ðsys>; + #address-cells = <1>; + #size-cells = <0>; + }; + + 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 0x4000000>; + }; + + partition@4580000 { + label = "pdt_data"; + reg = <0x4580000 0x0600000>; + read-only; + }; + + partition@4b80000 { + label = "pdt_data_1"; + reg = <0x4b80000 0x0600000>; + read-only; + }; + + partition@5180000 { + label = "exp"; + reg = <0x5180000 0x0100000>; + }; + + partition@5280000 { + label = "plugin"; + reg = <0x5280000 0x2580000>; + }; + }; + }; +}; + +&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 = "gmii"; + phy-handle = <&phy0>; + }; + + mdio: mdio-bus { + #address-cells = <1>; + #size-cells = <0>; + + phy0: ethernet-phy@0 { + compatible = "ethernet-phy-id03a2.9461"; + reg = <0>; + phy-mode = "gmii"; + nvmem-cells = <&phy_calibration>; + nvmem-cell-names = "phy-cal-data"; + }; + }; +}; + +&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"; + + port6: port@6 { + compatible = "mediatek,mt753x-port"; + mediatek,ssc-on; + reg = <6>; + phy-mode = "sgmii"; + + fixed-link { + speed = <2500>; + full-duplex; + }; + }; +}; + +&hnat { + mtketh-wan = "eth1"; + mtketh-lan = "eth0"; + 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 { + 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 = ; + }; + }; +}; diff --git a/target/linux/mediatek/image/mt7981.mk b/target/linux/mediatek/image/mt7981.mk index 8fc7811686..6fcfcef06a 100644 --- a/target/linux/mediatek/image/mt7981.mk +++ b/target/linux/mediatek/image/mt7981.mk @@ -354,3 +354,20 @@ define Device/cmcc_rax3000m IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata endef TARGET_DEVICES += cmcc_rax3000m + +define Device/h3c_nx30pro + DEVICE_VENDOR := H3C + DEVICE_MODEL := NX30PRO + DEVICE_DTS := mt7981-h3c-nx30pro + DEVICE_DTS_DIR := $(DTS_DIR)/mediatek + SUPPORTED_DEVICES := h3c,nx30pro + 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 +endef +TARGET_DEVICES += h3c_nx30pro 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 f6bd2153e9..935f0c04f9 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 @@ -23,6 +23,10 @@ xiaomi,mi-router-wr30u*) ucidef_set_led_default "green" "GREEN" "360t7:green" "1" ucidef_set_led_default "red" "RED" "360t7:red" "0" ;; +h3c,nx30pro) + ucidef_set_led_default "green" "GREEN" "nx30pro:green" "1" + ucidef_set_led_default "red" "RED" "nx30pro: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 eacb75e4d7..c1261ab075 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 @@ -42,6 +42,7 @@ mediatek_setup_interfaces() ucidef_add_switch "switch0" \ "1:lan" "2:lan" "3:lan" "0:wan" "6t@eth0" ;; + h3c,nx30pro |\ *rax3000m*) ucidef_set_interfaces_lan_wan "eth0" "eth1" ucidef_add_switch "switch0" \ @@ -151,16 +152,22 @@ mediatek_setup_macs() lan_mac=$(mtd_get_mac_ascii art MAC_ADDRESS) wan_mac=$(macaddr_add $lan_mac 3) label_mac=$lan_mac - #if [ "$(mtk_factory_get_byte Factory 4 2)" = "00-0c" ]; then - local wifi_mac="$(macaddr_add $lan_mac 1)" - mtk_facrory_write_mac Factory 4 "$wifi_mac" - #fi + local wifi_mac="$(macaddr_add $lan_mac 1)" + mtk_facrory_write_mac Factory 4 "$wifi_mac" ;; *jcg,q30*) wan_mac=$(mtd_get_mac_binary $part_name 0xa0024) lan_mac=$(mtd_get_mac_binary $part_name 0xa002a) label_mac=$lan_mac ;; + h3c,nx30pro) + wan_mac=$(mtd_get_mac_ascii pdt_data_1 ethaddr) + lan_mac=$(macaddr_add $wan_mac 1) + if [ "$(mtk_factory_get_byte "Factory" 4 2)" = "00-0c" ]; then + local wifi_mac="$(macaddr_add $wan_mac 2)" + mtk_facrory_write_mac "Factory" 4 $wifi_mac + fi + ;; *) wan_mac=$(mtd_get_mac_binary $part_name $wan_mac_offset) lan_mac=$(mtd_get_mac_binary $part_name $lan_mac_offset) diff --git a/target/linux/mediatek/mt7981/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7981/base-files/lib/upgrade/platform.sh index 92245c577b..02e4bac772 100644 --- a/target/linux/mediatek/mt7981/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/mt7981/base-files/lib/upgrade/platform.sh @@ -196,6 +196,7 @@ platform_do_upgrade() { *cetron,ct3003* |\ *jcg,q30* |\ cmcc,rax3000m |\ + h3c,nx30pro |\ *snand*) nand_do_upgrade "$1" ;; @@ -231,6 +232,7 @@ platform_check_image() { *cetron,ct3003* |\ *jcg,q30* |\ cmcc,rax3000m |\ + h3c,nx30pro |\ *snand* |\ *emmc*) # tar magic `ustar`