diff mbox series

[v2,2/5] spl: Introduce spl_board_prepare_for_optee() hook

Message ID 20210315154715.2258433-3-mr.nuke.me@gmail.com
State Superseded
Delegated to: Patrice Chotard
Headers show
Series stm32mp: Enable OP-TEE and TZC support in SPL | expand

Commit Message

Alexandru Gagniuc March 15, 2021, 3:47 p.m. UTC
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>
---
 common/spl/spl.c |  5 +++++
 include/spl.h    | 14 ++++++++++++++
 2 files changed, 19 insertions(+)

Comments

Patrick DELAUNAY April 7, 2021, 8:02 a.m. UTC | #1
Hi,

On 3/15/21 4:47 PM, Alexandru Gagniuc wrote:
> 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>
> ---
>   common/spl/spl.c |  5 +++++
>   include/spl.h    | 14 ++++++++++++++
>   2 files changed, 19 insertions(+)
>

Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick
diff mbox series

Patch

diff --git a/common/spl/spl.c b/common/spl/spl.c
index e3d84082f4..bf4629588e 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -161,6 +161,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! */
@@ -706,6 +710,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;
diff --git a/include/spl.h b/include/spl.h
index 0d134587de..939b77972a 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -387,6 +387,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);