[U-Boot] [PATCH 16/17] SPL: Enhance drivers/mtd/nand/nand_spl_load.c

Tom Rini trini at ti.com
Wed Aug 15 23:30:53 CEST 2012


Takes the load function from arch/arm/lib/spl_nand.c instead.  This will
allow for easier integration of SPL-boots-Linux code on other arches.
Kill off CONFIG_SPL_NAND_LOAD as a separate option.

Signed-off-by: Tom Rini <trini at ti.com>
---
 arch/arm/cpu/arm926ejs/davinci/spl.c |    2 +-
 arch/arm/lib/Makefile                |    1 -
 arch/arm/lib/spl_nand.c              |  102 ----------------------------------
 doc/README.SPL                       |    1 -
 drivers/mtd/nand/Makefile            |    7 +--
 drivers/mtd/nand/nand_spl_load.c     |   89 +++++++++++++++++++++--------
 include/configs/cam_enc_4xx.h        |    1 -
 include/configs/hawkboard.h          |    1 -
 8 files changed, 67 insertions(+), 137 deletions(-)
 delete mode 100644 arch/arm/lib/spl_nand.c

diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c
index 833f721..f1a97cb 100644
--- a/arch/arm/cpu/arm926ejs/davinci/spl.c
+++ b/arch/arm/cpu/arm926ejs/davinci/spl.c
@@ -60,7 +60,7 @@ void spl_board_init(void)
 
 u32 spl_boot_device(void)
 {
-#ifdef CONFIG_SPL_NAND_LOAD
+#ifdef CONFIG_SPL_NAND_SIMPLE
 	return BOOT_DEVICE_NAND;
 #elif defined(CONFIG_SPL_SPI_LOAD)
 	return BOOT_DEVICE_SPI;
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index abf550a..d8e565f 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -29,7 +29,6 @@ LIBGCC	= $(obj)libgcc.o
 ifdef CONFIG_SPL_BUILD
 ifdef CONFIG_SPL_FRAMEWORK
 COBJS-$(CONFIG_SPL_FRAMEWORK)		+= spl.o
-COBJS-$(CONFIG_SPL_NAND_SUPPORT)	+= spl_nand.o
 COBJS-$(CONFIG_SPL_MMC_SUPPORT)		+= spl_mmc.o
 COBJS-$(CONFIG_SPL_YMODEM_SUPPORT)	+= spl_ymodem.o
 endif
diff --git a/arch/arm/lib/spl_nand.c b/arch/arm/lib/spl_nand.c
deleted file mode 100644
index 1e6b5f0..0000000
--- a/arch/arm/lib/spl_nand.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2011
- * Corscience GmbH & Co. KG - Simon Schwarz <schwarz at corscience.de>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-#include <common.h>
-#include <asm/spl.h>
-#include <asm/u-boot.h>
-#include <asm/utils.h>
-#include <asm/io.h>
-#include <nand.h>
-#include <version.h>
-
-void spl_nand_load_image(void)
-{
-	struct image_header *header;
-	int *src __attribute__((unused));
-	int *dst __attribute__((unused));
-
-	debug("spl: nand - using hw ecc\n");
-	nand_init();
-
-	/*use CONFIG_SYS_TEXT_BASE as temporary storage area */
-	header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
-#ifdef CONFIG_SPL_OS_BOOT
-	if (!spl_start_uboot()) {
-		/*
-		 * load parameter image
-		 * load to temp position since nand_spl_load_image reads
-		 * a whole block which is typically larger than
-		 * CONFIG_CMD_SPL_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);
-		if (header->ih_os == IH_OS_LINUX) {
-			/* happy - was a linux */
-			nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
-				spl_image.size, (void *)spl_image.load_addr);
-			nand_deselect();
-			return;
-		} else {
-			printf("The Expected Linux image was not"
-				"found. Please check your NAND"
-				"configuration.\n");
-			printf("Trying to start u-boot now...\n");
-		}
-	}
-#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 *)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 *)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);
-	nand_deselect();
-}
diff --git a/doc/README.SPL b/doc/README.SPL
index e4a5ac3..3faf91c 100644
--- a/doc/README.SPL
+++ b/doc/README.SPL
@@ -64,7 +64,6 @@ CONFIG_SPL_POWER_SUPPORT (drivers/power/libpower.o)
 CONFIG_SPL_NAND_SUPPORT (drivers/mtd/nand/libnand.o)
 CONFIG_SPL_DMA_SUPPORT (drivers/dma/libdma.o)
 CONFIG_SPL_POST_MEM_SUPPORT (post/drivers/memory.o)
