aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Shijie <b32955@freescale.com>2013-09-25 02:58:11 -0400
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:06:04 -0400
commit37b488c0e6699389cc376bff606bf08940652af4 (patch)
tree328d998fc9574e9535d3d70d899e1f4ee16f4849
parent71c7a81b9205b5ab75a36c774d263f912acbf55a (diff)
mtd: nand: rename the cellinfo to bits_per_cell
The @cellinfo fields contains unused information, such as write caching, internal chip numbering, etc. But we only use it to check the SLC or MLC. This patch tries to make it more clear and simple, renames the @cellinfo to @bits_per_cell. In order to avoiding the bisect issue, this patch also does the following changes: (0) add a macro NAND_CI_CELLTYPE_SHIFT to avoid the hardcode. (1) add a helper to parse out the cell type : nand_get_bits_per_cell() (2) parse out the cell type for extended-ID chips and the full-id nand chips. Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--drivers/mtd/nand/nand_base.c14
-rw-r--r--include/linux/mtd/nand.h7
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 */
3097static 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 */
203struct nand_chip; 204struct 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 */
766static inline bool nand_is_slc(struct nand_chip *chip) 767static 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 */