[U-Boot] [PATCH 2/4] mtd/nand: Fixup for support ONFI detect

Shengzhou Liu Shengzhou.Liu at freescale.com
Fri Dec 2 10:17:15 CET 2011


There was a bug logically in the order of nand_flash_detect_onfi
and checking nand_flash_ids. We should get NAND devices related
informations first by ONFI method instead of querying nand_flash_ids table,
if ONFI fails, then query nand_flash_ids table.

Signed-off-by: Shengzhou Liu <Shengzhou.Liu at freescale.com>
---
 drivers/mtd/nand/nand_base.c |   48 +++++++++++++++++++++--------------------
 1 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 6aac6a2..8d03f54 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2585,36 +2585,38 @@ static const struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
 		return ERR_PTR(-ENODEV);
 	}
 
-	if (!type)
-		type = nand_flash_ids;
+	ret = nand_flash_detect_onfi(mtd, chip, &busw);
+	if (!ret) {
+		if (!type)
+			type = nand_flash_ids;
 
-	for (; type->name != NULL; type++)
-		if (*dev_id == type->id)
-			break;
+		for (; type->name != NULL; type++)
+			if (*dev_id == type->id)
+				break;
 
-	if (!type->name) {
-		/* supress warning if there is no nand */
-		if (*maf_id != 0x00 && *maf_id != 0xff &&
-		    *dev_id  != 0x00 && *dev_id  != 0xff)
-			printk(KERN_INFO "%s: unknown NAND device: "
-				"Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n",
-				__func__, *maf_id, *dev_id);
-		return ERR_PTR(-ENODEV);
-	}
+		if (!type->name) {
+			/* supress warning if there is no nand */
+			if (*maf_id != 0x00 && *maf_id != 0xff &&
+			    *dev_id  != 0x00 && *dev_id  != 0xff) {
+				printk(KERN_INFO "%s: unknown NAND device: "
+				  "Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n",
+				  __func__, *maf_id, *dev_id);
+			}
+			return ERR_PTR(-ENODEV);
+		}
 
-	if (!mtd->name)
-		mtd->name = type->name;
+		if (!mtd->name)
+			mtd->name = type->name;
 
-	chip->chipsize = (uint64_t)type->chipsize << 20;
-	chip->onfi_version = 0;
+		chip->chipsize = (uint64_t)type->chipsize << 20;
+		chip->onfi_version = 0;
 
-	ret = nand_flash_detect_onfi(mtd, chip, &busw);
-	if (!ret)
 		nand_flash_detect_non_onfi(mtd, chip, type, &busw);
 
-	/* Get chip options, preserve non chip based options */
-	chip->options &= ~NAND_CHIPOPTIONS_MSK;
-	chip->options |= type->options & NAND_CHIPOPTIONS_MSK;
+		/* Get chip options, preserve non chip based options */
+		chip->options &= ~NAND_CHIPOPTIONS_MSK;
+		chip->options |= type->options & NAND_CHIPOPTIONS_MSK;
+	}
 
 	/*
 	 * Set chip as a default. Board drivers can override it, if necessary
-- 
1.6.4




More information about the U-Boot mailing list