Skip to contentSkip to conversation

add SPL ONENAND support.

PATCH New Enric Balletbo i Serra 2 participants 6 messages Feb 8, 2013 – Mar 11, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover add SPL ONENAND support.

From: Enric Balletbo i Serra <[email protected]>

Hi all,

This is the second version to add ONENAND support to the SPL.

Changes since v1:
* Replace ONE_NAND defines for ONENAND (Tom and Kyungmin)
* Remove unnused variables (Kyungmin)
* Split patch 2 in two, things related to SPL and things related to OMAP3 (Kyungmin)

Cheers,

Enric Balletbo i Serra (4):
SPL: ONENAND: Fix some ONENAND related defines.
SPL: ONENAND: Fix onenand_spl_load_image implementation.
SPL: ONENAND: Support SPL to boot u-boot from OneNAND.
OMAP3: Initialize gpmc if SPL_ONENAND_SUPPORT is enabled.

 arch/arm/cpu/arm1136/mx35/generic.c   |    2 +-
 arch/arm/cpu/armv7/omap3/board.c      |    2 +-
 arch/arm/include/asm/arch-mx35/spl.h  |    2 +-
 arch/arm/include/asm/arch-omap3/spl.h |    2 +-
 arch/arm/include/asm/arch-omap4/spl.h |    2 +-
 arch/arm/include/asm/arch-omap5/spl.h |    2 +-
 common/spl/Makefile                   |    1 +
 common/spl/spl.c                      |    5 ++++
 common/spl/spl_onenand.c              |   47 +++++++++++++++++++++++++++++++++
 drivers/mtd/onenand/onenand_spl.c     |   14 +++++-----
 10 files changed, 65 insertions(+), 14 deletions(-)
 create mode 100644 common/spl/spl_onenand.c
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/4 SPL: ONENAND: Fix some ONENAND related defines.

From: Enric Balletbo i Serra <[email protected]>

Some ONENAND related defines use the term ONE_NAND instead of ONENAND, as the technology name is ONENAND this patch replaces all these defines.

---
 arch/arm/cpu/arm1136/mx35/generic.c   |    2 +-
 arch/arm/include/asm/arch-mx35/spl.h  |    2 +-
 arch/arm/include/asm/arch-omap3/spl.h |    2 +-
 arch/arm/include/asm/arch-omap4/spl.h |    2 +-
 arch/arm/include/asm/arch-omap5/spl.h |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
arch/arm/cpu/arm1136/mx35/generic.c +1 -1
index d11e6f6..46f4b64 100644
@@ -519,7 +519,7 @@ u32 spl_boot_device(void)
 		case RCSR_MEM_TYPE_NOR:
 			return BOOT_DEVICE_NOR;
 		case RCSR_MEM_TYPE_ONENAND:
-			return BOOT_DEVICE_ONE_NAND;
+			return BOOT_DEVICE_ONENAND;
 		default:
 			return BOOT_DEVICE_NONE;
 		}
arch/arm/include/asm/arch-mx35/spl.h +1 -1
index 91d11ae..3ca4c94 100644
@@ -27,7 +27,7 @@
 #define BOOT_DEVICE_XIP		1
 #define BOOT_DEVICE_XIPWAIT	2
 #define BOOT_DEVICE_NAND	3
-#define BOOT_DEVICE_ONE_NAND	4
+#define BOOT_DEVICE_ONENAND	4
 #define BOOT_DEVICE_MMC1	5
 #define BOOT_DEVICE_MMC2	6
 #define BOOT_DEVICE_MMC2_2	7
arch/arm/include/asm/arch-omap3/spl.h +1 -1
index 404e16a..dec4dac 100644
@@ -26,7 +26,7 @@
 #define BOOT_DEVICE_NONE	0
 #define BOOT_DEVICE_XIP		1
 #define BOOT_DEVICE_NAND	2
-#define BOOT_DEVICE_ONE_NAND	3
+#define BOOT_DEVICE_ONENAND	3
 #define BOOT_DEVICE_MMC2	5 /*emmc*/
 #define BOOT_DEVICE_MMC1	6
 #define BOOT_DEVICE_XIPWAIT	7
