[openwrt/openwrt] filogic: support Telenor branded ZyXEL EX5700

LEDE Commits lede-commits at lists.infradead.org
Thu Dec 7 01:44:07 PST 2023


rmilecki pushed a commit to openwrt/openwrt.git, branch openwrt-23.05:
https://git.openwrt.org/3846b6eb49e75cae52fd82a601238aa75cf82270

commit 3846b6eb49e75cae52fd82a601238aa75cf82270
Author: Bjørn Mork <bjorn at mork.no>
AuthorDate: Tue Mar 28 15:04:21 2023 +0200

    filogic: support Telenor branded ZyXEL EX5700
    
    Telenor quirks
    --------------
    The operator specific firmware running on the Telenor branded
    ZyXEL EX5700 includes U-Boot modifications affecting the OpenWrt
    installation.
    
    Notable changes to U-Boot include
    - environment is stored in RAM and reset to defaults when power
      cycled
    - dual partition scheme with "nomimal" or "rescue" systems, falling
      back to "rescue" unless the OS signals success in 3 attempts
    - several runtime additions to the device-tree
    
    Some of these modifications have side effects requiring workarounds
    - U-Boot modifies /chosen/bootargs in an unsafe manner, and will crash
      unless this node exists
    - U-Boot verifies that the selected rootfs UBI volume exists, and
      refuses to boot if it doesn't. The chosen "rootfs" volume must contain
      a squashfs signature even for tftp or initramfs booting.
    - U-Boot parses the "factoryparams" UBI volume, setting the "ethaddr"
      variable to the label mac.  But "factoryparams" does not always
      exist.  Instead there is a "RIP" volume containing all the factory
      data.  Copying the "RIP" volume to  "factoryparams" will fix this
    
    Hardware
    --------
    SOC:   MediaTek MT7986
    RAM:   1GB DDR4
    FLASH: 512MB SPI-NAND (Mikron xxx)
    WIFI:  Mediatek MT7986 802.11ax 5 GHz
           Mediatek MT7916 DBDC 802.11ax 2.4 + 6 GHz
    ETH:   MediaTek MT7531 Switch + SoC
           3 x builtin 1G phy (lan1, lan2, lan3)
           2 x MaxLinear GPY211C 2.5 N-Base-T phy (lan4, wan)
    USB:   1 x USB 3.2 Enhanced SuperSpeed port
    UART:  3V3 115200 8N1 (Pinout: GND KEY RX TX VCC)
    
    Installation
    ------------
    1. Download the OpenWrt initramfs image. Copy the image to a TFTP server
       reachable at 192.168.1.2/24. Rename the image to C0A80101.img.
    
    2. Connect the TFTP server to lan1, lan2 or lan3. Connect to the serial
       console, Interrupt the autoboot process by pressing ESC when prompted.
    
    3. Download and boot the OpenWrt initramfs image.
    
       $ env set uboot_bootcount 0
       $ env set firmware nominal
       $ tftpboot
       $ bootm
    
    4. Wait for OpenWrt to boot. Transfer the sysupgrade image to the device
       using scp and install using sysupgrade.
    
       $ sysupgrade -n <path-to-sysupgrade.bin>
    
    Missing features
    ----------------
    
    - The "lan1", "lan2" and "lan3" port LEDs are driven by the switch but
      OpenWrt does not correctly configure the output.
    - The "lan4" and "wan" port LEDs are driven by the GPH211C phys and
      not configured by OpenWrt.
    
    Signed-off-by: Bjørn Mork <bjorn at mork.no>
    (cherry picked from commit 6cc14bf66aa924962b926ea9702b6153ae418a7d)
---
 package/boot/uboot-envtools/files/mediatek_filogic |   3 +
 .../mediatek/dts/mt7986a-zyxel-ex5700-telenor.dts  | 374 +++++++++++++++++++++
 .../filogic/base-files/etc/init.d/bootcount        |  12 +
 target/linux/mediatek/image/filogic.mk             |  14 +
 4 files changed, 403 insertions(+)

diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic
index 6e39fac657..7bfdee24f3 100644
--- a/package/boot/uboot-envtools/files/mediatek_filogic
+++ b/package/boot/uboot-envtools/files/mediatek_filogic
@@ -88,6 +88,9 @@ zyxel,ex5601-t0)
 	local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
 	ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x40000" "2"
 	;;
+zyxel,ex5700-telenor)
+	ubootenv_add_uci_config "/dev/ubootenv" "0x0" "0x4000" "0x4000" "1"
+	;;
 esac
 
 config_load ubootenv
