[PATCH v3 2/3] mtd: nand: add new parsing rule for Hynix's H27UBG8T2CTR

Huang Shijie b32955 at freescale.com
Fri Jan 3 03:08:37 EST 2014


The H27UBG8T2CTR is produced by the 20nm technology, and Hynix uses
different ID rules for it.

In order to parse out the correct information, we should check the
process technology and the Device ID, and then determine whether to
use a new parsing rule for this chip.

This patch adds the new parsing rule for the H27UBG8T2CTR.

Tested with H27UBG8T2CTR(8192 + 640).

Signed-off-by: Huang Shijie <b32955 at freescale.com>
---
 drivers/mtd/nand/nand_base.c |   90 +++++++++++++++++++++++++++++++-----------
 1 files changed, 67 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index d6b7dc3..2c2f7af 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3204,34 +3204,78 @@ static void nand_parse_hynix(struct mtd_info *mtd, struct nand_chip *chip,
 {
 	int extid = id_data[3];
 	unsigned int tmp;
+	bool new_rule;
 
+	/*
+	 * The ((id_data[5] & 0x7) < 4) means the nand uses >20nm technology;
+	 * The ((id_data[5] & 0x7) >= 4) means the nand uses <=20nm technology;
+	 *
+	 * Please reference to the H27UBG8T2B (p.23) and H27UBG8T2C (p.23).
+	 *
+	 * The new parsing rule is used in the H27UBG8T2C, we have to use the
+	 * process technology and the Device ID to distinguish this new rule.
+	 */
+	new_rule = ((id_data[5] & 0x7) >= 4) && (id_data[1] == 0xd7);
+
+	tmp = new_rule ? SZ_4K : SZ_2K;
 	/* 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 (!new_rule) {
+		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