From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ch1ehsobe006.messaging.microsoft.com ([216.32.181.186] helo=ch1outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UDYQ0-0008Mo-25 for linux-mtd@lists.infradead.org; Thu, 07 Mar 2013 10:51:25 +0000 From: Huang Shijie To: Subject: [PATCH V4 3/3] mtd: add the support to parse out the full-id nand type Date: Thu, 7 Mar 2013 18:49:24 +0800 Message-ID: <1362653364-29993-4-git-send-email-b32955@freescale.com> In-Reply-To: <1362653364-29993-1-git-send-email-b32955@freescale.com> References: <1362653364-29993-1-git-send-email-b32955@freescale.com> MIME-Version: 1.0 Content-Type: text/plain Cc: artem.bityutskiy@linux.intel.com, computersforpeace@gmail.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Huang Shijie List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , When we meet a full-id nand type which @mfr_id is true, we can use the find_full_id_nand() to parse out the neccessary information for a nand chip. If we meet a non full-id nand type, we can handle it in the lagacy way. Signed-off-by: Huang Shijie --- drivers/mtd/nand/nand_base.c | 36 +++++++++++++++++++++++++++++++++--- 1 files changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 29c0378..b9a24ff 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -3074,6 +3074,30 @@ static void nand_decode_bbm_options(struct mtd_info *mtd, chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; } +static inline bool is_full_id_nand(struct nand_flash_dev *type) +{ + return type->mfr_id; +} + +static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, + struct nand_flash_dev *type, u8 *id_data, int *busw) +{ + if (!strncmp(type->id, id_data, type->id_len)) { + mtd->writesize = type->pagesize; + mtd->erasesize = type->erasesize; + mtd->oobsize = type->oobsize; + + chip->cellinfo = id_data[2]; + chip->chipsize = (uint64_t)type->chipsize << 20; + chip->options |= type->options; + + *busw = type->options & NAND_BUSWIDTH_16; + + return true; + } + return false; +} + /* * Get the flash and manufacturer id and lookup if the type is supported. */ @@ -3125,9 +3149,15 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, if (!type) type = nand_flash_ids; - for (; type->name != NULL; type++) - if (*dev_id == type->dev_id) - break; + for (; type->name != NULL; type++) { + if (is_full_id_nand(type)) { + if (find_full_id_nand(mtd, chip, type, id_data, &busw)) + goto ident_done; + } else { + if (*dev_id == type->dev_id) + break; + } + } chip->onfi_version = 0; if (!type->name || !type->pagesize) { -- 1.7.1