arch/arm/include/asm/arch-omap4/spl.h +1 -1
index cec84dc..4e094f9 100644
@@ -27,7 +27,7 @@
 #define BOOT_DEVICE_XIP		1
 #define BOOT_DEVICE_XIPWAIT	2
 #define BOOT_DEVICE_NAND	3
-#define BOOT_DEVICE_ONE_NAND	4
+#define BOOT_DEVICE_ONENAND	4
 #define BOOT_DEVICE_MMC1	5
 #define BOOT_DEVICE_MMC2	6
 #define BOOT_DEVICE_MMC2_2	0xFF
arch/arm/include/asm/arch-omap5/spl.h +1 -1
index d125c61..323cd63 100644
@@ -27,7 +27,7 @@
 #define BOOT_DEVICE_XIP         1
 #define BOOT_DEVICE_XIPWAIT     2
 #define BOOT_DEVICE_NAND        3
-#define BOOT_DEVICE_ONE_NAND    4
+#define BOOT_DEVICE_ONENAND    4
 #define BOOT_DEVICE_MMC1        5
 #define BOOT_DEVICE_MMC2        6
 #define BOOT_DEVICE_MMC2_2	7
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v2 2/4 SPL: ONENAND: Fix onenand_spl_load_image implementation.

In reply to Enric Balletbo i Serra

From: Enric Balletbo i Serra <[email protected]>

Tested with an IGEPv2 board seems that current onenand_spl_load_image implementation doesn't work. This patch fixes this function changing the read loop and reading the onenand blocks from page to page.

Tested with various IGEP based boards with a OneNAND from Numonyx.

---
 drivers/mtd/onenand/onenand_spl.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/mtd/onenand/onenand_spl.c +6 -8
