Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modifie the 4052-NAND-add-easybox904-bbt.patch and add "customized-sa… #26

Open
wants to merge 1 commit into
base: master-lede
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
lantiq,cs = <1>; // Seems to be needed (EASY80920NAND.dts)

nand-on-flash-bbt;
customized-samsung-K9F4G08U0x;

partitions {
compatible = "fixed-partitions";
Expand Down
109 changes: 86 additions & 23 deletions target/linux/lantiq/patches-4.14/4052-NAND-add-easybox904-bbt.patch
Original file line number Diff line number Diff line change
@@ -1,68 +1,131 @@
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -76,6 +76,13 @@
diff -aurN a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
--- a/drivers/mtd/nand/nand_bbt.c 2019-02-26 10:04:39.551525839 +0000
+++ b/drivers/mtd/nand/nand_bbt.c 2019-02-26 10:04:39.697524014 +0000
@@ -76,6 +76,32 @@
#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
+#if CUSTOMIZED_BBT
+ #define BAD_BLK_OOB_MARK_START 4
+ #define BAD_BLK_OOB_MARK_END 5
+ #define BAD_BLK_OOB_MARK_PATT 0xFF
+
+
+#include <linux/mtd/rawnand.h>
+#include <linux/of.h>
+
+static bool of_get_customized_bbt_from_mtd(struct mtd_info *mtd)
+{
+ struct nand_chip *chip = mtd_to_nand(mtd);
+ struct device_node *dn = nand_get_flash_node(chip);
+ return of_property_read_bool(dn, "customized-samsung-K9F4G08U0x");
+}
+
+static bool of_get_customized_bbt_from_chip(struct nand_chip *chip)
+{
+ struct device_node *dn = nand_get_flash_node(chip);
+ return of_property_read_bool(dn, "customized-samsung-K9F4G08U0x");
+}
+
+#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
@@ -109,8 +135,15 @@
* Check for a pattern at the given place. Used to search bad block tables and
* good / bad block identifiers.
*/
static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td)
{
+#if CUSTOMIZED_BBT /*ctc*/
+#if CUSTOMIZED_BBT
+static int check_pattern(struct mtd_info *mtd, uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td)
+{
+ int i;
+ uint8_t *p = buf;
+#else
static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td)
{
+#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, i
@@ -118,6 +151,15 @@
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;
+ if (of_get_customized_bbt_from_mtd(mtd)) {
+ 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_in
@@ -561,7 +603,11 @@

/* Read first page */
scan_read(mtd, buf, offs, mtd->writesize, td);
+#if CUSTOMIZED_BBT
+ if (!check_pattern(mtd, buf, scanlen, mtd->writesize, td)) {
+#else
if (!check_pattern(buf, scanlen, mtd->writesize, td)) {
+#endif
td->pages[i] = actblock << blocktopage;
if (td->options & NAND_BBT_VERSION) {
offs = bbt_get_ver_offs(mtd, td);
@@ -1277,8 +1323,13 @@
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
+//#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
+//#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(
@@ -1340,7 +1391,16 @@
bd = kzalloc(sizeof(*bd), GFP_KERNEL);
if (!bd)
return -ENOMEM;
+
+#if CUSTOMIZED_BBT /*ctc*/
+ bd->options = 0 & BADBLOCK_SCAN_MASK;
+ if (of_get_customized_bbt_from_chip(this)) {
+ bd->options = 0 & BADBLOCK_SCAN_MASK;
+ } else {
+ bd->options = this->bbt_options & 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;
@@ -1360,6 +1420,19 @@
{
struct nand_chip *this = mtd_to_nand(mtd);
int ret;
+/* change the generic bad / good block scan pattern if of_get_customized_bbt_from_chip(this) true */
+#if CUSTOMIZED_BBT
+ if(of_get_customized_bbt_from_chip(this)) {
+ bbt_pattern[0] = 'A';
+ bbt_pattern[1] = 'R';
+ bbt_pattern[2] = 'C';
+ bbt_pattern[3] = 'A';
+ mirror_pattern[0] = 'a';
+ mirror_pattern[1] = 'c';
+ mirror_pattern[2] = 'r';
+ mirror_pattern[3] = 'a';
+ }
+#endif

/* Is a flash based bad block table requested? */
if (this->bbt_options & NAND_BBT_USE_FLASH) {