[PATCH 00/18] Minor board_f/board_r cleanups

* Use IS_ENABLED() instead of #ifdef where possible * Add int return values to various functions so we can drop multiple initr_* stub wrappers * Clean some arch-specific ifdefs * Minor CONFIG_HANDOFF patches
Ovidiu Panait (18): common: board_f: Drop initf_console_record wrapper common: board_f: Use IS_ENABLED(CONFIG_TIMER_EARLY) in initf_dm common: board_f: Move setup_machine code to setup_bdinfo common: board_f: Use IS_ENABLED(CONFIG_OF_EMBED) in reserve_fdt,reloc_fdt common: board_r: Drop initr_console_record wrapper common: board_r: Drop initr_secondary_cpu wrapper common: board_r: Drop initr_post_backlog wrapper common: board_r: Drop initr_pci_ep wrapper common: board_r: Drop initr_pci wrapper common: board_r: Drop initr_addr_map wrapper common: board_r: Drop initr_noncached wrapper common: board_r: Drop initr_xen wrapper common: board_r: Drop initr_jumptable wrapper common: board_r: Drop initr_api wrapper common: board_r: Drop initr_bbmii wrapper common: board_r: Drop arch-specific ifdefs around initr_trap spl: Kconfig: Add SPL dependency to CONFIG_HANDOFF global_data: Enable spl_handoff only if CONFIG_HANDOFF is set
api/api.c | 6 +- api/api_private.h | 2 +- arch/arm/include/asm/mmu.h | 2 +- arch/arm/include/asm/system.h | 2 +- arch/arm/lib/cache.c | 4 +- arch/arm/mach-bcm283x/init.c | 4 +- arch/m68k/lib/traps.c | 7 ++ arch/mips/lib/traps.c | 7 ++ arch/powerpc/cpu/mpc85xx/cpu_init.c | 4 +- arch/powerpc/cpu/mpc85xx/tlb.c | 4 +- arch/powerpc/cpu/mpc86xx/cpu_init.c | 4 +- arch/powerpc/include/asm/mmu.h | 2 +- arch/powerpc/lib/Makefile | 1 + arch/powerpc/lib/traps.c | 17 ++++ common/board_f.c | 78 +++++++------- common/board_r.c | 145 ++++----------------------- common/exports.c | 4 +- common/spl/Kconfig | 2 +- drivers/net/phy/miiphybb.c | 4 +- drivers/pci/pci-uclass.c | 4 +- drivers/pci/pci.c | 6 +- drivers/pci_endpoint/pci_ep-uclass.c | 4 +- drivers/xen/hypervisor.c | 4 +- include/api.h | 2 +- include/asm-generic/global_data.h | 4 +- include/exports.h | 2 +- include/init.h | 13 ++- include/miiphy.h | 2 +- include/post.h | 2 +- include/xen.h | 2 +- post/post.c | 4 +- 31 files changed, 148 insertions(+), 200 deletions(-) create mode 100644 arch/powerpc/lib/traps.c

