]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mach-k3: move k3_falcon_fdt_fixup out of r5/common.c
authorAnshul Dalal <anshuld@ti.com>
Thu, 12 Mar 2026 12:04:17 +0000 (17:34 +0530)
committerTom Rini <trini@konsulko.com>
Wed, 25 Mar 2026 20:37:12 +0000 (14:37 -0600)
k3_falcon_fdt_fixup is used to perform fdt fixups at runtime in falcon
mode such as adding bootargs. Currently the function is only accessible
to the R5 SPL but could be useful for A53 SPL based falcon mode setups
as well.

Therefore this patch moves the function from r5/common.c to common.c.

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 2f3df5519c530b06bb395bd017fb2f8408a2348a..b0a759887147ec4aa7a38749f29d6f28d007f74c 100644 (file)
@@ -457,6 +457,83 @@ static __maybe_unused void k3_dma_remove(void)
                pr_warn("DMA Device not found (err=%d)\n", rc);
 }
 
+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;
+}
+
+int k3_falcon_fdt_fixup(void *fdt)
+{
+       int ret;
+
+       if (!fdt)
+               return -EINVAL;
+
+       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) {
+                       printf("%s: Failed in board setup: %s\n", __func__,
+                              fdt_strerror(ret));
+                       return ret;
+               }
+       }
+
+       if (IS_ENABLED(CONFIG_OF_SYSTEM_SETUP)) {
+               ret = ft_system_setup(fdt, gd->bd);
+               if (ret) {
+                       printf("%s: Failed in system setup: %s\n", __func__,
+                              fdt_strerror(ret));
+                       return ret;
+               }
+       }
+
+       return 0;
+}
+
 void spl_perform_arch_fixups(struct spl_image_info *spl_image)
 {
        void *fdt = spl_image_fdt_addr(spl_image);
@@ -465,6 +542,9 @@ void spl_perform_arch_fixups(struct spl_image_info *spl_image)
                return;
 
        fdt_fixup_reserved(fdt);
+
+       if (IS_ENABLED(CONFIG_SPL_OS_BOOT))
+               k3_falcon_fdt_fixup(fdt);
 }
 
 void spl_board_prepare_for_boot(void)
index e970076d08eccb1e0d41794a6798c5f06bbcf48d..466ad22f895de3b4952507ae70f127bf0cfc2128 100644 (file)
@@ -61,10 +61,13 @@ 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)
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_SECURE)
+int k3_falcon_fdt_fixup(void *fdt);
+#if !IS_ENABLED(CONFIG_ARM64)
 int k3_r5_falcon_bootmode(void);
 int k3_r5_falcon_prep(void);
 #endif
+#endif
 
 #if (IS_ENABLED(CONFIG_K3_QOS))
 void setup_qos(void);
index 03638366046bfed0ffd711ddab4051aaaa79ca24..484d96f953691fbd8c07d5ec389d14c1536e563c 100644 (file)
@@ -406,83 +406,6 @@ 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;
-
-       if (!fdt)
-               return -EINVAL;
-
-       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) {
-                       printf("%s: Failed in board setup: %s\n", __func__,
-                              fdt_strerror(ret));
-                       return ret;
-               }
-       }
-
-       if (IS_ENABLED(CONFIG_OF_SYSTEM_SETUP)) {
-               ret = ft_system_setup(fdt, gd->bd);
-               if (ret) {
-                       printf("%s: Failed in system setup: %s\n", __func__,
-                              fdt_strerror(ret));
-                       return ret;
-               }
-       }
-
-       return 0;
-}
-
 int k3_r5_falcon_prep(void)
 {
        struct spl_image_loader *loader, *drv;