pnv/psi: Consolidate some duplicated code in pnv_psi_realize()
The proper way to do that would be to use device_class_set_parent_realize(), but defining a Pnv8PsiClass and a Pnv9PsiClass types with a parent_realize pointer adds a fair amount of code. Calling pnv_psi_realize() explicitely is fine for now. This should probably be achieved with a device realize hook in the PSI base class and device_class_set_parent_realize() in the children classes. Signed-off-by: Greg Kurz <groug@kaod.org> Signed-off-by: Cédric Le Goater <clg@kaod.org> Message-Id: <157841476667.66386.13659183399113837990.stgit@bahia.tlslab.ibm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
fcb7e4a8f4
commit
b91cad2f07
|
@ -469,6 +469,16 @@ static void pnv_psi_reset_handler(void *dev)
|
||||||
device_reset(DEVICE(dev));
|
device_reset(DEVICE(dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void pnv_psi_realize(DeviceState *dev, Error **errp)
|
||||||
|
{
|
||||||
|
PnvPsi *psi = PNV_PSI(dev);
|
||||||
|
|
||||||
|
/* Default BAR for MMIO region */
|
||||||
|
pnv_psi_set_bar(psi, psi->bar | PSIHB_BAR_EN);
|
||||||
|
|
||||||
|
qemu_register_reset(pnv_psi_reset_handler, dev);
|
||||||
|
}
|
||||||
|
|
||||||
static void pnv_psi_power8_instance_init(Object *obj)
|
static void pnv_psi_power8_instance_init(Object *obj)
|
||||||
{
|
{
|
||||||
Pnv8Psi *psi8 = PNV8_PSI(obj);
|
Pnv8Psi *psi8 = PNV8_PSI(obj);
|
||||||
|
@ -521,9 +531,6 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp)
|
||||||
memory_region_init_io(&psi->regs_mr, OBJECT(dev), &psi_mmio_ops, psi,
|
memory_region_init_io(&psi->regs_mr, OBJECT(dev), &psi_mmio_ops, psi,
|
||||||
"psihb", PNV_PSIHB_SIZE);
|
"psihb", PNV_PSIHB_SIZE);
|
||||||
|
|
||||||
/* Default BAR for MMIO region */
|
|
||||||
pnv_psi_set_bar(psi, psi->bar | PSIHB_BAR_EN);
|
|
||||||
|
|
||||||
/* Default sources in XIVR */
|
/* Default sources in XIVR */
|
||||||
for (i = 0; i < PSI_NUM_INTERRUPTS; i++) {
|
for (i = 0; i < PSI_NUM_INTERRUPTS; i++) {
|
||||||
uint8_t xivr = irq_to_xivr[i];
|
uint8_t xivr = irq_to_xivr[i];
|
||||||
|
@ -531,7 +538,7 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp)
|
||||||
((uint64_t) i << PSIHB_XIVR_SRC_SH);
|
((uint64_t) i << PSIHB_XIVR_SRC_SH);
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_register_reset(pnv_psi_reset_handler, dev);
|
pnv_psi_realize(dev, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pnv_psi_dt_xscom(PnvXScomInterface *dev, void *fdt, int xscom_offset)
|
static int pnv_psi_dt_xscom(PnvXScomInterface *dev, void *fdt, int xscom_offset)
|
||||||
|
@ -866,9 +873,7 @@ static void pnv_psi_power9_realize(DeviceState *dev, Error **errp)
|
||||||
memory_region_init_io(&psi->regs_mr, OBJECT(dev), &pnv_psi_p9_mmio_ops, psi,
|
memory_region_init_io(&psi->regs_mr, OBJECT(dev), &pnv_psi_p9_mmio_ops, psi,
|
||||||
"psihb", PNV9_PSIHB_SIZE);
|
"psihb", PNV9_PSIHB_SIZE);
|
||||||
|
|
||||||
pnv_psi_set_bar(psi, psi->bar | PSIHB_BAR_EN);
|
pnv_psi_realize(dev, errp);
|
||||||
|
|
||||||
qemu_register_reset(pnv_psi_reset_handler, dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pnv_psi_power9_class_init(ObjectClass *klass, void *data)
|
static void pnv_psi_power9_class_init(ObjectClass *klass, void *data)
|
||||||
|
|
Loading…
Reference in a new issue