[PATCH 4/6] nand_wait_read : add code to wait on status for LP

Matthieu CASTET matthieu.castet at parrot.com
Sun Jun 26 12:26:54 EDT 2011


Use read status instead of waiting a fixed time.

For reading data after read status a command 0x0 should be issued (on large page) [1].
Only apply it for driver that use nand_command_lp, because other cmdfunc won't expect
NAND_CMD_READ0 without address.

[1]
While monitoring the read status to determine when the tR (transfer from Flash array to page
register) is complete, the host shall re-issue a command value of 00h to start reading data.
Issuing a command value of 00h will cause data to be returned starting at the selected column
address.

Signed-off-by: Matthieu CASTET <matthieu.castet at parrot.com>
---
 drivers/mtd/nand/nand_base.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 70af1c0..5f0a0de 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -703,6 +703,8 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
 		return;
 
 	case NAND_CMD_READ0:
+		if (column == -1 && page_addr == -1)
+			return;
 		chip->cmd_ctrl(mtd, NAND_CMD_READSTART,
 			       NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE);
 		chip->cmd_ctrl(mtd, NAND_CMD_NONE,
@@ -889,11 +891,20 @@ static void nand_wait_reset(struct mtd_info *mtd, struct nand_chip *chip)
   */
 static void nand_wait_read(struct mtd_info *mtd, struct nand_chip *chip)
 {
+	if (!chip->dev_ready && chip->cmdfunc == nand_command_lp) {
+		int status;
+		/* same timeout than nand_wait_ready */
+		unsigned long timeo = jiffies + (2 * HZ) / 1000;
+		status = nand_wait_timeout(mtd, chip, timeo);
+		WARN_ON(!(status & NAND_STATUS_READY));
+		/* start reading data */
+		chip->cmdfunc(mtd, NAND_CMD_READ0, -1, -1);
+	}
 	/*
 	 * If we don't have access to the busy pin, we apply the given
 	 * command delay
 	 */
-	if (!chip->dev_ready) {
+	else if (!chip->dev_ready) {
 		udelay(chip->chip_delay);
 	}
 	else {
-- 
1.7.5.4




More information about the linux-mtd mailing list