Drop initf_console_record wrapper and call console_record_init directly.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- common/board_f.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/common/board_f.c b/common/board_f.c index 9f441c44f1..cc4f32f9c3 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -765,15 +765,6 @@ static int initf_bootstage(void) return 0; }
-static int initf_console_record(void) -{ -#if defined(CONFIG_CONSOLE_RECORD) && CONFIG_VAL(SYS_MALLOC_F_LEN) - return console_record_init(); -#else - return 0; -#endif -} - static int initf_dm(void) { #if defined(CONFIG_DM) && CONFIG_VAL(SYS_MALLOC_F_LEN) @@ -830,7 +821,9 @@ static const init_fnc_t init_sequence_f[] = { bloblist_init, #endif setup_spl_handoff, - initf_console_record, +#if defined(CONFIG_CONSOLE_RECORD) && CONFIG_VAL(SYS_MALLOC_F_LEN) + console_record_init, +#endif #if defined(CONFIG_HAVE_FSP) arch_fsp_init, #endif

On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Drop initf_console_record wrapper and call console_record_init directly.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
common/board_f.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
See below
diff --git a/common/board_f.c b/common/board_f.c index 9f441c44f1..cc4f32f9c3 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -765,15 +765,6 @@ static int initf_bootstage(void) return 0; }
-static int initf_console_record(void) -{ -#if defined(CONFIG_CONSOLE_RECORD) && CONFIG_VAL(SYS_MALLOC_F_LEN)
I wonder if we need the second term? We could make a SPL_CONSOLE_RECORD which depends on SYS_MALLOC_F perhaps?
Regards, Simon
return console_record_init();
-#else
return 0;
-#endif -}
static int initf_dm(void) { #if defined(CONFIG_DM) && CONFIG_VAL(SYS_MALLOC_F_LEN) @@ -830,7 +821,9 @@ static const init_fnc_t init_sequence_f[] = { bloblist_init, #endif setup_spl_handoff,
initf_console_record,
+#if defined(CONFIG_CONSOLE_RECORD) && CONFIG_VAL(SYS_MALLOC_F_LEN)
console_record_init,
+#endif #if defined(CONFIG_HAVE_FSP) arch_fsp_init,
#endif
2.17.1

Use IS_ENABLED(CONFIG_TIMER_EARLY) instead of #ifdef in initf_dm. Also, move timer code to the main ifdef, so that ret is defined.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- common/board_f.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/common/board_f.c b/common/board_f.c index cc4f32f9c3..a3c353a4b5 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -775,11 +775,12 @@ static int initf_dm(void) bootstage_accum(BOOTSTAGE_ID_ACCUM_DM_F); if (ret) return ret; -#endif -#ifdef CONFIG_TIMER_EARLY - ret = dm_timer_init(); - if (ret) - return ret; + + if (IS_ENABLED(CONFIG_TIMER_EARLY)) { + ret = dm_timer_init(); + if (ret) + return ret; + } #endif
return 0;

On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Use IS_ENABLED(CONFIG_TIMER_EARLY) instead of #ifdef in initf_dm. Also, move timer code to the main ifdef, so that ret is defined.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
common/board_f.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

setup_bdinfo is used to populate various bdinfo fields, so move setup_machine code there, as all it does is setting gd->bd->bi_arch_number.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- common/board_f.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/common/board_f.c b/common/board_f.c index a3c353a4b5..408b95826a 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -503,14 +503,6 @@ static int reserve_board(void) return 0; }
-static int setup_machine(void) -{ -#ifdef CONFIG_MACH_TYPE - gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */ -#endif - return 0; -} - static int reserve_global_data(void) { gd->start_addr_sp = reserve_stack_aligned(sizeof(gd_t)); @@ -605,6 +597,10 @@ int setup_bdinfo(void) bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM */ }
+#ifdef CONFIG_MACH_TYPE + bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */ +#endif + return arch_setup_bdinfo(); }
@@ -916,7 +912,6 @@ static const init_fnc_t init_sequence_f[] = { reserve_uboot, reserve_malloc, reserve_board, - setup_machine, reserve_global_data, reserve_fdt, reserve_bootstage,

Hi Ovidiu
On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
setup_bdinfo is used to populate various bdinfo fields, so move setup_machine code there, as all it does is setting gd->bd->bi_arch_number.
But you are moving it to reserve_global_data() aren't you? I don't like the sound of that.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
common/board_f.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/common/board_f.c b/common/board_f.c index a3c353a4b5..408b95826a 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -503,14 +503,6 @@ static int reserve_board(void) return 0; }
-static int setup_machine(void) -{ -#ifdef CONFIG_MACH_TYPE
gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
-#endif
return 0;
-}
static int reserve_global_data(void) { gd->start_addr_sp = reserve_stack_aligned(sizeof(gd_t)); @@ -605,6 +597,10 @@ int setup_bdinfo(void) bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM */ }
+#ifdef CONFIG_MACH_TYPE
bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
+#endif
return arch_setup_bdinfo();
}
@@ -916,7 +912,6 @@ static const init_fnc_t init_sequence_f[] = { reserve_uboot, reserve_malloc, reserve_board,
setup_machine, reserve_global_data, reserve_fdt, reserve_bootstage,
-- 2.17.1
Regards, SImon

Hi Simon,
On 14.11.2020 17:17, Simon Glass wrote:
[Please note this e-mail is from an EXTERNAL e-mail address]
Hi Ovidiu
On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
setup_bdinfo is used to populate various bdinfo fields, so move setup_machine code there, as all it does is setting gd->bd->bi_arch_number.
But you are moving it to reserve_global_data() aren't you? I don't like the sound of that.
reserve_global_data() is part of context of the previous diff:
@@ -503,14 +503,6 @@ static int reserve_board(void) return 0; }
-static int setup_machine(void) -{ -#ifdef CONFIG_MACH_TYPE - gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */ -#endif - return 0; -} - static int reserve_global_data(void) { gd->start_addr_sp = reserve_stack_aligned(sizeof(gd_t));
setup_machine() contents get moved to setup_bdinfo() in the next diff:
@@ -605,6 +597,10 @@ int setup_bdinfo(void) bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM */ }
+#ifdef CONFIG_MACH_TYPE + bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */ +#endif + return arch_setup_bdinfo(); }
Ovidiu
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
common/board_f.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/common/board_f.c b/common/board_f.c index a3c353a4b5..408b95826a 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -503,14 +503,6 @@ static int reserve_board(void) return 0; }
-static int setup_machine(void) -{ -#ifdef CONFIG_MACH_TYPE
gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
-#endif
return 0;
-}
- static int reserve_global_data(void) { gd->start_addr_sp = reserve_stack_aligned(sizeof(gd_t));
@@ -605,6 +597,10 @@ int setup_bdinfo(void) bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM */ }
+#ifdef CONFIG_MACH_TYPE
bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
+#endif
}return arch_setup_bdinfo();
@@ -916,7 +912,6 @@ static const init_fnc_t init_sequence_f[] = { reserve_uboot, reserve_malloc, reserve_board,
setup_machine, reserve_global_data, reserve_fdt, reserve_bootstage,
-- 2.17.1
Regards, SImon

Hi Ovidiu,
On Tue, 17 Nov 2020 at 01:00, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Hi Simon,
On 14.11.2020 17:17, Simon Glass wrote:
[Please note this e-mail is from an EXTERNAL e-mail address]
Hi Ovidiu
On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
setup_bdinfo is used to populate various bdinfo fields, so move setup_machine code there, as all it does is setting gd->bd->bi_arch_number.
But you are moving it to reserve_global_data() aren't you? I don't like the sound of that.
reserve_global_data() is part of context of the previous diff:
@@ -503,14 +503,6 @@ static int reserve_board(void) return 0; }
-static int setup_machine(void) -{ -#ifdef CONFIG_MACH_TYPE
gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
-#endif
return 0;
-}
- static int reserve_global_data(void) { gd->start_addr_sp = reserve_stack_aligned(sizeof(gd_t));
setup_machine() contents get moved to setup_bdinfo() in the next diff:
@@ -605,6 +597,10 @@ int setup_bdinfo(void) bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM */ }
+#ifdef CONFIG_MACH_TYPE
bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
+#endif
}return arch_setup_bdinfo();
OK thanks. I misread the diff.
Reviewed-by: Simon Glass sjg@chromium.org
Regards, Simon

Use IS_ENABLED(CONFIG_OF_EMBED) in instead of #ifdefs in reserve_fdt, reloc_fdt functions.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- common/board_f.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/common/board_f.c b/common/board_f.c index 408b95826a..b6175196a5 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -514,21 +514,21 @@ static int reserve_global_data(void)
static int reserve_fdt(void) { -#ifndef CONFIG_OF_EMBED - /* - * If the device tree is sitting immediately above our image then we - * must relocate it. If it is embedded in the data section, then it - * will be relocated with other data. - */ - if (gd->fdt_blob) { - gd->fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob), 32); + if (!IS_ENABLED(CONFIG_OF_EMBED)) { + /* + * If the device tree is sitting immediately above our image + * then we must relocate it. If it is embedded in the data + * section, then it will be relocated with other data. + */ + if (gd->fdt_blob) { + gd->fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob), 32);
- gd->start_addr_sp = reserve_stack_aligned(gd->fdt_size); - gd->new_fdt = map_sysmem(gd->start_addr_sp, gd->fdt_size); - debug("Reserving %lu Bytes for FDT at: %08lx\n", - gd->fdt_size, gd->start_addr_sp); + gd->start_addr_sp = reserve_stack_aligned(gd->fdt_size); + gd->new_fdt = map_sysmem(gd->start_addr_sp, gd->fdt_size); + debug("Reserving %lu Bytes for FDT at: %08lx\n", + gd->fdt_size, gd->start_addr_sp); + } } -#endif
return 0; } @@ -616,14 +616,15 @@ static int init_post(void)
static int reloc_fdt(void) { -#ifndef CONFIG_OF_EMBED - if (gd->flags & GD_FLG_SKIP_RELOC) - return 0; - if (gd->new_fdt) { - memcpy(gd->new_fdt, gd->fdt_blob, fdt_totalsize(gd->fdt_blob)); - gd->fdt_blob = gd->new_fdt; + if (!IS_ENABLED(CONFIG_OF_EMBED)) { + if (gd->flags & GD_FLG_SKIP_RELOC) + return 0; + if (gd->new_fdt) { + memcpy(gd->new_fdt, gd->fdt_blob, + fdt_totalsize(gd->fdt_blob)); + gd->fdt_blob = gd->new_fdt; + } } -#endif
return 0; }

