hw/nand: Support multiple reads following READ STATUS
authorJuha Riihimäki <juha.riihimaki@nokia.com>
Fri, 29 Jul 2011 15:35:22 +0000 (16:35 +0100)
committerAndrzej Zaborowski <andrew.zaborowski@intel.com>
Sat, 30 Jul 2011 04:10:06 +0000 (06:10 +0200)
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>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
hw/nand.c

index 4d1dff16647e9ebaf60f5202b1c78002901cdb90..1eefe28c56ebbbc83bb5a7ad9a48b5ee5d832074 100644 (file)
--- 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;
 }