From: Stefan Roese <sr@denx.de>
Date: Wed, 19 Nov 2014 08:37:48 +0000 (+0100)
Subject: powerpc: mpc52xx: Clear GD in the main U-Boot stage for SPL usage
X-Git-Tag: v2025.01-rc5-pxa1908~14278^2
X-Git-Url: http://git.dujemihanovic.xyz/%22/icons/right.gif/static/git-favicon.png?a=commitdiff_plain;h=5fc3494fdb00dd7894090ce0c21936815a575558;p=u-boot.git

powerpc: mpc52xx: Clear GD in the main U-Boot stage for SPL usage

When an MPC5200 based board is used with SPL support, the main
U-Boot needs to clear the GD (global data) struct again.

Otherwise the generic board init code in board_init_f (when
CONFIG_SYS_GENERIC_BOARD is defined) will not initialize all
GD variables correctly. Resulting in a hangup on the a4m2k
board.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
---

diff --git a/arch/powerpc/cpu/mpc5xxx/start.S b/arch/powerpc/cpu/mpc5xxx/start.S
index 02c706ec63..94eb0d3fff 100644
--- a/arch/powerpc/cpu/mpc5xxx/start.S
+++ b/arch/powerpc/cpu/mpc5xxx/start.S
@@ -76,6 +76,21 @@ _start:
 	 * been done in the SPL u-boot version.
 	 */
 	GET_GOT			/* initialize GOT access		*/
+
+	/*
+	 * The GD (global data) struct needs to get cleared. Lets do
+	 * this by calling memset().
+	 * This function is called when the platform is build with SPL
+	 * support from the main (full-blown) U-Boot. And the GD needs
+	 * to get cleared (again) so that the following generic
+	 * board support code, defined via CONFIG_SYS_GENERIC_BOARD,
+	 * initializes all variables correctly.
+	 */
+	mr	r3, r2		/* parameter 1:	 GD pointer		*/
+	li	r4,0		/* parameter 2:	 value to fill		*/
+	li	r5,GD_SIZE	/* parameter 3:	 count			*/
+	bl	memset
+
 	bl	board_init_f	/* run 1st part of board init code (in Flash)*/
 	/* NOTREACHED - board_init_f() does not return */
 #else