On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Use IS_ENABLED(CONFIG_OF_EMBED) in instead of #ifdefs in reserve_fdt, reloc_fdt functions.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
common/board_f.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Drop initr_console_record wrapper and call console_record_init directly.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- common/board_r.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/common/board_r.c b/common/board_r.c index 29dd7d26d9..07c0ad363e 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -282,15 +282,6 @@ static int initr_malloc(void) return 0; }
-static int initr_console_record(void) -{ -#if defined(CONFIG_CONSOLE_RECORD) - return console_record_init(); -#else - return 0; -#endif -} - #ifdef CONFIG_SYS_NONCACHED_MEMORY static int initr_noncached(void) { @@ -713,7 +704,9 @@ static init_fnc_t init_sequence_r[] = { initr_malloc, log_init, initr_bootstage, /* Needs malloc() but has its own timer */ - initr_console_record, +#if defined(CONFIG_CONSOLE_RECORD) + console_record_init, +#endif #ifdef CONFIG_SYS_NONCACHED_MEMORY initr_noncached, #endif

On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Drop initr_console_record wrapper and call console_record_init directly.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
common/board_r.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Add a return value to cpu_secondary_init_r and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- arch/powerpc/cpu/mpc85xx/cpu_init.c | 4 +++- common/board_r.c | 17 ++--------------- 2 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/arch/powerpc/cpu/mpc85xx/cpu_init.c b/arch/powerpc/cpu/mpc85xx/cpu_init.c index e0f0f7ecda..e920e01b25 100644 --- a/arch/powerpc/cpu/mpc85xx/cpu_init.c +++ b/arch/powerpc/cpu/mpc85xx/cpu_init.c @@ -1028,7 +1028,7 @@ void arch_preboot_os(void) mtmsr(msr); }
-void cpu_secondary_init_r(void) +int cpu_secondary_init_r(void) { #ifdef CONFIG_QE #ifdef CONFIG_U_QE @@ -1040,6 +1040,8 @@ void cpu_secondary_init_r(void) qe_init(qe_base); qe_reset(); #endif + + return 0; }
#ifdef CONFIG_BOARD_LATE_INIT diff --git a/common/board_r.c b/common/board_r.c index 07c0ad363e..a291543d74 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -91,21 +91,8 @@ __weak int board_flash_wp_on(void) return 0; }
-__weak void cpu_secondary_init_r(void) +__weak int cpu_secondary_init_r(void) { -} - -static int initr_secondary_cpu(void) -{ - /* - * after non-volatile devices & environment is setup and cpu code have - * another round to deal with any initialization that might require - * full access to the environment or loading of some image (firmware) - * from a non-volatile device - */ - /* TODO: maybe define this for all archs? */ - cpu_secondary_init_r(); - return 0; }
@@ -801,7 +788,7 @@ static init_fnc_t init_sequence_r[] = { initr_malloc_bootparams, #endif INIT_FUNC_WATCHDOG_RESET - initr_secondary_cpu, + cpu_secondary_init_r, #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET) mac_read_from_eeprom, #endif

Hi Ovidiu
On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Add a return value to cpu_secondary_init_r and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
arch/powerpc/cpu/mpc85xx/cpu_init.c | 4 +++- common/board_r.c | 17 ++--------------- 2 files changed, 5 insertions(+), 16 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
nit below
diff --git a/arch/powerpc/cpu/mpc85xx/cpu_init.c b/arch/powerpc/cpu/mpc85xx/cpu_init.c index e0f0f7ecda..e920e01b25 100644 --- a/arch/powerpc/cpu/mpc85xx/cpu_init.c +++ b/arch/powerpc/cpu/mpc85xx/cpu_init.c @@ -1028,7 +1028,7 @@ void arch_preboot_os(void) mtmsr(msr); }
-void cpu_secondary_init_r(void) +int cpu_secondary_init_r(void) { #ifdef CONFIG_QE #ifdef CONFIG_U_QE @@ -1040,6 +1040,8 @@ void cpu_secondary_init_r(void) qe_init(qe_base); qe_reset(); #endif
return 0;
}
#ifdef CONFIG_BOARD_LATE_INIT diff --git a/common/board_r.c b/common/board_r.c index 07c0ad363e..a291543d74 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -91,21 +91,8 @@ __weak int board_flash_wp_on(void) return 0; }
-__weak void cpu_secondary_init_r(void) +__weak int cpu_secondary_init_r(void) { -}
-static int initr_secondary_cpu(void) -{
/*
* after non-volatile devices & environment is setup and cpu code have
* another round to deal with any initialization that might require
* full access to the environment or loading of some image (firmware)
* from a non-volatile device
Can you add this comment to the header file that declares cpu_secondary_init_r()?
*/
/* TODO: maybe define this for all archs? */
cpu_secondary_init_r();
return 0;
}
@@ -801,7 +788,7 @@ static init_fnc_t init_sequence_r[] = { initr_malloc_bootparams, #endif INIT_FUNC_WATCHDOG_RESET
initr_secondary_cpu,
cpu_secondary_init_r,
#if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET) mac_read_from_eeprom,
#endif
2.17.1
Regards, Simon

Add a return value to post_output_backlog and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- common/board_r.c | 10 +--------- include/post.h | 2 +- post/post.c | 4 +++- 3 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/common/board_r.c b/common/board_r.c index a291543d74..7a06627ba9 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -206,14 +206,6 @@ static int initr_addr_map(void) } #endif
-#ifdef CONFIG_POST -static int initr_post_backlog(void) -{ - post_output_backlog(); - return 0; -} -#endif - #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500) static int initr_unlock_ram_in_cache(void) { @@ -746,7 +738,7 @@ static init_fnc_t init_sequence_r[] = { #endif INIT_FUNC_WATCHDOG_RESET #ifdef CONFIG_POST - initr_post_backlog, + post_output_backlog, #endif INIT_FUNC_WATCHDOG_RESET #if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT) diff --git a/include/post.h b/include/post.h index eb218acde5..3dd68a6d9f 100644 --- a/include/post.h +++ b/include/post.h @@ -107,7 +107,7 @@ int post_init_f (void); void post_bootmode_init (void); int post_bootmode_get (unsigned int * last_test); void post_bootmode_clear (void); -void post_output_backlog ( void ); +int post_output_backlog(void); int post_run (char *name, int flags); int post_info (char *name); int post_log (char *format, ...); diff --git a/post/post.c b/post/post.c index 0f1fe8d905..7d6a647312 100644 --- a/post/post.c +++ b/post/post.c @@ -128,7 +128,7 @@ static void post_log_mark_succ(unsigned long testid) }
/* ... and the messages are output once we are relocated */ -void post_output_backlog(void) +int post_output_backlog(void) { int j;
@@ -143,6 +143,8 @@ void post_output_backlog(void) } } } + + return 0; }
static void post_bootmode_test_on(unsigned int last_test)

