]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mach-k3: common: enable falcon mode from R5 SPL
authorAnshul Dalal <anshuld@ti.com>
Fri, 31 Oct 2025 07:37:53 +0000 (13:07 +0530)
committerTom Rini <trini@konsulko.com>
Thu, 6 Nov 2025 23:39:49 +0000 (17:39 -0600)
We use the spl_board_prepare_for_boot hook to call k3_r5_falcon_prep
which is ran after tispl is loaded but before jump_to_image.

In k3_r5_falcon_prep, we find the boot media and load the kernel FIT
just as standard secure falcon mode (since spl_start_uboot returns 0
now). Once the kernel and args are loaded.

Now when the flow goes to jump_to_image, we do the regular pre-jump
procedure and jump to TFA which jumps to the kernel directly since we
have already loaded the kernel and dtb at their respective addresses
(PRELOADED_BL33_BASE and K3_HW_CONFIG_BASE).

Overall execution for the R5 SPL after this patch:

  board_init_r
  |-> boot_from_devices
  |   +-> load_image (we load tifalcon.bin here since spl_start_uboot
  |                   returns 1)
  |
  +-> spl_prepare_for_boot
  |   +-> k3_falcon_prep
  |       +-> load_image (we load fitImage here since spl_start_uboot
  |                       returns 0 now)
  |
  +-> jump_to_image

Signed-off-by: Anshul Dalal <anshuld@ti.com>
arch/arm/mach-k3/common.c
arch/arm/mach-k3/common.h
arch/arm/mach-k3/r5/common.c

index 3f51b9614d967d921492c07b39fb7b63b57f508f..760aaad03411441e3cc169f2501134cf69dcbee6 100644 (file)
@@ -361,6 +361,14 @@ void spl_perform_arch_fixups(struct spl_image_info *spl_image)
 
 void spl_board_prepare_for_boot(void)
 {
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_SECURE) && !IS_ENABLED(CONFIG_ARM64)
+       int ret;
+
+       ret = k3_r5_falcon_prep();
+       if (ret)
+               panic("%s: Failed to boot in falcon mode: %d\n", __func__, ret);
+#endif /* falcon mode on R5 SPL */
+
 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
        dcache_disable();
 #endif
index 52d3faaab5c94578cf4f7e288cbf840500d490a1..5807d3584645d3e80443842c7e11e653c6bb8468 100644 (file)
@@ -52,6 +52,10 @@ void do_board_detect(void);
 void ti_secure_image_check_binary(void **p_image, size_t *p_size);
 int shutdown_mcu_r5_core1(void);
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_SECURE) && !IS_ENABLED(CONFIG_ARM64)
+int k3_r5_falcon_bootmode(void);
+#endif
+
 #if (IS_ENABLED(CONFIG_K3_QOS))
 void setup_qos(void);
 #else
index 6269b33f66b0a65dd26b555619a81feb57dd2ed5..f0654102737466ef9a1519d950d6137c6a9e8452 100644 (file)
@@ -376,3 +376,49 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image,
        }
 }
 #endif
+
+#ifdef CONFIG_SPL_OS_BOOT_SECURE
+
+static bool tifalcon_loaded = false;
+
+int spl_start_uboot(void)
+{
+       /* If tifalcon.bin is not loaded, proceed to regular boot */
+       if (!tifalcon_loaded)
+               return 1;
+
+       /* Boot to linux on R5 SPL with tifalcon.bin loaded */
+       return 0;
+}
+
+int k3_r5_falcon_prep(void)
+{
+       struct spl_image_loader *loader, *drv;
+       struct spl_image_info kernel_image;
+       struct spl_boot_device bootdev;
+       int ret = -ENXIO, n_ents;
+
+       tifalcon_loaded = true;
+       memset(&kernel_image, '\0', sizeof(kernel_image));
+       drv = ll_entry_start(struct spl_image_loader, spl_image_loader);
+       n_ents = ll_entry_count(struct spl_image_loader, spl_image_loader);
+       bootdev.boot_device = spl_boot_device();
+
+       for (loader = drv; loader != drv + n_ents; loader++) {
+               if (loader && bootdev.boot_device != loader->boot_device)
+                       continue;
+
+               printf("Load falcon from %s\n", spl_loader_name(loader));
+               ret = loader->load_image(&kernel_image, &bootdev);
+               if (ret)
+                       continue;
+
+               return 0;
+       }
+
+       printf("%s: ERROR: No supported loader for boot dev '%d'\n", __func__,
+              bootdev.boot_device);
+
+       return ret;
+}
+#endif