Skip to content

Commit

Permalink
VGV952CJW33: Add bad block table implementation.
Browse files Browse the repository at this point in the history
This is based of the vendor implementation which uses
a proprietary bad block signature

bbt_pattern[] = {'A', 'R', 'C', 'A' };
mirror_pattern[] = {'a', 'c', 'r', 'a' };

instead of the upstream one:

bbt_pattern[] = {'B', 'b', 't', '0' }
mirror_pattern[] = {'1', 't', 'b', 'B' }
  • Loading branch information
Quallenauge committed Oct 30, 2017
1 parent 7fb4519 commit b2159b8
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
4 changes: 4 additions & 0 deletions target/linux/lantiq/dts/VGV952CJW33.dts
Expand Up @@ -172,6 +172,10 @@
#size-cells = <1>;
lantiq,cs = <1>; // Seems to be needed (EASY80920NAND.dts)

nand-on-flash-bbt;
nand-ecc-strength = <3>;
nand-ecc-step-size = <256>;

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
Expand Down
70 changes: 70 additions & 0 deletions target/linux/lantiq/patches-4.9/4052-NAND-add-easybox904-bbt.patch
@@ -0,0 +1,70 @@
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 7695efe..6dd80a9 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -76,6 +76,13 @@
#define BBT_ENTRY_MASK 0x03
#define BBT_ENTRY_SHIFT 2

+#define CUSTOMIZED_BBT 1
+#if CUSTOMIZED_BBT /*ctc*/
+ #define BAD_BLK_OOB_MARK_START 4
+ #define BAD_BLK_OOB_MARK_END 5
+ #define BAD_BLK_OOB_MARK_PATT 0xFF
+#endif
+
static int nand_update_bbt(struct mtd_info *mtd, loff_t offs);

static inline uint8_t bbt_get_entry(struct nand_chip *chip, int block)
@@ -111,6 +118,10 @@ static int check_pattern_no_oob(uint8_t *buf, struct nand_bbt_descr *td)
*/
static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td)
{
+#if CUSTOMIZED_BBT /*ctc*/
+ int i;
+ uint8_t *p = buf;
+#endif
if (td->options & NAND_BBT_NO_OOB)
return check_pattern_no_oob(buf, td);

@@ -118,6 +129,13 @@ static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_desc
if (memcmp(buf + paglen + td->offs, td->pattern, td->len))
return -1;

+#if CUSTOMIZED_BBT /*ctc*/
+ for (i = BAD_BLK_OOB_MARK_START, p=buf+paglen; i <= BAD_BLK_OOB_MARK_END; i++) {
+ if (p[i] != BAD_BLK_OOB_MARK_PATT)
+ return -1;
+ }
+#endif
+
return 0;
}

@@ -1277,8 +1295,13 @@ static int nand_update_bbt(struct mtd_info *mtd, loff_t offs)
static uint8_t scan_ff_pattern[] = { 0xff, 0xff };

/* Generic flash bbt descriptors */
+#if CUSTOMIZED_BBT /*ctc*/
+static uint8_t bbt_pattern[] = {'A', 'R', 'C', 'A' };
+static uint8_t mirror_pattern[] = {'a', 'c', 'r', 'a' };
+#else
static uint8_t bbt_pattern[] = {'B', 'b', 't', '0' };
static uint8_t mirror_pattern[] = {'1', 't', 'b', 'B' };
+#endif

static struct nand_bbt_descr bbt_main_descr = {
.options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
@@ -1340,7 +1363,12 @@ static int nand_create_badblock_pattern(struct nand_chip *this)
bd = kzalloc(sizeof(*bd), GFP_KERNEL);
if (!bd)
return -ENOMEM;
+
+#if CUSTOMIZED_BBT /*ctc*/
+ bd->options = 0 & BADBLOCK_SCAN_MASK;
+#else
bd->options = this->bbt_options & BADBLOCK_SCAN_MASK;
+#endif
bd->offs = this->badblockpos;
bd->len = (this->options & NAND_BUSWIDTH_16) ? 2 : 1;
bd->pattern = scan_ff_pattern;

0 comments on commit b2159b8

Please sign in to comment.