mediatek: convert mt7988a-rfb to keep bl31/uboot in UBI
authorFelix Fietkau <nbd@nbd.name>
Wed, 8 May 2024 11:40:14 +0000 (13:40 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sun, 19 May 2024 07:47:04 +0000 (09:47 +0200)
Add ubi volumes for mt7988a-rfb and support for using factory data
for Ethernet MAC addresses and MT7996 WLAN calibration data.
Also add rootdisk handle. Removes the need to keep using nmbm

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/boot/uboot-mediatek/patches/105-configs-add-usefull-stuff-to-mt7988-rfb.patch
target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-rfb-spim-nand-factory.dtso [new file with mode: 0644]
target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-rfb-spim-nand.dtso
target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
target/linux/mediatek/image/filogic.mk

index 311a828a9370b7c3b50c1cae9215c50a4e755d19..535af4fa0956a62b9826169286477bf773dab86b 100644 (file)
  CONFIG_MMC_HS200_SUPPORT=y
  CONFIG_MMC_MTK=y
  CONFIG_MTD=y
+--- a/arch/arm/dts/mt7988-rfb.dts
++++ b/arch/arm/dts/mt7988-rfb.dts
+@@ -144,6 +144,23 @@
+               compatible = "spi-nand";
+               reg = <0>;
+               spi-max-frequency = <52000000>;
++
++              partitions {
++                      compatible = "fixed-partitions";
++                      #address-cells = <1>;
++                      #size-cells = <1>;
++
++                      partition@0 {
++                              label = "bl2";
++                              reg = <0x0 0x200000>;
++                      };
++
++                      partition@200000 {
++                              label = "ubi";
++                              reg = <0x200000 0x7e00000>;
++                              compatible = "linux,ubi";
++                      };
++              };
+       };
+ };
diff --git a/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-rfb-spim-nand-factory.dtso b/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-rfb-spim-nand-factory.dtso
new file mode 100644 (file)
index 0000000..3fe75ac
--- /dev/null
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+
+/dts-v1/;
+/plugin/;
+
+/ {
+       compatible = "mediatek,mt7988a-rfb", "mediatek,mt7988a";
+
+       fragment@0 {
+               target = <&ubi_part>;
+
+               __overlay__ {
+                       volumes {
+                               ubi_factory: ubi-volume-factory {
+                                       volname = "factory";
+
+                                       nvmem-layout {
+                                               compatible = "fixed-layout";
+                                               #address-cells = <1>;
+                                               #size-cells = <1>;
+
+                                               eeprom_wmac: eeprom@0 {
+                                                       reg = <0x0 0x1e00>;
+                                               };
+
+                                               gmac2_mac: eeprom@fffee {
+                                                       reg = <0xfffee 0x6>;
+                                               };
+
+                                               gmac1_mac: eeprom@ffff4 {
+                                                       reg = <0xffff4 0x6>;
+                                               };
+
+                                               gmac0_mac: eeprom@ffffa {
+                                                       reg = <0xffffa 0x6>;
+                                               };
+                                       };
+                               };
+                       };
+               };
+       };
+
+       fragment@1 {
+               target = <&pcie0>;
+               __overlay__ {
+                       pcie@0,0 {
+                               reg = <0x0000 0 0 0 0>;
+
+                               wifi@0,0 {
+                                       compatible = "mediatek,mt76";
+                                       reg = <0x0000 0 0 0 0>;
+                                       nvmem-cell-names = "eeprom";
+                                       nvmem-cells = <&eeprom_wmac>;
+                               };
+                       };
+               };
+       };
+
+       fragment@2 {
+               target = <&gmac0>;
+               __overlay__ {
+                       nvmem-cell-names = "mac-address";
+                       nvmem-cells = <&gmac0_mac>;
+               };
+       };
+
+       fragment@3 {
+               target = <&gmac1>;
+               __overlay__ {
+                       nvmem-cell-names = "mac-address";
+                       nvmem-cells = <&gmac1_mac>;
+               };
+       };
+
+       fragment@4 {
+               target = <&gmac2>;
+               __overlay__ {
+                       nvmem-cell-names = "mac-address";
+                       nvmem-cells = <&gmac2_mac>;
+               };
+       };
+};
index a9eca00d4416cb2e85c3a922d1c8aaf535465f68..b5a67c725bf109863cddc798660fdf07027cf923 100644 (file)
@@ -23,9 +23,6 @@
                                spi-max-frequency = <52000000>;
                                spi-tx-bus-width = <4>;
                                spi-rx-bus-width = <4>;
