All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH 00/18] Minor board_f/board_r cleanups
@ 2021-01-16 16:08 Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 01/18] common: Kconfig: Introduce CONFIG_CONSOLE_RECORD_INIT_F Ovidiu Panait
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

Ovidiu Panait (18):
  common: Kconfig: Introduce CONFIG_CONSOLE_RECORD_INIT_F
  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_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/system.h        |  13 ++-
 arch/arm/lib/cache.c                 |   4 +-
 arch/m68k/lib/traps.c                |   9 +-
 arch/mips/lib/traps.c                |   9 +-
 arch/powerpc/cpu/mpc85xx/cpu_init.c  |   4 +-
 arch/powerpc/lib/Makefile            |   1 +
 arch/powerpc/lib/traps.c             |  19 ++++
 common/Kconfig                       |   8 ++
 common/board_f.c                     |  78 +++++++---------
 common/board_r.c                     | 134 ++++-----------------------
 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                        |  10 +-
 include/asm-generic/global_data.h    |   4 +-
 include/exports.h                    |  10 +-
 include/init.h                       |  47 +++++++++-
 include/miiphy.h                     |  10 +-
 include/post.h                       |  11 ++-
 include/xen.h                        |   2 +-
 post/post.c                          |   4 +-
 27 files changed, 225 insertions(+), 188 deletions(-)
 create mode 100644 arch/powerpc/lib/traps.c

-- 
2.17.1

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [RESEND PATCH 01/18] common: Kconfig: Introduce CONFIG_CONSOLE_RECORD_INIT_F
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 02/18] common: board_f: Drop initf_console_record wrapper Ovidiu Panait
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

Currently, the following #ifdef construct is used to check whether to run
console_record_init() during pre-relocation init:
 defined(CONFIG_CONSOLE_RECORD) && CONFIG_VAL(SYS_MALLOC_F_LEN)

Introduce CONFIG_CONSOLE_RECORD_INIT_F Kconfig option to get rid of the
complex ifdef check. Also, use IS_ENABLED() instead of #ifdef.

Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 common/Kconfig   | 8 ++++++++
 common/board_f.c | 7 +++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 2bce8c9ba1..d8982ba377 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -17,6 +17,14 @@ config CONSOLE_RECORD
 	  To enable console recording, call console_record_reset_enable()
 	  from your code.
 
+config CONSOLE_RECORD_INIT_F
+	bool "Enable console recording during pre-relocation init"
+	depends on CONSOLE_RECORD && SYS_MALLOC_F
+	default y
+	help
+	  This option enables console recording during pre-relocation init.
+	  CONFIG_SYS_MALLOC_F must be enabled to use this feature.
+
 config CONSOLE_RECORD_OUT_SIZE
 	hex "Output buffer size"
 	depends on CONSOLE_RECORD
diff --git a/common/board_f.c b/common/board_f.c
index 9f441c44f1..e5e69ff0fa 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -767,11 +767,10 @@ static int initf_bootstage(void)
 
 static int initf_console_record(void)
 {
-#if defined(CONFIG_CONSOLE_RECORD) && CONFIG_VAL(SYS_MALLOC_F_LEN)
-	return console_record_init();
-#else
+	if (IS_ENABLED(CONFIG_CONSOLE_RECORD_INIT_F))
+		return console_record_init();
+
 	return 0;
-#endif
 }
 
 static int initf_dm(void)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 02/18] common: board_f: Drop initf_console_record wrapper
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 01/18] common: Kconfig: Introduce CONFIG_CONSOLE_RECORD_INIT_F Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 03/18] common: board_f: Use IS_ENABLED(CONFIG_TIMER_EARLY) in initf_dm Ovidiu Panait
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

Drop initf_console_record wrapper and call console_record_init directly.

Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 common/board_f.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index e5e69ff0fa..552552e328 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -765,14 +765,6 @@ static int initf_bootstage(void)
 	return 0;
 }
 
