diff options
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 14 | ||||
-rw-r--r-- | include/linux/mtd/nand.h | 7 |
2 files changed, 16 insertions, 5 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 6ea66270dbf5..5fb00957fd25 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -3082,6 +3082,16 @@ static int nand_id_len(u8 *id_data, int arrlen) | |||
3082 | return arrlen; | 3082 | return arrlen; |
3083 | } | 3083 | } |
3084 | 3084 | ||
3085 | /* Extract the bits of per cell from the 3rd byte of the extended ID */ | ||
3086 | static int nand_get_bits_per_cell(u8 cellinfo) | ||
3087 | { | ||
3088 | int bits; | ||
3089 | |||
3090 | bits = cellinfo & NAND_CI_CELLTYPE_MSK; | ||
3091 | bits >>= NAND_CI_CELLTYPE_SHIFT; | ||
3092 | return bits + 1; | ||
3093 | } | ||
3094 | |||
3085 | /* | 3095 | /* |
3086 | * Many new NAND share similar device ID codes, which represent the size of the | 3096 | * Many new NAND share similar device ID codes, which represent the size of the |
3087 | * chip. The rest of the parameters must be decoded according to generic or | 3097 | * chip. The rest of the parameters must be decoded according to generic or |
@@ -3092,7 +3102,7 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, | |||
3092 | { | 3102 | { |
3093 | int extid, id_len; | 3103 | int extid, id_len; |
3094 | /* The 3rd id byte holds MLC / multichip data */ | 3104 | /* The 3rd id byte holds MLC / multichip data */ |
3095 | chip->cellinfo = id_data[2]; | 3105 | chip->bits_per_cell = nand_get_bits_per_cell(id_data[2]); |
3096 | /* The 4th id byte is the important one */ | 3106 | /* The 4th id byte is the important one */ |
3097 | extid = id_data[3]; | 3107 | extid = id_data[3]; |
3098 | 3108 | ||
@@ -3292,7 +3302,7 @@ static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, | |||
3292 | mtd->erasesize = type->erasesize; | 3302 | mtd->erasesize = type->erasesize; |
3293 | mtd->oobsize = type->oobsize; | 3303 | mtd->oobsize = type->oobsize; |
3294 | 3304 | ||
3295 | chip->cellinfo = id_data[2]; | 3305 | chip->bits_per_cell = nand_get_bits_per_cell(id_data[2]); |
3296 | chip->chipsize = (uint64_t)type->chipsize << 20; | 3306 | chip->chipsize = (uint64_t)type->chipsize << 20; |
3297 | chip->options |= type->options; | 3307 | chip->options |= type->options; |
3298 | chip->ecc_strength_ds = NAND_ECC_STRENGTH(type); | 3308 | chip->ecc_strength_ds = NAND_ECC_STRENGTH(type); |
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 5c05bab0ad89..9e6c8f9f306e 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -198,6 +198,7 @@ typedef enum { | |||
198 | /* Cell info constants */ | 198 | /* Cell info constants */ |
199 | #define NAND_CI_CHIPNR_MSK 0x03 | 199 | #define NAND_CI_CHIPNR_MSK 0x03 |
200 | #define NAND_CI_CELLTYPE_MSK 0x0C | 200 | #define NAND_CI_CELLTYPE_MSK 0x0C |
201 | #define NAND_CI_CELLTYPE_SHIFT 2 | ||
201 | 202 | ||
202 | /* Keep gcc happy */ | 203 | /* Keep gcc happy */ |
203 | struct nand_chip; | 204 | struct nand_chip; |
@@ -477,7 +478,7 @@ struct nand_buffers { | |||
477 | * @badblockbits: [INTERN] minimum number of set bits in a good block's | 478 | * @badblockbits: [INTERN] minimum number of set bits in a good block's |
478 | * bad block marker position; i.e., BBM == 11110111b is | 479 | * bad block marker position; i.e., BBM == 11110111b is |
479 | * not bad when badblockbits == 7 | 480 | * not bad when badblockbits == 7 |
480 | * @cellinfo: [INTERN] MLC/multichip data from chip ident | 481 | * @bits_per_cell: [INTERN] number of bits per cell. i.e., 1 means SLC. |
481 | * @ecc_strength_ds: [INTERN] ECC correctability from the datasheet. | 482 | * @ecc_strength_ds: [INTERN] ECC correctability from the datasheet. |
482 | * Minimum amount of bit errors per @ecc_step_ds guaranteed | 483 | * Minimum amount of bit errors per @ecc_step_ds guaranteed |
483 | * to be correctable. If unknown, set to zero. | 484 | * to be correctable. If unknown, set to zero. |
@@ -558,7 +559,7 @@ struct nand_chip { | |||
558 | int pagebuf; | 559 | int pagebuf; |
559 | unsigned int pagebuf_bitflips; | 560 | unsigned int pagebuf_bitflips; |
560 | int subpagesize; | 561 | int subpagesize; |
561 | uint8_t cellinfo; | 562 | uint8_t bits_per_cell; |
562 | uint16_t ecc_strength_ds; | 563 | uint16_t ecc_strength_ds; |
563 | uint16_t ecc_step_ds; | 564 | uint16_t ecc_step_ds; |
564 | int badblockpos; | 565 | int badblockpos; |
@@ -802,6 +803,6 @@ static inline int onfi_get_sync_timing_mode(struct nand_chip *chip) | |||
802 | */ | 803 | */ |
803 | static inline bool nand_is_slc(struct nand_chip *chip) | 804 | static inline bool nand_is_slc(struct nand_chip *chip) |
804 | { | 805 | { |
805 | return !(chip->cellinfo & NAND_CI_CELLTYPE_MSK); | 806 | return chip->bits_per_cell == 1; |
806 | } | 807 | } |
807 | #endif /* __LINUX_MTD_NAND_H */ | 808 | #endif /* __LINUX_MTD_NAND_H */ |