On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Add a return value to post_output_backlog and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
common/board_r.c | 10 +--------- include/post.h | 2 +- post/post.c | 4 +++- 3 files changed, 5 insertions(+), 11 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Add a return value to pci_ep_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- common/board_r.c | 11 +---------- drivers/pci_endpoint/pci_ep-uclass.c | 4 +++- include/init.h | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/common/board_r.c b/common/board_r.c index 7a06627ba9..d86ff0cb5e 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -214,15 +214,6 @@ static int initr_unlock_ram_in_cache(void) } #endif
-#ifdef CONFIG_PCI_ENDPOINT -static int initr_pci_ep(void) -{ - pci_ep_init(); - - return 0; -} -#endif - #ifdef CONFIG_PCI static int initr_pci(void) { @@ -836,7 +827,7 @@ static init_fnc_t init_sequence_r[] = { initr_bbmii, #endif #ifdef CONFIG_PCI_ENDPOINT - initr_pci_ep, + pci_ep_init, #endif #ifdef CONFIG_CMD_NET INIT_FUNC_WATCHDOG_RESET diff --git a/drivers/pci_endpoint/pci_ep-uclass.c b/drivers/pci_endpoint/pci_ep-uclass.c index 38a5f08376..aa89701de8 100644 --- a/drivers/pci_endpoint/pci_ep-uclass.c +++ b/drivers/pci_endpoint/pci_ep-uclass.c @@ -210,7 +210,7 @@ UCLASS_DRIVER(pci_ep) = { .flags = DM_UC_FLAG_SEQ_ALIAS, };
-void pci_ep_init(void) +int pci_ep_init(void) { struct udevice *dev;
@@ -219,4 +219,6 @@ void pci_ep_init(void) uclass_next_device_check(&dev)) { ; } + + return 0; } diff --git a/include/init.h b/include/init.h index 0f48ccb57a..a887c2b4fc 100644 --- a/include/init.h +++ b/include/init.h @@ -235,7 +235,7 @@ int set_cpu_clk_info(void); int update_flash_size(int flash_size); int arch_early_init_r(void); void pci_init(void); -void pci_ep_init(void); +int pci_ep_init(void); int misc_init_r(void); #if defined(CONFIG_VID) int init_func_vid(void);

