mtd: add init_size hook for NAND driver
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Sun Oct 24 20:59:07 EDT 2010
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=12a40a57f762f569f58a393437d8c13864db390a
Commit: 12a40a57f762f569f58a393437d8c13864db390a
Parent: 088bd455c954c0c42edde9d4463e44be10101aac
Author: Huang Shijie <shijie8 at gmail.com>
AuthorDate: Mon Sep 27 10:43:53 2010 +0800
Committer: David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Oct 25 00:49:57 2010 +0100
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 at gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
drivers/mtd/nand/nand_base.c | 6 ++++--
include/linux/mtd/nand.h | 6 ++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 0b70c17..53f4e41 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,
chip->chipsize = (uint64_t)type->chipsize << 20;
- /* Newer devices have all the information in additional id bytes */
- if (!type->pagesize) {
+ if (!type->pagesize && chip->init_size) {
+ /* set the pagesize, oobsize, erasesize by the driver*/
+ busw = chip->init_size(mtd, chip, id_data);
+ } else if (!type->pagesize) {
int extid;
/* The 3rd id byte holds MLC / multichip data */
chip->cellinfo = id_data[2];
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 7666c42..0f74454 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -396,6 +396,10 @@ struct nand_buffers {
* @block_markbad: [REPLACEABLE] mark the block bad
* @cmd_ctrl: [BOARDSPECIFIC] hardwarespecific funtion for controlling
* ALE/CLE/nCE. Also used to write command and address
+ * @init_size: [BOARDSPECIFIC] hardwarespecific funtion for setting
+ * mtd->oobsize, mtd->writesize and so on.
+ * @id_data contains the 8 bytes values of NAND_CMD_READID.
+ * Return with the bus width.
* @dev_ready: [BOARDSPECIFIC] hardwarespecific function for accesing device ready/busy line
* If set to NULL no access to ready/busy is available and the ready/busy information
* is read from the chip status register
@@ -452,6 +456,8 @@ struct nand_chip {
int (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
void (*cmd_ctrl)(struct mtd_info *mtd, int dat,
unsigned int ctrl);
+ int (*init_size)(struct mtd_info *mtd,
+ struct nand_chip *this, u8 *id_data);
int (*dev_ready)(struct mtd_info *mtd);
void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr);
int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this);
More information about the linux-mtd-cvs
mailing list