-CONFIG_SPL_NAND_LOAD (drivers/mtd/nand/nand_spl_load.o)
 CONFIG_SPL_SPI_LOAD (drivers/mtd/spi/spi_spl_load.o)
 
 
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index 29dc20e..5475c8c 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -27,12 +27,7 @@ LIB	:= $(obj)libnand.o
 
 ifdef CONFIG_CMD_NAND
 ifdef CONFIG_SPL_BUILD
-ifdef CONFIG_SPL_NAND_SIMPLE
-COBJS-y += nand_spl_simple.o
-endif
-ifdef CONFIG_SPL_NAND_LOAD
-COBJS-y	+= nand_spl_load.o
-endif
+COBJS-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o nand_spl_load.o
 else
 COBJS-y += nand.o
 COBJS-y += nand_bbt.o
diff --git a/drivers/mtd/nand/nand_spl_load.c b/drivers/mtd/nand/nand_spl_load.c
index 215459a..a829ab2 100644
--- a/drivers/mtd/nand/nand_spl_load.c
+++ b/drivers/mtd/nand/nand_spl_load.c
@@ -20,36 +20,77 @@
 
 #include <common.h>
 #include <nand.h>
+#include <asm/io.h>
+#include <asm/spl.h>
 
-/*
- * The main entry for NAND booting. It's necessary that SDRAM is already
- * configured and available since this code loads the main U-Boot image
- * from NAND into SDRAM and starts it from there.
- */
-void nand_boot(void)
+void spl_nand_load_image(void)
 {
-	__attribute__((noreturn)) void (*uboot)(void);
+	struct image_header *header;
+	int *src __attribute__((unused));
+	int *dst __attribute__((unused));
 
-	/*
-	 * Load U-Boot image from NAND into RAM
-	 */
-	nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
-			CONFIG_SYS_NAND_U_BOOT_SIZE,
-			(void *)CONFIG_SYS_NAND_U_BOOT_DST);
+	nand_init();
 
-#ifdef CONFIG_NAND_ENV_DST
-	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
-			(void *)CONFIG_NAND_ENV_DST);
+	/* use CONFIG_SYS_TEXT_BASE as temporary storage area */
+	header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
+#ifdef CONFIG_SPL_OS_BOOT
+	if (!spl_start_uboot()) {
+		/*
+		 * load parameter image
+		 * load to temp position since nand_spl_load_image reads
+		 * a whole block which is typically larger than
+		 * CONFIG_CMD_SPL_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);
+		if (header->ih_os == IH_OS_LINUX) {
+			/* happy - was a linux */
+			nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
+				spl_image.size, (void *)spl_image.load_addr);
+			nand_deselect();
+			return;
+		} else {
+			puts("The Expected Linux image was not "
+				"found. Please check your NAND "
+				"configuration.\n");
+			puts("Trying to start u-boot now...\n");
+		}
+	}
+#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 *)spl_image.load_addr);
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, CONFIG_ENV_SIZE,
-			(void *)CONFIG_NAND_ENV_DST + CONFIG_ENV_SIZE);
+	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
-
-	/*
-	 * Jump to U-Boot image
-	 */
-	uboot = (void *)CONFIG_SYS_NAND_U_BOOT_START;
-	(*uboot)();
+	/* 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();
 }
diff --git a/include/configs/cam_enc_4xx.h b/include/configs/cam_enc_4xx.h
index fe28278..34aac8c 100644
--- a/include/configs/cam_enc_4xx.h
+++ b/include/configs/cam_enc_4xx.h
@@ -222,7 +222,6 @@
 #define CONFIG_SPL_LIBGENERIC_SUPPORT
 #define CONFIG_SPL_NAND_SUPPORT
 #define CONFIG_SPL_NAND_SIMPLE
-#define CONFIG_SPL_NAND_LOAD
 #define CONFIG_SYS_NAND_HW_ECC_OOBFIRST
 #define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_POST_MEM_SUPPORT
diff --git a/include/configs/hawkboard.h b/include/configs/hawkboard.h
index 838e572..5f2aa62 100644
--- a/include/configs/hawkboard.h
+++ b/include/configs/hawkboard.h
@@ -63,7 +63,6 @@
 #define CONFIG_SPL_BOARD_INIT
 #define CONFIG_SPL_NAND_SUPPORT
 #define CONFIG_SPL_NAND_SIMPLE
-#define CONFIG_SPL_NAND_LOAD
 #define CONFIG_SPL_LIBGENERIC_SUPPORT	/* for udelay and __div64_32 for NAND */
 #define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_LDSCRIPT		"board/$(BOARDDIR)/u-boot-spl-hawk.lds"
-- 
1.7.9.5



More information about the U-Boot mailing list