Skip to contentSkip to conversation

SPL: Add spl_early_board_init() generic function

PATCH New Lukasz Majewski 2 participants 3 messages Jan 15, 2017 – Jan 16, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SPL: Add spl_early_board_init() generic function

Some boards do require early adjustments (due to e.g. HW fix) in SPL code. In this particular case such operations must be performed just before ANY external IC is accessed (good example here is the I2C early bus access).

---
 common/spl/Kconfig | 8 ++++++++
 common/spl/spl.c   | 6 ++++++
 include/spl.h      | 4 ++++
 3 files changed, 18 insertions(+)
common/spl/Kconfig +8 -0
index bb99f1f..7e6f9c4 100644
@@ -185,6 +185,14 @@ config SPL_SAVEENV
 	  "reboot_image" and act accordingly and change the reboot_image
 	  to default mode using setenv and save the environemnt.
 
+config SPL_EARLY_BOARD_INIT
+	bool "Support early board init code"
+	depends on SPL
+	help
+	  Enable support for very early SPL board code adjustments.
+	  Some boards require having adjustements done before any
+	  peripherals being operational (e.g. I2C, SPI, UART).
+
 config SPL_ETH_SUPPORT
 	bool "Support Ethernet"
 	depends on SPL_ENV_SUPPORT
common/spl/spl.c +6 -0
index bdb165a..a15647b 100644
@@ -393,6 +393,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	struct spl_image_info spl_image;
 	int i;
 
+#ifdef CONFIG_SPL_EARLY_BOARD_INIT
+	debug(">>spl:early_board_init()\n");
+
+	spl_early_board_init();
+#endif
+
 	debug(">>spl:board_init_r()\n");
 
 #if defined(CONFIG_SYS_SPL_MALLOC_START)
include/spl.h +4 -0
index e080a82..00a2058 100644
@@ -215,6 +215,10 @@ int spl_init(void);
 void spl_board_init(void);
 #endif
 
+#ifdef CONFIG_SPL_EARLY_BOARD_INIT
+void spl_early_board_init(void);
+#endif
+
 /**
  * spl_was_boot_source() - check if U-Boot booted from SPL
  *
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 SPL: Add spl_early_board_init() generic function

Quoted 3 lines · Lukasz Majewski

Some boards do require early adjustments (due to e.g. HW fix) in SPL code. In this particular case such operations must be performed just before ANY external IC is accessed (good example here is the I2C early bus access).

Shouldn't such stuff be done in board_init_f or so then ? board_init_r is pretty late ...

btw I'm not a big fan of adding more and more callbacks, what is the usecase here ?

Quoted 59 lines
---
 common/spl/Kconfig | 8 ++++++++
 common/spl/spl.c   | 6 ++++++
 include/spl.h      | 4 ++++
 3 files changed, 18 insertions(+)
common/spl/Kconfig +8 -0
index bb99f1f..7e6f9c4 100644
@@ -185,6 +185,14 @@ config SPL_SAVEENV
 	  "reboot_image" and act accordingly and change the reboot_image
 	  to default mode using setenv and save the environemnt.
 
+config SPL_EARLY_BOARD_INIT
+	bool "Support early board init code"
+	depends on SPL
+	help
+	  Enable support for very early SPL board code adjustments.
+	  Some boards require having adjustements done before any
+	  peripherals being operational (e.g. I2C, SPI, UART).
+
 config SPL_ETH_SUPPORT
 	bool "Support Ethernet"
 	depends on SPL_ENV_SUPPORT
common/spl/spl.c +6 -0
index bdb165a..a15647b 100644
@@ -393,6 +393,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	struct spl_image_info spl_image;
 	int i;
 
+#ifdef CONFIG_SPL_EARLY_BOARD_INIT
+	debug(">>spl:early_board_init()\n");
+
+	spl_early_board_init();
+#endif
+
 	debug(">>spl:board_init_r()\n");
 
 #if defined(CONFIG_SYS_SPL_MALLOC_START)
include/spl.h +4 -0
index e080a82..00a2058 100644
@@ -215,6 +215,10 @@ int spl_init(void);
 void spl_board_init(void);
 #endif
 
+#ifdef CONFIG_SPL_EARLY_BOARD_INIT
+void spl_early_board_init(void);
+#endif
+
 /**
  * spl_was_boot_source() - check if U-Boot booted from SPL
  *
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

PATCH 1/1 SPL: Add spl_early_board_init() generic function

Dear All,

Quoted 11 lines · Lukasz Majewski
Quoted 4 lines

Some boards do require early adjustments (due to e.g. HW fix) in SPL code. In this particular case such operations must be performed just before ANY external IC is accessed (good example here is the I2C early bus access).

Shouldn't such stuff be done in board_init_f or so then ? board_init_r is pretty late ...

btw I'm not a big fan of adding more and more callbacks, what is the usecase here ?

We had some discussion with Marek and we have found better (and more important already existing) place for this code.

Please regard this patch as not needed and hence dropped.

Quoted 52 lines
Quoted 52 lines
---
 common/spl/Kconfig | 8 ++++++++
 common/spl/spl.c   | 6 ++++++
 include/spl.h      | 4 ++++
 3 files changed, 18 insertions(+)
common/spl/Kconfig +0 -0
index bb99f1f..7e6f9c4 100644
@@ -185,6 +185,14 @@ config SPL_SAVEENV
 	  "reboot_image" and act accordingly and change the

reboot_image to default mode using setenv and save the environemnt.

common/spl/Kconfig +8 -0
+config SPL_EARLY_BOARD_INIT
+	bool "Support early board init code"
+	depends on SPL
+	help
+	  Enable support for very early SPL board code adjustments.
+	  Some boards require having adjustements done before any
+	  peripherals being operational (e.g. I2C, SPI, UART).
+
 config SPL_ETH_SUPPORT
 	bool "Support Ethernet"
 	depends on SPL_ENV_SUPPORT
common/spl/spl.c +6 -0
index bdb165a..a15647b 100644
@@ -393,6 +393,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	struct spl_image_info spl_image;
 	int i;
 
+#ifdef CONFIG_SPL_EARLY_BOARD_INIT
+	debug(">>spl:early_board_init()\n");
+
+	spl_early_board_init();
+#endif
+
 	debug(">>spl:board_init_r()\n");
 
 #if defined(CONFIG_SYS_SPL_MALLOC_START)
include/spl.h +0 -0
index e080a82..00a2058 100644
@@ -215,6 +215,10 @@ int spl_init(void);
 void spl_board_init(void);
 #endif
 
Quoted 10 lines

include/spl.h int spl_init(void); · line 224

Quoted 8 lines
include/spl.h +4 -0
+#ifdef CONFIG_SPL_EARLY_BOARD_INIT
+void spl_early_board_init(void);
+#endif
+
 /**
  * spl_was_boot_source() - check if U-Boot booted from SPL
  *

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de