-static int initf_console_record(void)
-{
-	if (IS_ENABLED(CONFIG_CONSOLE_RECORD_INIT_F))
-		return console_record_init();
-
-	return 0;
-}
-
 static int initf_dm(void)
 {
 #if defined(CONFIG_DM) && CONFIG_VAL(SYS_MALLOC_F_LEN)
@@ -829,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_INIT_F)
+	console_record_init,
+#endif
 #if defined(CONFIG_HAVE_FSP)
 	arch_fsp_init,
 #endif
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 03/18] common: board_f: Use IS_ENABLED(CONFIG_TIMER_EARLY) in initf_dm
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 01/18] common: Kconfig: Introduce CONFIG_CONSOLE_RECORD_INIT_F Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 02/18] common: board_f: Drop initf_console_record wrapper Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 04/18] common: board_f: Move setup_machine code to setup_bdinfo Ovidiu Panait
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 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 552552e328..3c4437341a 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;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 04/18] common: board_f: Move setup_machine code to setup_bdinfo
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (2 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 03/18] common: board_f: Use IS_ENABLED(CONFIG_TIMER_EARLY) in initf_dm Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 05/18] common: board_f: Use IS_ENABLED(CONFIG_OF_EMBED) in reserve_fdt, reloc_fdt Ovidiu Panait
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 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 3c4437341a..fbf622e0f0 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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 05/18] common: board_f: Use IS_ENABLED(CONFIG_OF_EMBED) in reserve_fdt, reloc_fdt
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (3 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 04/18] common: board_f: Move setup_machine code to setup_bdinfo Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 06/18] common: board_r: Drop initr_console_record wrapper Ovidiu Panait
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 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 fbf622e0f0..ae3001bed1 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;
 }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 06/18] common: board_r: Drop initr_console_record wrapper
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (4 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 05/18] common: board_f: Use IS_ENABLED(CONFIG_OF_EMBED) in reserve_fdt, reloc_fdt Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 07/18] common: board_r: Drop initr_secondary_cpu wrapper Ovidiu Panait
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

Drop initr_console_record wrapper and call console_record_init directly.

Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 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
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 07/18] common: board_r: Drop initr_secondary_cpu wrapper
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (5 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 06/18] common: board_r: Drop initr_console_record wrapper Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 08/18] common: board_r: Drop initr_post_backlog wrapper Ovidiu Panait
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 arch/powerpc/cpu/mpc85xx/cpu_init.c |  4 +++-
 common/board_r.c                    | 17 ++---------------
 include/init.h                      | 14 ++++++++++++++
 3 files changed, 19 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
diff --git a/include/init.h b/include/init.h
index 0f48ccb57a..7cdc47cff1 100644
--- a/include/init.h
+++ b/include/init.h
@@ -163,6 +163,20 @@ int arch_setup_bdinfo(void);
  */
 int setup_bdinfo(void);
 
+/**
+ * cpu_secondary_init_r() - CPU-specific secondary initialization
+ *
+ * After non-volatile devices, environment and cpu code are setup, 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.
+ *
+ * It is called during the generic post-relocation init sequence.
+ *
+ * Return: 0 if OK
+ */
+int cpu_secondary_init_r(void);
+
 /**
  * init_cache_f_r() - Turn on the cache in preparation for relocation
  *
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 08/18] common: board_r: Drop initr_post_backlog wrapper
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (6 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 07/18] common: board_r: Drop initr_secondary_cpu wrapper Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 09/18] common: board_r: Drop initr_pci_ep wrapper Ovidiu Panait
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 common/board_r.c | 10 +---------
 include/post.h   | 11 ++++++++++-
 post/post.c      |  4 +++-
 3 files changed, 14 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..5695e2b533 100644
--- a/include/post.h
+++ b/include/post.h
@@ -107,7 +107,6 @@ 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_run (char *name, int flags);
 int post_info (char *name);
 int post_log (char *format, ...);
@@ -116,6 +115,16 @@ void post_reloc (void);
 #endif
 unsigned long post_time_ms (unsigned long base);
 
+/**
+ * post_output_backlog() - Print POST results
+ *
+ * Print POST results during the generic board init sequence, after
+ * relocation.
+ *
+ * Return: 0 if OK
+ */
+int post_output_backlog(void);
+
 extern struct post_test post_list[];
 extern unsigned int post_list_size;
 extern int post_hotkeys_pressed(void);
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)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 09/18] common: board_r: Drop initr_pci_ep wrapper
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (7 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 08/18] common: board_r: Drop initr_post_backlog wrapper Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 10/18] common: board_r: Drop initr_pci wrapper Ovidiu Panait
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 common/board_r.c                     | 11 +----------
 drivers/pci_endpoint/pci_ep-uclass.c |  4 +++-
 include/init.h                       | 10 +++++++++-
 3 files changed, 13 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 7cdc47cff1..c6c5f34b55 100644