diff --git a/target/linux/mediatek/dts/mt7986a-zyxel-ex5700-telenor.dts b/target/linux/mediatek/dts/mt7986a-zyxel-ex5700-telenor.dts
new file mode 100644
index 0000000000..b6bd746ef3
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7986a-zyxel-ex5700-telenor.dts
@@ -0,0 +1,374 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+#include "mt7986a.dtsi"
+
+/ {
+	model = "ZyXEL EX5700 (Telenor)";
+	compatible = "zyxel,ex5700-telenor", "mediatek,mt7986a";
+
+	aliases {
+		serial0 = &uart0;
+		ethernet0 = &gmac0;
+		led-boot = &led_status_green;
+		led-failsafe = &led_status_green;
+		led-running = &led_status_green;
+		led-upgrade = &led_status_amber;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+
+		// Stock U-Boot crashes unless /chosen/bootargs exists
+		bootargs = "earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n8";
+	};
+
+	memory {
+		reg = <0 0x40000000 0 0x40000000>;
+	};
+
+	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;
+	};
+
+
+	keys {
+		compatible = "gpio-keys";
+		poll-interval = <20>;
+
+		reset-button {
+			label = "reset";
+			gpios = <&pio 9 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_RESTART>;
+		};
+
+		wps-button {
+			label = "wps";
+			gpios = <&pio 10 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_WPS_BUTTON>;
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		red1 {
+			label = "red:net";
+			gpios = <&pio 23 GPIO_ACTIVE_HIGH>;
+			default-state = "off";
+		};
+
+		green1 {
+			label = "green:net";
+			gpios = <&pio 25 GPIO_ACTIVE_HIGH>;
+			default-state = "off";
+		};
+
+		amber1 {
+			label = "amber:net";
+			gpios = <&pio 29 GPIO_ACTIVE_HIGH>;
+			default-state = "off";
+		};
+
+		white2 {
+			label = "white:status";
+			gpios = <&pio 16 GPIO_ACTIVE_HIGH>;
+			default-state = "off";
+		};
+
+		red2 {
+			label = "red:status";
+			gpios = <&pio 17 GPIO_ACTIVE_HIGH>;
+			default-state = "off";
+		};
+
+		led_status_green: green2 {
+			label = "green:status";
+			gpios = <&pio 31 GPIO_ACTIVE_HIGH>;
+			default-state = "off";
+		};
+
+		led_status_amber: amber2 {
+			label = "amber:status";
+			gpios = <&pio 18 GPIO_ACTIVE_HIGH>;
+			default-state = "off";
+		};
+	};
+
+};
+
+&eth {
+	status = "okay";
+	pinctrl-names = "default";
+	pinctrl-0 = <&eth_pins>;
+
+	gmac0: mac at 0 {
+		compatible = "mediatek,eth-mac";
+		reg = <0>;
+		phy-mode = "2500base-x";
+
+		fixed-link {
+			speed = <2500>;
+			full-duplex;
+			pause;
+		};
+	};
+
+	mac at 1 {
+		compatible = "mediatek,eth-mac";
+		reg = <1>;
+		label = "wan";
+		phy-mode = "2500base-x";
+		phy-handle = <&phy6>;
+	};
+
+	mdio: mdio-bus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
+};
+
+&mdio {
+	reset-gpios = <&pio 6 GPIO_ACTIVE_LOW>;
+	reset-delay-us = <50000>;
+	reset-post-delay-us = <20000>;
+
+	phy5: phy at 5 {
+		compatible = "ethernet-phy-ieee802.3-c45";
+		reg = <5>;
+	};
+
+	phy6: phy at 6 {
+		compatible = "ethernet-phy-ieee802.3-c45";
+		reg = <6>;
+	};
+
+	switch: switch at 1f {
+		compatible = "mediatek,mt7531";
+		reg = <31>;
+		reset-gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		interrupt-parent = <&pio>;
+		interrupts = <66 IRQ_TYPE_LEVEL_HIGH>;
+	};
+};
+
+&switch {
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port at 0 {
+			reg = <0>;
+			label = "lan3";
+		};
+
+		port at 1 {
+			reg = <1>;
+			label = "lan2";
+		};
+
+		port at 2 {
+			reg = <2>;
+			label = "lan1";
+		};
+
+		port at 5 {
+			reg = <5>;
+			label = "lan4";
+			phy-mode = "2500base-x";
+			phy-handle = <&phy5>;
+		};
+
+		port at 6 {
+			reg = <6>;
+			ethernet = <&gmac0>;
+			phy-mode = "2500base-x";
+
+			fixed-link {
+				speed = <2500>;
+				full-duplex;
+				pause;
+			};
+		};
+	};
+};
+
+&crypto {
+	status = "okay";
+};
+
+&pcie {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pcie_pins>;
+	status = "okay";
+
+	pcie at 0,0 {
+		reg = <0x0000 0 0 0 0>;
+
+		wifi at 0,0 {
+			compatible = "mediatek,mt76";
+			reg = <0x0000 0 0 0 0>;
+			mediatek,mtd-eeprom = <&factory 0xa0000>;
+		};
+	};
+};
+
+&pcie_phy {
+	status = "okay";
+};
+
+&watchdog {
+	status = "okay";
+};
+
+&wifi {
+	status = "okay";
+	pinctrl-names = "default";
+	pinctrl-0 = <&wf_5g_pins>;
+
+	mediatek,mtd-eeprom = <&factory 0x0>;
+};
+
+&pio {
+	eth_pins: eth-pins {
+		mux {
+			function = "eth";
+			groups = "switch_int", "mdc_mdio";
+		};
+	};
+
+	pcie_pins: pcie-pins {
+		mux {
+			function = "pcie";
+			groups = "pcie_pereset"; // "pcie_clk" and "pcie_wake" is unused?
+		};
+	};
+
+	spi_flash_pins: spi-flash-pins-33-to-38 {
+		mux {
+			function = "spi";
+			groups = "spi0", "spi0_wp_hold";
+		};
+		conf-pu {
+			pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
+			drive-strength = <8>;
+			mediatek,pull-up-adv = <0>; /* bias-disable */
+		};
+		conf-pd {
+			pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
+			drive-strength = <8>;
+			mediatek,pull-down-adv = <0>; /* bias-disable */
+		};
+	};
+
+	wf_5g_pins: wf_5g-pins {
+		mux {
+			function = "wifi";
+			groups = "wf_5g";
+		};
+		conf {
+			pins = "WF1_HB1", "WF1_HB2", "WF1_HB3", "WF1_HB4",
+			       "WF1_HB0", "WF1_HB5", "WF1_HB6", "WF1_HB7",
+			       "WF1_HB8", "WF1_TOP_CLK", "WF1_TOP_DATA";
+			drive-strength = <4>;
+		};
+	};
+
+};
+
+&spi0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi_flash_pins>;
+	cs-gpios = <0>, <0>;
+	status = "okay";
+
+	flash at 0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <20000000>;
+	};
+
+	flash at 1 {
+		compatible = "spi-nand";
+		reg = <1>;
+
+		mediatek,nmbm;
+		mediatek,bmt-max-ratio = <1>;
+		mediatek,bmt-max-reserved-blocks = <64>;
+
+		spi-max-frequency = <20000000>;
+		spi-tx-buswidth = <4>;
+		spi-rx-buswidth = <4>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "BL2";
+				reg = <0x000000 0x100000>;
+				read-only;
+			};
+			partition at 100000 {
+				label = "u-boot-env";
+				reg = <0x100000 0x80000>;
+			};
+			factory: partition at 180000 {
+				label = "Factory";
+				reg = <0x180000 0x200000>;
+				read-only;
+
+				compatible = "nvmem-cells";
+				#address-cells = <1>;
+				#size-cells = <1>;
+			};
+			partition at 380000 {
+				label = "FIP";
+				reg = <0x380000 0x200000>;
+				read-only;
+			};
+			partition at 580000 {
+				label = "ubi";
+				reg = <0x580000 0x1da80000>;
+			};
+		};
+	};
+};
+
+&ssusb {
+	vusb33-supply = <&reg_3p3v>;
+	vbus-supply = <&reg_5v>;
+	status = "okay";
+};
+
+&trng {
+	status = "okay";
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&usb_phy {
+	status = "okay";
+};
diff --git a/target/linux/mediatek/filogic/base-files/etc/init.d/bootcount b/target/linux/mediatek/filogic/base-files/etc/init.d/bootcount
new file mode 100644
index 0000000000..c52d004c63
--- /dev/null
+++ b/target/linux/mediatek/filogic/base-files/etc/init.d/bootcount
@@ -0,0 +1,12 @@
+#!/bin/sh /etc/rc.common
+# SPDX-License-Identifier: GPL-2.0-only
+
+START=99
+
+boot() {
+	case $(board_name) in
+	zyxel,ex5700-telenor)
+		fw_setenv uboot_bootcount 0
+		;;
+	esac
+}
diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk
index 06cf3d7883..bf3ef599cf 100644
--- a/target/linux/mediatek/image/filogic.mk
+++ b/target/linux/mediatek/image/filogic.mk
@@ -653,6 +653,20 @@ define Device/zyxel_ex5601-t0-stock
 endef
 TARGET_DEVICES += zyxel_ex5601-t0-stock
 
+define Device/zyxel_ex5700-telenor
+  DEVICE_VENDOR := ZyXEL
+  DEVICE_MODEL := EX5700 (Telenor)
+  DEVICE_DTS := mt7986a-zyxel-ex5700-telenor
+  DEVICE_DTS_DIR := ../dts
+  DEVICE_PACKAGES := kmod-mt7916-firmware kmod-ubootenv-nvram kmod-usb3 kmod-mt7986-firmware mt7986-wo-firmware
+  UBINIZE_OPTS := -E 5
+  BLOCKSIZE := 128k
+  PAGESIZE := 2048
+  IMAGE_SIZE := 65536k
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+endef
+TARGET_DEVICES += zyxel_ex5700-telenor
+
 define Device/zyxel_nwa50ax-pro
   DEVICE_VENDOR := ZyXEL
   DEVICE_MODEL := NWA50AX Pro




More information about the lede-commits mailing list