[U-Boot] [PATCH] mtd: nand: allow to skip BBT scanning during NAND inititialization

Masahiro Yamada yamada.m at jp.panasonic.com
Thu Oct 23 09:22:12 CEST 2014


Since commit ff94bc40af34 (mtd, ubi, ubifs: resync with Linux-3.14),
chip->scan_bbt() is called at the end of nand_scan_tail().
It means the first read access happens immediately after the generic
NAND initialization process.

It causes a problem to some SoCs of UniPhier platform because some of
their register values need to be fixed up after the general
initialization procedure has been finished.  Otherwise, read asccess
fails.  Such a fix-up is SoC-specific enough to be written in a board
file rather than in driver code.

One of possible and clean enough ways to work around this issue is
postpone the BBT scanning until necessary fix-up is done in
board_late_init() or somewhere else.

CONFIG_MTD_NAND_SKIP_BBTSCAN, if enabled, allows to skip the BBT
scanning at the end of nand_scan_tail().

Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
Cc: Scott Wood <scottwood at freescale.com>
---

If this patch is accepted, I will turn on this config option
for my boards.


 drivers/mtd/nand/Kconfig | 13 +++++++++++++
 drivers/mtd/nand/nand.c  |  4 ++++
 2 files changed, 17 insertions(+)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 75c2c06..e9d133d 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -2,6 +2,19 @@ menu "NAND Device Support"
 
 if !SPL_BUILD
 
+MTD_NAND_SKIP_BBTSCAN
+	bool "Skip BBT scanning"
+	help
+	  The current implementation of nand_scan_tail() calls scan_bbt handler
+	  at the end of itself to build a bad block table.  It means the first
+	  read access happens in the initizalization procedure.  It causes a
+	  problem on some SoCs that need some extra SoC-specific settings
+	  before starting read/write access.
+
+	  If this option is enabled, bad block scanning is skipped during the
+	  nand device initialization.  You are resposible to build a bad block
+	  table lator.
+
 config NAND_DENALI
 	bool "Support Denali NAND controller"
 	help
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
index 4cf4c1c..a249647 100644
--- a/drivers/mtd/nand/nand.c
+++ b/drivers/mtd/nand/nand.c
@@ -88,6 +88,10 @@ static void nand_init_chip(int i)
 	mtd->priv = nand;
 	nand->IO_ADDR_R = nand->IO_ADDR_W = (void  __iomem *)base_addr;
 
+#ifdef CONFIG_MTD_NAND_SKIP_BBTSCAN
+	nand->options |= NAND_SKIP_BBTSCAN;
+#endif
+
 	if (board_nand_init(nand))
 		return;
 
-- 
1.9.1



More information about the U-Boot mailing list