Skip to contentSkip to conversation

arm:am33xx: Fix problems with XIP booting and i2c

PATCH New Tom Rini 1 participant 5 messages May 21, 2014 – Jun 6, 2014 Arm (32-bit)

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

cover arm:am33xx: Fix problems with XIP booting and i2c

The following series fixes problems with booting U-Boot without SPL on am33xx/am43xx, which only happens in the case of NOR or QSPI. The changes themselves are rather straight forward. The biggest thing is that they highlight that SPL needs to migrate over to common/board_f.c because, yeah, there's some duplication of and getting things just a little wrong in the SPL version of the s_init / _main / board_init_f / board_init_r flow.

Signature · 1 line
Tom
author
#1 lore raw

PATCH 1/2 arm:am33xx: Make dram_init call sdram_init() in some contexts

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.

---
 arch/arm/cpu/armv7/am33xx/board.c |    2 ++
 arch/arm/cpu/armv7/am33xx/emif4.c |    4 ++++
 2 files changed, 6 insertions(+)
arch/arm/cpu/armv7/am33xx/board.c +2 -0
index e5c922a..9a69b6c 100644
@@ -238,7 +238,9 @@ void s_init(void)
 	/* Enable RTC32K clock */
 	rtc32k_enable();
 #endif
+#ifdef CONFIG_SPL_BUILD
 	sdram_init();
+#endif
 }
 #endif
 
arch/arm/cpu/armv7/am33xx/emif4.c +4 -0
index 2c67c32..a7a3e88 100644
@@ -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,
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH 1/2 arm:am33xx: Make dram_init call sdram_init() in some contexts

Quoted 7 lines · Tom Rini

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.

Quoted 7 lines

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.

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

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140606/434a0342/attachment.pgp>
author
#3 lore raw

PATCH 2/2 arm:am33xx: Rework s_init and add board_early_init_f

In reply to Tom Rini

With the changes to the i2c framework (and adopting the omap24xx_i2c driver to them) we can no longer call i2c functions prior to gd having been set and cleared. When SPL booting, this is handled by setting gd to point to SRAM in s_init. However in the cases where we are loaded directly by ROM (memory mapped NOR or QSPI) we need to make use of the normal hooks to slightly delay these calls.

---
 arch/arm/cpu/armv7/am33xx/board.c  |   16 ++++++++++++++--
 include/configs/am43xx_evm.h       |    9 +++++++++
 include/configs/ti_am335x_common.h |    9 +++++++++
 3 files changed, 32 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/am33xx/board.c +14 -2
index 9a69b6c..7fe049e 100644
@@ -144,6 +144,19 @@ int arch_misc_init(void)
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
 /*
+ * In the case of non-SPL based booting we'll want to call these
+ * functions a tiny bit later as it will require gd to be set and cleared
+ * and that's not true in s_init in this case so we cannot do it there.
+ */
+int board_early_init_f(void)
+{
+	prcm_init();
+	set_mux_conf_regs();
+
+	return 0;
+}
+
+/*
  * This function is the place to do per-board things such as ramp up the
  * MPU clock frequency.
  */
@@ -232,13 +245,12 @@ void s_init(void)
 	gd = &gdata;
 	preloader_console_init();
 #endif
-	prcm_init();
-	set_mux_conf_regs();
 #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC)
 	/* Enable RTC32K clock */
 	rtc32k_enable();
 #endif
 #ifdef CONFIG_SPL_BUILD
+	board_early_init_f();
 	sdram_init();
 #endif
 }
include/configs/am43xx_evm.h +9 -0
index 94126c7..470fa39 100644
@@ -52,6 +52,15 @@
 #define CONFIG_SKIP_LOWLEVEL_INIT
 #endif
 
+/*
+ * When building U-Boot such that there is no previous loader
+ * we need to call board_early_init_f.  This is taken care of in
+ * s_init when we have SPL used.
+ */
+#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && !defined(CONFIG_SPL)
+#define CONFIG_BOARD_EARLY_INIT_F
+#endif
+
 /* Now bring in the rest of the common code. */
 #include <configs/ti_armv7_common.h>
 
include/configs/ti_am335x_common.h +9 -0
index 128b66e..80976e7 100644
@@ -75,6 +75,15 @@
 #define CONFIG_SKIP_LOWLEVEL_INIT
 #endif
 
+/*
+ * When building U-Boot such that there is no previous loader
+ * we need to call board_early_init_f.  This is taken care of in
+ * s_init when we have SPL used.
+ */
+#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && !defined(CONFIG_SPL)
+#define CONFIG_BOARD_EARLY_INIT_F
+#endif
+
 #ifdef CONFIG_NAND
 #define CONFIG_SPL_NAND_AM33XX_BCH	/* ELM support */
 #endif
Signature · 1 line
1.7.9.5
author
#4 lore raw

PATCH 2/2 arm:am33xx: Rework s_init and add board_early_init_f

Quoted 8 lines · Tom Rini

With the changes to the i2c framework (and adopting the omap24xx_i2c driver to them) we can no longer call i2c functions prior to gd having been set and cleared. When SPL booting, this is handled by setting gd to point to SRAM in s_init. However in the cases where we are loaded directly by ROM (memory mapped NOR or QSPI) we need to make use of the normal hooks to slightly delay these calls.

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

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140606/880032d9/attachment.pgp>