[U-Boot] [RFC 3/7] board: MCR3000: properly setup initial RAM

Christophe Leroy christophe.leroy at c-s.fr
Wed Mar 14 17:16:13 UTC 2018


In order to use CONFIG_DM, some initial RAM is needed for
malloc()

Signed-off-by: Christophe Leroy <christophe.leroy at c-s.fr>
---
 arch/powerpc/cpu/mpc8xx/cpu_init.c | 2 +-
 arch/powerpc/cpu/mpc8xx/start.S    | 5 +++--
 include/configs/MCR3000.h          | 7 ++++---
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/cpu/mpc8xx/cpu_init.c b/arch/powerpc/cpu/mpc8xx/cpu_init.c
index 3dfea6125ea..f27ad86e393 100644
--- a/arch/powerpc/cpu/mpc8xx/cpu_init.c
+++ b/arch/powerpc/cpu/mpc8xx/cpu_init.c
@@ -28,7 +28,7 @@ void cpu_init_f(immap_t __iomem *immr)
 
 	gd = (gd_t *)(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
 	/* Clear initial global data */
-	memset((void *)gd, 0, sizeof(*gd));
+	board_init_f_init_reserve((ulong)gd);
 
 	/* SYPCR - contains watchdog control (11-9) */
 
diff --git a/arch/powerpc/cpu/mpc8xx/start.S b/arch/powerpc/cpu/mpc8xx/start.S
index 202ea81ae49..781bcd887e0 100644
--- a/arch/powerpc/cpu/mpc8xx/start.S
+++ b/arch/powerpc/cpu/mpc8xx/start.S
@@ -130,8 +130,9 @@ in_flash:
 	/* initialize some SPRs that are hard to access from C			*/
 	/*----------------------------------------------------------------------*/
 
-	lis	r3, CONFIG_SYS_IMMR at h		/* pass IMMR as arg1 to C routine */
-	ori	r1, r3, CONFIG_SYS_INIT_SP_OFFSET /* set up the stack in internal DPRAM */
+	/* set up the stack in internal DPRAM */
+	lis	r3, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)@h
+	ori	r1, r3, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)@l
 	/* Note: R0 is still 0 here */
 	stwu	r0, -4(r1)		/* clear final stack frame so that	*/
 	stwu	r0, -4(r1)		/* stack backtraces terminate cleanly	*/
diff --git a/include/configs/MCR3000.h b/include/configs/MCR3000.h
index 2b49f97e091..7f31c427791 100644
--- a/include/configs/MCR3000.h
+++ b/include/configs/MCR3000.h
@@ -70,11 +70,12 @@
 #define	CONFIG_SYS_HZ			1000
 
 /* Definitions for initial stack pointer and data area (in DPRAM) */
-#define CONFIG_SYS_INIT_RAM_ADDR	CONFIG_SYS_IMMR
-#define	CONFIG_SYS_INIT_RAM_SIZE	0x2f00
+#define CONFIG_SYS_INIT_RAM_ADDR	(CONFIG_SYS_IMMR + 0x2800)
+#define	CONFIG_SYS_INIT_RAM_SIZE	(0x2e00 - 0x2800)
 #define	CONFIG_SYS_GBL_DATA_SIZE	64
 #define CONFIG_SYS_GBL_DATA_OFFSET	(CONFIG_SYS_INIT_RAM_SIZE - \
-					 CONFIG_SYS_GBL_DATA_SIZE)
+					 CONFIG_SYS_GBL_DATA_SIZE - \
+					 CONFIG_SYS_MALLOC_F_LEN)
 #define CONFIG_SYS_INIT_SP_OFFSET	CONFIG_SYS_GBL_DATA_OFFSET
 
 /* RAM configuration (note that CONFIG_SYS_SDRAM_BASE must be zero) */
-- 
2.13.3



More information about the U-Boot mailing list