[openwrt/openwrt] mediatek: filogic: add support for GatoNetworks GDSP

LEDE Commits lede-commits at lists.infradead.org
Thu Nov 28 10:57:40 PST 2024


ynezz pushed a commit to openwrt/openwrt.git, branch openwrt-24.10:
https://git.openwrt.org/f2a40e11176f74adba1228880725af7a95ebfaf0

commit f2a40e11176f74adba1228880725af7a95ebfaf0
Author: Enrico Mioso <mrkiko.rs at gmail.com>
AuthorDate: Sat Nov 9 22:14:33 2024 +0100

    mediatek: filogic: add support for GatoNetworks GDSP
    
    The GatoNetworks GDSP is a re-branded version of the R5000 5G Industrial
    router from Yinghua Technologies.
    The re-branded device comes with OpenWrt preinstalled, and an OpenWrt-based
    U-Boot bootloader version. While the flash layout has been kept compatible
    with the OpenWrt version found on the stock device (see [5]), the image format
    changed, making a bootloader upgrade necessary.
    
    Specifications:
    SoC: Mediatek MT7981BA
    RAM: 256MB
    Flash: SPI-NOR 32 MiB (Winbond W25Q256)
    WLAN: MT7976CN DBDC AX Wi-Fi
    Switch: MT7531AE (4x LAN Gigabit ports, 1x WAN Gigabit port)
    5G: Quectel RM520N modem
    Watchdog: an external WDT connected to GPIO 6 is present and always running;
              the built-in Mediatek watchdog is also present and effective, but
              not used at the moment.
    
    This porting has been tested only with 1x 5G modems installed (the device
    supports up to two).
    
    Installation:
    Installation is possible via sysupgrade both in the stock device and
    re-branded version. However, in the former case, updating the bootloader is
    required.
    
    OpenWrt-based U-Boot Bootloader installation
    --------------------------------------------
    The firmware flashed in the re-branded device at manifacturing time will
    flash an OpenWrt-based U-Boot bootloader with some extra recovery features
    (see [1]) at first boot.
    To update the bootloader, you need to install the mtd-rw module and
    insmod it:
    
    insmod mtd-rw i_want_a_brick=1
    
    Then update relevant flash partitions:
    
    mtd erase u-boot-env
    mtd erase BL2
    mtd erase FIP
    mtd write openwrt-mediatek-filogic-gatonetworks_gdsp-preloader.bin BL2
    mtd write openwrt-mediatek-filogic-gatonetworks_gdsp-bl31-uboot.fip FIP
    
    And reboot, making sure all previous commands ran succesfully.
    If something goes wrong, you can recover your device via the mtk_uartboot
    tool.
    In my testing, it was possible to start the process even without (un)-plugging
    the device, may be handy for remote recovery.
    
    Installation from stock device and firmware
    -------------------------------------------
    To install vanilla OpenWrt in the stock device (R5000 5G Industrial router
    from Yinghua Technologies) running the stock vendor firmware, you will need
    to update your bootloader as described in previous section. Remember to use
    -F (force upgrade) and -n (not keeping settings).
    
    U-Boot Recovery
    ---------------
    This procedure has been tested only with the OpenWrt-based U-boot bootloader.
    Assign your system static IP address 192.168.1.1 and start a TFTP server. The
    device will look for an initramfs image named
    openwrt-mediatek-filogic-gatonetworks_gdsp-initramfs-kernel.bin
    (so you may use openwrt/bin/targets/mediatek/filogic as root dir for your
    TFTP server).
    Power on the device while keeping the reset button pressed, until you see
    a TFTP request from 192.168.1.10. Your environment will be restored to it's
    default state.
    
    MAC addresses assignment
    ------------------------
    MAC addresses are assigned slightly differently than in stock firmware. In
    particular, the 5 GHz Wi-Fi uses 2.4 GHZ MAC + 1, rather than reusing it with
    LA bit set as done in stock firmware. This MAC address is allocated to the
    device, so it can be used.
    The 2.4 GHz Wi-Fi MAC address is the label MAC. LAN MAC is used to set the
    special U-Boot environment ethaddr variable.
    
    device                                  MAC address             U-Boot env variable             factory partition offset
    2.4 GHz Wi-Fi           :84                                             wifi_mac                                                        0x4
    5.8 GHz Wi-Fi           :85                                             not present                                             not present
    WAN                                                     :86                                             wan_mac                                                         0x24
    LAN                                                     :87                                             lan_mac                                                         0x2A
    
    Notes
    -----
    [1]: the OpenWrt-based U-Boot bootloader you will find installed in the
    re-branded device is configured to request for the initramfs image via
    TFTP for $gdsp_tftp_tries times before trying normal boot from NOR flash.
    Setting this U-Boot environment variable to 0x0 will disable the feature,
    which is not implemented in this patch.
    [2]: the exposed UART port is connected to ttyS1; the ttyS0 console port is
    not exposed.
    [3]: the provided bootloader environment has no provision for operating on
    BL2 and the FIP partitions. This is an intentional choice to make it
    (slightly) more difficult to brick the device.
    [4]: it seems GPIO 6 is used both for the "SYS" LED and external WDT.
    [5] BL2 expects to find FIP payload at a fixed offset, so some constraints
    apply.
    
    Signed-off-by: Enrico Mioso <mrkiko.rs at gmail.com>
    (cherry picked from commit b43194e041b17fbb574fb3721dafedcc30a20ab5)
    Link: https://github.com/openwrt/openwrt/pull/17097
    Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
 .../mediatek/dts/mt7981b-gatonetworks-gdsp.dts     | 389 +++++++++++++++++++++
 .../filogic/base-files/lib/upgrade/platform.sh     |   1 +
 target/linux/mediatek/image/filogic.mk             |  20 ++
 3 files changed, 410 insertions(+)

