ramips: mt76x8: add support for Yuncore M300
authorDaniel Golle <daniel@makrotopia.org>
Wed, 14 Aug 2024 18:21:06 +0000 (19:21 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 15 Aug 2024 02:19:30 +0000 (03:19 +0100)
Hardware:
 - SoC: MediaTek MT7628DAN (MIPS 580MHz)
 - Flash: 8 MiB Spansion S25FL064K
 - RAM: 64 MiB (built-into SoC)
 - WLAN: 2.4 GHz (MT7628)
 - Ethernet: 1x 10/100 Mbps WAN, 1x 10/100 LAN (MT7628)
 - Buttons: 1 Reset button
 - LEDs: 1x Red, 1x Green
 - Serial console: unpopulated header, 57600 8n1 (RX only)
 - Power: 12 VDC, 1 A

There are unpopulated areas on the board for 5 GHz WiFi via PCIe as well
as (most likely) Quectel EG25-G 4G module. As both are not populated on
my board support for both is missing for now.

Installation:
The installation can be done via the recovery HTTP server which is built
into the bootloader. Hold down the reset button while connecting the
device to power and keep holding a bit more than 3 seconds. Connect to
http://192.168.188.253/ and upload sysupgrade.bin file.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
target/linux/ramips/dts/mt7628an_yuncore_m300.dts [new file with mode: 0644]
target/linux/ramips/image/mt76x8.mk
target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds
target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
target/linux/ramips/mt76x8/config-6.6

diff --git a/target/linux/ramips/dts/mt7628an_yuncore_m300.dts b/target/linux/ramips/dts/mt7628an_yuncore_m300.dts
new file mode 100644 (file)
index 0000000..7a28c66
--- /dev/null
@@ -0,0 +1,147 @@
+#include "mt7628an.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
+
+/ {
+       compatible = "yuncore,m300", "mediatek,mt7628an-soc";
+
+       chosen {
+               bootargs = "console=ttyS0,57600";
+       };
+
+       keys {
+               compatible = "gpio-keys";
+
+               reset {
+                       label = "reset";
+                       gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+               };
+       };
+
+       aliases {
+               label-mac = &ethernet;
+               led-boot = &led_indicator;
+               led-failsafe = &led_indicator;
+               led-running = &led_indicator;
+               led-upgrade = &led_indicator;
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_indicator: indicator {
+                       function = LED_FUNCTION_INDICATOR;
+                       color = <LED_COLOR_ID_RED>;
+                       gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
+               };
+
+               lan {
+                       function = LED_FUNCTION_LAN;
+                       color = <LED_COLOR_ID_GREEN>;
+                       gpios = <&gpio 40 GPIO_ACTIVE_LOW>;
+               };
+
+               wan {
+                       function = LED_FUNCTION_WAN;
+                       color = <LED_COLOR_ID_GREEN>;
+                       gpios = <&gpio 39 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       watchdog {
+               compatible = "linux,wdt-gpio";
+               gpios = <&gpio 37 GPIO_ACTIVE_HIGH>;
+               hw_algo = "toggle";
+               hw_margin_ms = <20000>;
+               always-running;
+       };
+};
+
+&spi0 {
+       status = "okay";
+
+       flash@0 {
+               compatible = "jedec,spi-nor";
+               reg = <0>;
+               spi-max-frequency = <10000000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x0 0x30000>;
+                               read-only;
+                       };
+
+                       partition@30000 {
+                               label = "u-boot-env";
+                               reg = <0x30000 0x10000>;
+                               read-only;
+                       };
+
+                       partition@40000 {
+                               label = "factory";
+                               reg = <0x40000 0x10000>;
+                               read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       eeprom_factory_0: eeprom@0 {
+                                               reg = <0x0 0x400>;
+                                       };
+
+                                       macaddr_factory_4: macaddr@4 {
+                                               reg = <0x4 0x6>;
+                                       };
+                               };
+                       };
+
+                       partition@50000 {
+                               compatible = "denx,uimage";
+                               label = "firmware";
+                               reg = <0x50000 0x7b0000>;
+                       };
+               };
+       };
+};
+
+&ethernet {
+       nvmem-cells = <&macaddr_factory_4>;
+       nvmem-cell-names = "mac-address";
+};
+
+&esw {
+       mediatek,portmap = <0x3e>;
+};
+
+&wmac {
+       status = "okay";
+
+       nvmem-cells = <&eeprom_factory_0>;
+       nvmem-cell-names = "eeprom";
+};
+
+&state_default {
+       gpio {
+               groups = "pwm1", "pwm0", "uart2", "uart1", "i2c", "refclk",
+                        "perst", "wdt", "sdmode", "i2s", "spi cs1", "spis",
+                        "gpio", "p0led_an", "p1led_an", "p2led_an", "p3led_an",
+                        "p4led_an", "wled_kn", "p0led_kn", "p1led_kn",
+                        "p2led_kn", "p3led_kn", "p4led_kn";
+               function = "gpio";
+       };
+
+       wlan {
+               groups = "wled_an";
+               function = "wled_an";
+       };
+};
index 867c0e377b8dfd1a06c25b1ca48f888671e05d37..71f09f816f850bbd3ea65e65da3f5e3b9e69c79f 100644 (file)
@@ -1136,6 +1136,13 @@ define Device/xiaomi_mi-ra75
 endef
 TARGET_DEVICES += xiaomi_mi-ra75
 
+define Device/yuncore_m300
+  IMAGE_SIZE := 7872k
+  DEVICE_VENDOR := Yuncore
+  DEVICE_MODEL := M300
+endef
+TARGET_DEVICES += yuncore_m300
+
 define Device/zbtlink_zbt-we1226
   IMAGE_SIZE := 7872k
   DEVICE_VENDOR := Zbtlink
index a42c9fe640bd17dbce7eb7f64b31e13c196ca03c..5a937617801e4c5f82616f4288f00e9ca532568d 100644 (file)
@@ -18,7 +18,8 @@ asus,rt-n11p-b1|\
 asus,rt-n12-vp-b1|\
 netgear,r6020|\
 netgear,r6080|\
-netgear,r6120)
+netgear,r6120|\
+yuncore,m300)
        ucidef_set_led_switch "lan" "lan" "green:lan" "switch0" "0xf"
        ucidef_set_led_switch "wan" "wan" "green:wan" "switch0" "0x10"
        ;;
index e5326dfe7951159d2c93e44345095850ff9b8d99..2989d36e9b78fe16feca822548026d65bbee7be6 100644 (file)
@@ -81,7 +81,8 @@ ramips_setup_interfaces()
        buffalo,wcr-1166ds|\
        elecom,wrc-1167fs|\
        wavlink,wl-wn577a2|\
-       wavlink,wl-wn578a2)
+       wavlink,wl-wn578a2|\
+       yuncore,m300)
                ucidef_add_switch "switch0" \
                        "3:lan" "4:wan" "6@eth0"
                ;;
index a2d7bc98664ee1dc03b9f93b15bbd5f1e0376c8c..b9dc8525df90d62983ff7ec1a032b6d725f648a9 100644 (file)
@@ -84,6 +84,8 @@ CONFIG_GPIO_CDEV=y
 CONFIG_GPIO_GENERIC=y
 CONFIG_GPIO_MT7621=y
 # CONFIG_GPIO_RALINK is not set
+CONFIG_GPIO_WATCHDOG=y
+# CONFIG_GPIO_WATCHDOG_ARCH_INITCALL is not set
 CONFIG_HARDWARE_WATCHPOINTS=y
 CONFIG_HAS_DMA=y
 CONFIG_HAS_IOMEM=y