spl: split spl_board_fixups to arch/board specific
authorAnshul Dalal <anshuld@ti.com>
Fri, 17 Oct 2025 13:15:30 +0000 (18:45 +0530)
committerTom Rini <trini@konsulko.com>
Wed, 22 Oct 2025 18:05:52 +0000 (12:05 -0600)
The current spl_board_fixups API allows for modification of spl_image
before the SPL jumps to it. This can be used to modify the DT for the
next boot stage, however the current API only allows either the machine
arch or the board to use it.

This limits the utility of the API as there might be certain fixups that
should be applied to all boards sharing the same machine architecture
with others being board specific.

For TI's K3 specifically, this prevents us from performing architecture
level fixups since a lot of TI boards are already making use of the
spl_board_fixups API.

Therefore this patch splits the API into two to allow both board and the
architecture specific fixups. The order is kept as arch then board to
give board specific fixups the precedence.

Reviewed-by: Dhruva Gole <d-gole@ti.com>
Signed-off-by: Anshul Dalal <anshuld@ti.com>
Tested-by: Wadim Egorov <w.egorov@phytec.de>
20 files changed:
arch/arm/cpu/armv7m/cpu.c
arch/arm/mach-rockchip/spl-boot-order.c
arch/arm/mach-socfpga/spl_soc64.c
board/beagle/beagley-ai/beagley-ai.c
board/dhelectronics/dh_stm32mp1/board.c
board/phytec/phycore_am62x/phycore-am62x.c
board/phytec/phycore_am64x/phycore-am64x.c
board/renesas/sparrowhawk/sparrowhawk.c
board/starfive/visionfive2/spl.c
board/ti/am62ax/evm.c
board/ti/am62dx/evm.c
board/ti/am62px/evm.c
board/ti/am62x/evm.c
board/ti/am64x/evm.c
board/ti/j721e/evm.c
board/ti/j721s2/evm.c
board/ti/j722s/evm.c
board/ti/j784s4/evm.c
common/spl/spl.c
include/spl.h

index b4440d3..bea0e1d 100644 (file)
@@ -57,7 +57,7 @@ void reset_cpu(void)
                | V7M_AIRCR_SYSRESET, &V7M_SCB->aircr);
 }
 
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_arch_fixups(struct spl_image_info *spl_image)
 {
        spl_image->entry_point |= 0x1;
 }
index 1bfd120..561bddd 100644 (file)
@@ -240,7 +240,7 @@ int spl_decode_boot_device(u32 boot_device, char *buf, size_t buflen)
 #endif
 }
 
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_arch_fixups(struct spl_image_info *spl_image)
 {
        const char *bootrom_ofpath = board_spl_was_booted_from();
        void *blob = spl_image_fdt_addr(spl_image);
index 651d9fc..fa7b150 100644 (file)
@@ -130,7 +130,7 @@ u32 spl_boot_mode(const u32 boot_device)
 #endif
 
 /* board specific function prior loading SSBL / U-Boot */
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_arch_fixups(struct spl_image_info *spl_image)
 {
        int ret;
        struct udevice *dev;
index 26fa54e..500cc30 100644 (file)
@@ -32,7 +32,7 @@ int dram_init_banksize(void)
 }
 
 #if defined(CONFIG_XPL_BUILD)
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        if (IS_ENABLED(CONFIG_K3_DDRSS)) {
                if (IS_ENABLED(CONFIG_K3_INLINE_ECC))
index bd9326d..d98b2c6 100644 (file)
@@ -776,7 +776,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 #endif
 
 #if defined(CONFIG_XPL_BUILD)
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        dh_stm32_ks8851_fixup(spl_image_fdt_addr(spl_image));
 }
index 51da864..3cdcbf2 100644 (file)
@@ -199,7 +199,7 @@ int do_board_detect(void)
 #endif
 
 #if IS_ENABLED(CONFIG_XPL_BUILD)
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        if (IS_ENABLED(CONFIG_K3_DDRSS) && IS_ENABLED(CONFIG_K3_INLINE_ECC))
                fixup_ddr_driver_for_ecc(spl_image);
index 33c3937..114aa21 100644 (file)
@@ -118,7 +118,7 @@ int do_board_detect(void)
 #endif
 
 #if IS_ENABLED(CONFIG_XPL_BUILD)
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        if (IS_ENABLED(CONFIG_K3_DDRSS) && IS_ENABLED(CONFIG_K3_INLINE_ECC))
                fixup_ddr_driver_for_ecc(spl_image);
index a4eda85..f5b1a56 100644 (file)
@@ -134,7 +134,7 @@ unsigned int spl_spi_get_uboot_offs(struct spi_flash *flash)
        return CONFIG_SYS_SPI_U_BOOT_OFFS;
 }
 
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        void *blob = spl_image_fdt_addr(spl_image);
        int err, offs;
index 420a8cf..48b034a 100644 (file)
@@ -20,7 +20,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define JH7110_CLK_CPU_ROOT_SHIFT              24
 #define JH7110_CLK_CPU_ROOT_MASK               GENMASK(29, 24)
 
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        /* Update the memory size which read from eeprom or DT */
        if (spl_image->fdt_addr)