On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Add a return value to pci_ep_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
common/board_r.c | 11 +---------- drivers/pci_endpoint/pci_ep-uclass.c | 4 +++- include/init.h | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Add a return value to pci_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- common/board_r.c | 18 ++++-------------- drivers/pci/pci-uclass.c | 4 +++- drivers/pci/pci.c | 6 ++++-- include/init.h | 2 +- 4 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/common/board_r.c b/common/board_r.c index d86ff0cb5e..414b6272c5 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -214,16 +214,6 @@ static int initr_unlock_ram_in_cache(void) } #endif
-#ifdef CONFIG_PCI -static int initr_pci(void) -{ - if (IS_ENABLED(CONFIG_PCI_INIT_R)) - pci_init(); - - return 0; -} -#endif - static int initr_barrier(void) { #ifdef CONFIG_PPC @@ -732,12 +722,12 @@ static init_fnc_t init_sequence_r[] = { post_output_backlog, #endif INIT_FUNC_WATCHDOG_RESET -#if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT) +#if defined(CONFIG_PCI_INIT_R) && defined(CONFIG_SYS_EARLY_PCI_INIT) /* * Do early PCI configuration _before_ the flash gets initialised, * because PCU resources are crucial for flash access on some boards. */ - initr_pci, + pci_init, #endif #ifdef CONFIG_ARCH_EARLY_INIT_R arch_early_init_r, @@ -776,11 +766,11 @@ static init_fnc_t init_sequence_r[] = { mac_read_from_eeprom, #endif INIT_FUNC_WATCHDOG_RESET -#if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT) +#if defined(CONFIG_PCI_INIT_R) && !defined(CONFIG_SYS_EARLY_PCI_INIT) /* * Do pci configuration */ - initr_pci, + pci_init, #endif stdio_add_devices, initr_jumptable, diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index eb07d25301..7e9b5cf0fa 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -1834,7 +1834,7 @@ U_BOOT_DRIVER(pci_generic_drv) = { .of_match = pci_generic_ids, };
-void pci_init(void) +int pci_init(void) { struct udevice *bus;
@@ -1847,4 +1847,6 @@ void pci_init(void) uclass_next_device_check(&bus)) { ; } + + return 0; } diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 664e8379eb..a7453e5755 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -454,16 +454,18 @@ int pci_hose_scan(struct pci_controller *hose) return pci_hose_scan_bus(hose, hose->current_busno); }
-void pci_init(void) +int pci_init(void) { hose_head = NULL;
/* allow env to disable pci init/enum */ if (env_get("pcidisable") != NULL) - return; + return 0;
/* now call board specific pci_init()... */ pci_init_board(); + + return 0; }
/* Returns the address of the requested capability structure within the diff --git a/include/init.h b/include/init.h index a887c2b4fc..5519562163 100644 --- a/include/init.h +++ b/include/init.h @@ -234,7 +234,7 @@ int mac_read_from_eeprom(void); int set_cpu_clk_info(void); int update_flash_size(int flash_size); int arch_early_init_r(void); -void pci_init(void); +int pci_init(void); int pci_ep_init(void); int misc_init_r(void); #if defined(CONFIG_VID)

On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Add a return value to pci_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
common/board_r.c | 18 ++++-------------- drivers/pci/pci-uclass.c | 4 +++- drivers/pci/pci.c | 6 ++++-- include/init.h | 2 +- 4 files changed, 12 insertions(+), 18 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
nit below
diff --git a/common/board_r.c b/common/board_r.c index d86ff0cb5e..414b6272c5 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -214,16 +214,6 @@ static int initr_unlock_ram_in_cache(void) } #endif
-#ifdef CONFIG_PCI -static int initr_pci(void) -{
if (IS_ENABLED(CONFIG_PCI_INIT_R))
pci_init();
return 0;
-} -#endif
static int initr_barrier(void) { #ifdef CONFIG_PPC @@ -732,12 +722,12 @@ static init_fnc_t init_sequence_r[] = { post_output_backlog, #endif INIT_FUNC_WATCHDOG_RESET -#if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT) +#if defined(CONFIG_PCI_INIT_R) && defined(CONFIG_SYS_EARLY_PCI_INIT) /* * Do early PCI configuration _before_ the flash gets initialised, * because PCU resources are crucial for flash access on some boards. */
initr_pci,
pci_init,
#endif #ifdef CONFIG_ARCH_EARLY_INIT_R arch_early_init_r, @@ -776,11 +766,11 @@ static init_fnc_t init_sequence_r[] = { mac_read_from_eeprom, #endif INIT_FUNC_WATCHDOG_RESET -#if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT) +#if defined(CONFIG_PCI_INIT_R) && !defined(CONFIG_SYS_EARLY_PCI_INIT) /* * Do pci configuration */
initr_pci,
pci_init,
#endif stdio_add_devices, initr_jumptable, diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index eb07d25301..7e9b5cf0fa 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -1834,7 +1834,7 @@ U_BOOT_DRIVER(pci_generic_drv) = { .of_match = pci_generic_ids, };
-void pci_init(void) +int pci_init(void) { struct udevice *bus;
@@ -1847,4 +1847,6 @@ void pci_init(void) uclass_next_device_check(&bus)) { ; }
return 0;
} diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 664e8379eb..a7453e5755 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -454,16 +454,18 @@ int pci_hose_scan(struct pci_controller *hose) return pci_hose_scan_bus(hose, hose->current_busno); }
-void pci_init(void) +int pci_init(void) { hose_head = NULL;
/* allow env to disable pci init/enum */ if (env_get("pcidisable") != NULL)
return;
return 0; /* now call board specific pci_init()... */ pci_init_board();
return 0;
}
/* Returns the address of the requested capability structure within the diff --git a/include/init.h b/include/init.h index a887c2b4fc..5519562163 100644 --- a/include/init.h +++ b/include/init.h @@ -234,7 +234,7 @@ int mac_read_from_eeprom(void); int set_cpu_clk_info(void); int update_flash_size(int flash_size); int arch_early_init_r(void); -void pci_init(void); +int pci_init(void);
Please add a comment about what it does and the return value
int pci_ep_init(void); int misc_init_r(void);
#if defined(CONFIG_VID)
2.17.1

Add a return value to init_addr_map and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- arch/arm/include/asm/mmu.h | 2 +- arch/arm/mach-bcm283x/init.c | 4 +++- arch/powerpc/cpu/mpc85xx/tlb.c | 4 ++-- arch/powerpc/cpu/mpc86xx/cpu_init.c | 4 +++- arch/powerpc/include/asm/mmu.h | 2 +- common/board_r.c | 11 +---------- 6 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h index 9ac16f599e..8449720fad 100644 --- a/arch/arm/include/asm/mmu.h +++ b/arch/arm/include/asm/mmu.h @@ -3,6 +3,6 @@ #ifndef __ASM_ARM_MMU_H #define __ASM_ARM_MMU_H
-void init_addr_map(void); +int init_addr_map(void);
#endif diff --git a/arch/arm/mach-bcm283x/init.c b/arch/arm/mach-bcm283x/init.c index f2a5411623..ba32187315 100644 --- a/arch/arm/mach-bcm283x/init.c +++ b/arch/arm/mach-bcm283x/init.c @@ -151,7 +151,7 @@ int mach_cpu_init(void) #include <addr_map.h> #include <asm/system.h>
-void init_addr_map(void) +int init_addr_map(void) { mmu_set_region_dcache_behaviour_phys(BCM2711_RPI4_PCIE_XHCI_MMIO_VIRT, BCM2711_RPI4_PCIE_XHCI_MMIO_PHYS, @@ -164,6 +164,8 @@ void init_addr_map(void) addrmap_set_entry(BCM2711_RPI4_PCIE_XHCI_MMIO_VIRT, BCM2711_RPI4_PCIE_XHCI_MMIO_PHYS, BCM2711_RPI4_PCIE_XHCI_MMIO_SIZE, 1); + + return 0; } #endif
diff --git a/arch/powerpc/cpu/mpc85xx/tlb.c b/arch/powerpc/cpu/mpc85xx/tlb.c index 4465ae7565..4afc11125b 100644 --- a/arch/powerpc/cpu/mpc85xx/tlb.c +++ b/arch/powerpc/cpu/mpc85xx/tlb.c @@ -218,7 +218,7 @@ int find_tlb_idx(void *addr, u8 tlbsel) }
#ifdef CONFIG_ADDR_MAP -void init_addr_map(void) +int init_addr_map(void) { int i; unsigned int num_cam = mfspr(SPRN_TLB1CFG) & 0xfff; @@ -234,7 +234,7 @@ void init_addr_map(void) addrmap_set_entry(epn, rpn, TSIZE_TO_BYTES(tsize), i); }
- return ; + return 0; } #endif
diff --git a/arch/powerpc/cpu/mpc86xx/cpu_init.c b/arch/powerpc/cpu/mpc86xx/cpu_init.c index a17091d2ff..f7cbf9658b 100644 --- a/arch/powerpc/cpu/mpc86xx/cpu_init.c +++ b/arch/powerpc/cpu/mpc86xx/cpu_init.c @@ -77,7 +77,7 @@ int cpu_init_r(void)
#ifdef CONFIG_ADDR_MAP /* Initialize address mapping array */ -void init_addr_map(void) +int init_addr_map(void) { int i; ppc_bat_t bat = DBAT0; @@ -99,5 +99,7 @@ void init_addr_map(void) bat = DBAT4 - 1; #endif } + + return 0; } #endif diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h index 353dc4e874..a49758a625 100644 --- a/arch/powerpc/include/asm/mmu.h +++ b/arch/powerpc/include/asm/mmu.h @@ -138,7 +138,7 @@ extern void _tlbie(unsigned long va); /* invalidate a TLB entry */ extern void _tlbia(void); /* invalidate all TLB entries */
#ifdef CONFIG_ADDR_MAP -extern void init_addr_map(void); +int init_addr_map(void); #endif
typedef enum { diff --git a/common/board_r.c b/common/board_r.c index 414b6272c5..964f3df918 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -197,15 +197,6 @@ static int initr_trap(void) } #endif
-#ifdef CONFIG_ADDR_MAP -static int initr_addr_map(void) -{ - init_addr_map(); - - return 0; -} -#endif - #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500) static int initr_unlock_ram_in_cache(void) { @@ -712,7 +703,7 @@ static init_fnc_t init_sequence_r[] = { initr_trap, #endif #ifdef CONFIG_ADDR_MAP - initr_addr_map, + init_addr_map, #endif #if defined(CONFIG_BOARD_EARLY_INIT_R) board_early_init_r,

On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Add a return value to init_addr_map and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
arch/arm/include/asm/mmu.h | 2 +- arch/arm/mach-bcm283x/init.c | 4 +++- arch/powerpc/cpu/mpc85xx/tlb.c | 4 ++-- arch/powerpc/cpu/mpc86xx/cpu_init.c | 4 +++- arch/powerpc/include/asm/mmu.h | 2 +- common/board_r.c | 11 +---------- 6 files changed, 11 insertions(+), 16 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Add a return value to noncached_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- arch/arm/include/asm/system.h | 2 +- arch/arm/lib/cache.c | 4 +++- common/board_r.c | 10 +--------- 3 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h index ce552944b7..fb059c4588 100644 --- a/arch/arm/include/asm/system.h +++ b/arch/arm/include/asm/system.h @@ -628,7 +628,7 @@ void mmu_set_region_dcache_behaviour(phys_addr_t start, size_t size, enum dcache_option option);
#ifdef CONFIG_SYS_NONCACHED_MEMORY -void noncached_init(void); +int noncached_init(void); phys_addr_t noncached_alloc(size_t size, size_t align); #endif /* CONFIG_SYS_NONCACHED_MEMORY */
diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c index ee7d14b2d3..bdde9cdad5 100644 --- a/arch/arm/lib/cache.c +++ b/arch/arm/lib/cache.c @@ -86,7 +86,7 @@ void noncached_set_region(void) #endif }
-void noncached_init(void) +int noncached_init(void) { phys_addr_t start, end; size_t size; @@ -103,6 +103,8 @@ void noncached_init(void) noncached_next = start;
noncached_set_region(); + + return 0; }
phys_addr_t noncached_alloc(size_t size, size_t align) diff --git a/common/board_r.c b/common/board_r.c index 964f3df918..7f69e59250 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -233,14 +233,6 @@ static int initr_malloc(void) return 0; }
-#ifdef CONFIG_SYS_NONCACHED_MEMORY -static int initr_noncached(void) -{ - noncached_init(); - return 0; -} -#endif - static int initr_of_live(void) { if (CONFIG_IS_ENABLED(OF_LIVE)) { @@ -659,7 +651,7 @@ static init_fnc_t init_sequence_r[] = { console_record_init, #endif #ifdef CONFIG_SYS_NONCACHED_MEMORY - initr_noncached, + noncached_init, #endif initr_of_live, #ifdef CONFIG_DM

