hw/arm: QOM'ify stellaris.c
* Drop the use of old SysBus init function and use instance_init * Use DeviceClass::vmsd instead of 'vmstate_register' function Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
f68575c956
commit
15c4fff5d8
|
@ -316,23 +316,22 @@ static const VMStateDescription vmstate_stellaris_gptm = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int stellaris_gptm_init(SysBusDevice *sbd)
|
static void stellaris_gptm_init(Object *obj)
|
||||||
{
|
{
|
||||||
DeviceState *dev = DEVICE(sbd);
|
DeviceState *dev = DEVICE(obj);
|
||||||
gptm_state *s = STELLARIS_GPTM(dev);
|
gptm_state *s = STELLARIS_GPTM(obj);
|
||||||
|
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
||||||
|
|
||||||
sysbus_init_irq(sbd, &s->irq);
|
sysbus_init_irq(sbd, &s->irq);
|
||||||
qdev_init_gpio_out(dev, &s->trigger, 1);
|
qdev_init_gpio_out(dev, &s->trigger, 1);
|
||||||
|
|
||||||
memory_region_init_io(&s->iomem, OBJECT(s), &gptm_ops, s,
|
memory_region_init_io(&s->iomem, obj, &gptm_ops, s,
|
||||||
"gptm", 0x1000);
|
"gptm", 0x1000);
|
||||||
sysbus_init_mmio(sbd, &s->iomem);
|
sysbus_init_mmio(sbd, &s->iomem);
|
||||||
|
|
||||||
s->opaque[0] = s->opaque[1] = s;
|
s->opaque[0] = s->opaque[1] = s;
|
||||||
s->timer[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[0]);
|
s->timer[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[0]);
|
||||||
s->timer[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[1]);
|
s->timer[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[1]);
|
||||||
vmstate_register(dev, -1, &vmstate_stellaris_gptm, s);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -873,23 +872,22 @@ static const VMStateDescription vmstate_stellaris_i2c = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int stellaris_i2c_init(SysBusDevice *sbd)
|
static void stellaris_i2c_init(Object *obj)
|
||||||
{
|
{
|
||||||
DeviceState *dev = DEVICE(sbd);
|
DeviceState *dev = DEVICE(obj);
|
||||||
stellaris_i2c_state *s = STELLARIS_I2C(dev);
|
stellaris_i2c_state *s = STELLARIS_I2C(obj);
|
||||||
|
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
||||||
I2CBus *bus;
|
I2CBus *bus;
|
||||||
|
|
||||||
sysbus_init_irq(sbd, &s->irq);
|
sysbus_init_irq(sbd, &s->irq);
|
||||||
bus = i2c_init_bus(dev, "i2c");
|
bus = i2c_init_bus(dev, "i2c");
|
||||||
s->bus = bus;
|
s->bus = bus;
|
||||||
|
|
||||||
memory_region_init_io(&s->iomem, OBJECT(s), &stellaris_i2c_ops, s,
|
memory_region_init_io(&s->iomem, obj, &stellaris_i2c_ops, s,
|
||||||
"i2c", 0x1000);
|
"i2c", 0x1000);
|
||||||
sysbus_init_mmio(sbd, &s->iomem);
|
sysbus_init_mmio(sbd, &s->iomem);
|
||||||
/* ??? For now we only implement the master interface. */
|
/* ??? For now we only implement the master interface. */
|
||||||
stellaris_i2c_reset(s);
|
stellaris_i2c_reset(s);
|
||||||
vmstate_register(dev, -1, &vmstate_stellaris_i2c, s);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Analogue to Digital Converter. This is only partially implemented,
|
/* Analogue to Digital Converter. This is only partially implemented,
|
||||||
|
@ -1160,23 +1158,22 @@ static const VMStateDescription vmstate_stellaris_adc = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int stellaris_adc_init(SysBusDevice *sbd)
|
static void stellaris_adc_init(Object *obj)
|
||||||
{
|
{
|
||||||
DeviceState *dev = DEVICE(sbd);
|
DeviceState *dev = DEVICE(obj);
|
||||||
stellaris_adc_state *s = STELLARIS_ADC(dev);
|
stellaris_adc_state *s = STELLARIS_ADC(obj);
|
||||||
|
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
for (n = 0; n < 4; n++) {
|
for (n = 0; n < 4; n++) {
|
||||||
sysbus_init_irq(sbd, &s->irq[n]);
|
sysbus_init_irq(sbd, &s->irq[n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
memory_region_init_io(&s->iomem, OBJECT(s), &stellaris_adc_ops, s,
|
memory_region_init_io(&s->iomem, obj, &stellaris_adc_ops, s,
|
||||||
"adc", 0x1000);
|
"adc", 0x1000);
|
||||||
sysbus_init_mmio(sbd, &s->iomem);
|
sysbus_init_mmio(sbd, &s->iomem);
|
||||||
stellaris_adc_reset(s);
|
stellaris_adc_reset(s);
|
||||||
qdev_init_gpio_in(dev, stellaris_adc_trigger, 1);
|
qdev_init_gpio_in(dev, stellaris_adc_trigger, 1);
|
||||||
vmstate_register(dev, -1, &vmstate_stellaris_adc, s);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -1425,43 +1422,46 @@ type_init(stellaris_machine_init)
|
||||||
|
|
||||||
static void stellaris_i2c_class_init(ObjectClass *klass, void *data)
|
static void stellaris_i2c_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
|
||||||
sdc->init = stellaris_i2c_init;
|
dc->vmsd = &vmstate_stellaris_i2c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo stellaris_i2c_info = {
|
static const TypeInfo stellaris_i2c_info = {
|
||||||
.name = TYPE_STELLARIS_I2C,
|
.name = TYPE_STELLARIS_I2C,
|
||||||
.parent = TYPE_SYS_BUS_DEVICE,
|
.parent = TYPE_SYS_BUS_DEVICE,
|
||||||
.instance_size = sizeof(stellaris_i2c_state),
|
.instance_size = sizeof(stellaris_i2c_state),
|
||||||
|
.instance_init = stellaris_i2c_init,
|
||||||
.class_init = stellaris_i2c_class_init,
|
.class_init = stellaris_i2c_class_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void stellaris_gptm_class_init(ObjectClass *klass, void *data)
|
static void stellaris_gptm_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
|
||||||
sdc->init = stellaris_gptm_init;
|
dc->vmsd = &vmstate_stellaris_gptm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo stellaris_gptm_info = {
|
static const TypeInfo stellaris_gptm_info = {
|
||||||
.name = TYPE_STELLARIS_GPTM,
|
.name = TYPE_STELLARIS_GPTM,
|
||||||
.parent = TYPE_SYS_BUS_DEVICE,
|
.parent = TYPE_SYS_BUS_DEVICE,
|
||||||
.instance_size = sizeof(gptm_state),
|
.instance_size = sizeof(gptm_state),
|
||||||
|
.instance_init = stellaris_gptm_init,
|
||||||
.class_init = stellaris_gptm_class_init,
|
.class_init = stellaris_gptm_class_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void stellaris_adc_class_init(ObjectClass *klass, void *data)
|
static void stellaris_adc_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
|
||||||
sdc->init = stellaris_adc_init;
|
dc->vmsd = &vmstate_stellaris_adc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo stellaris_adc_info = {
|
static const TypeInfo stellaris_adc_info = {
|
||||||
.name = TYPE_STELLARIS_ADC,
|
.name = TYPE_STELLARIS_ADC,
|
||||||
.parent = TYPE_SYS_BUS_DEVICE,
|
.parent = TYPE_SYS_BUS_DEVICE,
|
||||||
.instance_size = sizeof(stellaris_adc_state),
|
.instance_size = sizeof(stellaris_adc_state),
|
||||||
|
.instance_init = stellaris_adc_init,
|
||||||
.class_init = stellaris_adc_class_init,
|
.class_init = stellaris_adc_class_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue