From af176f27f5f263bdf133a0b9a3378ab4eee9ca5a Mon Sep 17 00:00:00 2001 From: JiaY-shi Date: Thu, 13 Apr 2023 21:51:48 +0800 Subject: [PATCH] mediatek: add support for the GL.iNet GL-MT2500 --- .../mediatek/dts/mt7981b-glinet-gl-mt2500.dts | 197 ++++++++++++++++++ .../filogic/base-files/etc/board.d/02_network | 5 + .../base-files/lib/upgrade/platform.sh | 14 ++ target/linux/mediatek/image/filogic.mk | 11 + 4 files changed, 227 insertions(+) create mode 100644 target/linux/mediatek/dts/mt7981b-glinet-gl-mt2500.dts diff --git a/target/linux/mediatek/dts/mt7981b-glinet-gl-mt2500.dts b/target/linux/mediatek/dts/mt7981b-glinet-gl-mt2500.dts new file mode 100644 index 00000000000000..44f63c9d9a224e --- /dev/null +++ b/target/linux/mediatek/dts/mt7981b-glinet-gl-mt2500.dts @@ -0,0 +1,197 @@ +/dts-v1/; +#include "mt7981.dtsi" +/ { + model = "GL.iNet GL-MT2500"; + compatible = "glinet,gl-mt2500", "mediatek,mt7981"; + + chosen { + bootargs = "console=ttyS0,115200n1 loglevel=8 \ + earlycon=uart8250,mmio32,0x11002000 \ + root=PARTLABEL=rootfs rootwait rootfstype=squashfs,f2fs \ + block2mtd.block2mtd=/dev/mmcblk0p1,65536,log"; + }; + + reserved-memory { + /delete-node/ wmcpu-reserved@47c80000; + /delete-node/ wo-emi@47d80000; + /delete-node/ wo-data@47dc0000; + /delete-node/ wo-ilm@151e0000; + /delete-node/ wo-dlm@151e8000; + /delete-node/ wo-boot@15194000; + }; + + aliases { + led-boot = &led_blue; + led-failsafe = &led_blue; + led-running = &led_white; + led-upgrade = &led_blue; + serial0 = &uart0; + }; + + reg_3p3v: regulator-3p3v { + compatible = "regulator-fixed"; + regulator-name = "fixed-3.3V"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + regulator-always-on; + }; + + usb_vbus: regulator-usb-vbus { + compatible = "regulator-fixed"; + regulator-name = "usb_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&pio 12 GPIO_ACTIVE_HIGH>; + enable-active-high; + regulator-boot-on; + }; + + + gpio-keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&pio 1 GPIO_ACTIVE_LOW>; + }; + }; + + gpio-export { + compatible = "gpio-export"; + + usb_power { + gpio-export,name = "usb_power"; + gpio-export,output = <1>; + gpios = <&pio 12 GPIO_ACTIVE_HIGH>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led@0 { + label = "vpn"; + gpios = <&pio 31 GPIO_ACTIVE_LOW>; + }; + + led_white: led@1 { + label = "white:system"; + gpios = <&pio 30 GPIO_ACTIVE_LOW>; + }; + + led_blue: led@2 { + label = "blue:system"; + gpios = <&pio 29 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + }; +}; + + +&uart0 { + status = "okay"; +}; + +&watchdog { + status = "okay"; +}; + +&mmc0 { + pinctrl-names = "default", "state_uhs"; + pinctrl-0 = <&mmc0_pins_default>; + pinctrl-1 = <&mmc0_pins_uhs>; + bus-width = <8>; + max-frequency = <52000000>; + cap-mmc-highspeed; + vmmc-supply = <®_3p3v>; + non-removable; + status = "okay"; +}; + +ð { + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&mdio_pins>; + + gmac0: mac@0 { + compatible = "mediatek,eth-mac"; + reg = <0>; + phy-mode = "2500base-x"; + phy-handle = <&phy0>; + }; + + gmac1: mac@1 { + compatible = "mediatek,eth-mac"; + reg = <1>; + phy-mode = "gmii"; + phy-handle = <&int_gbe_phy>; + }; +}; + +&mdio_bus { + reset-gpios = <&pio 14 GPIO_ACTIVE_LOW>; + reset-delay-us = <600>; + reset-post-delay-us = <20000>; + + phy0: ethernet-phy@5 { + reg = <5>; + compatible = "ethernet-phy-ieee802.3-c45"; + phy-mode = "2500base-x"; + }; +}; + + +&spi1 { + pinctrl-names = "default"; + pinctrl-0 = <&spic_pins>; + status = "disabled"; +}; + +&pio { + spic_pins: spi1-pins { + mux { + function = "spi"; + groups = "spi1_1"; + }; + }; + mmc0_pins_default: mmc0-pins-default { + mux { + function = "flash"; + groups = "emmc_45"; + }; + }; + mmc0_pins_uhs: mmc0-pins-uhs { + mux { + function = "flash"; + groups = "emmc_45"; + }; + }; +}; + +&usb_phy { + status = "okay"; +}; + +&xhci { + vbus-supply = <&usb_vbus>; + + status = "okay"; +}; + +&wifi { + /delete-property/ memory-region; +}; + +&consys { + /delete-property/ memory-region; + status = "disabled"; +}; + +&wed { + /delete-property/ memory-region; + /delete-property/ memory-region-names; + status = "disabled"; +}; \ No newline at end of file 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 aad1d67ff6fde5..02d906d9a00982 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 @@ -29,6 +29,7 @@ mediatek_setup_interfaces() cudy,wr3000-v1) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" ;; + glinet,gl-mt2500|\ glinet,gl-mt3000) ucidef_set_interfaces_lan_wan eth1 eth0 ;; @@ -105,6 +106,10 @@ mediatek_setup_macs() ;; esac ;; + glinet,gl-mt2500) + wan_mac=$(get_mac_binary /dev/mmcblk0boot1 0x0a) + lan_mac=$(macaddr_add "$wan_mac" 1) + ;; glinet,gl-mt6000) label_mac=$(mmc_get_mac_binary factory 0x0a) wan_mac=$label_mac diff --git a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh index b7b9d659932561..7cb3b55cabd0e3 100755 --- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh @@ -128,6 +128,11 @@ platform_do_upgrade() { CI_ROOT_UBIPART=ubi nand_do_upgrade "$1" ;; + glinet,gl-mt2500) + CI_KERNPART="kernel" + CI_ROOTPART="rootfs" + emmc_do_upgrade "$1" + ;; *) nand_do_upgrade "$1" ;; @@ -149,6 +154,15 @@ platform_check_image() { echo "Invalid image type." return 1 } + return 0 + ;; + glinet,gl-mt2500) + magic="$(dd if="$1" bs=1 skip=257 count=5 2>/dev/null)" + [ "$magic" != "ustar" ] && { + echo "Invalid image type." + return 1 + } + return 0 ;; *) diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index 4ce9b7f2ba1433..78a0538fe82e53 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -288,6 +288,17 @@ define Device/glinet_gl-mt3000 endef TARGET_DEVICES += glinet_gl-mt3000 +define Device/glinet_gl-mt2500 + DEVICE_VENDOR := GL.iNet + DEVICE_MODEL := GL-MT2500 + DEVICE_DTS := mt7981b-glinet-gl-mt2500 + DEVICE_DTS_DIR := ../dts + SUPPORTED_DEVICES := glinet,gl-mt2500 + DEVICE_PACKAGES := mkf2fs kmod-mmc kmod-fs-f2fs gdisk + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata +endef +TARGET_DEVICES += glinet_gl-mt2500 + define Device/glinet_gl-mt6000 DEVICE_VENDOR := GL.iNet DEVICE_MODEL := GL-MT6000