From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vogar-0001SO-Cb for qemu-devel@nongnu.org; Thu, 05 Dec 2013 16:36:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vogah-0003db-8t for qemu-devel@nongnu.org; Thu, 05 Dec 2013 16:36:21 -0500 Received: from mail-pb0-f51.google.com ([209.85.160.51]:53575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vogah-0003dX-2Q for qemu-devel@nongnu.org; Thu, 05 Dec 2013 16:36:11 -0500 Received: by mail-pb0-f51.google.com with SMTP id up15so26600313pbc.24 for ; Thu, 05 Dec 2013 13:36:10 -0800 (PST) From: Roy Franz Date: Thu, 5 Dec 2013 13:35:55 -0800 Message-Id: <1386279359-32286-4-git-send-email-roy.franz@linaro.org> In-Reply-To: <1386279359-32286-1-git-send-email-roy.franz@linaro.org> References: <1386279359-32286-1-git-send-email-roy.franz@linaro.org> Subject: [Qemu-devel] [PATCH V5 3/7] return status for each NOR flash device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, peter.maydell@linaro.org, kwolf@redhat.com, stefanha@redhat.com Cc: Roy Franz , patches@linaro.org Now that we know how wide each flash device that makes up the bank is, return status for each device in the bank. Leave existing code that treats 32 bit wide banks as composed of two 16 bit devices as otherwise we may break configurations that do not set the device_width propery. Signed-off-by: Roy Franz --- hw/block/pflash_cfi01.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index a458ad6..82a2519 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -193,9 +193,20 @@ static uint32_t pflash_read (pflash_t *pfl, hwaddr offset, case 0x60: /* Block /un)lock */ case 0x70: /* Status Register */ case 0xe8: /* Write block */ - /* Status register read */ + /* Status register read. Return status from each device in + * bank. + */ ret = pfl->status; - if (width > 2) { + if (pfl->device_width && width > pfl->device_width) { + int shift = pfl->device_width * 8; + while (shift + pfl->device_width * 8 <= width * 8) { + ret |= pfl->status << shift; + shift += pfl->device_width * 8; + } + } else if (!pfl->device_width && width > 2) { + /* Handle 32 bit flash cases where device width is not + * set. (Existing behavior before device width added.) + */ ret |= pfl->status << 16; } DPRINTF("%s: status %x\n", __func__, ret); -- 1.7.10.4