[PATCH v2 2/2 fix] mtd: nand: parse the Hynix nand which uses <26nm technology

Huang Shijie b32955 at freescale.com
Wed Dec 25 03:05:00 EST 2013


The Hynix uses different ID parsing rules for <26nm technology.
We should check the id_data[5] for Hynix nand now.

This patch adds the parsing code for the Hynix nand which use <26nm technology.

Tested with H27UBG8T2CTR(8192 + 640).

Signed-off-by: Huang Shijie <b32955 at freescale.com>
---
mask the technology field 
---
 drivers/mtd/nand/nand_base.c |   87 +++++++++++++++++++++++++++++++-----------
 1 files changed, 64 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 79f0050..ce4dec7 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3110,34 +3110,75 @@ static void nand_parse_hynix(struct mtd_info *mtd, struct nand_chip *chip,
 {
 	int extid = id_data[3];
 	unsigned int tmp;
+	int tech;
 
+	/*
+	 * The ((id_data[5] & 0x7) <= 3) means the nand uses >=26nm technology;
+	 * The ((id_data[5] & 0x7) > 3) means the nand uses <26nm technology;
+	 *
+	 * Please reference to the H27UBG8T2B (p.23) and H27UBG8T2C (p.23).
+	 */
+	tech = id_data[5] & 0x7;
+
+	tmp = (tech <= 3) ? SZ_2K : SZ_4K;
 	/* Calc pagesize */
-	mtd->writesize = 2048 << (extid & 0x03);
+	mtd->writesize = tmp << (extid & 0x03);
 	extid >>= 2;
 
 	/* Calc oobsize */
-	switch (((extid >> 2) & 0x04) | (extid & 0x03)) {
-	case 0:
-		mtd->oobsize = 128;
-		break;
-	case 1:
-		mtd->oobsize = 224;
-		break;
-	case 2:
-		mtd->oobsize = 448;
-		break;
-	case 3:
-		mtd->oobsize = 64;
-		break;
-	case 4:
-		mtd->oobsize = 32;
-		break;
-	case 5:
-		mtd->oobsize = 16;
-		break;
-	default:
-		mtd->oobsize = 640;
-		break;
+	tmp = ((extid >> 2) & 0x04) | (extid & 0x03);
+
+	if (tech <= 3) {
+		switch (tmp) {
+		case 0:
+			mtd->oobsize = 128;
+			break;
+		case 1:
+			mtd->oobsize = 224;
+			break;
+		case 2:
+			mtd->oobsize = 448;
+			break;
+		case 3:
+			mtd->oobsize = 64;
+			break;
+		case 4:
+			mtd->oobsize = 32;
+			break;
+		case 5:
+			mtd->oobsize = 16;
+			break;
+		default:
+			mtd->oobsize = 640;
+			break;
+		}
+	} else {
+		switch (tmp) {
+		case 0:
+			mtd->oobsize = 640;
+			break;
+		case 1:
+			mtd->oobsize = 448;
+			break;
+		case 2:
+			mtd->oobsize = 224;
+			break;
+		case 3:
+			mtd->oobsize = 128;
+			break;
+		case 4:
+			mtd->oobsize = 64;
+			break;
+		case 5:
+			mtd->oobsize = 32;
+			break;
+		case 6:
+			mtd->oobsize = 16;
+			break;
+		default:
+			mtd->oobsize = 640;
+			break;
+		}
 	}
 	extid >>= 2;
 
-- 
1.7.2.rc3





More information about the linux-mtd mailing list