--- a/include/init.h
+++ b/include/init.h
@@ -177,6 +177,15 @@ int setup_bdinfo(void);
  */
 int cpu_secondary_init_r(void);
 
+/**
+ * pci_ep_init() - Initialize pci endpoint devices
+ *
+ * It is called during the generic post-relocation init sequence.
+ *
+ * Return: 0 if OK
+ */
+int pci_ep_init(void);
+
 /**
  * init_cache_f_r() - Turn on the cache in preparation for relocation
  *
@@ -249,7 +258,6 @@ 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 misc_init_r(void);
 #if defined(CONFIG_VID)
 int init_func_vid(void);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 10/18] common: board_r: Drop initr_pci wrapper
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (8 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 09/18] common: board_r: Drop initr_pci_ep wrapper Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 11/18] common: board_r: Drop initr_noncached wrapper Ovidiu Panait
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 common/board_r.c         | 18 ++++--------------
 drivers/pci/pci-uclass.c |  4 +++-
 drivers/pci/pci.c        |  6 ++++--
 include/init.h           | 13 ++++++++++++-
 4 files changed, 23 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 4cdd06b125..ba65f47e80 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -1842,7 +1842,7 @@ U_BOOT_DRIVER(pci_generic_drv) = {
 	.of_match	= pci_generic_ids,
 };
 
-void pci_init(void)
+int pci_init(void)
 {
 	struct udevice *bus;
 
@@ -1855,4 +1855,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 c6c5f34b55..dded1cb871 100644
--- a/include/init.h
+++ b/include/init.h
@@ -186,6 +186,18 @@ int cpu_secondary_init_r(void);
  */
 int pci_ep_init(void);
 
