hw/arm/mps2: Use qdev_prop_set_array()

Instead of manually setting "foo-len" and "foo[i]" properties, build a
QList and use the new qdev_prop_set_array() helper to set the whole
array property with a single call.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20231109174240.72376-4-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Kevin Wolf 2023-11-09 18:42:32 +01:00
parent 31805a0aa4
commit 80e09151c2
1 changed files with 8 additions and 4 deletions

View File

@ -48,6 +48,7 @@
#include "net/net.h" #include "net/net.h"
#include "hw/watchdog/cmsdk-apb-watchdog.h" #include "hw/watchdog/cmsdk-apb-watchdog.h"
#include "hw/qdev-clock.h" #include "hw/qdev-clock.h"
#include "qapi/qmp/qlist.h"
#include "qom/object.h" #include "qom/object.h"
typedef enum MPS2FPGAType { typedef enum MPS2FPGAType {
@ -138,6 +139,7 @@ static void mps2_common_init(MachineState *machine)
MemoryRegion *system_memory = get_system_memory(); MemoryRegion *system_memory = get_system_memory();
MachineClass *mc = MACHINE_GET_CLASS(machine); MachineClass *mc = MACHINE_GET_CLASS(machine);
DeviceState *armv7m, *sccdev; DeviceState *armv7m, *sccdev;
QList *oscclk;
int i; int i;
if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) { if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) {
@ -402,10 +404,12 @@ static void mps2_common_init(MachineState *machine)
qdev_prop_set_uint32(sccdev, "scc-aid", 0x00200008); qdev_prop_set_uint32(sccdev, "scc-aid", 0x00200008);
qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id); qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id);
/* All these FPGA images have the same OSCCLK configuration */ /* All these FPGA images have the same OSCCLK configuration */
qdev_prop_set_uint32(sccdev, "len-oscclk", 3); oscclk = qlist_new();
qdev_prop_set_uint32(sccdev, "oscclk[0]", 50000000); qlist_append_int(oscclk, 50000000);
qdev_prop_set_uint32(sccdev, "oscclk[1]", 24576000); qlist_append_int(oscclk, 24576000);
qdev_prop_set_uint32(sccdev, "oscclk[2]", 25000000); qlist_append_int(oscclk, 25000000);
qdev_prop_set_array(sccdev, "oscclk", oscclk);
sysbus_realize(SYS_BUS_DEVICE(&mms->scc), &error_fatal); sysbus_realize(SYS_BUS_DEVICE(&mms->scc), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000); sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000);
object_initialize_child(OBJECT(mms), "fpgaio", object_initialize_child(OBJECT(mms), "fpgaio",