]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
mediatek: filogic: add SD card support to GatoNetworks GDSP
authorEnrico Mioso <mrkiko.rs@gmail.com>
Fri, 11 Jul 2025 11:22:56 +0000 (13:22 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Fri, 18 Jul 2025 11:36:39 +0000 (12:36 +0100)
The device is equipped with a GPS module, reporting data via /dev/ttyS1.
A TF card reader is also present. Only one of those components can be
used at once, since they share some PINs.
This commit adds two devicetree overlays to allow for the user to select
the desired configuration. Another overlay configuration to allow booting
from SD card is provided.

Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp-gps.dtso [new file with mode: 0644]
target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp-sd-boot.dtso [new file with mode: 0644]
target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp-sd.dtso [new file with mode: 0644]
target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp.dts
target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
target/linux/mediatek/image/filogic.mk

diff --git a/target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp-gps.dtso b/target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp-gps.dtso
new file mode 100644 (file)
index 0000000..f2175d8
--- /dev/null
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+/plugin/;
+
+/ {
+       compatible = "gatonetworks,gdsp", "mediatek,mt7981";
+
+       fragment@0 {
+               target = <&uart1>;
+               __overlay__ {
+                       status = "okay";
+               };
+       };
+};
diff --git a/target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp-sd-boot.dtso b/target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp-sd-boot.dtso
new file mode 100644 (file)
index 0000000..46a07cf
--- /dev/null
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+/plugin/;
+
+/ {
+       compatible = "gatonetworks,gdsp", "mediatek,mt7981";
+
+       fragment@1 {
+               target = <&mmc0>;
+               __overlay__ {
+                       card@0 {
+                               compatible = "mmc-card";
+                               reg = <0>;
+
+                               partitions {
+                                       compatible = "gpt-partitions";
+
+                                       sdmmc_fit: block-partition-fit {
+                                               partname = "FIT";
+                                       };
+                               };
+                       };
+               };
+       };
+};
+
+&{/chosen} {
+       rootdisk = <&sdmmc_fit>;
+};
diff --git a/target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp-sd.dtso b/target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp-sd.dtso
new file mode 100644 (file)
index 0000000..cc82281
--- /dev/null
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+/plugin/;
+
+/ {
+       compatible = "gatonetworks,gdsp", "mediatek,mt7981";
+
+       fragment@0 {
+               target = <&mmc0>;
+               __overlay__ {
+                       status = "okay";
+               };
+       };
+};
index ad09ff8bcd1f03116735e2cd6ff0e28018aaa23a..2719b1765604c0d4863eaae494ba6de1064daa40 100644 (file)
        status = "okay";
 };
 
+&mmc0 {
+       status = "disabled";
+
+       #address-cells = <1>;
+       #size-cells = <0>;
+       pinctrl-names = "default", "state_uhs";
+       pinctrl-0 = <&mmc0_pins_default>;
+       pinctrl-1 = <&mmc0_pins_uhs>;
+       bus-width = <4>;
+       max-frequency = <50000000>;
+       cap-sd-highspeed;
+       vmmc-supply = <&reg_3p3v>;
+       vqmmc-supply = <&reg_3p3v>;
+       no-mmc;
+       no-sdio;
+};
+
 &eth {
        status = "okay";
 
                };
        };
 
