[][OpenWrt Dev][Enable NMBM for mt7986 SNFI]

[Description]
Add and enable NMBM support for mt7986 SNFI

[Release-log]
N/A

Change-Id: I2ea42e0a5cc27d81556ea726cbd46a9880f1c85a
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/4583323
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dtsi b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dtsi
index 566a1f8..3cb5260 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dtsi
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dtsi
@@ -12,6 +12,48 @@
 		// fpga ddr2: 128MB*2
 		reg = <0 0x40000000 0 0x10000000>;
 	};
+
+	nmbm_snfi {
+		compatible = "generic,nmbm";
+
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		lower-mtd-device = <&snand>;
+		forced-create;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "BL2";
+				reg = <0x00000 0x0100000>;
+				read-only;
+			};
+
+			partition@100000 {
+				label = "u-boot-env";
+				reg = <0x0100000 0x0080000>;
+			};
+
+			partition@180000 {
+				label = "Factory";
+				reg = <0x180000 0x0200000>;
+			};
+
+			partition@380000 {
+				label = "FIP";
+				reg = <0x380000 0x0200000>;
+			};
+
+			partition@580000 {
+				label = "ubi";
+				reg = <0x580000 0x4000000>;
+			};
+		};
+	};
 };
 
 &uart0 {
@@ -215,32 +257,6 @@
 		compatible = "fixed-partitions";
 		#address-cells = <1>;
 		#size-cells = <1>;
-
-		partition@0 {
-			label = "BL2";
-			reg = <0x00000 0x0100000>;
-			read-only;
-		};
-
-		partition@100000 {
-			label = "u-boot-env";
-			reg = <0x0100000 0x0080000>;
-		};
-
-		partition@180000 {
-			label = "Factory";
-			reg = <0x180000 0x0200000>;
-		};
-
-		partition@380000 {
-			label = "FIP";
-			reg = <0x380000 0x0200000>;
-		};
-
-		partition@580000 {
-			label = "ubi";
-			reg = <0x580000 0x4000000>;
-		};
 	};
 };
 
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dtsi b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dtsi
index 1fb5f03..89450e6 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dtsi
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dtsi
@@ -12,6 +12,48 @@
 		// fpga ddr2: 128MB*2
 		reg = <0 0x40000000 0 0x10000000>;
 	};
+
+	nmbm_snfi {
+		compatible = "generic,nmbm";
+
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		lower-mtd-device = <&snand>;
+		forced-create;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "BL2";
+				reg = <0x00000 0x0100000>;
+				read-only;
+			};
+
+			partition@100000 {
+				label = "u-boot-env";
+				reg = <0x0100000 0x0080000>;
+			};
+
+			partition@180000 {
+				label = "Factory";
+				reg = <0x180000 0x0200000>;
+			};
+
+			partition@380000 {
+				label = "FIP";
+				reg = <0x380000 0x0200000>;
+			};
+
+			partition@580000 {
+				label = "ubi";
+				reg = <0x580000 0x4000000>;
+			};
+		};
+	};
 };
 
 &uart0 {
@@ -215,32 +257,6 @@
 		compatible = "fixed-partitions";
 		#address-cells = <1>;
 		#size-cells = <1>;
-
-		partition@0 {
-			label = "BL2";
-			reg = <0x00000 0x0100000>;
-			read-only;
-		};
-
-		partition@100000 {
-			label = "u-boot-env";
-			reg = <0x0100000 0x0080000>;
-		};
-
-		partition@180000 {
-			label = "Factory";
-			reg = <0x180000 0x0200000>;
-		};
-
-		partition@380000 {
-			label = "FIP";
-			reg = <0x380000 0x0200000>;
-		};
-
-		partition@580000 {
-			label = "ubi";
-			reg = <0x580000 0x4000000>;
-		};
 	};
 };
 
diff --git a/target/linux/mediatek/mt7986/config-5.4 b/target/linux/mediatek/mt7986/config-5.4
index 0fd1750..6c4b511 100644
--- a/target/linux/mediatek/mt7986/config-5.4
+++ b/target/linux/mediatek/mt7986/config-5.4
@@ -307,6 +307,14 @@
 CONFIG_NET_SWITCHDEV=y
 CONFIG_NET_VENDOR_MEDIATEK=y
 CONFIG_NLS=y
+CONFIG_NMBM=y
+# CONFIG_NMBM_LOG_LEVEL_DEBUG is not set
+CONFIG_NMBM_LOG_LEVEL_INFO=y
+# CONFIG_NMBM_LOG_LEVEL_WARN is not set
+# CONFIG_NMBM_LOG_LEVEL_ERR is not set
+# CONFIG_NMBM_LOG_LEVEL_EMERG is not set
+# CONFIG_NMBM_LOG_LEVEL_NONE is not set
+CONFIG_NMBM_MTD=y
 CONFIG_NO_HZ_COMMON=y
 CONFIG_NO_HZ_IDLE=y
 CONFIG_NR_CPUS=4