Patchwork [U-Boot,V7,2/5] omap-common: Add NAND SPL linux booting

login
register
mail settings
Submitter Simon Schwarz
Date Oct. 31, 2011, 4:23 p.m.
Message ID <1320078187-28423-3-git-send-email-simonschwarzcor@gmail.com>
Download mbox | patch
Permalink /patch/122880/
State Superseded
Delegated to: Tom Rini
Headers show

Comments

Simon Schwarz - Oct. 31, 2011, 4:23 p.m.
From: Simon Schwarz <simonschwarzcor@googlemail.com>

This implements booting of Linux from NAND in SPL

Related config parameters:
CONFIG_SYS_NAND_SPL_KERNEL_OFFS
	Offset in NAND of direct boot kernel image to use in SPL
CONFIG_SYS_SPL_ARGS_ADDR
	Address where the kernel boot arguments are expected - this is
	normally RAM-start + 0x100 (on ARM)

Signed-off-by: Simon Schwarz <simonschwarzcor@gmail.com>
---

V2 changes:
nothing

V3 changes:
nothing

V4 changes:
ADD define description to commit message
CHG renaming some defines - renaming SAVEBP SPL

V5 changes:
nothing

V6 changes:
nothing

V7 changes:
nothing
---
 arch/arm/cpu/armv7/omap-common/spl_nand.c |   62 +++++++++++++++++++++-------
 1 files changed, 46 insertions(+), 16 deletions(-)
Tom Rini - Dec. 6, 2011, 2:38 p.m.
On Mon, Oct 31, 2011 at 9:23 AM, Simon Schwarz
<simonschwarzcor@googlemail.com> wrote:
> From: Simon Schwarz <simonschwarzcor@googlemail.com>
>
> This implements booting of Linux from NAND in SPL
[snip]
> +               /* load parameter image */
> +               /* load to temp position since nand_spl_load_image reads
> +                * a whole block which is typically larger than
> +                * CONFIG_CMD_SAVEBP_WRITE_SIZE therefore may overwrite
> +                * following sections like BSS */

In v6 Wolfgang asked you to fix incorrect multiline comments in the
whole series, but this is still here :(  This is the only problem I
see so if you can't respin this patch shortly I'll update the comment
and SIgned-off-by the change since it's just reformatting a comment,
which I assume is fine with you.

Patch

diff --git a/arch/arm/cpu/armv7/omap-common/spl_nand.c b/arch/arm/cpu/armv7/omap-common/spl_nand.c
index 38d06b1..1b9e171 100644
--- a/arch/arm/cpu/armv7/omap-common/spl_nand.c
+++ b/arch/arm/cpu/armv7/omap-common/spl_nand.c
@@ -24,6 +24,7 @@ 
 #include <asm/u-boot.h>
 #include <asm/utils.h>
 #include <asm/arch/sys_proto.h>
+#include <asm/io.h>
 #include <nand.h>
 #include <version.h>
 #include <asm/omap_common.h>
@@ -32,6 +33,7 @@ 
 void spl_nand_load_image(void)
 {
 	struct image_header *header;
+	int *src, *dst;
 	switch (omap_boot_mode()) {
 	case NAND_MODE_HW_ECC:
 		debug("spl: nand - using hw ecc\n");
@@ -45,26 +47,54 @@  void spl_nand_load_image(void)
 
 	/*use CONFIG_SYS_TEXT_BASE as temporary storage area */
 	header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
+#ifdef CONFIG_SPL_OS_BOOT
+	if (!spl_uboot_key()) {
+		/* load parameter image */
+		/* load to temp position since nand_spl_load_image reads
+		 * a whole block which is typically larger than
+		 * CONFIG_CMD_SAVEBP_WRITE_SIZE therefore may overwrite
+		 * following sections like BSS */
+		nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS,
+			CONFIG_CMD_SPL_WRITE_SIZE,
+			(void *)CONFIG_SYS_TEXT_BASE);
+		/* copy to destintion */
+		for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR,
+				src = (int *)CONFIG_SYS_TEXT_BASE;
+				src < (int *)(CONFIG_SYS_TEXT_BASE +
+				CONFIG_CMD_SPL_WRITE_SIZE);
+				src++, dst++) {
+			writel(readl(src), dst);
+		}
 
+		/* load linux */
+		nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
+			CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+		spl_parse_image_header(header);
+		nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
+			spl_image.size, (void *)spl_image.load_addr);
+	} else
+#endif
+	{
 #ifdef CONFIG_NAND_ENV_DST
-	nand_spl_load_image(CONFIG_ENV_OFFSET,
-		CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
-	spl_parse_image_header(header);
-	nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
-		(void *)image_load_addr);
+		nand_spl_load_image(CONFIG_ENV_OFFSET,
+			CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+		spl_parse_image_header(header);
+		nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
+			(void *)spl_image.load_addr);
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
-		CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
-	spl_parse_image_header(header);
-	nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
-		(void *)image_load_addr);
+		nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
+			CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+		spl_parse_image_header(header);
+		nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
+			(void *)spl_image.load_addr);
 #endif
 #endif
-	/* Load u-boot */
-	nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
-		CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
-	spl_parse_image_header(header);
-	nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
-		spl_image.size, (void *)spl_image.load_addr);
+		/* Load u-boot */
+		nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
+			CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+		spl_parse_image_header(header);
+		nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
+			spl_image.size, (void *)spl_image.load_addr);
+	}
 	nand_deselect();
 }