@@ -416,8 +416,6 @@ static void icp_pit_init(Object *obj)
for (unsigned i = 0; i < ARRAY_SIZE(s->timer); i++) {
s->timer[i] = arm_timer_new(tmr_freq[i], s->irq_in[i]);
sysbus_init_irq(dev, &s->irq[i]);
- sysbus_connect_irq(dev, i,
- qdev_get_gpio_in_named(DEVICE(obj), "timer-in", i));
}
memory_region_init_io(&s->iomem, obj, &icp_pit_ops, s,
@@ -427,12 +425,30 @@ static void icp_pit_init(Object *obj)
save themselves. */
}
+static void icp_pit_realize(DeviceState *dev, Error **errp)
+{
+ IntegratorPitState *s = INTEGRATOR_PIT(dev);
+
+ for (unsigned i = 0; i < ARRAY_SIZE(s->timer); i++) {
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), i,
+ qdev_get_gpio_in_named(dev, "timer-in", i));
+ }
+}
+
+static void icp_pit_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *k = DEVICE_CLASS(klass);
+
+ k->realize = icp_pit_realize;
+}
+
static const TypeInfo arm_timer_types[] = {
{
.name = TYPE_INTEGRATOR_PIT,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(IntegratorPitState),
.instance_init = icp_pit_init,
+ .class_init = icp_pit_class_init,
}, {
.name = TYPE_SP804,
To make the next commit easier to digest, extract icp_pit_realize() from icp_pit_init() as a preliminary step. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/timer/arm_timer.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)