Skip to contentSkip to conversation

Detect the MLC OneNAND from Technology Register (0xF006h)

PATCH New Kyungmin Park 1 participant 1 message Dec 11, 2007 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Detect the MLC OneNAND from Technology Register (0xF006h)

Set correct values if the detected chip is MLC

---
 drivers/mtd/onenand/onenand_base.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/mtd/onenand/onenand_base.c +8 -1
index 18c79ee..bfc8399 100644
@@ -2571,8 +2571,8 @@ static void onenand_resume(struct mtd_info *mtd)
  */
 int onenand_scan(struct mtd_info *mtd, int maxchips)
 {
-	int i;
 	struct onenand_chip *this = mtd->priv;
+	int i, MLC;
 
 	if (!this->read_word)
 		this->read_word = onenand_readw;
@@ -2628,6 +2628,7 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
 	this->state = FL_READY;
 	init_waitqueue_head(&this->wq);
 	spin_lock_init(&this->chip_lock);
+	MLC = this->read_word(this->base + ONENAND_REG_TECHNOLOGY);
 
 	/*
 	 * Allow subpage writes up to oobsize.
@@ -2652,6 +2653,10 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
 		break;
 	}
 
+	/* Don't allow the sub-page write in MLC */
+	if (MLC)
+		mtd->subpage_sft = 0;
+
 	this->subpagesize = mtd->writesize >> mtd->subpage_sft;
 
 	/*
@@ -2670,6 +2675,8 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
 	/* Fill in remaining MTD driver data */
 	mtd->type = MTD_NANDFLASH;
 	mtd->flags = MTD_CAP_NANDFLASH;
+	if (MLC)
+		mtd->flags &= ~MTD_OOB_WRITEABLE;
 	mtd->erase = onenand_erase;
 	mtd->point = NULL;
 	mtd->unpoint = NULL;
Signature · 1 line
1.5.0.6