[PATCH] ramips: add support for Tozed S12 Plus (UNISOC)

Ian Pangilinan ian.pangilinan at upd.edu.ph
Wed Jul 27 22:31:24 PDT 2022


 From: Ian Pangilinan <braveheart_leo at yahoo.com>
Date: Sun, 28 July 2022 11:27:00 +0800
Subject: [PATCH] ramips: add support for Tozed S12 Plus (UNISOC)

Tozed S12 Plus (UNISOC) is a Cat.6 LTE CPE. It is known as ZLT S12 Pro 
in some markets.

Product link: https://www.sztozed.com/en/contents/58/84.html

Hardware Highlights:

  * SOC: MT7621A 2C4T @ 880MHz
  * RAM: DDR3 256MB @ 800MHz
  * FLASH: MX25L12805D 16MB SPI NOR
  * WLAN0: MT7612E 5GHz 802.11nac 2x2:2 @ 867Mbps
  * WLAN1: MT7603E 2.4GHz 802.11bgn 2x2:2 @ 300Mbps
  * SWITCH: MT7530 4-port GbE
  * WWAN: UNISOC SL8563 Cat.6 LTE
  * SIM: 1x Mini-SIM 2FF
  * BUTTONS: Reset, WPS, Wi-Fi
  * LEDS: Power (Yellow/Blue), Wi-Fi, Data (Red/Blue), Signal1-5, 
Telephone
  * POWER: 12VDc 2A


There is an existing PR for this device here: 
https://github.com/openwrt/openwrt/pull/10321, but the author seems to 
have abandoned it after a week of no update in reply to reviewer 
suggestions and inquiries. This submission aims to remedy the 
shortcomings of that PR and will be made up-to-date by this author.

The device can be sysupgrade-d directly from the stock firmware. The 
flash layout remains the same between stock and OpenWrt.

This is the flash layout from stock firmware:

0x000000000000-0x000000030000 : "u-boot"
0x000000030000-0x000000038000 : "u-boot-env"
0x000000040000-0x000000050000 : "factory"
0x000000050000-0x000001000000 : "firmware"
0x000000000000-0x000000217058 : "kernel"
0x000000217058-0x000000fb0000 : "rootfs"
0x000000c30000-0x000000fb0000 : "rootfs_data"
0x000000038000-0x000000040000 : "tozed-conf"


Installation Instructions:

Stock firmware runs an old OpenWrt SNAPSHOT release. Installation can be 
either via

a) webui (gain superadmin access, use the sysupgrade image),
b) sysupgrade (gain root shell access, use the sysupgrade image), or
c) tftpboot in the bootloader.

Instructions below are for c). Connect the USB-TTL serial converter as 
follows when facing the board upright on the side of the buttons and 
RJ45 ports, located under the WPS/Wi-Fi buttons from left to right:

(TX) (GND) (RX)

Baud rate is 115200.

1. Connect the computer to the device via ethernet cable. Set a static 
adddress of 10.10.10.3/24 to the wired interface.
2. Start the TFTP server, point it to where the initramfs image is 
located. Rename the image to 'test.bin'.
3. Turn on the device. There will be a three-second delay before the 
default 'Boot system code via flash' is selected.
4. Interrupt the boot process by pressing 1 to 'System Load Linux to 
SDRAM via TFTP'.
5. Press enter to accept the default 'Input device IP (10.10.10.123)'.
6. Press enter to accept the default 'Input server IP (10.10.10.3)'.
7. Press enter to accept the default 'Input Linux Kernel filename ()', 
or enter 'test.bin'.
8. Wait for the initramfs image to finish loading.
9. Reconnect the wired interface to any LAN ports of the device via 
DHCP.
9. Flash the sysupgrade image at 
http://192.168.1.1/cgi-bin/luci/admin/system/flash


What Works?

+ LEDs
+ Buttons
+ Wired LAN and WAN
+ Wireless LAN

What Doesn't?

- Wireless WAN
- Telephone

The only non-configurable LEDs are those from each of the switch ports. 
They function as intended. I set the yellow and blue power LEDs as 
status indicators for OpenWrt. There is also an exported GPIO to reset 
the WWAN.

Support fgor WWAN could come at a later date. I have setup LAN4 of the 
device as WAN.

