OSPI updates
v2 cover OSPI updates
Add a new 2Gib octal flash mt35xu02gbba. Add an interface for versal virt board to swap the default flash.
Changes for V2:
Added type checks for provided flash part name.
Sai Pavan Boddu (2):
block: m25p80: Add support of mt35xu02gbba
arm: xlnx-versal-virt: Add machine property ospi-flash
hw/block/m25p80_sfdp.h | 1 + hw/arm/xlnx-versal-virt.c | 44 ++++++++++++++++++++++++++++++++++++++- hw/block/m25p80.c | 3 +++ hw/block/m25p80_sfdp.c | 36 ++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
PATCH v2 1/2 block: m25p80: Add support of mt35xu02gbba
Add Micro 2Gb OSPI flash part with sfdp data.
--- hw/block/m25p80_sfdp.h | 1 + hw/block/m25p80.c | 3 +++ hw/block/m25p80_sfdp.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+)
hw/block/m25p80_sfdp.h +1 -0
@@ -16,6 +16,7 @@#define M25P80_SFDP_MAX_SIZE (1 << 24)uint8_t m25p80_sfdp_n25q256a (uint32_t addr); +uint8_t m25p80_sfdp_mt35xu02g (uint32_t addr);uint8_t m25p80_sfdp_mx25l25635e (uint32_t addr);uint8_t m25p80_sfdp_mx25l25635f (uint32_t addr);
hw/block/m25p80.c +3 -0
@@ -267,6 +267,9 @@ static const FlashPartInfo known_devices[] = { { INFO("mt25ql512ab", 0x20ba20, 0x1044, 64 << 10, 1024, ER_4K | ER_32K) }, { INFO_STACKED("mt35xu01g", 0x2c5b1b, 0x104100, 128 << 10, 1024, ER_4K | ER_32K, 2) }, + { INFO_STACKED("mt35xu02gbba", 0x2c5b1c, 0x104100, 128 << 10, 2048, +ER_4K |ER_32K ,4 ), + .sfdp_read = m25p80_sfdp_mt35xu02g }, { INFO_STACKED("n25q00", 0x20ba21, 0x1000, 64 << 10, 2048, ER_4K, 4) }, { INFO_STACKED("n25q00a", 0x20bb21, 0x1000, 64 << 10, 2048, ER_4K, 4) }, { INFO_STACKED("mt25ql01g", 0x20ba21, 0x1040, 64 << 10, 2048, ER_4K, 2) },
hw/block/m25p80_sfdp.c +36 -0
@@ -57,6 +57,42 @@ static const uint8_t sfdp_n25q256a[] = { };define_sfdp_read (n25q256a); +static const uint8_t sfdp_mt35xu02g[] = { +0x53 ,0x46 ,0x44 ,0x50 ,0x06 ,0x01 ,0x01 ,0xff , +0x00 ,0x06 ,0x01 ,0x10 ,0x30 ,0x00 ,0x00 ,0xff , +0x84 ,0x00 ,0x01 ,0x02 ,0x80 ,0x00 ,0x00 ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xe5 ,0x20 ,0x8a ,0xff ,0xff ,0xff ,0xff ,0x7f , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0xee ,0xff ,0xff ,0xff ,0xff ,0xff ,0x00 ,0x00 , +0xff ,0xff ,0x00 ,0x00 ,0x0c ,0x20 ,0x11 ,0xd8 , +0x0f ,0x52 ,0x00 ,0x00 ,0x24 ,0x5a ,0x99 ,0x00 , +0x8b ,0x8e ,0x03 ,0xe1 ,0xac ,0x01 ,0x27 ,0x38 , +0x7a ,0x75 ,0x7a ,0x75 ,0xfb ,0xbd ,0xd5 ,0x5c , +0x00 ,0x00 ,0x70 ,0xff ,0x81 ,0xb0 ,0x38 ,0x36 , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0x43 ,0x0e ,0xff ,0xff ,0x21 ,0xdc ,0x5c ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +}; + +define_sfdp_read (mt35xu02g);/* * Matronix
Signature · 1 line
2.25.1
PATCH v2 2/2 arm: xlnx-versal-virt: Add machine property ospi-flash
In reply to Sai Pavan BodduThis property allows users to change flash model on command line as below.
ex: "-M xlnx-versal-virt,ospi-flash=mt35xu02gbba"
--- hw/arm/xlnx-versal-virt.c | 44 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)
hw/arm/xlnx-versal-virt.c +43 -1
@@ -49,6 +49,7 @@ struct VersalVirt {struct {bool secure; } cfg; +char *ospi_model; };static void fdt_create (VersalVirt *s)
@@ -638,6 +639,22 @@ static void sd_plugin_card(SDHCIState *sd, DriveInfo *di) &error_fatal); } +static char *versal_get_ospi_model (Object *obj,Error **errp) +{ +VersalVirt *s =XLNX_VERSAL_VIRT_MACHINE (obj); + +return g_strdup (s->ospi_model); +} + +static void versal_set_ospi_model (Object *obj,const char *value,Error **errp) +{ +VersalVirt *s =XLNX_VERSAL_VIRT_MACHINE (obj); + +g_free (s->ospi_model); + s->ospi_model =g_strdup (value); +} + +static void versal_virt_init (MachineState *machine) {VersalVirt *s =XLNX_VERSAL_VIRT_MACHINE (machine);
@@ -732,12 +749,25 @@ static void versal_virt_init(MachineState *machine)for (i =0 ; i <XLNX_VERSAL_NUM_OSPI_FLASH ; i++) {BusState *spi_bus;DeviceState *flash_dev; +ObjectClass *flash_klass;qemu_irq cs_line;DriveInfo *dinfo =drive_get (IF_MTD ,0 , i); spi_bus =qdev_get_child_bus (DEVICE (&s->soc.pmc.iou.ospi),"spi0" ); - flash_dev =qdev_new ("mt35xu01g" ); +if (s->ospi_model) { + flash_klass =object_class_by_name (s->ospi_model); +if (!flash_klass || +object_class_is_abstract (flash_klass) || + !object_class_dynamic_cast (flash_klass,"m25p80-generic" )) { +error_setg (&error_fatal,"'%s' is either abstract or" +" not a subtype of m25p80" , s->ospi_model); +return ; + } + } + + flash_dev =qdev_new (s->ospi_model ? s->ospi_model :"mt35xu01g" ); +if (dinfo) {qdev_prop_set_drive_err (flash_dev,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal);
@@ -770,6 +800,13 @@ static void versal_virt_machine_instance_init(Object *obj) 0); } +static void versal_virt_machine_finalize (Object *obj) +{ +VersalVirt *s =XLNX_VERSAL_VIRT_MACHINE (obj); + +g_free (s->ospi_model); +} +static void versal_virt_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -781,6 +818,10 @@ static void versal_virt_machine_class_init(ObjectClass *oc, void *data) mc->default_cpus =XLNX_VERSAL_NR_ACPUS +XLNX_VERSAL_NR_RCPUS ; mc->no_cdrom = true; mc->default_ram_id ="ddr" ; +object_class_property_add_str (oc,"ospi-flash" , versal_get_ospi_model, + versal_set_ospi_model); +object_class_property_set_description (oc,"ospi-flash" , +"Change the OSPI Flash model" ); }static const TypeInfo versal_virt_machine_init_typeinfo = {
@@ -789,6 +830,7 @@ static const TypeInfo versal_virt_machine_init_typeinfo = { .class_init = versal_virt_machine_class_init, .instance_init = versal_virt_machine_instance_init, .instance_size = sizeof(VersalVirt), + .instance_finalize = versal_virt_machine_finalize, };static void versal_virt_machine_init_register_types (void )
Signature · 1 line
2.25.1
Peter Maydell
AppliedQuoted 11 lines · Sai Pavan Boddu
Add a new 2Gib octal flash mt35xu02gbba. Add an interface for versal virt board to swap the default flash.
Changes for V2:
Added type checks for provided flash part name.Sai Pavan Boddu (2):
block: m25p80: Add support of mt35xu02gbba
arm: xlnx-versal-virt: Add machine property ospi-flash
Quoted 5 lines
hw/block/m25p80_sfdp.h | 1 + hw/arm/xlnx-versal-virt.c | 44 ++++++++++++++++++++++++++++++++++++++- hw/block/m25p80.c | 3 +++ hw/block/m25p80_sfdp.c | 36 ++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 1 deletion(-)
Applied to target-arm.next, thanks.
-- PMM