[PATCH v3 0/2] Introduce spl_soc_init() for SoC specific initialization

From: Lukas Funke lukas.funke@weidmueller.com
Currently some vendors use spl_board_init() for their SoC specific initialization. This prohibits board developers from adding board init code using said function. This series introduces a new function in order to separate SoC init code from board init code.
Changes in v3: - Rephrase Kconfig description and correct minor typo
Changes in v2: - Change spl_arch_init() to spl_soc_init()
Lukas Funke (2): spl: Introduce SoC specific init function arm64: zynq(mp): Rename spl_board_init() to spl_soc_init()
arch/arm/Kconfig | 4 ++-- arch/arm/mach-zynq/spl.c | 4 ++-- arch/arm/mach-zynqmp/spl.c | 4 ++-- common/spl/Kconfig | 7 +++++++ common/spl/spl.c | 3 +++ include/spl.h | 8 ++++++++ 6 files changed, 24 insertions(+), 6 deletions(-)

From: Lukas Funke lukas.funke@weidmueller.com
Some architectures use spl_board_init() in their SoC specific implementation. Board developers should be able to add board specific implementation via spl_board_init(). Hence, introduce a spl_soc_init() method which is called right before spl_board_init() for SoC specific implementation.
Signed-off-by: Lukas Funke lukas.funke@weidmueller.com Reviewed-by: Devarsh Thakkar devarsht@ti.com ---
(no changes since v1)
common/spl/Kconfig | 7 +++++++ common/spl/spl.c | 3 +++ include/spl.h | 8 ++++++++ 3 files changed, 18 insertions(+)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 6405374bcc..eece8e58ce 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -272,6 +272,13 @@ config SPL_TEXT_BASE help The address in memory that SPL will be running from.
+config SPL_SOC_INIT + bool "Call SoC-specific initialization in SPL" + help + If this option is enabled, U-Boot will call the function + spl_soc_init() from board_init_r(). This function should be + provided by the SoC vendor. + config SPL_BOARD_INIT bool "Call board-specific initialization in SPL" help diff --git a/common/spl/spl.c b/common/spl/spl.c index b65c439e7a..9b83c85df5 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -711,6 +711,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } }
+ if (CONFIG_IS_ENABLED(SOC_INIT)) + spl_soc_init(); + if (CONFIG_IS_ENABLED(BOARD_INIT)) spl_board_init();
diff --git a/include/spl.h b/include/spl.h index 043875f10f..5dfdf778d2 100644 --- a/include/spl.h +++ b/include/spl.h @@ -816,6 +816,14 @@ int spl_early_init(void); */ int spl_init(void);
+/* + * spl_soc_init() - Do architecture-specific init in SPL + * + * If SPL_SOC_INIT is enabled, this is called from board_init_r() before + * jumping to the next phase. + */ +void spl_soc_init(void); + /* * spl_board_init() - Do board-specific init in SPL *

From: Lukas Funke lukas.funke@weidmueller.com
Rename spl_board_init() to spl_soc_init(). SoC specific implementation should be separated from board specific implementation in order to be extended by board developers.
Signed-off-by: Lukas Funke lukas.funke@weidmueller.com ---
Changes in v3: - Rephrase Kconfig description and correct minor typo
Changes in v2: - Change spl_arch_init() to spl_soc_init()
arch/arm/Kconfig | 4 ++-- arch/arm/mach-zynq/spl.c | 4 ++-- arch/arm/mach-zynqmp/spl.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 01d6556c42..db56db9414 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1275,7 +1275,7 @@ config ARCH_ZYNQ select OF_CONTROL select MTD select SPI - select SPL_BOARD_INIT if SPL + select SPL_SOC_INIT if SPL select SPL_CLK if SPL select SPL_DM if SPL select SPL_DM_SPI if SPL @@ -1318,7 +1318,7 @@ config ARCH_ZYNQMP imply FIRMWARE select GICV2 select OF_CONTROL - select SPL_BOARD_INIT if SPL + select SPL_SOC_INIT if SPL select SPL_CLK if SPL select SPL_DM if SPL select SPL_DM_SPI if SPI && SPL_DM diff --git a/arch/arm/mach-zynq/spl.c b/arch/arm/mach-zynq/spl.c index fea1c9b12a..112b44e2e1 100644 --- a/arch/arm/mach-zynq/spl.c +++ b/arch/arm/mach-zynq/spl.c @@ -32,8 +32,8 @@ void board_init_f(ulong dummy) arch_cpu_init(); }
-#ifdef CONFIG_SPL_BOARD_INIT -void spl_board_init(void) +#ifdef CONFIG_SPL_SOC_INIT +void spl_soc_init(void) { preloader_console_init(); #if defined(CONFIG_ARCH_EARLY_INIT_R) && defined(CONFIG_SPL_FPGA) diff --git a/arch/arm/mach-zynqmp/spl.c b/arch/arm/mach-zynqmp/spl.c index a0f35f36fa..71f9932525 100644 --- a/arch/arm/mach-zynqmp/spl.c +++ b/arch/arm/mach-zynqmp/spl.c @@ -56,8 +56,8 @@ static void ps_mode_reset(ulong mode) # define MODE_RESET PS_MODE1 #endif
-#ifdef CONFIG_SPL_BOARD_INIT -void spl_board_init(void) +#ifdef CONFIG_SPL_SOC_INIT +void spl_soc_init(void) { preloader_console_init(); ps_mode_reset(MODE_RESET);

On 3/27/24 13:11, lukas.funke-oss@weidmueller.com wrote:
From: Lukas Funke lukas.funke@weidmueller.com
Rename spl_board_init() to spl_soc_init(). SoC specific implementation should be separated from board specific implementation in order to be extended by board developers.
Signed-off-by: Lukas Funke lukas.funke@weidmueller.com
Changes in v3:
- Rephrase Kconfig description and correct minor typo
Changes in v2:
- Change spl_arch_init() to spl_soc_init()
arch/arm/Kconfig | 4 ++-- arch/arm/mach-zynq/spl.c | 4 ++-- arch/arm/mach-zynqmp/spl.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 01d6556c42..db56db9414 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1275,7 +1275,7 @@ config ARCH_ZYNQ select OF_CONTROL select MTD select SPI
- select SPL_BOARD_INIT if SPL
- select SPL_SOC_INIT if SPL select SPL_CLK if SPL select SPL_DM if SPL select SPL_DM_SPI if SPL
@@ -1318,7 +1318,7 @@ config ARCH_ZYNQMP imply FIRMWARE select GICV2 select OF_CONTROL
- select SPL_BOARD_INIT if SPL
- select SPL_SOC_INIT if SPL select SPL_CLK if SPL select SPL_DM if SPL select SPL_DM_SPI if SPI && SPL_DM
diff --git a/arch/arm/mach-zynq/spl.c b/arch/arm/mach-zynq/spl.c index fea1c9b12a..112b44e2e1 100644 --- a/arch/arm/mach-zynq/spl.c +++ b/arch/arm/mach-zynq/spl.c @@ -32,8 +32,8 @@ void board_init_f(ulong dummy) arch_cpu_init(); }
-#ifdef CONFIG_SPL_BOARD_INIT -void spl_board_init(void) +#ifdef CONFIG_SPL_SOC_INIT +void spl_soc_init(void) { preloader_console_init(); #if defined(CONFIG_ARCH_EARLY_INIT_R) && defined(CONFIG_SPL_FPGA) diff --git a/arch/arm/mach-zynqmp/spl.c b/arch/arm/mach-zynqmp/spl.c index a0f35f36fa..71f9932525 100644 --- a/arch/arm/mach-zynqmp/spl.c +++ b/arch/arm/mach-zynqmp/spl.c @@ -56,8 +56,8 @@ static void ps_mode_reset(ulong mode) # define MODE_RESET PS_MODE1 #endif
-#ifdef CONFIG_SPL_BOARD_INIT -void spl_board_init(void) +#ifdef CONFIG_SPL_SOC_INIT +void spl_soc_init(void) { preloader_console_init(); ps_mode_reset(MODE_RESET);
Acked-by: Michal Simek michal.simek@amd.com
Thanks, Michal

On 3/27/24 13:11, lukas.funke-oss@weidmueller.com wrote:
From: Lukas Funke lukas.funke@weidmueller.com
Currently some vendors use spl_board_init() for their SoC specific initialization. This prohibits board developers from adding board init code using said function. This series introduces a new function in order to separate SoC init code from board init code.
Changes in v3:
- Rephrase Kconfig description and correct minor typo
Changes in v2:
- Change spl_arch_init() to spl_soc_init()
Lukas Funke (2): spl: Introduce SoC specific init function arm64: zynq(mp): Rename spl_board_init() to spl_soc_init()
arch/arm/Kconfig | 4 ++-- arch/arm/mach-zynq/spl.c | 4 ++-- arch/arm/mach-zynqmp/spl.c | 4 ++-- common/spl/Kconfig | 7 +++++++ common/spl/spl.c | 3 +++ include/spl.h | 8 ++++++++ 6 files changed, 24 insertions(+), 6 deletions(-)
Applied. M

Hi,
On 4/8/24 14:59, Michal Simek wrote:
On 3/27/24 13:11, lukas.funke-oss@weidmueller.com wrote:
From: Lukas Funke lukas.funke@weidmueller.com
Currently some vendors use spl_board_init() for their SoC specific initialization. This prohibits board developers from adding board init code using said function. This series introduces a new function in order to separate SoC init code from board init code.
Changes in v3: - Rephrase Kconfig description and correct minor typo
Changes in v2: - Change spl_arch_init() to spl_soc_init()
Lukas Funke (2): spl: Introduce SoC specific init function arm64: zynq(mp): Rename spl_board_init() to spl_soc_init()
arch/arm/Kconfig | 4 ++-- arch/arm/mach-zynq/spl.c | 4 ++-- arch/arm/mach-zynqmp/spl.c | 4 ++-- common/spl/Kconfig | 7 +++++++ common/spl/spl.c | 3 +++ include/spl.h | 8 ++++++++ 6 files changed, 24 insertions(+), 6 deletions(-)
Applied.
Actually I need to drop these two patches. I pushed it to CI and got this error.
Building current source for 1 boards (1 thread, 32 jobs per thread) riscv64: + sifive_unleashed +In file included from board/sifive/unleashed/spl.c:17: +include/asm/arch/spl.h:12:5: error: conflicting types for 'spl_soc_init'; have 'int(void)' + 12 | int spl_soc_init(void); + | ^~~~~~~~~~~~ +In file included from board/sifive/unleashed/spl.c:10: +include/spl.h:825:6: note: previous declaration of 'spl_soc_init' with type 'void(void)' + 825 | void spl_soc_init(void); + | ^~~~~~~~~~~~ +make[3]: *** [scripts/Makefile.build:257: spl/board/sifive/unleashed/spl.o] Error 1 +make[2]: *** [scripts/Makefile.spl:533: spl/board/sifive/unleashed] Error 2 +make[1]: *** [Makefile:2055: spl/u-boot-spl] Error 2 +make: *** [Makefile:177: sub-make] Error 2
And it is valid because Risc-V guys are already using it.
$ git grep spl_soc_init arch/arm/mach-zynq/spl.c:36:void spl_soc_init(void) arch/arm/mach-zynqmp/spl.c:61:void spl_soc_init(void) arch/riscv/cpu/fu540/spl.c:10:int spl_soc_init(void) arch/riscv/cpu/fu740/spl.c:13:int spl_soc_init(void) arch/riscv/cpu/jh7110/spl.c:31:int spl_soc_init(void) arch/riscv/include/asm/arch-fu540/spl.h:12:int spl_soc_init(void); arch/riscv/include/asm/arch-fu740/spl.h:12:int spl_soc_init(void); arch/riscv/include/asm/arch-jh7110/spl.h:10:int spl_soc_init(void); board/sifive/unleashed/spl.c:30: ret = spl_soc_init(); board/sifive/unmatched/spl.c:137: ret = spl_soc_init(); board/starfive/visionfive2/spl.c:214: ret = spl_soc_init(); common/spl/Kconfig:279: spl_soc_init() from board_init_r(). This function should be common/spl/spl.c:715: spl_soc_init(); include/spl.h:820: * spl_soc_init() - Do architecture-specific init in SPL include/spl.h:825:void spl_soc_init(void);
It means please take a look at it and send v4.
Thanks, Michal

Hi Michal,
On 10.04.2024 09:06, Michal Simek wrote:
Hi,
On 4/8/24 14:59, Michal Simek wrote:
On 3/27/24 13:11, lukas.funke-oss@weidmueller.com wrote:
From: Lukas Funke lukas.funke@weidmueller.com
Currently some vendors use spl_board_init() for their SoC specific initialization. This prohibits board developers from adding board init code using said function. This series introduces a new function in order to separate SoC init code from board init code.
Changes in v3: - Rephrase Kconfig description and correct minor typo
Changes in v2: - Change spl_arch_init() to spl_soc_init()
Lukas Funke (2): spl: Introduce SoC specific init function arm64: zynq(mp): Rename spl_board_init() to spl_soc_init()
arch/arm/Kconfig | 4 ++-- arch/arm/mach-zynq/spl.c | 4 ++-- arch/arm/mach-zynqmp/spl.c | 4 ++-- common/spl/Kconfig | 7 +++++++ common/spl/spl.c | 3 +++ include/spl.h | 8 ++++++++ 6 files changed, 24 insertions(+), 6 deletions(-)
Applied.
Actually I need to drop these two patches. I pushed it to CI and got this error.
Building current source for 1 boards (1 thread, 32 jobs per thread) riscv64: + sifive_unleashed +In file included from board/sifive/unleashed/spl.c:17: +include/asm/arch/spl.h:12:5: error: conflicting types for 'spl_soc_init'; have 'int(void)' + 12 | int spl_soc_init(void); + | ^~~~~~~~~~~~ +In file included from board/sifive/unleashed/spl.c:10: +include/spl.h:825:6: note: previous declaration of 'spl_soc_init' with type 'void(void)' + 825 | void spl_soc_init(void); + | ^~~~~~~~~~~~ +make[3]: *** [scripts/Makefile.build:257: spl/board/sifive/unleashed/spl.o] Error 1 +make[2]: *** [scripts/Makefile.spl:533: spl/board/sifive/unleashed] Error 2 +make[1]: *** [Makefile:2055: spl/u-boot-spl] Error 2 +make: *** [Makefile:177: sub-make] Error 2
And it is valid because Risc-V guys are already using it.
The issue should be fixed on master. The function name was changed from spl_soc_init to spl_dram_init. The patch should apply now. Could you give it another try?
$ git grep spl_soc_init arch/arm/mach-zynq/spl.c:36:void spl_soc_init(void) arch/arm/mach-zynqmp/spl.c:61:void spl_soc_init(void) arch/riscv/cpu/fu540/spl.c:10:int spl_soc_init(void) arch/riscv/cpu/fu740/spl.c:13:int spl_soc_init(void) arch/riscv/cpu/jh7110/spl.c:31:int spl_soc_init(void) arch/riscv/include/asm/arch-fu540/spl.h:12:int spl_soc_init(void); arch/riscv/include/asm/arch-fu740/spl.h:12:int spl_soc_init(void); arch/riscv/include/asm/arch-jh7110/spl.h:10:int spl_soc_init(void); board/sifive/unleashed/spl.c:30: ret = spl_soc_init(); board/sifive/unmatched/spl.c:137: ret = spl_soc_init(); board/starfive/visionfive2/spl.c:214: ret = spl_soc_init(); common/spl/Kconfig:279: spl_soc_init() from board_init_r(). This function should be common/spl/spl.c:715: spl_soc_init(); include/spl.h:820: * spl_soc_init() - Do architecture-specific init in SPL include/spl.h:825:void spl_soc_init(void);
It means please take a look at it and send v4.
Thanks, Michal
Best regards - Lukas

Hi,
pá 3. 5. 2024 v 8:10 odesílatel Lukas Funke lukas.funke-oss@weidmueller.com napsal:
Hi Michal,
On 10.04.2024 09:06, Michal Simek wrote:
Hi,
On 4/8/24 14:59, Michal Simek wrote:
On 3/27/24 13:11, lukas.funke-oss@weidmueller.com wrote:
From: Lukas Funke lukas.funke@weidmueller.com
Currently some vendors use spl_board_init() for their SoC specific initialization. This prohibits board developers from adding board init code using said function. This series introduces a new function in order to separate SoC init code from board init code.
Changes in v3:
- Rephrase Kconfig description and correct minor typo
Changes in v2:
- Change spl_arch_init() to spl_soc_init()
Lukas Funke (2): spl: Introduce SoC specific init function arm64: zynq(mp): Rename spl_board_init() to spl_soc_init()
arch/arm/Kconfig | 4 ++-- arch/arm/mach-zynq/spl.c | 4 ++-- arch/arm/mach-zynqmp/spl.c | 4 ++-- common/spl/Kconfig | 7 +++++++ common/spl/spl.c | 3 +++ include/spl.h | 8 ++++++++ 6 files changed, 24 insertions(+), 6 deletions(-)
Applied.
Actually I need to drop these two patches. I pushed it to CI and got this error.
Building current source for 1 boards (1 thread, 32 jobs per thread) riscv64: + sifive_unleashed +In file included from board/sifive/unleashed/spl.c:17: +include/asm/arch/spl.h:12:5: error: conflicting types for 'spl_soc_init'; have 'int(void)'
- 12 | int spl_soc_init(void);
| ^~~~~~~~~~~~
+In file included from board/sifive/unleashed/spl.c:10: +include/spl.h:825:6: note: previous declaration of 'spl_soc_init' with type 'void(void)'
- 825 | void spl_soc_init(void);
| ^~~~~~~~~~~~
+make[3]: *** [scripts/Makefile.build:257: spl/board/sifive/unleashed/spl.o] Error 1 +make[2]: *** [scripts/Makefile.spl:533: spl/board/sifive/unleashed] Error 2 +make[1]: *** [Makefile:2055: spl/u-boot-spl] Error 2 +make: *** [Makefile:177: sub-make] Error 2
And it is valid because Risc-V guys are already using it.
The issue should be fixed on master. The function name was changed from spl_soc_init to spl_dram_init. The patch should apply now. Could you give it another try?
Looks good now.
Applied. M
--- Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
participants (4)
-
Lukas Funke
-
lukas.funke-oss@weidmueller.com
-
Michal Simek
-
Michal Simek