[MTD] [NAND] fsl_elbc_nand: implement support for flash-based BBT

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Jul 11 13:59:01 EDT 2008


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=ec6e0ea3bdf82ee9761d324c011c3627821f7410
Commit:     ec6e0ea3bdf82ee9761d324c011c3627821f7410
Parent:     452db2724351ff3d9416a183a7955e00ab4e6ab4
Author:     Anton Vorontsov <avorontsov at ru.mvista.com>
AuthorDate: Fri Jun 27 23:04:13 2008 +0400
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Jul 11 18:16:16 2008 +0100

    [MTD] [NAND] fsl_elbc_nand: implement support for flash-based BBT
    
    This patch implements support for flash-based BBT for chips working
    through ELBC NAND controller, so that NAND core will not have to re-scan
    for bad blocks on every boot.
    
    Because ELBC controller may provide HW-generated ECCs we should adjust
    bbt pattern and bbt version positions in the OOB free area.
    
    Signed-off-by: Anton Vorontsov <avorontsov at ru.mvista.com>
    Acked-by: Scott Wood <scottwood at freescale.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/nand/fsl_elbc_nand.c |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 99dc2be..5f1bc5e 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -130,6 +130,34 @@ static struct nand_bbt_descr largepage_memorybased = {
 	.pattern = scan_ff_pattern,
 };
 
+/*
+ * ELBC may use HW ECC, so that OOB offsets, that NAND core uses for bbt,
+ * interfere with ECC positions, that's why we implement our own descriptors.
+ * OOB {11, 5}, works for both SP and LP chips, with ECCM = 1 and ECCM = 0.
+ */
+static u8 bbt_pattern[] = {'B', 'b', 't', '0' };
+static u8 mirror_pattern[] = {'1', 't', 'b', 'B' };
+
+static struct nand_bbt_descr bbt_main_descr = {
+	.options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
+		   NAND_BBT_2BIT | NAND_BBT_VERSION,
+	.offs =	11,
+	.len = 4,
+	.veroffs = 15,
+	.maxblocks = 4,
+	.pattern = bbt_pattern,
+};
+
+static struct nand_bbt_descr bbt_mirror_descr = {
+	.options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
+		   NAND_BBT_2BIT | NAND_BBT_VERSION,
+	.offs =	11,
+	.len = 4,
+	.veroffs = 15,
+	.maxblocks = 4,
+	.pattern = mirror_pattern,
+};
+
 /*=================================*/
 
 /*
@@ -767,8 +795,12 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
 	chip->cmdfunc = fsl_elbc_cmdfunc;
 	chip->waitfunc = fsl_elbc_wait;
 
+	chip->bbt_td = &bbt_main_descr;
+	chip->bbt_md = &bbt_mirror_descr;
+
 	/* set up nand options */
-	chip->options = NAND_NO_READRDY | NAND_NO_AUTOINCR;
+	chip->options = NAND_NO_READRDY | NAND_NO_AUTOINCR |
+			NAND_USE_FLASH_BBT;
 
 	chip->controller = &ctrl->controller;
 	chip->priv = priv;



More information about the linux-mtd-cvs mailing list