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 ed34364f7620..64ee59eb01b7 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -3093,6 +3093,16 @@ static int nand_id_len(u8 *id_data, int arrlen) | |||
3093 | return arrlen; | 3093 | return arrlen; |
3094 | } | 3094 | } |
3095 | 3095 | ||
3096 | /* Extract the bits of per cell from the 3rd byte of the extended ID */ | ||
3097 | static int nand_get_bits_per_cell(u8 cellinfo) | ||
3098 | { | ||
3099 | int bits; | ||
3100 | |||
3101 | bits = cellinfo & NAND_CI_CELLTYPE_MSK; | ||
3102 | bits >>= NAND_CI_CELLTYPE_SHIFT; | ||
3103 | return bits + 1; | ||
3104 | } | ||
3105 | |||
3096 | /* | 3106 | /* |
3097 | * Many new NAND share similar device ID codes, which represent the size of the | 3107 | * Many new NAND share similar device ID codes, which represent the size of the |
3098 | * chip. The rest of the parameters must be decoded according to generic or | 3108 | * chip. The rest of the parameters must be decoded according to generic or |
@@ -3103,7 +3113,7 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, | |||
3103 | { | 3113 | { |
3104 | int extid, id_len; | 3114 | int extid, id_len; |
3105 | /* The 3rd id byte holds MLC / multichip data */ | 3115 | /* The 3rd id byte holds MLC / multichip data */ |
3106 | chip->cellinfo = id_data[2]; | 3116 | chip->bits_per_cell = nand_get_bits_per_cell(id_data[2]); |
3107 | /* The 4th id byte is the important one */ | 3117 | /* The 4th id byte is the important one */ |
3108 | extid = id_data[3]; | 3118 | extid = id_data[3]; |
3109 | 3119 | ||
@@ -3303,7 +3313,7 @@ static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, | |||
3303 | mtd->erasesize = type->erasesize; | 3313 | mtd->erasesize = type->erasesize; |
3304 | mtd->oobsize = type->oobsize; | 3314 | mtd->oobsize = type->oobsize; |
3305 | 3315 | ||
3306 | chip->cellinfo = id_data[2]; | 3316 | chip->bits_per_cell = nand_get_bits_per_cell(id_data[2]); |
3307 | chip->chipsize = (uint64_t)type->chipsize << 20; | 3317 | chip->chipsize = (uint64_t)type->chipsize << 20; |
3308 | chip->options |= type->options; | 3318 | chip->options |= type->options; |
3309 | chip->ecc_strength_ds = NAND_ECC_STRENGTH(type); | 3319 | chip->ecc_strength_ds = NAND_ECC_STRENGTH(type); |
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 8911709653fe..8646589b3fe8 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; |
@@ -440,7 +441,7 @@ struct nand_buffers { | |||
440 | * @badblockbits: [INTERN] minimum number of set bits in a good block's | 441 | * @badblockbits: [INTERN] minimum number of set bits in a good block's |
441 | * bad block marker position; i.e., BBM == 11110111b is | 442 | * bad block marker position; i.e., BBM == 11110111b is |
442 | * not bad when badblockbits == 7 | 443 | * not bad when badblockbits == 7 |
443 | * @cellinfo: [INTERN] MLC/multichip data from chip ident | 444 | * @bits_per_cell: [INTERN] number of bits per cell. i.e., 1 means SLC. |
444 | * @ecc_strength_ds: [INTERN] ECC correctability from the datasheet. | 445 | * @ecc_strength_ds: [INTERN] ECC correctability from the datasheet. |
445 | * Minimum amount of bit errors per @ecc_step_ds guaranteed | 446 | * Minimum amount of bit errors per @ecc_step_ds guaranteed |
446 | * to be correctable. If unknown, set to zero. | 447 | * to be correctable. If unknown, set to zero. |
@@ -521,7 +522,7 @@ struct nand_chip { | |||
521 | int pagebuf; | 522 | int pagebuf; |
522 | unsigned int pagebuf_bitflips; | 523 | unsigned int pagebuf_bitflips; |
523 | int subpagesize; | 524 | int subpagesize; |
524 | uint8_t cellinfo; | 525 | uint8_t bits_per_cell; |
525 | uint16_t ecc_strength_ds; | 526 | uint16_t ecc_strength_ds; |
526 | uint16_t ecc_step_ds; | 527 | uint16_t ecc_step_ds; |
527 | int badblockpos; | 528 | int badblockpos; |
@@ -765,6 +766,6 @@ static inline int onfi_get_sync_timing_mode(struct nand_chip *chip) | |||
765 | */ | 766 | */ |
766 | static inline bool nand_is_slc(struct nand_chip *chip) | 767 | static inline bool nand_is_slc(struct nand_chip *chip) |
767 | { | 768 | { |
768 | return !(chip->cellinfo & NAND_CI_CELLTYPE_MSK); | 769 | return chip->bits_per_cell == 1; |
769 | } | 770 | } |
770 | #endif /* __LINUX_MTD_NAND_H */ | 771 | #endif /* __LINUX_MTD_NAND_H */ |