summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnshul Dalal <[email protected]>2025-10-31 13:07:56 +0530
committerTom Rini <[email protected]>2025-11-06 17:39:49 -0600
commit2da694254df2f061b4f5c7cecbc8a32ce77c6e68 (patch)
tree124b030402c8ea587cf52a52253ede82e9bf02fd
parent518d8c1bec4cd78d3dc2ef574ae99f0918913175 (diff)
mach-k3: r5: common: add bootargs to kernel's dtb
The bootargs are passed to the kernel in the chosen node, this patch adds support for populating bootargs in the dtb if missing. The values for kernel boot params is taken from the env, with 'boot' and 'bootpart' specifying the rootfs for the kernel similar to the non-falcon boot flow. Signed-off-by: Anshul Dalal <[email protected]>
-rw-r--r--arch/arm/mach-k3/r5/common.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/arch/arm/mach-k3/r5/common.c b/arch/arm/mach-k3/r5/common.c
index 8e002504897..03638366046 100644
--- a/arch/arm/mach-k3/r5/common.c
+++ b/arch/arm/mach-k3/r5/common.c
@@ -406,6 +406,46 @@ int k3_r5_falcon_bootmode(void)
return BOOT_DEVICE_NOBOOT;
}
+static int k3_falcon_fdt_add_bootargs(void *fdt)
+{
+ struct disk_partition info;
+ struct blk_desc *dev_desc;
+ char bootmedia[32];
+ char bootpart[32];
+ char str[256];
+ int ret;
+
+ strlcpy(bootmedia, env_get("boot"), sizeof(bootmedia));
+ strlcpy(bootpart, env_get("bootpart"), sizeof(bootpart));
+ ret = blk_get_device_part_str(bootmedia, bootpart, &dev_desc, &info, 0);
+ if (ret < 0) {
+ printf("%s: Failed to get part details for %s %s [%d]\n",
+ __func__, bootmedia, bootpart, ret);
+ return ret;
+ }
+
+ if (!CONFIG_IS_ENABLED(PARTITION_UUIDS)) {
+ printf("ERROR: Failed to find rootfs PARTUUID\n");
+ printf("%s: CONFIG_SPL_PARTITION_UUIDS not enabled\n",
+ __func__);
+ return -EOPNOTSUPP;
+ }
+
+ snprintf(str, sizeof(str), "console=%s root=PARTUUID=%s rootwait",
+ env_get("console"), disk_partition_uuid(&info));
+
+ ret = fdt_find_and_setprop(fdt, "/chosen", "bootargs", str,
+ strlen(str) + 1, 1);
+ if (ret) {
+ printf("%s: Could not set bootargs: %s\n", __func__,
+ fdt_strerror(ret));
+ return ret;
+ }
+
+ debug("%s: Set bootargs to: %s\n", __func__, str);
+ return 0;
+}
+
static int k3_falcon_fdt_fixup(void *fdt)
{
int ret;
@@ -415,6 +455,13 @@ static int k3_falcon_fdt_fixup(void *fdt)
fdt_set_totalsize(fdt, fdt_totalsize(fdt) + CONFIG_SYS_FDT_PAD);
+ if (fdt_path_offset(fdt, "/chosen/bootargs") < 0) {
+ ret = k3_falcon_fdt_add_bootargs(fdt);
+
+ if (ret)
+ return ret;
+ }
+
if (IS_ENABLED(CONFIG_OF_BOARD_SETUP)) {
ret = ft_board_setup(fdt, gd->bd);
if (ret) {