index 50eaa71..4bec2c2 100644
@@ -112,7 +112,7 @@ static int onenand_spl_read_page(uint32_t block, uint32_t page, uint32_t *buf,
 void onenand_spl_load_image(uint32_t offs, uint32_t size, void *dst)
 {
 	uint32_t *addr = (uint32_t *)dst;
-	uint32_t total_pages;
+	uint32_t to_page;
 	uint32_t block;
 	uint32_t page, rpage;
 	enum onenand_spl_pagesize pagesize;
@@ -125,22 +125,20 @@ void onenand_spl_load_image(uint32_t offs, uint32_t size, void *dst)
 	 * pulling further unwanted functions into the SPL.
 	 */
 	if (pagesize == 2048) {
-		total_pages = DIV_ROUND_UP(size, 2048);
 		page = offs / 2048;
+		to_page = page + DIV_ROUND_UP(size, 2048);
 	} else {
-		total_pages = DIV_ROUND_UP(size, 4096);
 		page = offs / 4096;
+		to_page = page + DIV_ROUND_UP(size, 4096);
 	}
 
-	for (; page <= total_pages; page++) {
+	for (; page <= to_page; page++) {
 		block = page / ONENAND_PAGES_PER_BLOCK;
 		rpage = page & (ONENAND_PAGES_PER_BLOCK - 1);
 		ret = onenand_spl_read_page(block, rpage, addr, pagesize);
-		if (ret) {
-			total_pages += ONENAND_PAGES_PER_BLOCK;
+		if (ret)
 			page += ONENAND_PAGES_PER_BLOCK - 1;
-		} else {
+		else
 			addr += pagesize / 4;
-		}
 	}
 }
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v2 3/4 SPL: ONENAND: Support SPL to boot u-boot from OneNAND.

In reply to Enric Balletbo i Serra

From: Enric Balletbo i Serra <[email protected]>

This patch will allow use SPL to boot an u-boot from the OneNAND.

Tested with IGEPv2 board with a OneNAND from Numonyx

---
 common/spl/Makefile      |    1 +
 common/spl/spl.c         |    5 +++++
 common/spl/spl_onenand.c |   47 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 common/spl/spl_onenand.c
common/spl/Makefile +1 -0
index 5698a23..da2afc1 100644
@@ -18,6 +18,7 @@ COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
 COBJS-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o
 COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o
 COBJS-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o
+COBJS-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o
 endif
 
common/spl/spl.c +5 -0
index ff9ba7b..293c7e1 100644
@@ -197,6 +197,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 		spl_nand_load_image();
 		break;
 #endif
+#ifdef CONFIG_SPL_ONENAND_SUPPORT
+	case BOOT_DEVICE_ONENAND:
+		spl_onenand_load_image();
+		break;
+#endif
 #ifdef CONFIG_SPL_NOR_SUPPORT
 	case BOOT_DEVICE_NOR:
 		spl_nor_load_image();
common/spl/spl_onenand.c new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#4 lore raw

PATCH v2 3/4 SPL: ONENAND: Support SPL to boot u-boot from OneNAND.

Quoted 86 lines · Enric Balletbo i Serra

From: Enric Balletbo i Serra <[email protected]>

This patch will allow use SPL to boot an u-boot from the OneNAND.

Tested with IGEPv2 board with a OneNAND from Numonyx

---
common/spl/Makefile | 1 +

 common/spl/spl.c         |    5 +++++
 common/spl/spl_onenand.c |   47 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 common/spl/spl_onenand.c
common/spl/Makefile +1 -0
index 5698a23..da2afc1 100644
@@ -18,6 +18,7 @@ COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
 COBJS-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o
 COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o
 COBJS-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o
+COBJS-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o
 endif
 
common/spl/spl.c +5 -0
index ff9ba7b..293c7e1 100644
@@ -197,6 +197,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 		spl_nand_load_image();
 		break;
 #endif
+#ifdef CONFIG_SPL_ONENAND_SUPPORT
+	case BOOT_DEVICE_ONENAND:
+		spl_onenand_load_image();
+		break;
+#endif
 #ifdef CONFIG_SPL_NOR_SUPPORT
 	case BOOT_DEVICE_NOR:
 		spl_nor_load_image();
common/spl/spl_onenand.c new file +37 -0
new file mode 100644
index 0000000..a839557
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2013
+ * ISEE 2007 SL - Enric Balletbo i Serra <[email protected]>
+ *
+ * Based on common/spl/spl_nand.c
+ * Copyright (C) 2011
+ * Corscience GmbH & Co. KG - Simon Schwarz <[email protected]>
+ *
+ * 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 <config.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <onenand_uboot.h>
+
+void spl_onenand_load_image(void)
+{
+	struct image_header *header;
+
+	debug("spl: onenand\n");

common/spl/spl_onenand.c line 47

Quoted 10 lines
common/spl/spl_onenand.c new file +10 -0
+
+	/*use CONFIG_SYS_TEXT_BASE as temporary storage area */
+	header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
+	/* Load u-boot */
+	onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
+		CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header);
+	spl_parse_image_header(header);
+	onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
+		spl_image.size, (void *)spl_image.load_addr);
+}

With the following change:

include/spl.h +3 -0
index b02f36f..b40be80 100644
@@ -59,6 +59,9 @@ void spl_display_print(void);
 /* NAND SPL functions */
 void spl_nand_load_image(void);
 
+/* OneNAND SPL functions */
+void spl_onenand_load_image(void);
+
 /* NOR SPL functions */
 void spl_nor_load_image(void);
 

To fix a warning, applied to u-boot-ti/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130311/124d2c2a/attachment.pgp>
#5 lore raw

PATCH v2 4/4 OMAP3: Initialize gpmc if SPL_ONENAND_SUPPORT is enabled.

In reply to Enric Balletbo i Serra

From: Enric Balletbo i Serra <[email protected]>

In order to use SPL boot from OneNAND we should initialize the gpmc.

---
 arch/arm/cpu/armv7/omap3/board.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/armv7/omap3/board.c +1 -1
index 89c587e..63063c8 100644
@@ -110,7 +110,7 @@ int board_mmc_init(bd_t *bis)
 
 void spl_board_init(void)
 {
-#ifdef CONFIG_SPL_NAND_SUPPORT
+#if defined(CONFIG_SPL_NAND_SUPPORT) || defined(CONFIG_SPL_ONENAND_SUPPORT)
 	gpmc_init();
 #endif
 #ifdef CONFIG_SPL_I2C_SUPPORT
Signature · 1 line
1.7.10.4