index a445f98..da6c311 100644 (file)
@@ -17,7 +17,7 @@
 #include "../common/fdt_ops.h"
 
 #if defined(CONFIG_XPL_BUILD)
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        if (IS_ENABLED(CONFIG_K3_DDRSS)) {
                if (IS_ENABLED(CONFIG_K3_INLINE_ECC))
index 1d82161..0924954 100644 (file)
@@ -17,7 +17,7 @@
 #include "../common/fdt_ops.h"
 
 #if defined(CONFIG_XPL_BUILD)
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        if (IS_ENABLED(CONFIG_K3_DDRSS)) {
                if (IS_ENABLED(CONFIG_K3_INLINE_ECC))
index c06e387..85c332b 100644 (file)
@@ -50,7 +50,7 @@ void spl_board_init(void)
 #endif
 
 #if defined(CONFIG_XPL_BUILD)
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        if (IS_ENABLED(CONFIG_K3_DDRSS)) {
                if (IS_ENABLED(CONFIG_K3_INLINE_ECC))
index d7b07a0..c2c7a02 100644 (file)
@@ -91,7 +91,7 @@ void spl_board_init(void)
 
 }
 
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        if (IS_ENABLED(CONFIG_K3_DDRSS)) {
                if (IS_ENABLED(CONFIG_K3_INLINE_ECC))
index 8e89b3b..f9bb593 100644 (file)
@@ -98,7 +98,7 @@ static int fixup_usb_boot(const void *fdt_blob)
 }
 #endif
 
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        if (IS_ENABLED(CONFIG_K3_DDRSS)) {
                if (IS_ENABLED(CONFIG_K3_INLINE_ECC))
index 1527eaf..e030fe7 100644 (file)
@@ -127,7 +127,7 @@ static void __maybe_unused detect_enable_hyperflash(void *blob)
 
 #if defined(CONFIG_XPL_BUILD) && (defined(CONFIG_TARGET_J7200_A72_EVM) || defined(CONFIG_TARGET_J7200_R5_EVM) || \
                                        defined(CONFIG_TARGET_J721E_A72_EVM) || defined(CONFIG_TARGET_J721E_R5_EVM))
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        detect_enable_hyperflash(spl_image->fdt_addr);
 }
index 5d3b846..b6d1964 100644 (file)
@@ -40,7 +40,7 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
 }
 
 #if defined(CONFIG_XPL_BUILD)
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        if (IS_ENABLED(CONFIG_K3_DDRSS)) {
                if (IS_ENABLED(CONFIG_K3_INLINE_ECC))
index 32d767c..1173adc 100644 (file)
@@ -24,7 +24,7 @@ void spl_board_init(void)
 #endif
 
 #if defined(CONFIG_XPL_BUILD)
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        if (IS_ENABLED(CONFIG_K3_DDRSS)) {
                if (IS_ENABLED(CONFIG_K3_INLINE_ECC))
index 6335676..cabb301 100644 (file)
@@ -42,7 +42,7 @@ struct efi_capsule_update_info update_info = {
 };
 
 #if defined(CONFIG_XPL_BUILD)
-void spl_perform_fixups(struct spl_image_info *spl_image)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
        if (IS_ENABLED(CONFIG_K3_DDRSS)) {
                if (IS_ENABLED(CONFIG_K3_INLINE_ECC))
index 8c20b75..64313cb 100644 (file)
@@ -120,8 +120,13 @@ int __weak booti_setup(ulong image, ulong *relocated_addr, ulong *size, bool for
 }
 #endif
 
-/* Weak default function for arch/board-specific fixups to the spl_image_info */
-void __weak spl_perform_fixups(struct spl_image_info *spl_image)
+/* Weak default function for arch specific fixups to the spl_image_info */
+void __weak spl_perform_arch_fixups(struct spl_image_info *spl_image)
+{
+}
+
+/* Weak default function for board specific fixups to the spl_image_info */
+void __weak spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
 }
 
@@ -776,7 +781,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
                hang();
        }
 
-       spl_perform_fixups(&spl_image);
+       spl_perform_arch_fixups(&spl_image);
+       spl_perform_board_fixups(&spl_image);
 
        os = spl_image.os;
        if (os == IH_OS_U_BOOT) {
index 7c10c7f..cf45d41 100644 (file)
@@ -1116,10 +1116,16 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
 ulong board_spl_fit_size_align(ulong size);
 
 /**
- * spl_perform_fixups() - arch/board-specific callback before processing
- *                        the boot-payload
+ * spl_perform_arch_fixups() - arch specific callback before processing the
+ *                        boot-payload
  */
-void spl_perform_fixups(struct spl_image_info *spl_image);
+void spl_perform_arch_fixups(struct spl_image_info *spl_image);
+
+/**
+ * spl_perform_board_fixups() - board specific callback before processing the
+ *                        boot-payload
+ */
+void spl_perform_board_fixups(struct spl_image_info *spl_image);
 
 /*
  * spl_get_load_buffer() - get buffer for loading partial image data