From: Anshul Dalal <anshuld@ti.com>
To: <u-boot@lists.denx.de>
Cc: Anshul Dalal <anshuld@ti.com>, <vigneshr@ti.com>,
<trini@konsulko.com>, <afd@ti.com>, <m-chawdhry@ti.com>,
<n-francis@ti.com>, <b-liu@ti.com>
Subject: [PATCH v2 8/8] mach-k3: common: add falcon support for 62[axp]
Date: Tue, 11 Mar 2025 15:27:57 +0530 [thread overview]
Message-ID: <20250311095758.3383047-9-anshuld@ti.com> (raw)
In-Reply-To: <20250311095758.3383047-1-anshuld@ti.com>
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 <anshuld@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
next prev parent reply other threads:[~2025-03-11 9:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 9:57 [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
2025-03-11 9:57 ` [PATCH v2 1/8] spl: Kconfig: allow K3 devices to use falcon mode Anshul Dalal
2025-03-11 9:57 ` [PATCH v2 2/8] mach-k3: fix reading size and addr from fdt on R5 Anshul Dalal
2025-03-11 9:57 ` [PATCH v2 3/8] arm: dts: am62a: allow booting from eMMC Anshul Dalal
2025-03-11 9:57 ` [PATCH v2 4/8] arch: arm: k3-binman: add fit for falcon boot Anshul Dalal
2025-03-11 9:57 ` [PATCH v2 5/8] mach-k3: add eMMC FS boot support for am62[ap] Anshul Dalal
2025-03-11 9:57 ` [PATCH v2 6/8] mach-k3: sysfw-loader: update img_hdr for falcon Anshul Dalal
2025-03-11 9:57 ` [PATCH v2 7/8] config: add falcon boot config fragment for am62x Anshul Dalal
2025-03-11 9:57 ` Anshul Dalal [this message]
2025-04-03 22:08 ` [PATCH v2 0/8] Add falcon support for am62a, 62p and 62x Anshul Dalal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250311095758.3383047-9-anshuld@ti.com \
--to=anshuld@ti.com \
--cc=afd@ti.com \
--cc=b-liu@ti.com \
--cc=m-chawdhry@ti.com \
--cc=n-francis@ti.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox