* [Qemu-devel] [PATCH 0/2 v2] block, arm: Fix buffered flash writes on VExpress @ 2013-10-18 18:50 Roy Franz 2013-10-18 18:50 ` [Qemu-devel] [PATCH 1/2 v2] Add device-width property to pflash_cfi01 Roy Franz 2013-10-18 18:50 ` [Qemu-devel] [PATCH 2/2 v2] Set proper device-width for vexpress flash Roy Franz 0 siblings, 2 replies; 8+ messages in thread From: Roy Franz @ 2013-10-18 18:50 UTC (permalink / raw) To: qemu-devel, kwolf, stefanha; +Cc: Roy Franz, peter.maydell, patches Here is my updated patch to fix buffered flash writes on the VExpress platform. Buffered writes should now work properly on platforms whose flash interface width is different from the device width. The default is for the device-width to be set to the interface width, so platforms that can benefit from this change will need to be updated. This patchset updates the configuration for the VExpress platform which requires it. UEFI firmware uses buffered writes for persistent variable storage, and this patchset enables this usage on QEMU. Changes from v1: * Add device-width property and use this to mask write length instead of devices mas write length * Update vexpress init code to set device-width to proper value. Roy Franz (2): Add device-width property to pflash_cfi01 Set proper device-width for vexpress flash hw/arm/vexpress.c | 38 ++++++++++++++++++++++++++++++++++++-- hw/block/pflash_cfi01.c | 21 +++++++++++++-------- 2 files changed, 49 insertions(+), 10 deletions(-) -- 1.7.10.4 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 1/2 v2] Add device-width property to pflash_cfi01 2013-10-18 18:50 [Qemu-devel] [PATCH 0/2 v2] block, arm: Fix buffered flash writes on VExpress Roy Franz @ 2013-10-18 18:50 ` Roy Franz 2013-10-18 18:50 ` [Qemu-devel] [PATCH 2/2 v2] Set proper device-width for vexpress flash Roy Franz 1 sibling, 0 replies; 8+ messages in thread From: Roy Franz @ 2013-10-18 18:50 UTC (permalink / raw) To: qemu-devel, kwolf, stefanha; +Cc: Roy Franz, peter.maydell, patches 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 <roy.franz@linaro.org> --- hw/block/pflash_cfi01.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 018a967..cda8289 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -71,7 +71,8 @@ struct pflash_t { BlockDriverState *bs; uint32_t nb_blocs; uint64_t sector_len; - uint8_t width; + uint8_t bank_width; + uint8_t device_width; uint8_t be; uint8_t wcycle; /* if 0, the flash is read normally */ int ro; @@ -126,9 +127,9 @@ static uint32_t pflash_read (pflash_t *pfl, hwaddr offset, ret = -1; boff = offset & 0xFF; /* why this here ?? */ - if (pfl->width == 2) + if (pfl->bank_width == 2) boff = boff >> 1; - else if (pfl->width == 4) + else if (pfl->bank_width == 4) boff = boff >> 2; #if 0 @@ -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++; @@ -665,7 +668,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp) pfl->cfi_table[0x28] = 0x02; pfl->cfi_table[0x29] = 0x00; /* Max number of bytes in multi-bytes write */ - if (pfl->width == 1) { + if (pfl->bank_width == 1) { pfl->cfi_table[0x2A] = 0x08; } else { pfl->cfi_table[0x2A] = 0x0B; @@ -706,7 +709,8 @@ static Property pflash_cfi01_properties[] = { DEFINE_PROP_DRIVE("drive", struct pflash_t, bs), 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, width, 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), @@ -745,8 +749,8 @@ pflash_t *pflash_cfi01_register(hwaddr base, DeviceState *qdev, const char *name, hwaddr size, BlockDriverState *bs, - uint32_t sector_len, int nb_blocs, int width, - uint16_t id0, uint16_t id1, + uint32_t sector_len, int nb_blocs, + int bank_width, uint16_t id0, uint16_t id1, uint16_t id2, uint16_t id3, int be) { DeviceState *dev = qdev_create(NULL, TYPE_CFI_PFLASH01); @@ -756,7 +760,8 @@ 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", width); + 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 2/2 v2] Set proper device-width for vexpress flash 2013-10-18 18:50 [Qemu-devel] [PATCH 0/2 v2] block, arm: Fix buffered flash writes on VExpress Roy Franz 2013-10-18 18:50 ` [Qemu-devel] [PATCH 1/2 v2] Add device-width property to pflash_cfi01 Roy Franz @ 2013-10-18 18:50 ` Roy Franz 2013-10-19 9:47 ` Peter Maydell 1 sibling, 1 reply; 8+ messages in thread From: Roy Franz @ 2013-10-18 18:50 UTC (permalink / raw) To: qemu-devel, kwolf, stefanha; +Cc: Roy Franz, peter.maydell, patches Create vexpress specific pflash registration function which properly configures the device-width of 16 bits (2 bytes) for the NOR flash on the vexpress platform. This change is required for buffered flash writes to work properly. Signed-off-by: Roy Franz <roy.franz@linaro.org> --- hw/arm/vexpress.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index f48de00..2087245 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -480,6 +480,39 @@ static void vexpress_modify_dtb(const struct arm_boot_info *info, void *fdt) } } + +/* Open code a private version of plfash registration since we + * need to set non-default device width for Vexpress platform. + */ +static pflash_t *ve_pflash_cfi01_register(hwaddr base, + DeviceState *qdev, const char *name, + hwaddr size, + BlockDriverState *bs, + uint32_t sector_len, int nb_blocs, + int bank_width, uint16_t id0, uint16_t id1, + uint16_t id2, uint16_t id3, int be) +{ + DeviceState *dev = qdev_create(NULL, "cfi.pflash01"); + + if (bs && qdev_prop_set_drive(dev, "drive", bs)) { + abort(); + } + 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", 2); + qdev_prop_set_uint8(dev, "big-endian", !!be); + qdev_prop_set_uint16(dev, "id0", id0); + qdev_prop_set_uint16(dev, "id1", id1); + qdev_prop_set_uint16(dev, "id2", id2); + qdev_prop_set_uint16(dev, "id3", id3); + qdev_prop_set_string(dev, "name", name); + qdev_init_nofail(dev); + + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); + return OBJECT_CHECK(pflash_t, (dev), "cfi.pflash01"); +} + static void vexpress_common_init(VEDBoardInfo *daughterboard, QEMUMachineInitArgs *args) { @@ -561,7 +594,8 @@ static void vexpress_common_init(VEDBoardInfo *daughterboard, sysbus_create_simple("pl111", map[VE_CLCD], pic[14]); dinfo = drive_get_next(IF_PFLASH); - pflash0 = pflash_cfi01_register(map[VE_NORFLASH0], NULL, "vexpress.flash0", + pflash0 = ve_pflash_cfi01_register(map[VE_NORFLASH0], NULL, + "vexpress.flash0", VEXPRESS_FLASH_SIZE, dinfo ? dinfo->bdrv : NULL, VEXPRESS_FLASH_SECT_SIZE, VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE, 4, @@ -580,7 +614,7 @@ static void vexpress_common_init(VEDBoardInfo *daughterboard, } dinfo = drive_get_next(IF_PFLASH); - if (!pflash_cfi01_register(map[VE_NORFLASH1], NULL, "vexpress.flash1", + if (!ve_pflash_cfi01_register(map[VE_NORFLASH1], NULL, "vexpress.flash1", VEXPRESS_FLASH_SIZE, dinfo ? dinfo->bdrv : NULL, VEXPRESS_FLASH_SECT_SIZE, VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE, 4, -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2 v2] Set proper device-width for vexpress flash 2013-10-18 18:50 ` [Qemu-devel] [PATCH 2/2 v2] Set proper device-width for vexpress flash Roy Franz @ 2013-10-19 9:47 ` Peter Maydell 2013-10-19 17:04 ` [Qemu-devel] [PATCH 0/2 v3] block, arm: Fix buffered flash writes on VExpress Roy Franz 0 siblings, 1 reply; 8+ messages in thread From: Peter Maydell @ 2013-10-19 9:47 UTC (permalink / raw) To: Roy Franz; +Cc: Kevin Wolf, QEMU Developers, Stefan Hajnoczi, Patch Tracking On 18 October 2013 19:50, Roy Franz <roy.franz@linaro.org> wrote: > Create vexpress specific pflash registration > function which properly configures the device-width > of 16 bits (2 bytes) for the NOR flash on the > vexpress platform. This change is required for > buffered flash writes to work properly. > +/* Open code a private version of plfash registration since we "pflash" > + * need to set non-default device width for Vexpress platform. > + */ > +static pflash_t *ve_pflash_cfi01_register(hwaddr base, > + DeviceState *qdev, const char *name, > + hwaddr size, > + BlockDriverState *bs, > + uint32_t sector_len, int nb_blocs, > + int bank_width, uint16_t id0, uint16_t id1, > + uint16_t id2, uint16_t id3, int be) > +{ > + DeviceState *dev = qdev_create(NULL, "cfi.pflash01"); > + > + if (bs && qdev_prop_set_drive(dev, "drive", bs)) { > + abort(); > + } > + 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", 2); > + qdev_prop_set_uint8(dev, "big-endian", !!be); > + qdev_prop_set_uint16(dev, "id0", id0); > + qdev_prop_set_uint16(dev, "id1", id1); > + qdev_prop_set_uint16(dev, "id2", id2); > + qdev_prop_set_uint16(dev, "id3", id3); > + qdev_prop_set_string(dev, "name", name); > + qdev_init_nofail(dev); > + > + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); > + return OBJECT_CHECK(pflash_t, (dev), "cfi.pflash01"); > +} > + > static void vexpress_common_init(VEDBoardInfo *daughterboard, > QEMUMachineInitArgs *args) > { > @@ -561,7 +594,8 @@ static void vexpress_common_init(VEDBoardInfo *daughterboard, > sysbus_create_simple("pl111", map[VE_CLCD], pic[14]); > > dinfo = drive_get_next(IF_PFLASH); > - pflash0 = pflash_cfi01_register(map[VE_NORFLASH0], NULL, "vexpress.flash0", > + pflash0 = ve_pflash_cfi01_register(map[VE_NORFLASH0], NULL, > + "vexpress.flash0", > VEXPRESS_FLASH_SIZE, dinfo ? dinfo->bdrv : NULL, > VEXPRESS_FLASH_SECT_SIZE, > VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE, 4, > @@ -580,7 +614,7 @@ static void vexpress_common_init(VEDBoardInfo *daughterboard, > } > > dinfo = drive_get_next(IF_PFLASH); > - if (!pflash_cfi01_register(map[VE_NORFLASH1], NULL, "vexpress.flash1", > + if (!ve_pflash_cfi01_register(map[VE_NORFLASH1], NULL, "vexpress.flash1", > VEXPRESS_FLASH_SIZE, dinfo ? dinfo->bdrv : NULL, > VEXPRESS_FLASH_SECT_SIZE, > VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE, 4, Almost all the parameters you're passing here are the same for both calls, so it would be better to hard code them in the utility function. -- PMM ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 0/2 v3] block, arm: Fix buffered flash writes on VExpress 2013-10-19 9:47 ` Peter Maydell @ 2013-10-19 17:04 ` Roy Franz 2013-10-19 17:04 ` [Qemu-devel] [PATCH 1/2 v3] block: Add device-width property to pflash_cfi01 Roy Franz 2013-10-19 17:04 ` [Qemu-devel] [PATCH 2/2 v3] block, arm: Set proper device-width for vexpress flash Roy Franz 0 siblings, 2 replies; 8+ messages in thread From: Roy Franz @ 2013-10-19 17:04 UTC (permalink / raw) To: qemu-devel, kwolf, stefanha; +Cc: Roy Franz, peter.maydell, patches Here is my updated patch to fix buffered flash writes on the VExpress platform. Buffered writes should now work properly on platforms whose flash interface width is different from the device width. The default is for the device-width to be set to the interface width, so platforms that can benefit from this change will need to be updated. This patchset updates the configuration for the VExpress platform which requires it. UEFI firmware uses buffered writes for persistent variable storage, and this patchset enables this usage on QEMU. Changes from v2: (All changes in patch 2/2, 1/1 unchanged.) * Set flash invariant properties directly in VExpress specific flash init routine rather than passing long argument list. * Fix typo in comment. Changes from v1: * Add device-width property and use this to mask write length instead of devices mas write length * Update vexpress init code to set device-width to proper value. Roy Franz (2): Add device-width property to pflash_cfi01 Set proper device-width for vexpress flash hw/arm/vexpress.c | 43 +++++++++++++++++++++++++++++++++---------- hw/block/pflash_cfi01.c | 21 +++++++++++++-------- 2 files changed, 46 insertions(+), 18 deletions(-) -- 1.7.10.4 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 1/2 v3] block: Add device-width property to pflash_cfi01 2013-10-19 17:04 ` [Qemu-devel] [PATCH 0/2 v3] block, arm: Fix buffered flash writes on VExpress Roy Franz @ 2013-10-19 17:04 ` Roy Franz 2013-10-19 20:59 ` Peter Maydell 2013-10-19 17:04 ` [Qemu-devel] [PATCH 2/2 v3] block, arm: Set proper device-width for vexpress flash Roy Franz 1 sibling, 1 reply; 8+ messages in thread From: Roy Franz @ 2013-10-19 17:04 UTC (permalink / raw) To: qemu-devel, kwolf, stefanha; +Cc: Roy Franz, peter.maydell, patches 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 <roy.franz@linaro.org> --- hw/block/pflash_cfi01.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 018a967..cda8289 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -71,7 +71,8 @@ struct pflash_t { BlockDriverState *bs; uint32_t nb_blocs; uint64_t sector_len; - uint8_t width; + uint8_t bank_width; + uint8_t device_width; uint8_t be; uint8_t wcycle; /* if 0, the flash is read normally */ int ro; @@ -126,9 +127,9 @@ static uint32_t pflash_read (pflash_t *pfl, hwaddr offset, ret = -1; boff = offset & 0xFF; /* why this here ?? */ - if (pfl->width == 2) + if (pfl->bank_width == 2) boff = boff >> 1; - else if (pfl->width == 4) + else if (pfl->bank_width == 4) boff = boff >> 2; #if 0 @@ -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++; @@ -665,7 +668,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp) pfl->cfi_table[0x28] = 0x02; pfl->cfi_table[0x29] = 0x00; /* Max number of bytes in multi-bytes write */ - if (pfl->width == 1) { + if (pfl->bank_width == 1) { pfl->cfi_table[0x2A] = 0x08; } else { pfl->cfi_table[0x2A] = 0x0B; @@ -706,7 +709,8 @@ static Property pflash_cfi01_properties[] = { DEFINE_PROP_DRIVE("drive", struct pflash_t, bs), 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, width, 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), @@ -745,8 +749,8 @@ pflash_t *pflash_cfi01_register(hwaddr base, DeviceState *qdev, const char *name, hwaddr size, BlockDriverState *bs, - uint32_t sector_len, int nb_blocs, int width, - uint16_t id0, uint16_t id1, + uint32_t sector_len, int nb_blocs, + int bank_width, uint16_t id0, uint16_t id1, uint16_t id2, uint16_t id3, int be) { DeviceState *dev = qdev_create(NULL, TYPE_CFI_PFLASH01); @@ -756,7 +760,8 @@ 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", width); + 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2 v3] block: Add device-width property to pflash_cfi01 2013-10-19 17:04 ` [Qemu-devel] [PATCH 1/2 v3] block: Add device-width property to pflash_cfi01 Roy Franz @ 2013-10-19 20:59 ` Peter Maydell 0 siblings, 0 replies; 8+ messages in thread From: Peter Maydell @ 2013-10-19 20:59 UTC (permalink / raw) To: Roy Franz; +Cc: Kevin Wolf, QEMU Developers, Stefan Hajnoczi, Patch Tracking On 19 October 2013 18:04, Roy Franz <roy.franz@linaro.org> wrote: > 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 <roy.franz@linaro.org> > --- > hw/block/pflash_cfi01.c | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c > index 018a967..cda8289 100644 > --- a/hw/block/pflash_cfi01.c > +++ b/hw/block/pflash_cfi01.c > @@ -71,7 +71,8 @@ struct pflash_t { > BlockDriverState *bs; > uint32_t nb_blocs; > uint64_t sector_len; > - uint8_t width; > + uint8_t bank_width; If you want to rename this struct field can you put that in its own patch, please? Otherwise it's hard to see the actual functional changes. > + uint8_t device_width; > uint8_t be; > uint8_t wcycle; /* if 0, the flash is read normally */ > int ro; > @@ -126,9 +127,9 @@ static uint32_t pflash_read (pflash_t *pfl, hwaddr offset, > ret = -1; > boff = offset & 0xFF; /* why this here ?? */ > > - if (pfl->width == 2) > + if (pfl->bank_width == 2) > boff = boff >> 1; > - else if (pfl->width == 4) > + else if (pfl->bank_width == 4) > boff = boff >> 2; > > #if 0 > @@ -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; Is this really the only guest visible difference for banked flash devices? > DPRINTF("%s: block write of %x bytes\n", __func__, value); > pfl->counter = value; > pfl->wcycle++; thanks -- PMM ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 2/2 v3] block, arm: Set proper device-width for vexpress flash 2013-10-19 17:04 ` [Qemu-devel] [PATCH 0/2 v3] block, arm: Fix buffered flash writes on VExpress Roy Franz 2013-10-19 17:04 ` [Qemu-devel] [PATCH 1/2 v3] block: Add device-width property to pflash_cfi01 Roy Franz @ 2013-10-19 17:04 ` Roy Franz 1 sibling, 0 replies; 8+ messages in thread From: Roy Franz @ 2013-10-19 17:04 UTC (permalink / raw) To: qemu-devel, kwolf, stefanha; +Cc: Roy Franz, peter.maydell, patches Create vexpress specific pflash registration function which properly configures the device-width of 16 bits (2 bytes) for the NOR flash on the vexpress platform. This change is required for buffered flash writes to work properly. Signed-off-by: Roy Franz <roy.franz@linaro.org> --- hw/arm/vexpress.c | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index f48de00..8eae73c 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -480,6 +480,35 @@ static void vexpress_modify_dtb(const struct arm_boot_info *info, void *fdt) } } + +/* Open code a private version of pflash registration since we + * need to set non-default device width for VExpress platform. + */ +static pflash_t *ve_pflash_cfi01_register(hwaddr base, const char *name, + BlockDriverState *bs) +{ + DeviceState *dev = qdev_create(NULL, "cfi.pflash01"); + + if (bs && qdev_prop_set_drive(dev, "drive", bs)) { + abort(); + } + + qdev_prop_set_uint32(dev, "num-blocks", VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE); + qdev_prop_set_uint64(dev, "sector-length", VEXPRESS_FLASH_SECT_SIZE); + qdev_prop_set_uint8(dev, "width", 4); + qdev_prop_set_uint8(dev, "device-width", 2); + qdev_prop_set_uint8(dev, "big-endian", 0); + qdev_prop_set_uint16(dev, "id0", 0x00); + qdev_prop_set_uint16(dev, "id1", 0x89); + qdev_prop_set_uint16(dev, "id2", 0x00); + qdev_prop_set_uint16(dev, "id3", 0x18); + qdev_prop_set_string(dev, "name", name); + qdev_init_nofail(dev); + + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); + return OBJECT_CHECK(pflash_t, (dev), "cfi.pflash01"); +} + static void vexpress_common_init(VEDBoardInfo *daughterboard, QEMUMachineInitArgs *args) { @@ -561,11 +590,8 @@ static void vexpress_common_init(VEDBoardInfo *daughterboard, sysbus_create_simple("pl111", map[VE_CLCD], pic[14]); dinfo = drive_get_next(IF_PFLASH); - pflash0 = pflash_cfi01_register(map[VE_NORFLASH0], NULL, "vexpress.flash0", - VEXPRESS_FLASH_SIZE, dinfo ? dinfo->bdrv : NULL, - VEXPRESS_FLASH_SECT_SIZE, - VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE, 4, - 0x00, 0x89, 0x00, 0x18, 0); + pflash0 = ve_pflash_cfi01_register(map[VE_NORFLASH0], "vexpress.flash0", + dinfo ? dinfo->bdrv : NULL); if (!pflash0) { fprintf(stderr, "vexpress: error registering flash 0.\n"); exit(1); @@ -580,11 +606,8 @@ static void vexpress_common_init(VEDBoardInfo *daughterboard, } dinfo = drive_get_next(IF_PFLASH); - if (!pflash_cfi01_register(map[VE_NORFLASH1], NULL, "vexpress.flash1", - VEXPRESS_FLASH_SIZE, dinfo ? dinfo->bdrv : NULL, - VEXPRESS_FLASH_SECT_SIZE, - VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE, 4, - 0x00, 0x89, 0x00, 0x18, 0)) { + if (!ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1", + dinfo ? dinfo->bdrv : NULL)) { fprintf(stderr, "vexpress: error registering flash 1.\n"); exit(1); } -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-10-19 20:59 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-10-18 18:50 [Qemu-devel] [PATCH 0/2 v2] block, arm: Fix buffered flash writes on VExpress Roy Franz 2013-10-18 18:50 ` [Qemu-devel] [PATCH 1/2 v2] Add device-width property to pflash_cfi01 Roy Franz 2013-10-18 18:50 ` [Qemu-devel] [PATCH 2/2 v2] Set proper device-width for vexpress flash Roy Franz 2013-10-19 9:47 ` Peter Maydell 2013-10-19 17:04 ` [Qemu-devel] [PATCH 0/2 v3] block, arm: Fix buffered flash writes on VExpress Roy Franz 2013-10-19 17:04 ` [Qemu-devel] [PATCH 1/2 v3] block: Add device-width property to pflash_cfi01 Roy Franz 2013-10-19 20:59 ` Peter Maydell 2013-10-19 17:04 ` [Qemu-devel] [PATCH 2/2 v3] block, arm: Set proper device-width for vexpress flash Roy Franz
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).