[U-Boot] [PATCH] 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).
Signed-off-by: Lukasz Majewski lukma@denx.de --- common/spl/Kconfig | 8 ++++++++ common/spl/spl.c | 6 ++++++ include/spl.h | 4 ++++ 3 files changed, 18 insertions(+)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index bb99f1f..7e6f9c4 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -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 diff --git a/common/spl/spl.c b/common/spl/spl.c index bdb165a..a15647b 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -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) diff --git a/include/spl.h b/include/spl.h index e080a82..00a2058 100644 --- a/include/spl.h +++ b/include/spl.h @@ -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 *

On 01/15/2017 11:46 PM, Lukasz Majewski wrote:
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 ?
Signed-off-by: Lukasz Majewski lukma@denx.de
common/spl/Kconfig | 8 ++++++++ common/spl/spl.c | 6 ++++++ include/spl.h | 4 ++++ 3 files changed, 18 insertions(+)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index bb99f1f..7e6f9c4 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -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 diff --git a/common/spl/spl.c b/common/spl/spl.c index bdb165a..a15647b 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -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) diff --git a/include/spl.h b/include/spl.h index e080a82..00a2058 100644 --- a/include/spl.h +++ b/include/spl.h @@ -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

Dear All,
On 01/15/2017 11:46 PM, Lukasz Majewski wrote:
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.
Signed-off-by: Lukasz Majewski lukma@denx.de
common/spl/Kconfig | 8 ++++++++ common/spl/spl.c | 6 ++++++ include/spl.h | 4 ++++ 3 files changed, 18 insertions(+)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index bb99f1f..7e6f9c4 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -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 diff --git a/common/spl/spl.c b/common/spl/spl.c index bdb165a..a15647b 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -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) diff --git a/include/spl.h b/include/spl.h index e080a82..00a2058 100644 --- a/include/spl.h +++ b/include/spl.h @@ -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
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@denx.de
participants (2)
-
Lukasz Majewski
-
Marek Vasut