Signed-off-by: Ian Pangilinan <braveheart_leo at yahoo.com>
---
  .../dts/mt7621_tozed_s12-unisoc-plus.dts (new)     | 278 
+++++++++++++++++++++
  target/linux/ramips/image/mt7621.mk                |  10 +
  .../mt7621/base-files/etc/board.d/02_network       |   1 +
  3 files changed, 289 insertions(+), 0 deletion(-)
  create mode 100644 target/linux/ramips/dts/mt7621_notion_r281.dts
  create mode 100644 
target/linux/ramips/dts/mt7621_tozed_s12-unisoc-plus.dts
diff --git a/target/linux/ramips/dts/mt7621_tozed_s12-unisoc-plus.dts 
b/target/linux/ramips/dts/mt7621_tozed_s12-unisoc-plus.dts
new file mode 100644
index 0000000000..b4697ee63d
--- /dev/null
+++ b/target/linux/ramips/dts/mt7621_tozed_s12-unisoc-plus.dts
@@ -0,0 +1,278 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+// Copyright (C) 2022, Ian Pangilinan <braveheart_leo at yahoo.com>
+
+#include "mt7621.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	compatible = "tozed,s12-unisoc-plus", "mediatek,mt7621-soc";
+	model = "Tozed S12 Plus (UNISOC)";
+
+	chosen {
+		bootargs = "console=ttyS0,115200";
+	};
+
+	aliases {
+		led-boot = &led_power0;
+		led-failsafe = &led_power0;
+		led-running = &led_power1;
+		led-upgrade = &led_power0;
+		label-mac-device = &gmac0;
+	};
+
+	gpio-export {
+		compatible = "gpio-export";
+		#size-cells = <0>;
+
+		/* external LTE antenna 1 */
+		ext_ant0 {
+			gpio-export,name = "ext_ant0";
+			gpio-export,input = <0>;
+			gpios = <&gpio 6 GPIO_ACTIVE_HIGH>;
+		};
+
+		/* external LTE antenna 2 */
+		ext_ant1 {
+			gpio-export,name = "ext_ant1";
+			gpio-export,input = <0>;
+			gpios = <&gpio 7 GPIO_ACTIVE_HIGH>;
+		};
+
+		reset_cp {
+			gpio-export,name = "reset_cp";
+			gpio-export,output = <1>;
+			gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		led_power0: led-0 {
+			label = "yellow:power";
+			gpios = <&gpio 29 GPIO_ACTIVE_LOW>;
+		};
+
+		led_power1: led-1 {
+			label = "blue:power";
+			gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
+		};
+
+		led-2 {
+			label = "blue:wifi";
+			gpios = <&gpio 28 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "phy0tpt";
+		};
+
+		led-3 {
+			label = "red:data";
+			gpios = <&gpio 27 GPIO_ACTIVE_LOW>;
+		};
+
+		led-4 {
+			label = "blue:data";
+			gpios = <&gpio 33 GPIO_ACTIVE_LOW>;
+		};
+
+		led-5 {
+			label = "blue:signal1";
+			gpios = <&gpio 25 GPIO_ACTIVE_LOW>;
+		};
+
+		led-6 {
+			label = "blue:signal2";
+			gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
+		};
+
+		led-7 {
+			label = "blue:signal3";
+			gpios = <&gpio 23 GPIO_ACTIVE_LOW>;
+		};
+
+		led-8 {
+			label = "blue:signal4";
+			gpios = <&gpio 22 GPIO_ACTIVE_LOW>;
+		};
+
+		led-9 {
+			label = "blue:signal5";
+			gpios = <&gpio 26 GPIO_ACTIVE_LOW>;
+		};
+
+		led-10 {
+			label = "blue:tel";
+			gpios = <&gpio 31 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	keys {
+		compatible = "gpio-keys";
+
+		key-reset {
+			label = "reset";
+			gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_RESTART>;
+		};
+
+		key-wps {
+			label = "wps";
+			gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_WPS_BUTTON>;
+		};
+
+		key-wifi {
+			label = "wifi";
+			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_RFKILL>;
+		};
+	};
+};
+
+&state_default {
+	gpio {
+		groups = "jtag", "rgmii2", "uart3", "wdt";
+		function = "gpio";
+	};
+};
+
+&pcie {
+	status = "okay";
+};
+
+&pcie0 {
+	wifi at 0,0 {
+		compatible = "pci14c3,7662";
+		reg = <0x0 0 0 0 0>;
+
+		mediatek,mtd-eeprom = <&factory 0x8000>;
+		ieee80211-freq-limit = <5000000 6000000>;
+
+		nvmem-cells = <&macaddr_factory_8004>;
+		nvmem-cell-names = "mac-address";
+	};
+};
+
+&pcie1 {
+	wifi at 0,0 {
+		compatible = "pci14c3,7603";
+		reg = <0x0 0 0 0 0>;
+
+		mediatek,mtd-eeprom = <&factory 0x0>;
+		ieee80211-freq-limit = <2400000 2500000>;
+
+		nvmem-cells = <&macaddr_factory_4>;
+		nvmem-cell-names = "mac-address";
+	};
+};
+
+&switch0 {
+	ports {
+		port at 0 {
+			status = "okay";
+			label = "wan";
+
+			nvmem-cells = <&macaddr_factory_e006>;
+			nvmem-cell-names = "mac-address";
+		};
+
+		port at 1 {
+			status = "okay";
+			label = "lan3";
+		};
+
+		port at 2 {
+			status = "okay";
+			label = "lan2";
+		};
+
+		port at 4 {
+			status = "okay";
+			label = "lan1";
+		};
+	};
+};
+
+&spi0 {
+	status = "okay";
+
+	flash at 0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <50000000>;
+		m25p,fast-read;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "u-boot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition30000 {
+				label = "u-boot-env";
+				reg = <0x30000 0x8000>;
+				read-only;
+			};
+
+			factory: partition at 40000 {
+				label = "factory";
+				reg = <0x40000 0x10000>;
+				read-only;
+			};
+
+			partition at 50000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				reg = <0x50000 0xfb0000>;
+			};
+
+			partition at 38000 {
+				label = "tozed-conf";
+				reg = <0x38000 0x8000>;
+				read-only;
+			};
+		};
+	};
+};
+
+&ethernet {
+	pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;
+};
+
+&gmac0 {
+	nvmem-cells = <&macaddr_factory_e000>;
+	nvmem-cell-names = "mac-address";
+};
+
+&factory {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	/* WLAN24 MAC address */
+	macaddr_factory_4: macaddr at 4 {
+		reg = <0x4 0x6>;
+	};
+
+	/* WLAN5 MAC address */
+	macaddr_factory_8004: macaddr at 8004 {
+		reg = <0x8004 0x6>;
+	};
+
+	/* LAN MAC address */
+	macaddr_factory_e000: macaddr at e000 {
+		reg = <0xe000 0x6>;
+	};
+
+	/* WAN MAC address */
+	macaddr_factory_e006: macaddr at e006 {
+		reg = <0xe006 0x6>;
+	};
+};
diff --git a/target/linux/ramips/image/mt7621.mk 
b/target/linux/ramips/image/mt7621.mk
index aa7adeee60..d9a4c999db 100644
--- a/target/linux/ramips/image/mt7621.mk
+++ b/target/linux/ramips/image/mt7621.mk
@@ -1615,6 +1630,16 @@ define Device/totolink_x5000r
  endef
  TARGET_DEVICES += totolink_x5000r

+define Device/tozed_s12-unisoc-plus
+  $(Device/dsa-migration)
+  $(Device/uimage-lzma-loader)
+  IMAGE_SIZE := 16064k
+  DEVICE_VENDOR := Tozed
+  DEVICE_MODEL := S12 Plus (UNISOC)
+  DEVICE_PACKAGES := kmod-usb3 kmod-mt7603 kmod-mt76x2 comgt-ncm
+endef
+TARGET_DEVICES += tozed_s12-unisoc-plus
+
  define Device/tplink_archer-a6-v3
    $(Device/dsa-migration)
    $(Device/tplink-safeloader)
diff --git 
a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network 
b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
index 29336bad68..f4dbde8ba8 100644
--- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
@@ -27,6 +27,7 @@ ramips_setup_interfaces()
  	ampedwireless,ally-r1900k|\
  	gehua,ghl-r-001|\
  	hiwifi,hc5962|\
+	tozed,s12-unisoc-plus|\
  	xiaomi,mi-router-3-pro|\
  	xiaomi,mi-router-ac2100|\
  	xiaomi,mi-router-cr6606|\




More information about the openwrt-devel mailing list