+       mmc0_pins_default: mmc0-pins-default {
+               mux {
+                       function = "flash";
+                       groups = "emmc_45";
+               };
+               conf-cmd-dat {
+                       pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO",
+                               "SPI0_CS",  "SPI0_HOLD", "SPI0_WP",
+                               "SPI1_CLK", "SPI1_MOSI", "SPI1_MISO";
+                       input-enable;
+                       drive-strength = <MTK_DRIVE_4mA>;
+                       bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
+               };
+               conf-clk {
+                       pins = "SPI1_CS";
+                       drive-strength = <MTK_DRIVE_8mA>;
+                       bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
+               };
+               conf-rst {
+                       pins = "PWM0";
+                       drive-strength = <MTK_DRIVE_4mA>;
+                       bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
+               };
+       };
+
+       mmc0_pins_uhs: mmc0-pins-uhs {
+               mux {
+                       function = "flash";
+                       groups = "emmc_45";
+               };
+               conf-cmd-dat {
+                       pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO",
+                               "SPI0_CS",  "SPI0_HOLD", "SPI0_WP",
+                               "SPI1_CLK", "SPI1_MOSI", "SPI1_MISO";
+                       input-enable;
+                       drive-strength = <MTK_DRIVE_4mA>;
+                       bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
+               };
+               conf-clk {
+                       pins = "SPI1_CS";
+                       drive-strength = <MTK_DRIVE_8mA>;
+                       bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
+               };
+               conf-rst {
+                       pins = "PWM0";
+                       drive-strength = <MTK_DRIVE_4mA>;
+                       bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
+               };
+       };
+
        uart2_pins: uart2-pins {
                mux {
                        function = "uart";
 &uart1 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart1_pins>;
-       status = "okay";
+       status = "disabled";
 };
 
 &uart2 {
index e08e265ab323e84d27f3a004353d1690d98bf3cf..d0e2fff6eb40a2682fc6fa620373e5119f6128f8 100755 (executable)
@@ -269,6 +269,7 @@ platform_copy_config() {
        bananapi,bpi-r4-2g5|\
        bananapi,bpi-r4-poe|\
        cmcc,rax3000m|\
+       gatonetworks,gdsp|\
        mediatek,mt7988a-rfb)
                if [ "$CI_METHOD" = "emmc" ]; then
                        emmc_copy_config
index 78d7e2d249c1c5ab1096a3ec6bc2db5fed80d723..7c7d33098e2586d2d8d024b39b571881fa3304e3 100644 (file)
@@ -30,6 +30,14 @@ define Build/mt7988-bl31-uboot
        cat $(STAGING_DIR_IMAGE)/mt7988_$1-u-boot.fip >> $@
 endef
 
+define Build/simplefit
+       cp $@ $@.tmp 2>/dev/null || true
+       ptgen -g -o $@.tmp -a 1 -l 1024 \
+       -t 0x2e -N FIT          -p $(CONFIG_TARGET_ROOTFS_PARTSIZE)M@17k
+       cat $@.tmp >> $@
+       rm $@.tmp
+endef
+
 define Build/mt798x-gpt
        cp $@ $@.tmp 2>/dev/null || true
        ptgen -g -o $@.tmp -a 1 -l 1024 \
@@ -948,15 +956,23 @@ define Device/gatonetworks_gdsp
   DEVICE_VENDOR := GatoNetworks
   DEVICE_MODEL := gdsp
   DEVICE_DTS := mt7981b-gatonetworks-gdsp
+  DEVICE_DTS_OVERLAY := \
+  mt7981b-gatonetworks-gdsp-gps \
+  mt7981b-gatonetworks-gdsp-sd \
+  mt7981b-gatonetworks-gdsp-sd-boot
   DEVICE_DTS_DIR := ../dts
+  DEVICE_DTC_FLAGS := --pad 4096
   IMAGES := sysupgrade.itb
   IMAGE_SIZE := 32768k
-  DEVICE_PACKAGES := fitblk kmod-mt7915e kmod-mt7981-firmware \
+  DEVICE_PACKAGES := e2fsprogs f2fsck mkf2fs 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
+  ARTIFACTS := preloader.bin bl31-uboot.fip sdcard.img.gz
   ARTIFACT/preloader.bin := mt7981-bl2 nor-ddr3
   ARTIFACT/bl31-uboot.fip := mt7981-bl31-uboot gatonetworks_gdsp
+  ARTIFACT/sdcard.img.gz := simplefit |\
+  append-image squashfs-sysupgrade.itb | check-size | gzip
   KERNEL := kernel-bin | gzip
   KERNEL_INITRAMFS := kernel-bin | lzma | \
        fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k