--- /dev/null
+# SPDX-License-Identifier: GPL-2.0
+
+get_mac_gs3101() {
+ local part_name="romfile"
+ local idx;
+
+ idx=$(find_mtd_index "$part_name")
+ if [ -z "$idx" ]; then
+ echo "get_mac_gs3101: partition $part_name not found" >&2
+ return 1
+ fi
+
+ # <Entry0 Mac="5ac876db9bf0" newHwUpBytes="0" newHwDownBytes="0"
+ dd if="/dev/mtd${idx}" 2>/dev/null | \
+ gunzip 2>/dev/null | \
+ strings | \
+ sed -n -e 's/^.*Mac="\([a-f0-9]\{12\}\)".*$/\1/p' | \
+ while read mac; do
+ mac=$(macaddr_canonicalize "$mac")
+ [ "$mac" = "" ] && continue
+ # For some reason, GS3101 stores 5a:c8:76:...
+ # But the MAC address is 58:c8:76:...
+ echo "$(macaddr_unsetbit "$mac" 7)"
+ break
+ done | \
+ grep '[a-f0-9:]\{17\}' && return 0
+
+ echo "get_mac_gs3101: could not find mac address" >&2
+ return 1
+}
--- /dev/null
+// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
+
+#include "en7526f.dtsi"
+
+/ {
+ model = "ChinaMobile GS3101";
+ compatible = "chinamobile,gs3101", "econet,en7526f", "econet,en751221";
+
+ memory@0 {
+ device_type = "memory";
+ reg = <0x00000000 0x10000000>;
+ };
+
+ chosen {
+ stdout-path = "/serial@1fbf0000:115200";
+ };
+
+ keys {
+ compatible = "gpio-keys-polled";
+ poll-interval = <100>;
+
+ key-reset {
+ label = "reset";
+ linux,code = <KEY_RESTART>;
+ gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ aliases {
+ led-boot = &led_power_green;
+ led-failsafe = &led_signal_red;
+ led-running = &led_power_green;
+ led-upgrade = &led_registered_green;
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ led_power_green: led-0 {
+ /* Written "电源" (Power supply) */
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_POWER;
+ gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
+ };
+
+ led_registered_green: led-1 {
+ /* Written "注册" (Registered) */
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_WAN;
+ gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
+ };
+
+ led_signal_red: led-2 {
+ /* Written "光信号" (Optical signal) */
+ color = <LED_COLOR_ID_RED>;
+ function = "signal";
+ gpios = <&gpio0 31 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ virtual_flash {
+ compatible = "mtd-concat";
+ devices = <&rootA &rootB &root2>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "ubi";
+ reg = <0x0 0x0>;
+ };
+ };
+ };
+};
+
+&nand {
+ status = "okay";
+ econet,bmt;
+ econet,bbt-table-size = <250>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "bootloader";
+ reg = <0x0 0x40000>;
+ read-only;
+ };
+
+ partition@40000 {
+ label = "romfile";
+ reg = <0x40000 0x40000>;
+ };
+
+ partition@80000 {
+ label = "tclinux";
+ reg = <0x80000 0x1000000>;
+ econet,enable-remap;
+ };
+
+ partition1@80000 {
+ label = "tclinux_kernel";
+ reg = <0x80000 0x400000>;
+ econet,enable-remap;
+ };
+
+ rootA: partition1@480000 {
+ label = "tclinux_rootfs";
+ reg = <0x480000 0xc00000>;
+ };
+
+ partition@1080000 {
+ label = "tclinux_alt";
+ reg = <0x1080000 0x1000000>;
+ econet,enable-remap;
+ };
+
+ partition1@1080000 {
+ label = "tclinux_alt_kernel";
+ reg = <0x1080000 0x400000>;
+ econet,enable-remap;
+ };
+
+ rootB: partition1@1480000 {
+ label = "tclinux_alt_rootfs";
+ reg = <0x1480000 0xc00000>;
+ };
+
+ root2: partition@2080000 {
+ label = "common_rootfs";
+ reg = <0x2080000 0xbdc0000>;
+ };
+
+ partition@de40000 {
+ label = "reservearea";
+ reg = <0xde40000 0x1c0000>;
+
+ nvmem-layout {
+ compatible = "fixed-layout";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ eeprom_reserve_140000: eeprom@140000 {
+ /* MT7592 */
+ reg = <0x140000 0x200>;
+ };
+ };
+ };
+ };
+};
+
+&gmac0 {
+ status = "okay";
+ /*
+ * MAC address used in factory OS is found in an XML-like file
+ * in a tar.gz which is written to partition romfile.
+ * This address does not match the address on the device label
+ * and can only be extracted by a script.
+ */
+};
+
+/*
+ * There is an MT7592 (MT7603 compatible) chip on this board, but on a large
+ * fraction of devices it is apparently defective and attempting to start it
+ * causes a board hang. In the interest of not causing bricked devices, this
+ * is commented out.
+ * Adventurous users may uncomment this and try to re-flash at their own risk.
+
+&pcie0 {
+ status = "okay";
+};
+&slot0 {
+ wifi@0,0 {
+ compatible = "mediatek,mt76";
+ reg = <0x0000 0 0 0 0>;
+ nvmem-cells = <&eeprom_reserve_140000>;
+ nvmem-cell-names = "eeprom";
+ };
+};
+*/