diff --git a/target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp.dts b/target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp.dts
new file mode 100644
index 0000000000..fd9fdca124
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp.dts
@@ -0,0 +1,389 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+#include "mt7981.dtsi"
+
+/ {
+	model = "GatoNetworks GDSP";
+	compatible = "gatonetworks,gdsp", "mediatek,mt7981";
+
+	aliases {
+		serial0 = &uart0;
+		label-mac-device = &wifi_band_0;
+		led-boot = &sg1;
+		led-failsafe = &sg1;
+		led-running = &sg1;
+		led-upgrade = &sg1;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+		bootargs = "console=ttyS0,115200n1 earlycon=uart8250,mmio32,0x11002000";
+		rootdisk = <&firmware>;
+	};
+
+	memory {
+		reg = <0 0x40000000 0 0x10000000>;
+	};
+
+	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;
+	};
+
+	reg_5v: regulator-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-5V";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+
+	gpio-keys {
+		compatible = "gpio-keys";
+
+		reset {
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&pio 1 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	gpio-export {
+		compatible = "gpio-export";
+
+		modem1 {
+			gpio-export,name = "modem1";
+			gpio-export,output = <0>;
+			gpios = <&pio 2 GPIO_ACTIVE_LOW>;
+		};
+
+		modem2 {
+			gpio-export,name = "modem2";
+			gpio-export,output = <0>;
+			gpios = <&pio 14 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		sim1 {
+			label = "green:sim1";
+			gpios = <&pio 13 GPIO_ACTIVE_LOW>;
+		};
+
+		sim2 {
+			label = "green:sim2";
+			gpios = <&pio 0 GPIO_ACTIVE_LOW>;
+		};
+
+		sg1: sg1 {
+			label = "green:sg1";
+			gpios = <&pio 10 GPIO_ACTIVE_LOW>;
+		};
+
+		sg2 {
+			label = "green:sg2";
+			gpios = <&pio 11 GPIO_ACTIVE_LOW>;
+		};
+
+		sg3 {
+			label = "green:sg3";
+			gpios = <&pio 12 GPIO_ACTIVE_LOW>;
+		};
+
+		sg4 {
+			label = "green:sg4";
+			gpios = <&pio 7 GPIO_ACTIVE_LOW>;
+		};
+
+		sg5 {
+			label = "green:sg5";
+			gpios = <&pio 8 GPIO_ACTIVE_LOW>;
+		};
+
+		sg6 {
+			label = "green:sg6";
+			gpios = <&pio 9 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	gpio-watchdog {
+		compatible = "linux,wdt-gpio";
+		gpios = <&pio 6 GPIO_ACTIVE_LOW>;
+		hw_algo = "toggle";
+		hw_margin_ms = <25000>;
+		always-running;
+	};
+};
+
+&watchdog {
+	status = "okay";
+};
+
+&eth {
+	status = "okay";
+
+	gmac0: mac at 0 {
+		compatible = "mediatek,eth-mac";
+		reg = <0>;
+		phy-mode = "2500base-x";
+
+		nvmem-cells = <&macaddr_lan>;
+		nvmem-cell-names = "mac-address";
+
+		fixed-link {
+			speed = <2500>;
+			full-duplex;
+			pause;
+		};
+	};
+
+	mdio: mdio-bus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		switch at 1f {
+			compatible = "mediatek,mt7531";
+			reg = <31>;
+			reset-gpios = <&pio 39 0>;
+			interrupt-controller;
+			#interrupt-cells = <1>;
+			interrupt-parent = <&pio>;
+			interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
+
+			mdio {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				swphy0: phy at 0 {
+					reg = <0>;
+				};
+
+				swphy1: phy at 1 {
+					reg = <1>;
+				};
+
+				swphy2: phy at 2 {
+					reg = <2>;
+				};
+
+				swphy3: phy at 3 {
+					reg = <3>;
+				};
+
+				swphy4: phy at 4 {
+					reg = <4>;
+				};
+			};
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port at 0 {
+					reg = <0>;
+					label = "lan1";
+					phy-handle = <&swphy0>;
+				};
+
+				port at 1 {
+					reg = <1>;
+					label = "lan2";
+					phy-handle = <&swphy1>;
+				};
+
+				port at 2 {
+					reg = <2>;
+					label = "lan3";
+					phy-handle = <&swphy2>;
+				};
+
+				port at 3 {
+					reg = <3>;
+					label = "lan4";
+					phy-handle = <&swphy3>;
+				};
+
+				port at 4 {
+					reg = <4>;
+					label = "wan";
+					nvmem-cells = <&macaddr_wan>;
+					nvmem-cell-names = "mac-address";
+					phy-handle = <&swphy4>;
+				};
+
+				port at 6 {
+					reg = <6>;
+					ethernet = <&gmac0>;
+					phy-mode = "2500base-x";
+
+					fixed-link {
+						speed = <2500>;
+						full-duplex;
+						pause;
+					};
+				};
+			};
+		};
+	};
+};
+
+&crypto {
+	status = "okay";
+};
+
+&wifi {
+	mediatek,mtd-eeprom = <&factory 0x0>;
+	status = "okay";
+
+	wifi_band_0: band at 0 {
+		reg = <0>;
+		nvmem-cells = <&macaddr_wifi 0>;
+		nvmem-cell-names = "mac-address";
+	};
+
+	band at 1 {
+		reg = <1>;
+		nvmem-cells = <&macaddr_wifi 1>;
+		nvmem-cell-names = "mac-address";
+	};
+};
+
+&spi2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi2_flash_pins>;
+	status = "okay";
+
+	flash at 0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <52000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 00000 {
+				label = "BL2";
+				reg = <0x00000 0x0040000>;
+				read-only;
+			};
+
+			partition at 40000 {
+				label = "u-boot-env";
+				reg = <0x40000 0x0010000>;
+			};
+
+			factory: partition at 50000 {
+				label = "Factory";
+				reg = <0x50000 0x00B0000>;
+				read-only;
+
+				nvmem-layout {
+					compatible = "fixed-layout";
+					#address-cells = <1>;
+					#size-cells = <1>;
+
+					macaddr_wifi: macaddr at 4 {
+						reg = <0x4 0x6>;
+						compatible = "mac-base";
+						#nvmem-cell-cells = <1>;
+					};
+
+					macaddr_wan: macaddr at 24 {
+						reg = <0x24 0x6>;
+					};
+
+					macaddr_lan: macaddr at 2a {
+						reg = <0x2a 0x6>;
+					};
+				};
+			};
+
+			partition at 100000 {
+				label = "FIP";
+				reg = <0x100000 0x0080000>;
+				read-only;
+			};
+
+			firmware: partition at 180000 {
+				label = "firmware";
+				reg = <0x180000 0x1E80000>;
+			};
+		};
+	};
+};
+
+&pio {
+	uart1_pins: uart1-pins {
+		mux {
+			function = "uart";
+			groups = "uart1_0";
+		};
+	};
+
+	uart2_pins: uart2-pins {
+		mux {
+			function = "uart";
+			groups = "uart2_0_tx_rx";
+		};
+	};
+
+	spi2_flash_pins: spi2-pins {
+		mux {
+			function = "spi";
+			groups = "spi2", "spi2_wp_hold";
+		};
+
+		conf-pu {
+			pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
+			drive-strength = <MTK_DRIVE_8mA>;
+			bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
+		};
+
+		conf-pd {
+			pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
+			drive-strength = <MTK_DRIVE_8mA>;
+			bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
+		};
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&uart1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart1_pins>;
+	status = "okay";
+};
+
+&uart2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart2_pins>;
+	status = "okay";
+};
+
+&usb_phy {
+	status = "okay";
+};
+
+&xhci {
+	mediatek,u3p-dis-msk = <0x0>;
+	phys = <&u2port0 PHY_TYPE_USB2>,
+	       <&u3port0 PHY_TYPE_USB3>;
+	status = "okay";
+	vusb33-supply = <&reg_3p3v>;
+	vbus-supply = <&reg_5v>;
+};
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 7fe2d29d31..cfd77b62d7 100755
--- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
@@ -70,6 +70,7 @@ platform_do_upgrade() {
 	bananapi,bpi-r4|\
 	bananapi,bpi-r4-poe|\
 	cmcc,rax3000m|\
+	gatonetworks,gdsp|\
 	h3c,magic-nx30-pro|\
 	jcg,q30-pro|\
 	jdcloud,re-cp-03|\
diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk
index 5dfde755a0..739fd54308 100644
--- a/target/linux/mediatek/image/filogic.mk
+++ b/target/linux/mediatek/image/filogic.mk
@@ -670,6 +670,26 @@ define Device/edgecore_eap111
 endef
 TARGET_DEVICES += edgecore_eap111
 
+define Device/gatonetworks_gdsp
+  DEVICE_VENDOR := GatoNetworks
+  DEVICE_MODEL := gdsp
+  DEVICE_DTS := mt7981b-gatonetworks-gdsp
+  DEVICE_DTS_DIR := ../dts
+  IMAGES := sysupgrade.itb
+  IMAGE_SIZE := 32768k
+  DEVICE_PACKAGES := fitblk kmod-mt7915e kmod-mt7981-firmware \
+    kmod-usb-net-qmi-wwan kmod-usb-serial-option kmod-usb3 \
+    mt7981-wo-firmware -kmod-phy-aquantia
+  ARTIFACTS := preloader.bin bl31-uboot.fip
+  ARTIFACT/preloader.bin := mt7981-bl2 nor-ddr3
+  ARTIFACT/bl31-uboot.fip := mt7981-bl31-uboot gatonetworks_gdsp
+  KERNEL := kernel-bin | gzip
+  KERNEL_INITRAMFS := kernel-bin | lzma | \
+	fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
+  IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | pad-rootfs | append-metadata
+endef
+TARGET_DEVICES += gatonetworks_gdsp
+
 define Device/glinet_gl-mt2500
   DEVICE_VENDOR := GL.iNet
   DEVICE_MODEL := GL-MT2500




More information about the lede-commits mailing list