Patchwork [09/15] hw/nand: Support multiple reads following READ STATUS

login
register
mail settings
Submitter Peter Maydell
Date July 29, 2011, 3:35 p.m.
Message ID <1311953728-29084-10-git-send-email-peter.maydell@linaro.org>
Download mbox | patch
Permalink /patch/107411/
State New
Headers show

Comments

Peter Maydell - July 29, 2011, 3:35 p.m.
From: Juha Riihimäki <juha.riihimaki@nokia.com>

After receiving READ STATUS command all subsequent IO reads should return
the status register value until another command is issued.

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
[Riku Voipio: Fixes and restructuring patchset]
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
[Peter Maydell: More fixes and cleanups for upstream submission]
Signed-off-by:  Peter Maydell <peter.maydell@linaro.org>
---
 hw/nand.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

Patch

diff --git a/hw/nand.c b/hw/nand.c
index 2e98f25..e6c551d 100644
--- a/hw/nand.c
+++ b/hw/nand.c
@@ -496,9 +496,14 @@  uint32_t nand_getio(NANDFlashState *s)
     for (offset = s->buswidth; offset--;) {
         x |= s->ioaddr[offset] << (offset << 3);
     }
-    s->addr   += s->buswidth;
-    s->ioaddr += s->buswidth;
-    s->iolen  -= s->buswidth;
+    /* after receiving READ STATUS command all subsequent reads will
+     * return the status register value until another command is issued
+     */
+    if (s->cmd != NAND_CMD_READSTATUS) {
+        s->addr   += s->buswidth;
+        s->ioaddr += s->buswidth;
+        s->iolen  -= s->buswidth;
+    }
     return x;
 }