-                               mediatek,nmbm;
-                               mediatek,bmt-max-ratio = <1>;
-                               mediatek,bmt-max-reserved-blocks = <64>;
 
                                partitions {
                                        compatible = "fixed-partitions";
 
                                        partition@0 {
                                                label = "BL2";
-                                               reg = <0x00000 0x0100000>;
+                                               reg = <0x00000 0x0200000>;
                                                read-only;
                                        };
 
-                                       partition@100000 {
-                                               label = "u-boot-env";
-                                               reg = <0x0100000 0x0080000>;
-                                       };
+                                       ubi_part: partition@200000 {
+                                               label = "ubi";
+                                               reg = <0x0200000 0x7e00000>;
+                                               compatible = "linux,ubi";
 
-                                       partition@180000 {
-                                               label = "Factory";
-                                               reg = <0x180000 0x0400000>;
-                                       };
+                                               volumes {
+                                                       ubi-volume-ubootenv {
+                                                               volname = "ubootenv";
+                                                               nvmem-layout {
+                                                                       compatible = "u-boot,env-redundant-bool-layout";
+                                                               };
+                                                       };
 
-                                       partition@580000 {
-                                               label = "FIP";
-                                               reg = <0x580000 0x0200000>;
-                                       };
+                                                       ubi-volume-ubootenv2 {
+                                                               volname = "ubootenv2";
+                                                               nvmem-layout {
+                                                                       compatible = "u-boot,env-redundant-bool-layout";
+                                                               };
+                                                       };
 
-                                       partition@780000 {
-                                               label = "ubi";
-                                               reg = <0x780000 0x7080000>;
+                                                       ubi_root: ubi-volume-fit {
+                                                               volname = "fit";
+                                                       };
+
+                                               };
                                        };
                                };
                        };
                };
        };
+
+       fragment@1 {
+               target-path = "/chosen";
+               __overlay__ {
+                       rootdisk-spim-nand = <&ubi_root>;
+               };
+       };
 };
index ff791a600a3442101219657f96875abfe9d1cdc5..e7b347dc5f9828c75e6a9be50daa92b0dad89346 100755 (executable)
@@ -84,6 +84,7 @@ platform_do_upgrade() {
        bananapi,bpi-r3-mini|\
        bananapi,bpi-r4|\
        bananapi,bpi-r4-poe|\
+       mediatek,mt7988a-rfb|\
        jdcloud,re-cp-03|\
        tplink,tl-xdr4288|\
        tplink,tl-xdr6086|\
index 79489558421b7c041761081bf8ca2ab582f8cae6..5c2f67eb992a12a98017d7bac5736b038befcf99 100644 (file)
@@ -824,6 +824,7 @@ define Device/mediatek_mt7988a-rfb
        mt7988a-rfb-sd \
        mt7988a-rfb-snfi-nand \
        mt7988a-rfb-spim-nand \
+       mt7988a-rfb-spim-nand-factory \
        mt7988a-rfb-spim-nor \
        mt7988a-rfb-eth1-aqr \
        mt7988a-rfb-eth1-i2p5g-phy \
@@ -855,7 +856,7 @@ define Device/mediatek_mt7988a-rfb
   ARTIFACT/emmc-bl31-uboot.fip := mt7988-bl31-uboot rfb-emmc
   ARTIFACT/nor-preloader.bin   := mt7988-bl2 nor-comb
   ARTIFACT/nor-bl31-uboot.fip  := mt7988-bl31-uboot rfb-nor
-  ARTIFACT/snand-preloader.bin := mt7988-bl2 spim-nand-comb
+  ARTIFACT/snand-preloader.bin := mt7988-bl2 spim-nand-ubi-comb
   ARTIFACT/snand-bl31-uboot.fip        := mt7988-bl31-uboot rfb-snand
   ARTIFACT/sdcard.img.gz       := mt798x-gpt sdmmc |\
                                   pad-to 17k | mt7988-bl2 sdmmc-comb |\