aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorHuang Shijie <b32955@freescale.com>2013-03-14 23:01:00 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2013-04-05 08:20:42 -0400
commitec6e87e378e209fda3eb4dfdf3c6164afb5cc7f5 (patch)
treedf0472ecd029386423342cb95bd68500ab553b08 /drivers/mtd/nand
parentf22d5f638b0ea40e7cceb4639a608bd2c3eff97c (diff)
mtd: add the support to parse out the full-id nand type
When we meet a full-id nand type whose @id_len is not zero, we can use the find_full_id_nand() to parse out the necessary information for a nand chip. If we meet a non full-id nand type, we can handle it in the legacy way. Signed-off-by: Huang Shijie <b32955@freescale.com> Reviewed-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/nand_base.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index f159d5f184bf..ae9790b659b1 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3087,6 +3087,30 @@ static void nand_decode_bbm_options(struct mtd_info *mtd,
3087 chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; 3087 chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
3088} 3088}
3089 3089
3090static inline bool is_full_id_nand(struct nand_flash_dev *type)
3091{
3092 return type->id_len;
3093}
3094
3095static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip,
3096 struct nand_flash_dev *type, u8 *id_data, int *busw)
3097{
3098 if (!strncmp(type->id, id_data, type->id_len)) {
3099 mtd->writesize = type->pagesize;
3100 mtd->erasesize = type->erasesize;
3101 mtd->oobsize = type->oobsize;
3102
3103 chip->cellinfo = id_data[2];
3104 chip->chipsize = (uint64_t)type->chipsize << 20;
3105 chip->options |= type->options;
3106
3107 *busw = type->options & NAND_BUSWIDTH_16;
3108
3109 return true;
3110 }
3111 return false;
3112}
3113
3090/* 3114/*
3091 * Get the flash and manufacturer id and lookup if the type is supported. 3115 * Get the flash and manufacturer id and lookup if the type is supported.
3092 */ 3116 */
@@ -3138,9 +3162,14 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
3138 if (!type) 3162 if (!type)
3139 type = nand_flash_ids; 3163 type = nand_flash_ids;
3140 3164
3141 for (; type->name != NULL; type++) 3165 for (; type->name != NULL; type++) {
3142 if (*dev_id == type->dev_id) 3166 if (is_full_id_nand(type)) {
3143 break; 3167 if (find_full_id_nand(mtd, chip, type, id_data, &busw))
3168 goto ident_done;
3169 } else if (*dev_id == type->dev_id) {
3170 break;
3171 }
3172 }
3144 3173
3145 chip->onfi_version = 0; 3174 chip->onfi_version = 0;
3146 if (!type->name || !type->pagesize) { 3175 if (!type->name || !type->pagesize) {