diff mbox

[U-Boot,1/2] arm:am33xx: Make dram_init call sdram_init() in some contexts

Message ID 1400691442-32621-2-git-send-email-trini@ti.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Tom Rini May 21, 2014, 4:57 p.m. UTC
We have two contexts for booting these platforms.  One is SPL which is
roughly: reset, cpu_init_crit, lowlevel_init, s_init, sdram_init, _main,
board_init_f from SPL, ... then U-Boot loads.  The other is a
memory-mapped XIP case (NOR or QSPI) where we do not run an SPL.  In
this case we go, roughly: reset, cpu_init_crit, lowlevel_init, s_init,
_main, regular board_init_f.

In the first case s_init will set a valid gd and then be able to call
sdram_init which in many cases will need i2c (which needs a valid gd for
gd->cur_i2c_bus).  In this second case we must (and are able to and
should) defer sdram_init() into dram_init() called by board_init_f as gd
will have been set in _main and cleared in board_init_f.

Signed-off-by: Tom Rini <trini@ti.com>
---
 arch/arm/cpu/armv7/am33xx/board.c |    2 ++
 arch/arm/cpu/armv7/am33xx/emif4.c |    4 ++++
 2 files changed, 6 insertions(+)

Comments

Tom Rini June 6, 2014, 9:54 p.m. UTC | #1
On Wed, May 21, 2014 at 12:57:21PM -0400, Tom Rini wrote:

> We have two contexts for booting these platforms.  One is SPL which is
> roughly: reset, cpu_init_crit, lowlevel_init, s_init, sdram_init, _main,
> board_init_f from SPL, ... then U-Boot loads.  The other is a
> memory-mapped XIP case (NOR or QSPI) where we do not run an SPL.  In
> this case we go, roughly: reset, cpu_init_crit, lowlevel_init, s_init,
> _main, regular board_init_f.
> 
> In the first case s_init will set a valid gd and then be able to call
> sdram_init which in many cases will need i2c (which needs a valid gd for
> gd->cur_i2c_bus).  In this second case we must (and are able to and
> should) defer sdram_init() into dram_init() called by board_init_f as gd
> will have been set in _main and cleared in board_init_f.
> 
> Signed-off-by: Tom Rini <trini@ti.com>

Applied to u-boot-ti/master, thanks!
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c
index e5c922a..9a69b6c 100644
--- a/arch/arm/cpu/armv7/am33xx/board.c
+++ b/arch/arm/cpu/armv7/am33xx/board.c
@@ -238,7 +238,9 @@  void s_init(void)
 	/* Enable RTC32K clock */
 	rtc32k_enable();
 #endif
+#ifdef CONFIG_SPL_BUILD
 	sdram_init();
+#endif
 }
 #endif
 
diff --git a/arch/arm/cpu/armv7/am33xx/emif4.c b/arch/arm/cpu/armv7/am33xx/emif4.c
index 2c67c32..a7a3e88 100644
--- a/arch/arm/cpu/armv7/am33xx/emif4.c
+++ b/arch/arm/cpu/armv7/am33xx/emif4.c
@@ -21,6 +21,10 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	sdram_init();
+#endif
+
 	/* dram_init must store complete ramsize in gd->ram_size */
 	gd->ram_size = get_ram_size(
 			(void *)CONFIG_SYS_SDRAM_BASE,