+/**
+ * pci_init() - Enumerate pci devices
+ *
+ * It is called during the generic post-relocation init sequence to enumerate
+ * pci buses. This is needed, for instance, in the case of DM PCI-based
+ * Ethernet devices, which will not be detected without having the enumeration
+ * performed earlier.
+ *
+ * Return: 0 if OK
+ */
+int pci_init(void);
+
 /**
  * init_cache_f_r() - Turn on the cache in preparation for relocation
  *
@@ -257,7 +269,6 @@ 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 misc_init_r(void);
 #if defined(CONFIG_VID)
 int init_func_vid(void);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 11/18] common: board_r: Drop initr_noncached wrapper
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (9 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 10/18] common: board_r: Drop initr_pci wrapper Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 12/18] common: board_r: Drop initr_xen wrapper Ovidiu Panait
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 arch/arm/include/asm/system.h | 13 ++++++++++++-
 arch/arm/lib/cache.c          |  4 +++-
 common/board_r.c              | 10 +---------
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index ce552944b7..5fe83699f4 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -628,7 +628,18 @@ 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);
+/**
+ * noncached_init() - Initialize non-cached memory region
+ *
+ * Initialize non-cached memory area. This memory region will be typically
+ * located right below the malloc() area and mapped uncached in the MMU.
+ *
+ * It is called during the generic post-relocation init sequence.
+ *
+ * Return: 0 if OK
+ */
+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 414b6272c5..48e898b586 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -242,14 +242,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)) {
@@ -668,7 +660,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
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 12/18] common: board_r: Drop initr_xen wrapper
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (10 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 11/18] common: board_r: Drop initr_noncached wrapper Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 13/18] common: board_r: Drop initr_jumptable wrapper Ovidiu Panait
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 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 48e898b586..a5cbbcc343 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -428,14 +428,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)
 {
@@ -743,7 +735,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
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 13/18] common: board_r: Drop initr_jumptable wrapper
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (11 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 12/18] common: board_r: Drop initr_xen wrapper Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 14/18] common: board_r: Drop initr_api wrapper Ovidiu Panait
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 common/board_r.c  |  8 +-------
 common/exports.c  |  4 +++-
 include/exports.h | 10 ++++++++--
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index a5cbbcc343..32ad40d372 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -490,12 +490,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)
 {
@@ -757,7 +751,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..faf0f59244 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -15,8 +15,14 @@
 struct cmd_tbl;
 struct spi_slave;
 
-/* Set up the jump table for use by the API */
-void jumptable_init(void);
+/**
+ * jumptable_init() - Set up the jump table for use by the API
+ *
+ * It is called during the generic post-relocation init sequence.
+ *
+ * Return: 0 if OK
+ */
+int jumptable_init(void);
 
 /* These are declarations of exported functions available in C code */
 unsigned long get_version(void);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 14/18] common: board_r: Drop initr_api wrapper
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (12 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 13/18] common: board_r: Drop initr_jumptable wrapper Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 15/18] common: board_r: Drop initr_bbmii wrapper Ovidiu Panait
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 api/api.c         |  6 ++++--
 api/api_private.h |  2 +-
 common/board_r.c  | 11 +----------
 include/api.h     | 10 +++++++++-
 4 files changed, 15 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 32ad40d372..500457b080 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -490,15 +490,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)
 {
@@ -753,7 +744,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..83412a7c87 100644
--- a/include/api.h
+++ b/include/api.h
@@ -7,6 +7,14 @@
 #ifndef __API_H
 #define __API_H
 
-void api_init(void);
+/**
+ * api_init() - Initialize API for external applications
+ *
+ * Initialize API for external (standalone) applications running on top of
+ * U-Boot. It is called during the generic post-relocation init sequence.
+ *
+ * Return: 0 if OK
+ */
+int api_init(void);
 
 #endif
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 15/18] common: board_r: Drop initr_bbmii wrapper
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (13 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 14/18] common: board_r: Drop initr_api wrapper Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 16/18] common: board_r: Drop arch-specific ifdefs around initr_trap Ovidiu Panait
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 common/board_r.c           | 10 +---------
 drivers/net/phy/miiphybb.c |  4 +++-
 include/miiphy.h           | 10 +++++++++-
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index 500457b080..c083eb0a03 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -534,14 +534,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)
 {
@@ -783,7 +775,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..8b77bac01e 100644
--- a/include/miiphy.h
+++ b/include/miiphy.h
@@ -81,7 +81,15 @@ struct bb_miiphy_bus {
 extern struct bb_miiphy_bus bb_miiphy_buses[];
 extern int bb_miiphy_buses_num;
 
-void bb_miiphy_init(void);
+/**
+ * bb_miiphy_init() - Initialize bit-banged MII bus driver
+ *
+ * It is called during the generic post-relocation init sequence.
+ *
+ * Return: 0 if OK
+ */
+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);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 16/18] common: board_r: Drop arch-specific ifdefs around initr_trap
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (14 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 15/18] common: board_r: Drop initr_bbmii wrapper Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 17/18] spl: Kconfig: Add SPL dependency to CONFIG_HANDOFF Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 18/18] global_data: Enable spl_handoff only if CONFIG_HANDOFF is set Ovidiu Panait
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
---

 arch/m68k/lib/traps.c     |  9 ++++++++-
 arch/mips/lib/traps.c     |  9 ++++++++-
 arch/powerpc/lib/Makefile |  1 +
 arch/powerpc/lib/traps.c  | 19 +++++++++++++++++++
 common/board_r.c          | 16 ++--------------
 include/init.h            | 10 +++++++++-
 6 files changed, 47 insertions(+), 17 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..0c2c1a9965 100644
--- a/arch/m68k/lib/traps.c
+++ b/arch/m68k/lib/traps.c
@@ -40,7 +40,7 @@ void exc_handler(struct pt_regs *fp) {
 	for(;;);
 }
 