On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Add a return value to noncached_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
arch/arm/include/asm/system.h | 2 +- arch/arm/lib/cache.c | 4 +++- common/board_r.c | 10 +--------- 3 files changed, 5 insertions(+), 11 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
Again when you change a function signature, it's a good oppty to add a comment if one is missing

Add a return value to xen_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- common/board_r.c | 10 +--------- drivers/xen/hypervisor.c | 4 +++- include/xen.h | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/common/board_r.c b/common/board_r.c index 7f69e59250..1cb9f13dc2 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -419,14 +419,6 @@ static int initr_mmc(void) } #endif
-#ifdef CONFIG_XEN -static int initr_xen(void) -{ - xen_init(); - return 0; -} -#endif - #ifdef CONFIG_PVBLOCK static int initr_pvblock(void) { @@ -734,7 +726,7 @@ static init_fnc_t init_sequence_r[] = { initr_mmc, #endif #ifdef CONFIG_XEN - initr_xen, + xen_init, #endif #ifdef CONFIG_PVBLOCK initr_pvblock, diff --git a/drivers/xen/hypervisor.c b/drivers/xen/hypervisor.c index 178c206f5b..2560894832 100644 --- a/drivers/xen/hypervisor.c +++ b/drivers/xen/hypervisor.c @@ -232,7 +232,7 @@ void clear_evtchn(uint32_t port) synch_clear_bit(port, &s->evtchn_pending[0]); }
-void xen_init(void) +int xen_init(void) { debug("%s\n", __func__);
@@ -240,6 +240,8 @@ void xen_init(void) init_events(); init_xenbus(); init_gnttab(); + + return 0; }
void xen_fini(void) diff --git a/include/xen.h b/include/xen.h index a952a2c84b..868132156e 100644 --- a/include/xen.h +++ b/include/xen.h @@ -11,7 +11,7 @@ * Map Xen memory pages, initialize event handler and xenbus, * setup the grant table. */ -void xen_init(void); +int xen_init(void);
/** * xen_fini() - Board cleanup before Linux kernel start

On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Add a return value to xen_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
common/board_r.c | 10 +--------- drivers/xen/hypervisor.c | 4 +++- include/xen.h | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Add a return value to jumptable_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- common/board_r.c | 8 +------- common/exports.c | 4 +++- include/exports.h | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/common/board_r.c b/common/board_r.c index 1cb9f13dc2..cb9b2424d1 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -481,12 +481,6 @@ static int initr_malloc_bootparams(void) } #endif
-static int initr_jumptable(void) -{ - jumptable_init(); - return 0; -} - #if defined(CONFIG_API) static int initr_api(void) { @@ -748,7 +742,7 @@ static init_fnc_t init_sequence_r[] = { pci_init, #endif stdio_add_devices, - initr_jumptable, + jumptable_init, #ifdef CONFIG_API initr_api, #endif diff --git a/common/exports.c b/common/exports.c index 6253b55694..4578f07021 100644 --- a/common/exports.c +++ b/common/exports.c @@ -25,8 +25,10 @@ unsigned long get_version(void) # define miiphy_set_current_dev dummy #endif
-void jumptable_init(void) +int jumptable_init(void) { gd->jt = malloc(sizeof(struct jt_funcs)); #include <_exports.h> + + return 0; } diff --git a/include/exports.h b/include/exports.h index b300554091..be13c771a4 100644 --- a/include/exports.h +++ b/include/exports.h @@ -16,7 +16,7 @@ struct cmd_tbl; struct spi_slave;
/* Set up the jump table for use by the API */ -void jumptable_init(void); +int jumptable_init(void);
/* These are declarations of exported functions available in C code */ unsigned long get_version(void);

