]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
spl: make args file optional in falcon mode
authorAnshul Dalal <anshuld@ti.com>
Thu, 9 Oct 2025 11:58:43 +0000 (17:28 +0530)
committerTom Rini <trini@konsulko.com>
Mon, 20 Oct 2025 17:54:29 +0000 (11:54 -0600)
Falcon mode loads a kernel file and an args file which is the
device-tree. However in the case of kernel file being a FIT that
contains the device-tree within it, loading the args file is not
required.

Therefore, this patch introduces a new SPL_OS_BOOT_ARGS config options
that allows us to enable or disable loading of the args file in falcon
mode.

Signed-off-by: Anshul Dalal <anshuld@ti.com>
common/spl/Kconfig
common/spl/spl.c
common/spl/spl_ext.c
common/spl/spl_fat.c
common/spl/spl_nand.c
common/spl/spl_spi.c
common/spl/spl_ubi.c
include/system-constants.h

index ba94d6fe05ab268c064d48720543547442809e0c..7fd46ace8de83152befe8bcd765ab67d1ae0acff 100644 (file)
@@ -803,7 +803,7 @@ config SPL_FS_LOAD_KERNEL_NAME
 
 config SPL_FS_LOAD_ARGS_NAME
        string "File to load for the OS kernel argument parameters from the filesystem"
-       depends on (SPL_FS_EXT4 || SPL_FS_FAT || SPL_FS_SQUASHFS) && SPL_OS_BOOT
+       depends on (SPL_FS_EXT4 || SPL_FS_FAT || SPL_FS_SQUASHFS) && SPL_OS_BOOT_ARGS
        default "args"
        help
          Filename to read to load for the OS kernel argument parameters from
@@ -1121,7 +1121,7 @@ config SPL_UBI_LOAD_KERNEL_ID
 
 config SPL_UBI_LOAD_ARGS_ID
        int "id of kernel args volume"
-       depends on SPL_OS_BOOT
+       depends on SPL_OS_BOOT_ARGS
        help
          The UBI volume id from which to load the device tree
 
@@ -1215,9 +1215,16 @@ config SPL_OS_BOOT_SECURE
          to use falcon mode by disabling certain inherently non-securable options
          in the SPL boot flow.
 
+config SPL_OS_BOOT_ARGS
+       bool "Allow SPL to load args for kernel in falcon mode"
+       depends on SPL_OS_BOOT || SPL_LOAD_FIT_OPENSBI_OS_BOOT
+       help
+         This option enables the SPL to load an args file (usually the FDT)
+         alongside the kernel image in falcon boot mode.
+
 config SPL_PAYLOAD_ARGS_ADDR
        hex "Address in memory to load 'args' file for Falcon Mode to"
-       depends on SPL_OS_BOOT || SPL_LOAD_FIT_OPENSBI_OS_BOOT
+       depends on SPL_OS_BOOT_ARGS
        default 0x88000000 if ARCH_OMAP2PLUS
        default 0x99000000 if ARCH_SC5XX && SC59X_64
        default 0xA0000000 if ARCH_SC5XX && TARGET_SC594_SOM_EZKIT
@@ -1257,7 +1264,7 @@ config SYS_MMCSD_RAW_MODE_KERNEL_SECTOR
 
 config SYS_MMCSD_RAW_MODE_ARGS_SECTOR
        hex "Falcon mode: Sector to load 'args' from MMC"
-       depends on SPL_FALCON_BOOT_MMCSD
+       depends on SPL_FALCON_BOOT_MMCSD && SPL_OS_BOOT_ARGS
        help
          When Falcon mode is used with an MMC or SD media, SPL needs to know
          where to look for the OS 'args', typically a device tree. The
@@ -1267,7 +1274,7 @@ config SYS_MMCSD_RAW_MODE_ARGS_SECTOR
 
 config SYS_MMCSD_RAW_MODE_ARGS_SECTORS
        hex "Falcon mode: Number of sectors to load for 'args' from MMC"
-       depends on SPL_FALCON_BOOT_MMCSD && SYS_MMCSD_RAW_MODE_ARGS_SECTOR != 0x0
+       depends on SPL_FALCON_BOOT_MMCSD && SPL_OS_BOOT_ARGS
 
 config SPL_PAYLOAD
        string "SPL payload"
@@ -1503,14 +1510,14 @@ config SYS_SPI_KERNEL_OFFS
 
 config SYS_SPI_ARGS_OFFS
        hex "Falcon mode: address of args payload in SPI flash"
-       depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT
+       depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT_ARGS
        help
         Address within SPI-Flash from where the args payload (usually the
         dtb) is fetched in falcon boot.
 
 config SYS_SPI_ARGS_SIZE
        hex "Falcon mode: size of args payload in SPI flash"
-       depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT
+       depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT_ARGS
 
 config SPL_THERMAL
        bool "Driver support for thermal devices"
index 55ad497c86daddce86320cd8205585d338636e08..f1a1785beefc8196c3dcba6dd1c62eef9a1093d3 100644 (file)
@@ -692,6 +692,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
        spl_jump_to_image_t jumper = &jump_to_image;
        struct spl_image_info spl_image;
        int ret, os;
+       void *fdt;
 
        debug(">>" PHASE_PROMPT "board_init_r()\n");
 
