[PATCH] [MTD] NAND: Add support for driver-specific wait_ready function
Harald Welte
laforge at openmoko.org
Mon Oct 20 20:56:39 CEST 2008
This enables a driver to implement RnB-interrupt based waiting
for the RnB line to become ready, as opposed to the busy-waiting
polling implementation in the core NAND layer.
This is particularly important on battery-powered devices where
you try to save CPU cycles where you can.
Signed-off-by: Harald Welte <laforge at openmoko.org>
---
drivers/mtd/nand/nand_base.c | 10 ++++++----
include/linux/mtd/nand.h | 2 ++
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index e29c1da..81996b3 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -533,7 +533,7 @@ static void nand_command(struct mtd_info *mtd, unsigned int command,
* any case on any machine. */
ndelay(100);
- nand_wait_ready(mtd);
+ chip->wait_ready(mtd);
}
/**
@@ -654,7 +654,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
* any case on any machine. */
ndelay(100);
- nand_wait_ready(mtd);
+ chip->wait_ready(mtd);
}
/**
@@ -1033,7 +1033,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
if (!chip->dev_ready)
udelay(chip->chip_delay);
else
- nand_wait_ready(mtd);
+ chip->wait_ready(mtd);
}
} else {
memcpy(buf, chip->buffers->databuf + col, bytes);
@@ -1318,7 +1318,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
if (!chip->dev_ready)
udelay(chip->chip_delay);
else
- nand_wait_ready(mtd);
+ chip->wait_ready(mtd);
}
readlen -= len;
@@ -2211,6 +2211,8 @@ static void nand_set_defaults(struct nand_chip *chip, int busw)
chip->verify_buf = busw ? nand_verify_buf16 : nand_verify_buf;
if (!chip->scan_bbt)
chip->scan_bbt = nand_default_bbt;
+ if (!chip->wait_ready)
+ chip->wait_ready = nand_wait_ready;
if (!chip->controller) {
chip->controller = &chip->hwcontrol;
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index c42bc7f..ac0fd71 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -320,6 +320,7 @@ struct nand_buffers {
* @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
+ * @wait_ready: [REPLACEABLE] hardwarespecific function for waiting read/busy line
* @cmdfunc: [REPLACEABLE] hardwarespecific function for writing commands to the chip
* @waitfunc: [REPLACEABLE] hardwarespecific function for wait on ready
* @ecc: [BOARDSPECIFIC] ecc control ctructure
@@ -377,6 +378,7 @@ struct nand_chip {
void (*cmd_ctrl)(struct mtd_info *mtd, int dat,
unsigned int ctrl);
int (*dev_ready)(struct mtd_info *mtd);
+ void (*wait_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);
void (*erase_cmd)(struct mtd_info *mtd, int page);
--
1.5.6.5
--8t9RHnE3ZwKMSgU+
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0002--MTD-S3C24XX-NAND-Use-interrupt-based-RnB.patch"
More information about the openmoko-kernel
mailing list