qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] hw/nand.c: bug fix to BUSY/READY status bit
@ 2013-01-18  6:20 Dante
  2013-01-18  6:20 ` [Qemu-devel] [PATCH 2/2] hw/nand.c: bug fix to erase operation Dante
  0 siblings, 1 reply; 2+ messages in thread
From: Dante @ 2013-01-18  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: balrog, Dante

The status register coding for BUSY/READY(BIT6)
is actually [Busy:0, Ready:1].
BTW, this patch not only apply the bug fix to status bit,
but also update the Busy/Ready status upon nand flash read/write/erase.

Signed-off-by: Kuo-Jung Su <dantesu@faraday-tech.com>
---
 hw/nand.c |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/hw/nand.c b/hw/nand.c
index 6054f46..76479ed 100644
--- a/hw/nand.c
+++ b/hw/nand.c
@@ -46,7 +46,7 @@
 # define NAND_IOSTATUS_PLANE1	(1 << 2)
 # define NAND_IOSTATUS_PLANE2	(1 << 3)
 # define NAND_IOSTATUS_PLANE3	(1 << 4)
-# define NAND_IOSTATUS_BUSY	(1 << 6)
+# define NAND_IOSTATUS_READY	(1 << 6)
 # define NAND_IOSTATUS_UNPROTCT	(1 << 7)
 
 # define MAX_PAGE		0x800
@@ -646,6 +646,8 @@ static void glue(nand_blk_write_, PAGE_SIZE)(NANDFlashState *s)
     uint8_t iobuf[(PAGE_SECTORS + 2) * 0x200];
     if (PAGE(s->addr) >= s->pages)
         return;
+        
+    s->status &= ~NAND_IOSTATUS_READY;
 
     if (!s->bdrv) {
         mem_and(s->storage + PAGE_START(s->addr) + (s->addr & PAGE_MASK) +
@@ -656,6 +658,7 @@ static void glue(nand_blk_write_, PAGE_SIZE)(NANDFlashState *s)
         soff = SECTOR_OFFSET(s->addr);
         if (bdrv_read(s->bdrv, sector, iobuf, PAGE_SECTORS) < 0) {
             printf("%s: read error in sector %" PRIu64 "\n", __func__, sector);
+            s->status |= NAND_IOSTATUS_READY;
             return;
         }
 
@@ -675,6 +678,7 @@ static void glue(nand_blk_write_, PAGE_SIZE)(NANDFlashState *s)
         soff = off & 0x1ff;
         if (bdrv_read(s->bdrv, sector, iobuf, PAGE_SECTORS + 2) < 0) {
             printf("%s: read error in sector %" PRIu64 "\n", __func__, sector);
+            s->status |= NAND_IOSTATUS_READY;
             return;
         }
 
@@ -685,6 +689,8 @@ static void glue(nand_blk_write_, PAGE_SIZE)(NANDFlashState *s)
         }
     }
     s->offset = 0;
+    
+    s->status |= NAND_IOSTATUS_READY;
 }
 
 /* Erase a single block */
@@ -696,6 +702,8 @@ static void glue(nand_blk_erase_, PAGE_SIZE)(NANDFlashState *s)
 
     if (PAGE(addr) >= s->pages)
         return;
+        
+    s->status &= ~NAND_IOSTATUS_READY;
 
     if (!s->bdrv) {
         memset(s->storage + PAGE_START(addr),
@@ -738,6 +746,8 @@ static void glue(nand_blk_erase_, PAGE_SIZE)(NANDFlashState *s)
             printf("%s: write error in sector %" PRIu64 "\n", __func__, page);
         }
     }
+    
+    s->status |= NAND_IOSTATUS_READY;
 }
 
 static void glue(nand_blk_load_, PAGE_SIZE)(NANDFlashState *s,
@@ -745,6 +755,8 @@ static void glue(nand_blk_load_, PAGE_SIZE)(NANDFlashState *s,
 {
     if (PAGE(addr) >= s->pages)
         return;
+        
+    s->status &= ~NAND_IOSTATUS_READY;
 
     if (s->bdrv) {
         if (s->mem_oob) {
@@ -769,6 +781,8 @@ static void glue(nand_blk_load_, PAGE_SIZE)(NANDFlashState *s,
                         offset, PAGE_SIZE + OOB_SIZE - offset);
         s->ioaddr = s->io;
     }
+    
+    s->status |= NAND_IOSTATUS_READY;
 }
 
 static void glue(nand_init_, PAGE_SIZE)(NANDFlashState *s)
-- 
1.7.9.5


********************* Confidentiality Notice ************************
This electronic message and any attachments may contain
confidential and legally privileged information or
information which is otherwise protected from disclosure.
If you are not the intended recipient,please do not disclose
the contents, either in whole or in part, to anyone,and
immediately delete the message and any attachments from
your computer system and destroy all hard copies.
Thank you for your cooperation.
***********************************************************************

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Qemu-devel] [PATCH 2/2] hw/nand.c: bug fix to erase operation
  2013-01-18  6:20 [Qemu-devel] [PATCH 1/2] hw/nand.c: bug fix to BUSY/READY status bit Dante
@ 2013-01-18  6:20 ` Dante
  0 siblings, 0 replies; 2+ messages in thread
From: Dante @ 2013-01-18  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: balrog, Dante

The s->addr is supposed to be reset along with the s->addrlen,
or it might be contains the previous address at last address cycle,
and causes problem to nand erase operation.

Signed-off-by: Kuo-Jung Su <dantesu@faraday-tech.com>
---
 hw/nand.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/nand.c b/hw/nand.c
index 76479ed..b70a371 100644
--- a/hw/nand.c
+++ b/hw/nand.c
@@ -510,6 +510,7 @@ void nand_setio(DeviceState *dev, uint32_t value)
             nand_command(s);
 
         if (s->cmd != NAND_CMD_RANDOMREAD2) {
+            s->addr = 0;
             s->addrlen = 0;
         }
     }
-- 
1.7.9.5


********************* Confidentiality Notice ************************
This electronic message and any attachments may contain
confidential and legally privileged information or
information which is otherwise protected from disclosure.
If you are not the intended recipient,please do not disclose
the contents, either in whole or in part, to anyone,and
immediately delete the message and any attachments from
your computer system and destroy all hard copies.
Thank you for your cooperation.
***********************************************************************

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-18  6:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-18  6:20 [Qemu-devel] [PATCH 1/2] hw/nand.c: bug fix to BUSY/READY status bit Dante
2013-01-18  6:20 ` [Qemu-devel] [PATCH 2/2] hw/nand.c: bug fix to erase operation Dante

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).