From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
Jean-Hugues Deschenes <jean-hugues.deschenes@octasic.com>
Subject: [Qemu-devel] [PATCH 1/1] nand: Correct random data reads.
Date: Tue, 12 Jan 2010 15:05:32 +0100 [thread overview]
Message-ID: <1263305132-23157-2-git-send-email-edgar.iglesias@gmail.com> (raw)
In-Reply-To: <1263305132-23157-1-git-send-email-edgar.iglesias@gmail.com>
Random reading depends on having the last row/page latched and not beeing
clobbered between read and any following random reads.
Also, s->iolen must be updated when loading the io/data register with
randomly accessed flash data.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
hw/nand.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/hw/nand.c b/hw/nand.c
index 838f8bc..40d5a6a 100644
--- a/hw/nand.c
+++ b/hw/nand.c
@@ -212,6 +212,7 @@ static void nand_reset(NANDFlashState *s)
static void nand_command(NANDFlashState *s)
{
+ unsigned int offset;
switch (s->cmd) {
case NAND_CMD_READ0:
s->iolen = 0;
@@ -233,8 +234,12 @@ static void nand_command(NANDFlashState *s)
case NAND_CMD_NOSERIALREAD2:
if (!(nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP))
break;
-
- s->blk_load(s, s->addr, s->addr & ((1 << s->addr_shift) - 1));
+ offset = s->addr & ((1 << s->addr_shift) - 1);
+ s->blk_load(s, s->addr, offset);
+ if (s->gnd)
+ s->iolen = (1 << s->page_shift) - offset;
+ else
+ s->iolen = (1 << s->page_shift) + (1 << s->oob_shift) - offset;
break;
case NAND_CMD_RESET:
@@ -380,12 +385,15 @@ void nand_setio(NANDFlashState *s, uint8_t value)
if (s->cmd != NAND_CMD_RANDOMREAD2) {
s->addrlen = 0;
- s->addr = 0;
}
}
if (s->ale) {
- s->addr |= value << (s->addrlen * 8);
+ unsigned int shift = s->addrlen * 8;
+ unsigned int mask = ~(0xff << shift);
+ unsigned int v = value << shift;
+
+ s->addr = (s->addr & mask) | v;
s->addrlen ++;
if (s->addrlen == 1 && s->cmd == NAND_CMD_READID)
@@ -435,6 +443,7 @@ uint8_t nand_getio(NANDFlashState *s)
return 0;
s->iolen --;
+ s->addr++;
return *(s->ioaddr ++);
}
@@ -633,9 +642,6 @@ static void glue(nand_blk_load_, PAGE_SIZE)(NANDFlashState *s,
offset, PAGE_SIZE + OOB_SIZE - offset);
s->ioaddr = s->io;
}
-
- s->addr &= PAGE_SIZE - 1;
- s->addr += PAGE_SIZE;
}
static void glue(nand_init_, PAGE_SIZE)(NANDFlashState *s)
--
1.6.4.4
next prev parent reply other threads:[~2010-01-12 14:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-12 14:05 [Qemu-devel] [PATCH 0/1] nand: Support random data reads Edgar E. Iglesias
2010-01-12 14:05 ` Edgar E. Iglesias [this message]
2010-01-12 15:35 ` [Qemu-devel] " Jean-Hugues Deschenes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1263305132-23157-2-git-send-email-edgar.iglesias@gmail.com \
--to=edgar.iglesias@gmail.com \
--cc=jean-hugues.deschenes@octasic.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).