We use the spl_board_prepare_for_boot hook to call k3_falcon_prep which is ran after tispl is loaded but before jump_to_image.
In here, we find the boot media and load the image just as std falcon flow (since spl_start_uboot returns 0 now). Once the kernel and args are loaded, we perform fdt fixups on the fdt accompanying the kernel (if loaded as FIT) or the loaded up args and return. Now when the flow goes to jump_to_image, we do the regular pre-jump procedure and jump to ATF 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). Signed-off-by: Anshul Dalal <ansh...@ti.com> --- arch/arm/mach-k3/common.c | 105 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index fa8cd93d664..6e41aa8318b 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -263,8 +263,113 @@ static __maybe_unused void k3_dma_remove(void) pr_warn("DMA Device not found (err=%d)\n", rc); } +#if IS_ENABLED(CONFIG_SPL_OS_BOOT) && !IS_ENABLED(CONFIG_ARM64) +static bool tispl_loaded; + +int spl_start_uboot(void) +{ + if (!tispl_loaded) + return 1; + return 0; +} + +static int k3_falcon_fdt_fixup(void *fdt) +{ + struct disk_partition info; + struct blk_desc *dev_desc; + char bootmedia[32]; + char bootpart[32]; + char str[256]; + int ret; + + strcpy(bootmedia, env_get("boot")); + strcpy(bootpart, env_get("bootpart")); + ret = blk_get_device_part_str(bootmedia, bootpart, &dev_desc, &info, 0); + if (ret < 0) + printf("Failed to get part details for %s %s [%d]\n", bootmedia, + bootpart, ret); + sprintf(str, "console=%s root=PARTUUID=%s rootwait", env_get("console"), + info.uuid); + ret = fdt_find_and_setprop(fdt, "/chosen", "bootargs", str, + strlen(str) + 1, 1); + if (ret) { + printf("Could not set bootargs: %s\n", fdt_strerror(ret)); + return ret; + } + debug("Set bootargs to: %s\n", str); + +#ifdef CONFIG_OF_BOARD_SETUP + ret = ft_board_setup(fdt, gd->bd); + if (ret) { + printf("Failed in board fdt fixups: %s\n", fdt_strerror(ret)); + return ret; + } +#endif + +#ifdef CONFIG_OF_SYSTEM_SETUP + ret = ft_system_setup(fdt, gd->bd); + if (ret) { + printf("Failed in system fdt fixups: %s\n", fdt_strerror(ret)); + return ret; + } +#endif + + return 0; +} + +static int k3_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; + void *fdt; + + tispl_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(); + if (bootdev.boot_device == BOOT_DEVICE_SPI) { + if (strcmp(env_get("mmcdev"), "1") == 0) + bootdev.boot_device = BOOT_DEVICE_MMC; + else + bootdev.boot_device = BOOT_DEVICE_EMMC; + } + bootdev.boot_device_name = NULL; + + for (loader = drv; loader != drv + n_ents; loader++) { + if (bootdev.boot_device != loader->boot_device) + continue; + if (loader) { + printf("Loading falcon payload from %s\n", + spl_loader_name(loader)); + ret = loader->load_image(&kernel_image, &bootdev); + if (ret) + continue; + + fdt = spl_image_fdt_addr(&kernel_image); + if (!fdt) + fdt = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR; + ret = k3_falcon_fdt_fixup(fdt); + if (ret) { + printf("Failed performing fdt fixups in falcon flow: [%d]\n", + ret); + return ret; + } + return 0; + } + } + + return ret; +} +#endif + void spl_board_prepare_for_boot(void) { +#if IS_ENABLED(CONFIG_SPL_OS_BOOT) && !IS_ENABLED(CONFIG_ARM64) + k3_falcon_prep(); +#endif #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) dcache_disable(); #endif -- 2.43.0