ARM: dts: imx: Convert i.MX8M flash.bin image generation to binman

Rework the flash.bin image generation such that it uses the new binman
nxp_imx8mimage etype. This way, the flash.bin is assembled in correct
order using plain binman, without any workarounds or sections assembled
in special DT node order.

Reviewed-By: Tim Harvey <tharvey@gateworks.com>
Tested-By: Tim Harvey <tharvey@gateworks.com> # imx8mm_venice
Tested-by: Fabio Estevam <festevam@gmail.com> # imx8mm-evk and imx8mn-evk
Signed-off-by: Marek Vasut <marex@denx.de>
diff --git a/arch/arm/dts/imx8mn-u-boot.dtsi b/arch/arm/dts/imx8mn-u-boot.dtsi
index 96b1a1b..ba9967d 100644
--- a/arch/arm/dts/imx8mn-u-boot.dtsi
+++ b/arch/arm/dts/imx8mn-u-boot.dtsi
@@ -5,7 +5,6 @@
 
 / {
 	binman: binman {
-		multiple-images;
 	};
 
 #ifdef CONFIG_OPTEE
@@ -92,78 +91,83 @@
 };
 
 &binman {
-	 u-boot-spl-ddr {
-		filename = "u-boot-spl-ddr.bin";
-		pad-byte = <0xff>;
-		align-size = <4>;
-		align = <4>;
+	filename = "flash.bin";
+	section {
+		pad-byte = <0x00>;
 
-		u-boot-spl {
-			align-end = <4>;
-			filename = "u-boot-spl.bin";
+#ifdef CONFIG_FSPI_CONF_HEADER
+		fspi_conf_block {
+			filename = CONFIG_FSPI_CONF_FILE;
+			type = "blob-ext";
+			offset = <0x400>;
 		};
+#endif
+
+		nxp-imx8mimage {
+			filename = "u-boot-spl-mkimage.bin";
+			nxp,boot-from = "sd";
+			nxp,rom-version = <2>;
+			nxp,loader-address = <CONFIG_SPL_TEXT_BASE>;
+			args;	/* Needed by mkimage etype superclass */
 
-		ddr-1d-imem-fw {
+			section {
+				filename = "u-boot-spl-ddr.bin";
+				pad-byte = <0xff>;
+				align-size = <4>;
+				align = <4>;
+
+				u-boot-spl {
+					align-end = <4>;
+					filename = "u-boot-spl.bin";
+				};
+
+				ddr-1d-imem-fw {
 #ifdef CONFIG_IMX8M_LPDDR4
-			filename = "lpddr4_pmu_train_1d_imem.bin";
+					filename = "lpddr4_pmu_train_1d_imem.bin";
 #elif CONFIG_IMX8M_DDR4
-			filename = "ddr4_imem_1d_201810.bin";
+					filename = "ddr4_imem_1d_201810.bin";
 #else
-			filename = "ddr3_imem_1d.bin";
+					filename = "ddr3_imem_1d.bin";
 #endif
-			type = "blob-ext";
-			align-end = <4>;
-		};
+					type = "blob-ext";
+					align-end = <4>;
+				};
 
-		ddr-1d-dmem-fw {
+				ddr-1d-dmem-fw {
 #ifdef CONFIG_IMX8M_LPDDR4
-			filename = "lpddr4_pmu_train_1d_dmem.bin";
+					filename = "lpddr4_pmu_train_1d_dmem.bin";
 #elif CONFIG_IMX8M_DDR4
-			filename = "ddr4_dmem_1d_201810.bin";
+					filename = "ddr4_dmem_1d_201810.bin";
 #else
-			filename = "ddr3_dmem_1d.bin";
+					filename = "ddr3_dmem_1d.bin";
 #endif
-			type = "blob-ext";
-			align-end = <4>;
-		};
+					type = "blob-ext";
+					align-end = <4>;
+				};
 
 #if defined(CONFIG_IMX8M_LPDDR4) || defined(CONFIG_IMX8M_DDR4)
-		ddr-2d-imem-fw {
+				ddr-2d-imem-fw {
 #ifdef CONFIG_IMX8M_LPDDR4
-			filename = "lpddr4_pmu_train_2d_imem.bin";
+					filename = "lpddr4_pmu_train_2d_imem.bin";
 #else
-			filename = "ddr4_imem_2d_201810.bin";
+					filename = "ddr4_imem_2d_201810.bin";
 #endif
-			type = "blob-ext";
-			align-end = <4>;
-		};
+					type = "blob-ext";
+					align-end = <4>;
+				};
 
-		ddr-2d-dmem-fw {
+				ddr-2d-dmem-fw {
 #ifdef CONFIG_IMX8M_LPDDR4
-			filename = "lpddr4_pmu_train_2d_dmem.bin";
+					filename = "lpddr4_pmu_train_2d_dmem.bin";
 #else
-			filename = "ddr4_dmem_2d_201810.bin";
+					filename = "ddr4_dmem_2d_201810.bin";
 #endif
-			type = "blob-ext";
-			align-end = <4>;
-		};
+					type = "blob-ext";
+					align-end = <4>;
+				};
 #endif
-	};
-
-	spl {
-		filename = "spl.bin";
-
-		mkimage {
-			args = "-n spl/u-boot-spl.cfgout -T imx8mimage -e 0x912000";
-
-			blob {
-				filename = "u-boot-spl-ddr.bin";
 			};
 		};
-	};
-
-	itb {
-		filename = "u-boot.itb";
 
 		fit {
 			description = "Configuration to load ATF before U-Boot";
@@ -172,6 +176,11 @@
 #endif
 			fit,fdt-list = "of-list";
 			#address-cells = <1>;
+#ifdef CONFIG_FSPI_CONF_HEADER
+			offset = <0x59000>;
+#else
+			offset = <0x58000>;
+#endif
 
 			images {
 				uboot {
@@ -236,43 +245,5 @@
 				};
 			};
 		};
-	};
-
-	imx-boot {
-		filename = "flash.bin";
-		pad-byte = <0x00>;
-
-#ifdef CONFIG_FSPI_CONF_HEADER
-		fspi_conf_block {
-			filename = CONFIG_FSPI_CONF_FILE;
-			type = "blob-ext";
-			offset = <0x400>;
-		};
-
-		spl {
-			filename = "spl.bin";
-			offset = <0x1000>;
-			type = "blob-ext";
-		};
-
-		binman_uboot: uboot {
-			filename = "u-boot.itb";
-			offset = <0x59000>;
-			type = "blob-ext";
-		};
-#else
-
-		spl {
-			offset = <0x0>;
-			filename = "spl.bin";
-			type = "blob-ext";
-		};
-
-		binman_uboot: uboot {
-			offset = <0x58000>;
-			filename = "u-boot.itb";
-			type = "blob-ext";
-		};
-#endif
 	};
 };