On Thu, 5 Nov 2020 at 03:10, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Add a return value to jumptable_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
common/board_r.c | 8 +------- common/exports.c | 4 +++- include/exports.h | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Add a return value to api_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- api/api.c | 6 ++++-- api/api_private.h | 2 +- common/board_r.c | 11 +---------- include/api.h | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/api/api.c b/api/api.c index 493b77f809..89003c161c 100644 --- a/api/api.c +++ b/api/api.c @@ -642,7 +642,7 @@ int syscall(int call, int *retval, ...) return 1; }
-void api_init(void) +int api_init(void) { struct api_signature *sig;
@@ -679,7 +679,7 @@ void api_init(void) sig = malloc(sizeof(struct api_signature)); if (sig == NULL) { printf("API: could not allocate memory for the signature!\n"); - return; + return -ENOMEM; }
env_set_hex("api_address", (unsigned long)sig); @@ -691,6 +691,8 @@ void api_init(void) sig->checksum = crc32(0, (unsigned char *)sig, sizeof(struct api_signature)); debugf("syscall entry: 0x%lX\n", (unsigned long)sig->syscall); + + return 0; }
void platform_set_mr(struct sys_info *si, unsigned long start, unsigned long size, diff --git a/api/api_private.h b/api/api_private.h index 07fd50ad3a..bb23821c2c 100644 --- a/api/api_private.h +++ b/api/api_private.h @@ -8,7 +8,7 @@ #ifndef _API_PRIVATE_H_ #define _API_PRIVATE_H_
-void api_init(void); +int api_init(void); void platform_set_mr(struct sys_info *, unsigned long, unsigned long, int); int platform_sys_info(struct sys_info *);
diff --git a/common/board_r.c b/common/board_r.c index cb9b2424d1..b2d8331d6b 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -481,15 +481,6 @@ static int initr_malloc_bootparams(void) } #endif
-#if defined(CONFIG_API) -static int initr_api(void) -{ - /* Initialize API */ - api_init(); - return 0; -} -#endif - #ifdef CONFIG_CMD_NET static int initr_ethaddr(void) { @@ -744,7 +735,7 @@ static init_fnc_t init_sequence_r[] = { stdio_add_devices, jumptable_init, #ifdef CONFIG_API - initr_api, + api_init, #endif console_init_r, /* fully init console as a device */ #ifdef CONFIG_DISPLAY_BOARDINFO_LATE diff --git a/include/api.h b/include/api.h index 84d81dc817..5370fd5d40 100644 --- a/include/api.h +++ b/include/api.h @@ -7,6 +7,6 @@ #ifndef __API_H #define __API_H
-void api_init(void); +int api_init(void);
#endif

On Thu, 5 Nov 2020 at 03:11, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Add a return value to api_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
api/api.c | 6 ++++-- api/api_private.h | 2 +- common/board_r.c | 11 +---------- include/api.h | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Add a return value to bb_miiphy_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- common/board_r.c | 10 +--------- drivers/net/phy/miiphybb.c | 4 +++- include/miiphy.h | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/common/board_r.c b/common/board_r.c index b2d8331d6b..3ad4443c22 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -525,14 +525,6 @@ static int initr_scsi(void) } #endif
-#ifdef CONFIG_BITBANGMII -static int initr_bbmii(void) -{ - bb_miiphy_init(); - return 0; -} -#endif - #ifdef CONFIG_CMD_NET static int initr_net(void) { @@ -774,7 +766,7 @@ static init_fnc_t init_sequence_r[] = { initr_scsi, #endif #ifdef CONFIG_BITBANGMII - initr_bbmii, + bb_miiphy_init, #endif #ifdef CONFIG_PCI_ENDPOINT pci_ep_init, diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c index ba97a54c06..59a32c4913 100644 --- a/drivers/net/phy/miiphybb.c +++ b/drivers/net/phy/miiphybb.c @@ -105,7 +105,7 @@ int bb_miiphy_buses_num = sizeof(bb_miiphy_buses) / sizeof(bb_miiphy_buses[0]); #endif
-void bb_miiphy_init(void) +int bb_miiphy_init(void) { int i;
@@ -124,6 +124,8 @@ void bb_miiphy_init(void) bb_miiphy_buses[i].init(&bb_miiphy_buses[i]); } } + + return 0; }
static inline struct bb_miiphy_bus *bb_miiphy_getbus(const char *devname) diff --git a/include/miiphy.h b/include/miiphy.h index 61c136b114..c166f54e36 100644 --- a/include/miiphy.h +++ b/include/miiphy.h @@ -81,7 +81,7 @@ struct bb_miiphy_bus { extern struct bb_miiphy_bus bb_miiphy_buses[]; extern int bb_miiphy_buses_num;
-void bb_miiphy_init(void); +int bb_miiphy_init(void); int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg); int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, u16 value);

On Thu, 5 Nov 2020 at 03:11, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Add a return value to bb_miiphy_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
common/board_r.c | 10 +--------- drivers/net/phy/miiphybb.c | 4 +++- include/miiphy.h | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

