Received: from eggs.gnu.org ([2001:4830:134:3::10]:42516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYewF-0005z3-Uy for qemu-devel@nongnu.org; Tue, 22 Oct 2013 12:36:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VYewA-0001yQ-3c for qemu-devel@nongnu.org; Tue, 22 Oct 2013 12:36:11 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:65366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYew9-0001yI-Tj for qemu-devel@nongnu.org; Tue, 22 Oct 2013 12:36:06 -0400 Received: by mail-pd0-f180.google.com with SMTP id p10so7132576pdj.11 for ; Tue, 22 Oct 2013 09:36:05 -0700 (PDT) From: Roy Franz Date: Tue, 22 Oct 2013 09:35:54 -0700 Message-Id: <1382459756-6853-3-git-send-email-roy.franz@linaro.org> In-Reply-To: <1382459756-6853-1-git-send-email-roy.franz@linaro.org> References: <1382459756-6853-1-git-send-email-roy.franz@linaro.org> Subject: [Qemu-devel] [PATCH 2/4 v5] block: Add device-width property to pflash_cfi01 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, kwolf@redhat.com, stefanha@redhat.com Cc: Roy Franz , peter.maydell@linaro.org, patches@linaro.org The width of the devices that make up the flash interface is required to mask certain commands, in particular the write length for buffered writes. This length will be presented to each device on the interface by the program writing the flash, and the flash emulation code needs to be able to determine the length of the write as recieved by each flash device. The device-width defaults to the bank width which should maintain existing behavior for platforms that don't need this change. This change is required to support buffered writes on the vexpress platform that has a 32 bit flash interface with 2 16 bit devices on it. Signed-off-by: Roy Franz --- hw/block/pflash_cfi01.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index d5e366d..cda8289 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -72,6 +72,7 @@ struct pflash_t { uint32_t nb_blocs; uint64_t sector_len; uint8_t bank_width; + uint8_t device_width; uint8_t be; uint8_t wcycle; /* if 0, the flash is read normally */ int ro; @@ -378,6 +379,8 @@ static void pflash_write(pflash_t *pfl, hwaddr offset, break; case 0xe8: + /* Mask writeblock size based on device width */ + value &= (1ULL << (pfl->device_width * 8)) - 1; DPRINTF("%s: block write of %x bytes\n", __func__, value); pfl->counter = value; pfl->wcycle++; @@ -707,6 +710,7 @@ static Property pflash_cfi01_properties[] = { DEFINE_PROP_UINT32("num-blocks", struct pflash_t, nb_blocs, 0), DEFINE_PROP_UINT64("sector-length", struct pflash_t, sector_len, 0), DEFINE_PROP_UINT8("width", struct pflash_t, bank_width, 0), + DEFINE_PROP_UINT8("device-width", struct pflash_t, device_width, 0), DEFINE_PROP_UINT8("big-endian", struct pflash_t, be, 0), DEFINE_PROP_UINT16("id0", struct pflash_t, ident0, 0), DEFINE_PROP_UINT16("id1", struct pflash_t, ident1, 0), @@ -757,6 +761,7 @@ pflash_t *pflash_cfi01_register(hwaddr base, qdev_prop_set_uint32(dev, "num-blocks", nb_blocs); qdev_prop_set_uint64(dev, "sector-length", sector_len); qdev_prop_set_uint8(dev, "width", bank_width); + qdev_prop_set_uint8(dev, "device-width", bank_width); qdev_prop_set_uint8(dev, "big-endian", !!be); qdev_prop_set_uint16(dev, "id0", id0); qdev_prop_set_uint16(dev, "id1", id1); -- 1.7.10.4