mirror of https://github.com/xemu-project/xemu.git
arm: xlnx-versal-virt: Add machine property ospi-flash
This property allows users to change flash model on command line as below. ex: "-M xlnx-versal-virt,ospi-flash=mt35xu02gbba" Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@amd.com> Message-id: 20240220091721.82954-3-sai.pavan.boddu@amd.com Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
4d85bfc86b
commit
06005459dc
|
@ -49,6 +49,7 @@ struct VersalVirt {
|
||||||
struct {
|
struct {
|
||||||
bool secure;
|
bool secure;
|
||||||
} cfg;
|
} cfg;
|
||||||
|
char *ospi_model;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void fdt_create(VersalVirt *s)
|
static void fdt_create(VersalVirt *s)
|
||||||
|
@ -638,6 +639,22 @@ static void sd_plugin_card(SDHCIState *sd, DriveInfo *di)
|
||||||
&error_fatal);
|
&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)
|
static void versal_virt_init(MachineState *machine)
|
||||||
{
|
{
|
||||||
VersalVirt *s = XLNX_VERSAL_VIRT_MACHINE(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++) {
|
for (i = 0; i < XLNX_VERSAL_NUM_OSPI_FLASH; i++) {
|
||||||
BusState *spi_bus;
|
BusState *spi_bus;
|
||||||
DeviceState *flash_dev;
|
DeviceState *flash_dev;
|
||||||
|
ObjectClass *flash_klass;
|
||||||
qemu_irq cs_line;
|
qemu_irq cs_line;
|
||||||
DriveInfo *dinfo = drive_get(IF_MTD, 0, i);
|
DriveInfo *dinfo = drive_get(IF_MTD, 0, i);
|
||||||
|
|
||||||
spi_bus = qdev_get_child_bus(DEVICE(&s->soc.pmc.iou.ospi), "spi0");
|
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) {
|
if (dinfo) {
|
||||||
qdev_prop_set_drive_err(flash_dev, "drive",
|
qdev_prop_set_drive_err(flash_dev, "drive",
|
||||||
blk_by_legacy_dinfo(dinfo), &error_fatal);
|
blk_by_legacy_dinfo(dinfo), &error_fatal);
|
||||||
|
@ -770,6 +800,13 @@ static void versal_virt_machine_instance_init(Object *obj)
|
||||||
0);
|
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)
|
static void versal_virt_machine_class_init(ObjectClass *oc, void *data)
|
||||||
{
|
{
|
||||||
MachineClass *mc = MACHINE_CLASS(oc);
|
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->default_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS;
|
||||||
mc->no_cdrom = true;
|
mc->no_cdrom = true;
|
||||||
mc->default_ram_id = "ddr";
|
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 = {
|
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,
|
.class_init = versal_virt_machine_class_init,
|
||||||
.instance_init = versal_virt_machine_instance_init,
|
.instance_init = versal_virt_machine_instance_init,
|
||||||
.instance_size = sizeof(VersalVirt),
|
.instance_size = sizeof(VersalVirt),
|
||||||
|
.instance_finalize = versal_virt_machine_finalize,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void versal_virt_machine_init_register_types(void)
|
static void versal_virt_machine_init_register_types(void)
|
||||||
|
|
Loading…
Reference in New Issue