Generate the Genio 700 boot-chain images from the U-Boot build.

mtk-boot.bin wraps an external DDR loader, padded to its fixed
0x4b000-byte ABI, followed by a CONFIG_SPL_MAX_SIZE U-Boot SPL region
in a MediaTek eMMC BootROM image. The external loader copies that
complete fixed-size SPL window, so pad the region to keep every source
byte inside the BootROM-loaded payload.

bootloaders.img is a conventional FIT containing BL31, U-Boot proper,
OP-TEE, and the U-Boot control devicetree.

Use the standard BL31 and TEE binman inputs and obtain ddr-loader.bin
through BINMAN_INDIRS. Disable SPL binman symbols because SPL and
U-Boot proper live in separate storage images. SPL locates U-Boot
through the GPT FIT partition, so there are no in-image U-Boot offsets
to publish.

Signed-off-by: Vitor Sato Eschholz <[email protected]>
Signed-off-by: Julien Stephan <[email protected]>
Signed-off-by: Carlo Caione <[email protected]>
---
 arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi | 120 ++++++++++++++++++++++++++
 arch/arm/mach-mediatek/Kconfig                |   1 +
 configs/mt8390_genio_700_evk_defconfig        |   1 +
 3 files changed, 122 insertions(+)

diff --git a/arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi 
b/arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi
index 2b392c866fb..cd07538766a 100644
--- a/arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi
+++ b/arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi
@@ -4,6 +4,7 @@
  * Author: Julien Stephan <[email protected]>
  */
 
+#include <config.h>
 #include "mt8188-u-boot.dtsi"
 
 &clk26m {
@@ -43,11 +44,130 @@
 };
 
 / {
+       binman: binman {
+               multiple-images;
+       };
+
        memory@40000000 {
                bootph-pre-ram;
        };
 };
 
+&binman {
+       mtk-boot {
+               filename = "mtk-boot.bin";
+
+               mkimage {
+                       args = "-T", "mtk_image",
+                              "-a", "0x201000",
+                              "-e", "0x201000",
+                              "-n", "media=emmc;arm64=1";
+
+                       section {
+                               pad-byte = <0>;
+
+                               /* Must match SPL_OFFSET in the external DDR 
loader. */
+                               ddr-loader {
+                                       type = "blob-ext";
+                                       filename = "ddr-loader.bin";
+                                       size = <0x4b000>;
+                               };
+
+                               u-boot-spl {
+                                       size = <CONFIG_SPL_MAX_SIZE>;
+                               };
+                       };
+               };
+       };
+
+       bootloaders {
+               filename = "bootloaders.img";
+
+               fit {
+                       description = "MediaTek Genio 700 bootloaders";
+                       #address-cells = <1>;
+
+                       images {
+                               uboot {
+                                       description = "U-Boot";
+                                       type = "firmware";
+                                       os = "u-boot";
+                                       arch = "arm64";
+                                       compression = "none";
+                                       load = <CONFIG_TEXT_BASE>;
+                                       entry = <CONFIG_TEXT_BASE>;
+
+                                       u-boot-nodtb {
+                                       };
+
+                                       hash {
+                                               algo = "sha256";
+                                       };
+                               };
+
+                               atf {
+                                       description = "ARM Trusted Firmware 
BL31";
+                                       type = "firmware";
+                                       os = "arm-trusted-firmware";
+                                       arch = "arm64";
+                                       compression = "none";
+                                       load = <0x54601000>;
+                                       entry = <0x54601000>;
+
+                                       atf-bl31 {
+                                       };
+
+                                       hash {
+                                               algo = "sha256";
+                                       };
+                               };
+
+                               optee {
+                                       description = "OP-TEE";
+                                       type = "firmware";
+                                       os = "tee";
+                                       arch = "arm64";
+                                       compression = "none";
+                                       load = <0x431fffe4>;
+                                       entry = <0x43200000>;
+
+                                       tee-os {
+                                       };
+
+                                       hash {
+                                               algo = "sha256";
+                                       };
+                               };
+
+                               uboot-fdt {
+                                       description = "U-Boot control 
devicetree";
+                                       type = "flat_dt";
+                                       arch = "arm64";
+                                       compression = "none";
+
+                                       u-boot-dtb {
+                                       };
+
+                                       hash {
+                                               algo = "sha256";
+                                       };
+                               };
+                       };
+
+                       configurations {
+                               default = "conf";
+
+                               conf {
+                                       description = "Genio 700 boot chain";
+                                       firmware = "atf";
+                                       loadables = "uboot", "optee";
+                                       fdt = "uboot-fdt";
+                               };
+                       };
+               };
+       };
+};
+
 &mmc0_default_pins {
        bootph-pre-ram;
 
diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
index 5e6c50ca64d..9ff7e7a7f5e 100644
--- a/arch/arm/mach-mediatek/Kconfig
+++ b/arch/arm/mach-mediatek/Kconfig
@@ -87,6 +87,7 @@ config TARGET_MT8183
 config TARGET_MT8188
        bool "MediaTek MT8188 SoC"
        select ARM64
+       select BINMAN if SPL
        help
          The MediaTek MT8188 is a ARM64-based SoC with a dual-core Cortex-A78
          cluster and a six-core Cortex-A55 cluster. It includes UART, SPI,
diff --git a/configs/mt8390_genio_700_evk_defconfig 
b/configs/mt8390_genio_700_evk_defconfig
index 5730b056e29..1287cdf0af6 100644
--- a/configs/mt8390_genio_700_evk_defconfig
+++ b/configs/mt8390_genio_700_evk_defconfig
@@ -2,6 +2,7 @@
 
 CONFIG_DEFAULT_DEVICE_TREE="mediatek/mt8390-genio-700-evk"
 CONFIG_SPL=y
+# CONFIG_SPL_BINMAN_SYMBOLS is not set
 CONFIG_SPL_TEXT_BASE=0x40000000
 CONFIG_SPL_MAX_SIZE=0xaf000
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y

-- 
2.55.0

Reply via email to