mtd: rawnand: Make sure we wait tWB before polling the STATUS reg

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Tue May 8 10:59:02 PDT 2018


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=fc3a9e15b492eef707afd56b7478001fdecfe53f
Commit:     fc3a9e15b492eef707afd56b7478001fdecfe53f
Parent:     630691850131bc3b8cc13fd9b9c6eedb4eb64ad4
Author:     Boris Brezillon <boris.brezillon at bootlin.com>
AuthorDate: Fri May 4 21:24:31 2018 +0200
Committer:  Boris Brezillon <boris.brezillon at bootlin.com>
CommitDate: Mon May 7 11:36:02 2018 +0200

    mtd: rawnand: Make sure we wait tWB before polling the STATUS reg
    
    NAND chips require a bit of time to take the NAND operation into
    account and set the BUSY bit in the STATUS reg. Make sure we don't poll
    the STATUS reg too early in nand_soft_waitrdy().
    
    Fixes: 8878b126df76 ("mtd: nand: add ->exec_op() implementation")
    Cc: <stable at vger.kernel.org>
    Signed-off-by: Boris Brezillon <boris.brezillon at bootlin.com>
    Acked-by: Miquel Raynal <miquel.raynal at bootlin.com>
---
 drivers/mtd/nand/raw/nand_base.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 72f3a89da513..f28c3a555861 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -706,12 +706,17 @@ static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo)
  */
 int nand_soft_waitrdy(struct nand_chip *chip, unsigned long timeout_ms)
 {
+	const struct nand_sdr_timings *timings;
 	u8 status = 0;
 	int ret;
 
 	if (!chip->exec_op)
 		return -ENOTSUPP;
 
+	/* Wait tWB before polling the STATUS reg. */
+	timings = nand_get_sdr_timings(&chip->data_interface);
+	ndelay(PSEC_TO_NSEC(timings->tWB_max));
+
 	ret = nand_status_op(chip, NULL);
 	if (ret)
 		return ret;



More information about the linux-mtd-cvs mailing list