mtd: rawnand: Add a NAND_NO_BBM_QUIRK flag
authorBoris Brezillon <boris.brezillon@collabora.com>
Mon, 11 May 2020 06:49:15 +0000 (08:49 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 11 May 2020 07:51:43 +0000 (09:51 +0200)
Some controllers with embedded ECC engines override the BBM marker with
data or ECC bytes, thus making bad block detection through bad block
marker impossible. Let's flag those chips so the core knows it shouldn't
check the BBM and consider all blocks good.

This should allow us to get rid of two implementers of the
legacy.block_bad() hook.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200511064917.6255-1-boris.brezillon@collabora.com
drivers/mtd/nand/raw/nand_base.c
include/linux/mtd/rawnand.h

index ba37ca9c12600fc15713087c54fca415d94f8e28..2d2a216af120fdee7eac25d252100806026336dd 100644 (file)
@@ -395,6 +395,9 @@ static int nand_block_bad(struct nand_chip *chip, loff_t ofs)
 
 static int nand_isbad_bbm(struct nand_chip *chip, loff_t ofs)
 {
+       if (chip->options & NAND_NO_BBM_QUIRK)
+               return 0;
+
        if (chip->legacy.block_bad)
                return chip->legacy.block_bad(chip, ofs);
 
index 406e9ff0f45cef019d183a211e89ed354aba5e58..0f45b6984ad1974a368fd2a3c8ae817638661a4c 100644 (file)
@@ -221,6 +221,14 @@ enum nand_ecc_algo {
 #define NAND_BBM_SECONDPAGE    BIT(25)
 #define NAND_BBM_LASTPAGE      BIT(26)
 
+/*
+ * Some controllers with pipelined ECC engines override the BBM marker with
+ * data or ECC bytes, thus making bad block detection through bad block marker
+ * impossible. Let's flag those chips so the core knows it shouldn't check the
+ * BBM and consider all blocks good.
+ */
+#define NAND_NO_BBM_QUIRK      BIT(27)
+
 /* Cell info constants */
 #define NAND_CI_CHIPNR_MSK     0x03
 #define NAND_CI_CELLTYPE_MSK   0x0C