@@ -793,8 +794,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
                jumper = &spl_invoke_opensbi;
        } else if (CONFIG_IS_ENABLED(OS_BOOT) && os == IH_OS_LINUX) {
                debug("Jumping to Linux\n");
-               if (IS_ENABLED(CONFIG_SPL_OS_BOOT))
-                       spl_fixup_fdt((void *)SPL_PAYLOAD_ARGS_ADDR);
+               if (CONFIG_IS_ENABLED(OS_BOOT_ARGS))
+                       fdt = (void *)SPL_PAYLOAD_ARGS_ADDR;
+               else
+                       fdt = spl_image_fdt_addr(&spl_image);
+               spl_fixup_fdt(fdt);
                spl_board_prepare_for_linux();
                jumper = &jump_to_image_linux;
        } else {
index c66ba03feb29aabeabec266aa145f4c52a8a76f4..f03e2caaa3b09cb1447d6e67f11fdfc29f20b1cd 100644 (file)
@@ -103,6 +103,7 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image,
                        goto defaults;
                }
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
                ext4fs_set_blk_dev(block_dev, &part_info);
                ext4fs_mount();
                file = env_get("falcon_args_file");
@@ -123,6 +124,7 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image,
                } else {
                        puts("spl: falcon_args_file not set in environment, falling back to default\n");
                }
+#endif
        } else {
                puts("spl: falcon_image_file not set in environment, falling back to default\n");
        }
@@ -135,6 +137,7 @@ defaults:
        if (err)
                return err;
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
        ext4fs_set_blk_dev(block_dev, &part_info);
        ext4fs_mount();
        err = ext4fs_open(CONFIG_SPL_FS_LOAD_ARGS_NAME, &filelen);
@@ -147,6 +150,7 @@ defaults:
                       __func__, CONFIG_SPL_FS_LOAD_ARGS_NAME, err);
                return -1;
        }
+#endif
 
        return 0;
 }
index dc52bd13cec126db496c5c652314d64e1a598f06..e9ee5487d6e39b8701b8c793ae4bd6eef43531f5 100644 (file)
@@ -127,6 +127,7 @@ int spl_load_image_fat_os(struct spl_image_info *spl_image,
                        goto defaults;
                }
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
                file = env_get("falcon_args_file");
                if (file) {
                        err = file_fat_read(
@@ -139,6 +140,8 @@ int spl_load_image_fat_os(struct spl_image_info *spl_image,
                        return 0;
                } else
                        puts("spl: falcon_args_file not set in environment, falling back to default\n");
+#endif
+
        } else
                puts("spl: falcon_image_file not set in environment, falling back to default\n");
 
@@ -150,6 +153,7 @@ defaults:
        if (err)
                return err;
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
        err = file_fat_read(CONFIG_SPL_FS_LOAD_ARGS_NAME,
                            (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, 0);
        if (err <= 0) {
@@ -157,6 +161,7 @@ defaults:
                       __func__, CONFIG_SPL_FS_LOAD_ARGS_NAME, err);
                return -1;
        }
+#endif
 
        return 0;
 }
index 3da292f1437fbf7a105e61cbe90f5dd3511d3182..032f24662786d0a69d0779d64128d504e140f1b4 100644 (file)
@@ -79,7 +79,7 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,
 static int spl_nand_load_image_os(struct spl_image_info *spl_image,
                                  struct spl_boot_device *bootdev)
 {
-       int *src, *dst, err;
+       int err;
        struct legacy_img_hdr *header = spl_get_load_buffer(0, sizeof(*header));
 
        /* load linux */
@@ -101,12 +101,14 @@ static int spl_nand_load_image_os(struct spl_image_info *spl_image,
        if (err)
                return err;
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
        /*
         * load parameter image load to temp position since nand_spl_load_image
         * reads a whole block which is typically larger than
         * CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite following sections
         * like BSS
         */
+       int *src, *dst;
        nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS, CONFIG_CMD_SPL_WRITE_SIZE,
                            (void *)CONFIG_TEXT_BASE);
        /* copy to destintion */
@@ -116,6 +118,7 @@ static int spl_nand_load_image_os(struct spl_image_info *spl_image,
             src++, dst++) {
                writel(readl(src), dst);
        }
+#endif
 
        return 0;
 }
index 4d61214bceba874741f1c4878dd714054a9e1bcc..e8e62d5f9fb484c797fdc167887573835069b086 100644 (file)
@@ -61,10 +61,15 @@ static int spl_spi_load_image_os(struct spl_image_info *spl_image,
        if (err)
                return err;
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
        /* Read device tree. */
        return spi_flash_read(flash, CONFIG_SYS_SPI_ARGS_OFFS,
                              CONFIG_SYS_SPI_ARGS_SIZE,
                              (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR);
+#else
+       return 0;
+#endif
+
 }
 #endif
 
index 25e7599703c4afd1ea9066b9fa3116b5d20039b7..e9ee72277908d0ba658a77136d45646f4d6450ae 100644 (file)
@@ -22,10 +22,14 @@ int spl_ubi_load_image_os(struct spl_image_info *spl_image,
 
        volumes[0].vol_id = CONFIG_SPL_UBI_LOAD_KERNEL_ID;
        volumes[0].load_addr = (void *)CONFIG_SYS_LOAD_ADDR;
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
        volumes[1].vol_id = CONFIG_SPL_UBI_LOAD_ARGS_ID;
        volumes[1].load_addr = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR;
 
        err = ubispl_load_volumes(info, volumes, 2);
+#else
+       err = ubispl_load_volumes(info, volumes, 1);
+#endif
        if (err)
                return err;
 
index e09fc418a47c89f6b95fac04bbb2624c26b6e20a..908bf16d0b4416befed45787d39eaf8df4352815 100644 (file)
@@ -37,7 +37,7 @@
        IF_ENABLED_INT(CONFIG_SPL_SYS_MALLOC, CONFIG_SPL_SYS_MALLOC_SIZE)
 
 /* deal with an optional value */
-#ifdef CONFIG_SPL_OS_BOOT
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
 #define SPL_PAYLOAD_ARGS_ADDR  CONFIG_SPL_PAYLOAD_ARGS_ADDR
 #else
 #define SPL_PAYLOAD_ARGS_ADDR  0