[U-Boot] [PATCH V2 2/6] nand: Add SPL_NAND support to mxc_nand_spl

Marek Vasut marex at denx.de
Sun Apr 21 17:52:23 CEST 2013


Add support for generic NAND SPL via the SPL framework into the
mxc_nand_spl driver. This is basically just a simple rename and
publication of the already implemented functions. To avoid the
bare-bones functions getting in the way of the NAND_SPL, build
them only if CONFIG_SPL_FRAMEWORK is not defined.

Also make sure the requested payload is aligned to full pages,
otherwise this simple driver fails to load the last page.

Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Albert ARIBAUD <albert.u.boot at aribaud.net>
Cc: Benoît Thébaudeau <benoit.thebaudeau at advansee.com>
Cc: Fabio Estevam <fabio.estevam at freescale.com>
Cc: Scott Wood <scottwood at freescale.com>
Cc: Stefano Babic <sbabic at denx.de>
Cc: Tom Rini <trini at ti.com>
---
 drivers/mtd/nand/mxc_nand_spl.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

V2: Check CONFIG_SPL_FRAMEWORK instead to test if we're building
    with NAND_SPL or really bare-bones SPL.

diff --git a/drivers/mtd/nand/mxc_nand_spl.c b/drivers/mtd/nand/mxc_nand_spl.c
index 09f23c3..5608352 100644
--- a/drivers/mtd/nand/mxc_nand_spl.c
+++ b/drivers/mtd/nand/mxc_nand_spl.c
@@ -290,7 +290,7 @@ static int is_badblock(int pagenumber)
 	return 0;
 }
 
-static int nand_load(unsigned int from, unsigned int size, unsigned char *buf)
+int nand_spl_load_image(uint32_t from, unsigned int size, void *buf)
 {
 	int i;
 	unsigned int page;
@@ -303,6 +303,7 @@ static int nand_load(unsigned int from, unsigned int size, unsigned char *buf)
 	page = from / CONFIG_SYS_NAND_PAGE_SIZE;
 	i = 0;
 
+	size = roundup(size, CONFIG_SYS_NAND_PAGE_SIZE);
 	while (i < size / CONFIG_SYS_NAND_PAGE_SIZE) {
 		if (nfc_read_page(page, buf) < 0)
 			return -1;
@@ -332,6 +333,7 @@ static int nand_load(unsigned int from, unsigned int size, unsigned char *buf)
 	return 0;
 }
 
+#ifndef CONFIG_SPL_FRAMEWORK
 /*
  * 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
@@ -345,8 +347,9 @@ void nand_boot(void)
 	 * CONFIG_SYS_NAND_U_BOOT_OFFS and CONFIG_SYS_NAND_U_BOOT_SIZE must
 	 * be aligned to full pages
 	 */
-	if (!nand_load(CONFIG_SYS_NAND_U_BOOT_OFFS, CONFIG_SYS_NAND_U_BOOT_SIZE,
-		       (uchar *)CONFIG_SYS_NAND_U_BOOT_DST)) {
+	if (!nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
+			CONFIG_SYS_NAND_U_BOOT_SIZE,
+			(uchar *)CONFIG_SYS_NAND_U_BOOT_DST)) {
 		/* Copy from NAND successful, start U-boot */
 		uboot = (void *)CONFIG_SYS_NAND_U_BOOT_START;
 		uboot();
@@ -364,3 +367,7 @@ void hang(void)
 	/* Loop forever */
 	while (1) ;
 }
+#endif
+
+void nand_init(void) {}
+void nand_deselect(void) {}
-- 
1.7.10.4



More information about the U-Boot mailing list