]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
spl: Introduce spl_board_prepare_for_optee() hook
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>
Thu, 15 Jul 2021 19:19:24 +0000 (14:19 -0500)
committerPatrick Delaunay <patrick.delaunay@foss.st.com>
Tue, 27 Jul 2021 07:47:40 +0000 (09:47 +0200)
OP-TEE requires some particular setup, which is not needed for linux
or other payloads. Add a hook for platform-specific code to perform
any OP-TEE related configuration and initialization.

A weak function is used because it is symmetrical to other
spl_board_prepare_for_*() implementations. A solution to avoid the use
of weak functions would trivially apply to all these implementations.
However, re-designing this is beyond the scope of this patch.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
common/spl/spl.c
include/spl.h

index 3ec16d0de6598fdb340bdbb405151e98e02b76ce..d1b072d82c2d042aa7715ceaf9c66d9d6e779847 100644 (file)
@@ -167,6 +167,10 @@ __weak void spl_board_prepare_for_linux(void)
        /* Nothing to do! */
 }
 
+__weak void spl_board_prepare_for_optee(void *fdt)
+{
+}
+
 __weak void spl_board_prepare_for_boot(void)
 {
        /* Nothing to do! */
@@ -763,6 +767,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 #if CONFIG_IS_ENABLED(OPTEE)
        case IH_OS_TEE:
                debug("Jumping to U-Boot via OP-TEE\n");
+               spl_board_prepare_for_optee(spl_image.fdt_addr);
                spl_optee_entry(NULL, NULL, spl_image.fdt_addr,
                                (void *)spl_image.entry_point);
                break;
index 74a193945207ffa2cc9770688a6fda7f99ebaec3..925b6f0cc6461663f20271d3be35950b747e167f 100644 (file)
@@ -432,6 +432,20 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
                           const struct image_header *header);
 
 void spl_board_prepare_for_linux(void);
+
+/**
+ * spl_board_prepare_for_optee() - Prepare board for an OPTEE payload
+ *
+ * Prepares the board for booting an OP-TEE payload. Initialization is platform
+ * specific, and may include configuring the TrustZone memory, and other
+ * initialization steps required by OP-TEE.
+ * Note that @fdt is not used directly by OP-TEE. OP-TEE passes this @fdt to
+ * its normal world target. This target is not guaranteed to be u-boot, so @fdt
+ * changes that would normally be done by u-boot should be done in this step.
+ *
+ * @fdt: Devicetree that will be passed on, or NULL
+ */
+void spl_board_prepare_for_optee(void *fdt);
 void spl_board_prepare_for_boot(void);
 int spl_board_ubi_load_image(u32 boot_device);
 int spl_board_boot_device(u32 boot_device);