[U-Boot] [patch] dm355evm NAND support

David Brownell david-b at pacbell.net
Mon Oct 5 05:32:49 CEST 2009


This is the second half of my DM355 EVM support patches, adding
the NAND support now that the 4-bit ECC is merged:

 - Kick in NAND support, enabling
     * the DaVinci NAND driver
     * its 4-bit ECC support
     * MTD_DEVICE (newish, should be automatic!)
     * 64-bit printf (newish, should be automatic!)
     * saving the environment in one NAND block
 - Configure for the 2GB SLC flash normally shipped with the EVM
     * move all sizing info to the end
     * LARGEPAGE option is gone
     * use first block for environment (it's otherwise unused)
     * ... if small page NAND is used, use 1 MByte bootloader area
 - Enable default 5 second bootdelay

And a build fix:  set_bit()/clear_bit() param types changed.

Supporting 2GB MLC chips would need (a) 256K blocks (b) bigger
malloc heap and (c) 4K pages ... with that last requiring NAND
core changes, to support 80 bytes of ECC data.

Signed-off-by: David Brownell <dbrownell at users.sourceforge.net>
---
DIFFERS FROM SANDEEP'S PATCH:  (a) 64-bit VSPRINTf, (b) no MLC hooks,
(c) environment in block 0, which would otherwise be wasted, (d) no
dependency on dubious "remove SZ_* symbols" patches, (e) buildfix

 board/davinci/dm355evm/dm355evm.c  |    4 +--
 include/configs/davinci_dm355evm.h |   37 +++++++++++++++++++++--------------
 2 files changed, 25 insertions(+), 16 deletions(-)

--- a/board/davinci/dm355evm/dm355evm.c
+++ b/board/davinci/dm355evm/dm355evm.c
@@ -92,8 +92,8 @@ int board_eth_init(bd_t *bis)
 static void nand_dm355evm_select_chip(struct mtd_info *mtd, int chip)
 {
 	struct nand_chip	*this = mtd->priv;
-	u32			wbase = (u32) this->IO_ADDR_W;
-	u32			rbase = (u32) this->IO_ADDR_R;
+	unsigned long		wbase = (unsigned long) this->IO_ADDR_W;
+	unsigned long		rbase = (unsigned long) this->IO_ADDR_R;
 
 	if (chip == 1) {
 		__set_bit(14, &wbase);
--- a/include/configs/davinci_dm355evm.h
+++ b/include/configs/davinci_dm355evm.h
@@ -29,6 +29,7 @@
 #define CONFIG_SYS_NO_FLASH		/* that is, no *NOR* flash */
 #define CONFIG_SYS_CONSOLE_INFO_QUIET
 #define CONFIG_DISPLAY_CPUINFO
+#define CONFIG_SYS_64BIT_VSPRINTF	/* needed for nand_util.c */
 
 /* SoC Configuration */
 #define CONFIG_ARM926EJS				/* arm926ejs CPU */
@@ -66,11 +67,10 @@
 #define CONFIG_SYS_I2C_SLAVE		0x10	/* SMBus host address */
 
 /* NAND: socketed, two chipselects, normally 2 GBytes */
-/* NYET -- #define CONFIG_NAND_DAVINCI */
-#define CONFIG_SYS_NAND_HW_ECC
+#define CONFIG_NAND_DAVINCI
+#define CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST
 #define CONFIG_SYS_NAND_USE_FLASH_BBT
 
-#define CONFIG_SYS_NAND_LARGEPAGE
 #define CONFIG_SYS_NAND_BASE_LIST	{ 0x02000000, }
 /* socket has two chipselects, nCE0 gated by address BIT(14) */
 #define CONFIG_SYS_MAX_NAND_DEVICE	1
@@ -95,16 +95,14 @@
 
 #ifdef CONFIG_NAND_DAVINCI
 #define CONFIG_CMD_MTDPARTS
+#define CONFIG_MTD_DEVICE
 #define CONFIG_MTD_PARTITIONS
 #define CONFIG_CMD_NAND
 #define CONFIG_CMD_UBI
 #define CONFIG_RBTREE
+#define CONFIG_ENV_IS_IN_NAND
 #endif
 
-/* TEMPORARY -- no safe place to save env, yet */
-#define CONFIG_ENV_IS_NOWHERE
-#undef CONFIG_CMD_SAVEENV
-
 #ifdef CONFIG_USB_DAVINCI
 #define CONFIG_MUSB_HCD
 #define CONFIG_CMD_USB
@@ -130,9 +128,7 @@
 #define CONFIG_SYS_PROMPT_HUSH_PS2	"> "
 #define CONFIG_SYS_LONGHELP
 
-#define CONFIG_ENV_SIZE		SZ_16K
-
-/* NYET -- #define CONFIG_BOOTDELAY	5 */
+#define CONFIG_BOOTDELAY	5
 #define CONFIG_BOOTCOMMAND \
 		"dhcp;bootm"
 #define CONFIG_BOOTARGS \
@@ -174,14 +170,27 @@
  */
 #define MTDIDS_DEFAULT		"nand0=davinci_nand.0"
 
-#ifdef CONFIG_SYS_NAND_LARGEPAGE
-/*  Use same layout for 128K/256K blocks; allow some bad blocks */
+/* default: 2GByte SLC; large page (2KB), 128KB blocks */
+#define CONFIG_SYS_NAND_BLOCKSIZE	(128 * 1024)
+#define CONFIG_SYS_NAND_PAGE_2K
+#define NAND_LARGE_PAGE
+
+/* No support _yet_ for OOB layouts needed by U-Boot + 4-bit ECC with:
+ * (a) 512 byte small page chips ... driver just needs new oob struct
+ * (b) 4K large page chips, MLC ... NAND core can't handle 80 bytes ECC
+ */
+
+#ifdef NAND_LARGE_PAGE
+/* Use same layout for 128K/256K blocks; allow for some bad blocks */
 #define PART_BOOT		"2m(bootloader)ro,"
-#else
+#else /* small page */
 /* Assume 16K erase blocks; allow a few bad ones. */
-#define PART_BOOT		"512k(bootloader)ro,"
+#define PART_BOOT		"1m(bootloader)ro,"
 #endif
 
+#define CONFIG_ENV_OFFSET	0		/* block 0 not used by UBL */
+#define CONFIG_ENV_SIZE		(16 * 1024)
+
 #define PART_KERNEL		"4m(kernel),"	/* kernel + initramfs */
 #define PART_REST		"-(filesystem)"
 


More information about the U-Boot mailing list