-void trap_init(ulong value) {
+static void trap_init(ulong value) {
 	unsigned long *vec = (ulong *)value;
 	int i;
 
@@ -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..540ea48e32 100644
--- a/arch/mips/lib/traps.c
+++ b/arch/mips/lib/traps.c
@@ -99,7 +99,7 @@ static void set_handler(unsigned long offset, void *addr, unsigned long size)
 	flush_cache(ebase + offset, size);
 }
 
-void trap_init(ulong reloc_addr)
+static void trap_init(ulong reloc_addr)
 {
 	unsigned long ebase = gd->irq_sp;
 
@@ -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..288e377632
--- /dev/null
+++ b/arch/powerpc/lib/traps.c
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ */
+
+#include <common.h>
+#include <init.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void trap_init(unsigned long reloc_addr);
+
+int arch_initr_trap(void)
+{
+	trap_init(gd->relocaddr);
+
+	return 0;
+}
diff --git a/common/board_r.c b/common/board_r.c
index c083eb0a03..9fa4d4b42e 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
 
 #ifdef CONFIG_ADDR_MAP
 static int initr_addr_map(void)
@@ -669,9 +659,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
 	initr_addr_map,
 #endif
diff --git a/include/init.h b/include/init.h
index dded1cb871..980be27993 100644
--- a/include/init.h
+++ b/include/init.h
@@ -300,7 +300,15 @@ int board_early_init_r(void);
 /* TODO(sjg at chromium.org): Drop this when DM_PCI migration is completed */
 void pci_init_board(void);
 
-void trap_init(unsigned long reloc_addr);
+/**
+ * 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);
 
 /**
  * main_loop() - Enter the main loop of U-Boot
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 17/18] spl: Kconfig: Add SPL dependency to CONFIG_HANDOFF
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (15 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 16/18] common: board_r: Drop arch-specific ifdefs around initr_trap Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  2021-01-16 16:08 ` [RESEND PATCH 18/18] global_data: Enable spl_handoff only if CONFIG_HANDOFF is set Ovidiu Panait
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 common/spl/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 6b0186763b..7561335bfd 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -126,7 +126,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.
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RESEND PATCH 18/18] global_data: Enable spl_handoff only if CONFIG_HANDOFF is set
  2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
                   ` (16 preceding siblings ...)
  2021-01-16 16:08 ` [RESEND PATCH 17/18] spl: Kconfig: Add SPL dependency to CONFIG_HANDOFF Ovidiu Panait
@ 2021-01-16 16:08 ` Ovidiu Panait
  17 siblings, 0 replies; 19+ messages in thread
From: Ovidiu Panait @ 2021-01-16 16:08 UTC (permalink / raw)
  To: u-boot

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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 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 efa09a1943..19f70393b4 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -412,12 +412,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)
 	/**
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-01-16 16:08 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-16 16:08 [RESEND PATCH 00/18] Minor board_f/board_r cleanups Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 01/18] common: Kconfig: Introduce CONFIG_CONSOLE_RECORD_INIT_F Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 02/18] common: board_f: Drop initf_console_record wrapper Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 03/18] common: board_f: Use IS_ENABLED(CONFIG_TIMER_EARLY) in initf_dm Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 04/18] common: board_f: Move setup_machine code to setup_bdinfo Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 05/18] common: board_f: Use IS_ENABLED(CONFIG_OF_EMBED) in reserve_fdt, reloc_fdt Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 06/18] common: board_r: Drop initr_console_record wrapper Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 07/18] common: board_r: Drop initr_secondary_cpu wrapper Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 08/18] common: board_r: Drop initr_post_backlog wrapper Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 09/18] common: board_r: Drop initr_pci_ep wrapper Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 10/18] common: board_r: Drop initr_pci wrapper Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 11/18] common: board_r: Drop initr_noncached wrapper Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 12/18] common: board_r: Drop initr_xen wrapper Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 13/18] common: board_r: Drop initr_jumptable wrapper Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 14/18] common: board_r: Drop initr_api wrapper Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 15/18] common: board_r: Drop initr_bbmii wrapper Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 16/18] common: board_r: Drop arch-specific ifdefs around initr_trap Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 17/18] spl: Kconfig: Add SPL dependency to CONFIG_HANDOFF Ovidiu Panait
2021-01-16 16:08 ` [RESEND PATCH 18/18] global_data: Enable spl_handoff only if CONFIG_HANDOFF is set Ovidiu Panait

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.