aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Shijie <shijie8@gmail.com>2010-09-26 22:43:53 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-10-24 19:49:57 -0400
commit12a40a57f762f569f58a393437d8c13864db390a (patch)
tree2ab939b100ff7604422e31719fc1621e7b2f7ee3
parent088bd455c954c0c42edde9d4463e44be10101aac (diff)
mtd: add init_size hook for NAND driver
Not all the NAND devices have all the information in additional id bytes. So add a hook in the nand_chip{} is a good method to calculate the right value of oobsize, erasesize and so on. Without the hook,you will get the wrong value, and you have to hack in the ->scan_bbt() to change the wrong value which make the code mess. Signed-off-by: Huang Shijie <shijie8@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r--drivers/mtd/nand/nand_base.c6
-rw-r--r--include/linux/mtd/nand.h6
2 files changed, 10 insertions, 2 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 0b70c175999c..53f4e41836f1 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2976,8 +2976,10 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
2976 2976
2977 chip->chipsize = (uint64_t)type->chipsize << 20; 2977 chip->chipsize = (uint64_t)type->chipsize << 20;
2978 2978
2979 /* Newer devices have all the information in additional id bytes */ 2979 if (!type->pagesize && chip->init_size) {
2980 if (!type->pagesize) { 2980 /* set the pagesize, oobsize, erasesize by the driver*/
2981 busw = chip->init_size(mtd, chip, id_data);
2982 } else if (!type->pagesize) {
2981 int extid; 2983 int extid;
2982 /* The 3rd id byte holds MLC / multichip data */ 2984 /* The 3rd id byte holds MLC / multichip data */
2983 chip->cellinfo = id_data[2]; 2985 chip->cellinfo = id_data[2];
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 7666c42235c7..0f744547a48c 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -396,6 +396,10 @@ struct nand_buffers {
396 * @block_markbad: [REPLACEABLE] mark the block bad 396 * @block_markbad: [REPLACEABLE] mark the block bad
397 * @cmd_ctrl: [BOARDSPECIFIC] hardwarespecific funtion for controlling 397 * @cmd_ctrl: [BOARDSPECIFIC] hardwarespecific funtion for controlling
398 * ALE/CLE/nCE. Also used to write command and address 398 * ALE/CLE/nCE. Also used to write command and address
399 * @init_size: [BOARDSPECIFIC] hardwarespecific funtion for setting
400 * mtd->oobsize, mtd->writesize and so on.
401 * @id_data contains the 8 bytes values of NAND_CMD_READID.
402 * Return with the bus width.
399 * @dev_ready: [BOARDSPECIFIC] hardwarespecific function for accesing device ready/busy line 403 * @dev_ready: [BOARDSPECIFIC] hardwarespecific function for accesing device ready/busy line
400 * If set to NULL no access to ready/busy is available and the ready/busy information 404 * If set to NULL no access to ready/busy is available and the ready/busy information
401 * is read from the chip status register 405 * is read from the chip status register
@@ -452,6 +456,8 @@ struct nand_chip {
452 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); 456 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
453 void (*cmd_ctrl)(struct mtd_info *mtd, int dat, 457 void (*cmd_ctrl)(struct mtd_info *mtd, int dat,
454 unsigned int ctrl); 458 unsigned int ctrl);
459 int (*init_size)(struct mtd_info *mtd,
460 struct nand_chip *this, u8 *id_data);
455 int (*dev_ready)(struct mtd_info *mtd); 461 int (*dev_ready)(struct mtd_info *mtd);
456 void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr); 462 void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr);
457 int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this); 463 int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this);