[PATCH v5 7/7] arm: mach-k3: r5: common: Invoke boot of HSM M4 core

Beleswar Padhi <[email protected]> Mon, 20 Jul 2026 13:31:14 +0530
Newsgroups de.denx.lists.u-boot
Message-ID <[email protected]>
The tispl.bin fit image is packed with the HSM firmware image. Add
support to load and boot the HSM M4F core during R5 SPL stage using the
remoteprocessor framework.

Add IMAGE_ID_HSM enum and "hsm" OS type to detect HSM firmware in the
FIT image. Track the load address for all FIT images. Load HSM firmware
to remoteproc device 2 and start the core using the remoteprocessor
framework when CONFIG_REMOTEPROC_TI_K3_HSM_M4F is enabled.

Skip HSM firmware from R5 secure image authentication as TIFS will
authenticate it during the remoteproc load operation.

Signed-off-by: Beleswar Padhi <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
---
v5: Changelog:
1. Optimize if-else ladder for logging.
2. Call ti_secure_image_post_process() only once for HSM image (during
rproc load).
3. Add R/B tag.

Link to v4:
https://lore.kernel.org/all/[email protected]/

v4: Changelog:
1. None

Link to v3:
https://lore.kernel.org/all/[email protected]/

v3: Changelog:
1. Use remoteproc framework to boot HSM core.

Link to v2:
https://lore.kernel.org/all/[email protected]/

v2: Changelog:
1. Hang system boot if HSM firmware failed to boot.
2. __maybe_unused to decrease preprocessor usage.
3. Better error messages with return code.
4. Added Error case in if-elseif-else ladder.

Note:
#define PROC_ID_HSM_M4F seems to have extra tab in the diff/patch.
But when patch gets applied in file, all of them have consistent
tabs.

Link to v1:
https://lore.kernel.org/all/[email protected]

 arch/arm/mach-k3/r5/common.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-k3/r5/common.c b/arch/arm/mach-k3/r5/common.c
index a0e1b791c82..fe4d22fe25f 100644
--- a/arch/arm/mach-k3/r5/common.c
+++ b/arch/arm/mach-k3/r5/common.c
@@ -28,6 +28,7 @@ enum {
 	IMAGE_ID_TIFSSTUB_HS,
 	IMAGE_ID_TIFSSTUB_FS,
 	IMAGE_ID_TIFSSTUB_GP,
+	IMAGE_ID_HSM,
 	IMAGE_AMT,
 };
 
@@ -40,6 +41,7 @@ static const char *image_os_match[IMAGE_AMT] = {
 	"tifsstub-hs",
 	"tifsstub-fs",
 	"tifsstub-gp",
+	"hsm",
 };
 #endif
 
@@ -158,6 +160,23 @@ void __noreturn jump_to_image(struct spl_image_info *spl_image)
 				     &loadaddr);
 	}
 
+	/*
+	 * It is assumed that remoteproc device 2 is the corresponding
+	 * Cortex-M4F HSM core. Make sure DT reflects the same.
+	 */
+	if (IS_ENABLED(CONFIG_REMOTEPROC_TI_K3_HSM_M4F)) {
+		ret = rproc_load(2, fit_image_info[IMAGE_ID_HSM].load,
+				 fit_image_info[IMAGE_ID_HSM].image_len);
+		if (ret)
+			panic("Error while loading HSM firmware, ret = %d\n", ret);
+
+		ret = rproc_start(2);
+		if (ret)
+			panic("Error while starting HSM core\n");
+
+		printf("Successfully loaded and started HSM core\n");
+	}
+
 	/*
 	 * It is assumed that remoteproc device 1 is the corresponding
 	 * Cortex-A core which runs ATF. Make sure DT reflects the same.
@@ -330,17 +349,19 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image,
 	int len;
 	int i;
 	const char *os;
-	u32 addr;
+	u32 addr, load_addr;
 
 	os = fdt_getprop(fit, node, "os", &len);
 	addr = fdt_getprop_u32_default_node(fit, node, 0, "entry", -1);
+	load_addr = fdt_getprop_u32_default_node(fit, node, 0, "load", 0);
 
-	debug("%s: processing image: addr=%x, size=%d, os=%s\n", __func__,
-	      addr, *p_size, os);
+	debug("%s: processing image: addr=%x, load=%x, size=%d, os=%s\n", __func__,
+	      addr, load_addr, *p_size, os);
 
 	for (i = 0; i < IMAGE_AMT; i++) {
 		if (!strcmp(os, image_os_match[i])) {
 			fit_image_info[i].image_start = addr;
+			fit_image_info[i].load = load_addr;
 			fit_image_info[i].image_len = *p_size;
 			debug("%s: matched image for ID %d\n", __func__, i);
 			break;
@@ -369,7 +390,7 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image,
 	 * Only DM and the DTBs are being authenticated here,
 	 * rest will be authenticated when A72 cluster is up
 	 */
-	if ((i != IMAGE_ID_ATF) && (i != IMAGE_ID_OPTEE)) {
+	if ((i != IMAGE_ID_ATF) && (i != IMAGE_ID_OPTEE) && (i != IMAGE_ID_HSM)) {
 		ti_secure_image_check_binary(p_image, p_size);
 		ti_secure_image_post_process(p_image, p_size);
 	} else {
-- 
2.34.1