In order to remove the arch-specific ifdefs around initr_trap, introduce arch_initr_trap weak initcall. Implementations for ppc/m68k/mips have been moved to arch/<arch>/lib/traps.c
Default implementation is a nop stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- arch/m68k/lib/traps.c | 7 +++++++ arch/mips/lib/traps.c | 7 +++++++ arch/powerpc/lib/Makefile | 1 + arch/powerpc/lib/traps.c | 17 +++++++++++++++++ common/board_r.c | 16 ++-------------- include/init.h | 9 +++++++++ 6 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 arch/powerpc/lib/traps.c
diff --git a/arch/m68k/lib/traps.c b/arch/m68k/lib/traps.c index c49141f376..a9b055cedf 100644 --- a/arch/m68k/lib/traps.c +++ b/arch/m68k/lib/traps.c @@ -59,3 +59,10 @@ void trap_init(ulong value) {
setvbr(value); /* set vector base register to new table */ } + +int arch_initr_trap(void) +{ + trap_init(CONFIG_SYS_SDRAM_BASE); + + return 0; +} diff --git a/arch/mips/lib/traps.c b/arch/mips/lib/traps.c index df8b63f383..4f2efd6115 100644 --- a/arch/mips/lib/traps.c +++ b/arch/mips/lib/traps.c @@ -131,3 +131,10 @@ void trap_restore(void) clear_c0_status(ST0_BEV); execution_hazard_barrier(); } + +int arch_initr_trap(void) +{ + trap_init(CONFIG_SYS_SDRAM_BASE); + + return 0; +} diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile index f61809ab05..2782740bf5 100644 --- a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile @@ -40,6 +40,7 @@ obj-y += interrupts.o obj-$(CONFIG_CMD_KGDB) += kgdb.o obj-y += stack.o obj-y += time.o +obj-y += traps.o endif # not minimal
ifdef CONFIG_SPL_BUILD diff --git a/arch/powerpc/lib/traps.c b/arch/powerpc/lib/traps.c new file mode 100644 index 0000000000..80822a006a --- /dev/null +++ b/arch/powerpc/lib/traps.c @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2003 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + */ + +#include <common.h> +#include <init.h> + +DECLARE_GLOBAL_DATA_PTR; + +int arch_initr_trap(void) +{ + trap_init(gd->relocaddr); + + return 0; +} diff --git a/common/board_r.c b/common/board_r.c index 3ad4443c22..927caf1eca 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -182,20 +182,10 @@ static int initr_reloc_global_data(void) return 0; }
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS) -static int initr_trap(void) +__weak int arch_initr_trap(void) { - /* - * Setup trap handlers - */ -#if defined(CONFIG_PPC) - trap_init(gd->relocaddr); -#else - trap_init(CONFIG_SYS_SDRAM_BASE); -#endif return 0; } -#endif
#if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500) static int initr_unlock_ram_in_cache(void) @@ -660,9 +650,7 @@ static init_fnc_t init_sequence_r[] = { #ifdef CONFIG_NEEDS_MANUAL_RELOC initr_manual_reloc_cmdtable, #endif -#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS) - initr_trap, -#endif + arch_initr_trap, #ifdef CONFIG_ADDR_MAP init_addr_map, #endif diff --git a/include/init.h b/include/init.h index 5519562163..232a021845 100644 --- a/include/init.h +++ b/include/init.h @@ -267,6 +267,15 @@ int board_early_init_r(void); /* TODO(sjg@chromium.org): Drop this when DM_PCI migration is completed */ void pci_init_board(void);
+/** + * arch_initr_trap() - Init traps + * + * Arch specific routine for initializing traps. It is called during the + * generic board init sequence, after relocation. + * + * Return: 0 if OK + */ +int arch_initr_trap(void); void trap_init(unsigned long reloc_addr);
/**

On Thu, 5 Nov 2020 at 03:11, Ovidiu Panait ovidiu.panait@windriver.com wrote:
In order to remove the arch-specific ifdefs around initr_trap, introduce arch_initr_trap weak initcall. Implementations for ppc/m68k/mips have been moved to arch/<arch>/lib/traps.c
Default implementation is a nop stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
arch/m68k/lib/traps.c | 7 +++++++ arch/mips/lib/traps.c | 7 +++++++ arch/powerpc/lib/Makefile | 1 + arch/powerpc/lib/traps.c | 17 +++++++++++++++++ common/board_r.c | 16 ++-------------- include/init.h | 9 +++++++++ 6 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 arch/powerpc/lib/traps.c
Reviewed-by: Simon Glass sjg@chromium.org

CONFIG_HANDOFF is used in u-boot proper to locate handoff info from SPL during pre-relocation init (in setup_spl_handoff). Add explicit dependency on CONFIG_SPL, to fix the following build error when CONFIG_HANDOFF && !CONFIG_SPL:
common/board_f.c: In function ‘setup_spl_handoff’: common/board_f.c:283:4: error: ‘gd_t {aka struct global_data}’ has no member named ‘spl_handoff’ gd->spl_handoff = bloblist_find(BLOBLISTT_SPL_HANDOFF, ^~
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- common/spl/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index d8086bd9e8..cd980e96b8 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -117,7 +117,7 @@ endmenu
config HANDOFF bool "Pass hand-off information from SPL to U-Boot proper" - depends on BLOBLIST + depends on SPL && BLOBLIST help It is useful to be able to pass information from SPL to U-Boot proper to preserve state that is known in SPL and is needed in U-Boot.

On Thu, 5 Nov 2020 at 03:11, Ovidiu Panait ovidiu.panait@windriver.com wrote:
CONFIG_HANDOFF is used in u-boot proper to locate handoff info from SPL during pre-relocation init (in setup_spl_handoff). Add explicit dependency on CONFIG_SPL, to fix the following build error when CONFIG_HANDOFF && !CONFIG_SPL:
common/board_f.c: In function ‘setup_spl_handoff’: common/board_f.c:283:4: error: ‘gd_t {aka struct global_data}’ has no member named ‘spl_handoff’ gd->spl_handoff = bloblist_find(BLOBLISTT_SPL_HANDOFF, ^~
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
common/spl/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org

spl_handoff should only be enabled when CONFIG_HANDOFF is set. Drop the nested ifdefs and check for CONFIG_HANDOFF instead.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com --- include/asm-generic/global_data.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index f392043796..fc6105ca8d 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -399,12 +399,12 @@ struct global_data { * @new_bloblist: relocated blob list information */ struct bloblist_hdr *new_bloblist; -# ifdef CONFIG_SPL +#endif +#if CONFIG_IS_ENABLED(HANDOFF) /** * @spl_handoff: SPL hand-off information */ struct spl_handoff *spl_handoff; -# endif #endif #if defined(CONFIG_TRANSLATION_OFFSET) /**

On Thu, 5 Nov 2020 at 03:11, Ovidiu Panait ovidiu.panait@windriver.com wrote:
spl_handoff should only be enabled when CONFIG_HANDOFF is set. Drop the nested ifdefs and check for CONFIG_HANDOFF instead.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
include/asm-generic/global_data.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
participants (2)
-
Ovidiu Panait
-
Simon Glass