Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VGV952CJW33: Add bad block table implementation.
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
1 parent
7fb4519
commit b2159b8
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
target/linux/lantiq/patches-4.9/4052-NAND-add-easybox904-bbt.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |