omap_intc: QOM'ify omap-intc and omap2-intc
Create a new abstract base type and let omap-intc and omap2-intc inherit from it. Introduce a type constant and use QOM casts. Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
1f8a9eac51
commit
47edc5a479
|
@ -32,8 +32,13 @@ struct omap_intr_handler_bank_s {
|
||||||
unsigned char priority[32];
|
unsigned char priority[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define TYPE_OMAP_INTC "common-omap-intc"
|
||||||
|
#define OMAP_INTC(obj) \
|
||||||
|
OBJECT_CHECK(struct omap_intr_handler_s, (obj), TYPE_OMAP_INTC)
|
||||||
|
|
||||||
struct omap_intr_handler_s {
|
struct omap_intr_handler_s {
|
||||||
SysBusDevice busdev;
|
SysBusDevice parent_obj;
|
||||||
|
|
||||||
qemu_irq *pins;
|
qemu_irq *pins;
|
||||||
qemu_irq parent_intr[2];
|
qemu_irq parent_intr[2];
|
||||||
MemoryRegion mmio;
|
MemoryRegion mmio;
|
||||||
|
@ -328,8 +333,7 @@ static const MemoryRegionOps omap_inth_mem_ops = {
|
||||||
|
|
||||||
static void omap_inth_reset(DeviceState *dev)
|
static void omap_inth_reset(DeviceState *dev)
|
||||||
{
|
{
|
||||||
struct omap_intr_handler_s *s = FROM_SYSBUS(struct omap_intr_handler_s,
|
struct omap_intr_handler_s *s = OMAP_INTC(dev);
|
||||||
SYS_BUS_DEVICE(dev));
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < s->nbanks; ++i){
|
for (i = 0; i < s->nbanks; ++i){
|
||||||
|
@ -356,20 +360,21 @@ static void omap_inth_reset(DeviceState *dev)
|
||||||
qemu_set_irq(s->parent_intr[1], 0);
|
qemu_set_irq(s->parent_intr[1], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int omap_intc_init(SysBusDevice *dev)
|
static int omap_intc_init(SysBusDevice *sbd)
|
||||||
{
|
{
|
||||||
struct omap_intr_handler_s *s;
|
DeviceState *dev = DEVICE(sbd);
|
||||||
s = FROM_SYSBUS(struct omap_intr_handler_s, dev);
|
struct omap_intr_handler_s *s = OMAP_INTC(dev);
|
||||||
|
|
||||||
if (!s->iclk) {
|
if (!s->iclk) {
|
||||||
hw_error("omap-intc: clk not connected\n");
|
hw_error("omap-intc: clk not connected\n");
|
||||||
}
|
}
|
||||||
s->nbanks = 1;
|
s->nbanks = 1;
|
||||||
sysbus_init_irq(dev, &s->parent_intr[0]);
|
sysbus_init_irq(sbd, &s->parent_intr[0]);
|
||||||
sysbus_init_irq(dev, &s->parent_intr[1]);
|
sysbus_init_irq(sbd, &s->parent_intr[1]);
|
||||||
qdev_init_gpio_in(&dev->qdev, omap_set_intr, s->nbanks * 32);
|
qdev_init_gpio_in(dev, omap_set_intr, s->nbanks * 32);
|
||||||
memory_region_init_io(&s->mmio, OBJECT(s), &omap_inth_mem_ops, s,
|
memory_region_init_io(&s->mmio, OBJECT(s), &omap_inth_mem_ops, s,
|
||||||
"omap-intc", s->size);
|
"omap-intc", s->size);
|
||||||
sysbus_init_mmio(dev, &s->mmio);
|
sysbus_init_mmio(sbd, &s->mmio);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,8 +396,7 @@ static void omap_intc_class_init(ObjectClass *klass, void *data)
|
||||||
|
|
||||||
static const TypeInfo omap_intc_info = {
|
static const TypeInfo omap_intc_info = {
|
||||||
.name = "omap-intc",
|
.name = "omap-intc",
|
||||||
.parent = TYPE_SYS_BUS_DEVICE,
|
.parent = TYPE_OMAP_INTC,
|
||||||
.instance_size = sizeof(struct omap_intr_handler_s),
|
|
||||||
.class_init = omap_intc_class_init,
|
.class_init = omap_intc_class_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -500,8 +504,9 @@ static void omap2_inth_write(void *opaque, hwaddr addr,
|
||||||
case 0x10: /* INTC_SYSCONFIG */
|
case 0x10: /* INTC_SYSCONFIG */
|
||||||
s->autoidle &= 4;
|
s->autoidle &= 4;
|
||||||
s->autoidle |= (value & 1) << 2;
|
s->autoidle |= (value & 1) << 2;
|
||||||
if (value & 2) /* SOFTRESET */
|
if (value & 2) { /* SOFTRESET */
|
||||||
omap_inth_reset(&s->busdev.qdev);
|
omap_inth_reset(DEVICE(s));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 0x48: /* INTC_CONTROL */
|
case 0x48: /* INTC_CONTROL */
|
||||||
|
@ -594,10 +599,11 @@ static const MemoryRegionOps omap2_inth_mem_ops = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int omap2_intc_init(SysBusDevice *dev)
|
static int omap2_intc_init(SysBusDevice *sbd)
|
||||||
{
|
{
|
||||||
struct omap_intr_handler_s *s;
|
DeviceState *dev = DEVICE(sbd);
|
||||||
s = FROM_SYSBUS(struct omap_intr_handler_s, dev);
|
struct omap_intr_handler_s *s = OMAP_INTC(dev);
|
||||||
|
|
||||||
if (!s->iclk) {
|
if (!s->iclk) {
|
||||||
hw_error("omap2-intc: iclk not connected\n");
|
hw_error("omap2-intc: iclk not connected\n");
|
||||||
}
|
}
|
||||||
|
@ -606,12 +612,12 @@ static int omap2_intc_init(SysBusDevice *dev)
|
||||||
}
|
}
|
||||||
s->level_only = 1;
|
s->level_only = 1;
|
||||||
s->nbanks = 3;
|
s->nbanks = 3;
|
||||||
sysbus_init_irq(dev, &s->parent_intr[0]);
|
sysbus_init_irq(sbd, &s->parent_intr[0]);
|
||||||
sysbus_init_irq(dev, &s->parent_intr[1]);
|
sysbus_init_irq(sbd, &s->parent_intr[1]);
|
||||||
qdev_init_gpio_in(&dev->qdev, omap_set_intr_noedge, s->nbanks * 32);
|
qdev_init_gpio_in(dev, omap_set_intr_noedge, s->nbanks * 32);
|
||||||
memory_region_init_io(&s->mmio, OBJECT(s), &omap2_inth_mem_ops, s,
|
memory_region_init_io(&s->mmio, OBJECT(s), &omap2_inth_mem_ops, s,
|
||||||
"omap2-intc", 0x1000);
|
"omap2-intc", 0x1000);
|
||||||
sysbus_init_mmio(dev, &s->mmio);
|
sysbus_init_mmio(sbd, &s->mmio);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,13 +641,20 @@ static void omap2_intc_class_init(ObjectClass *klass, void *data)
|
||||||
|
|
||||||
static const TypeInfo omap2_intc_info = {
|
static const TypeInfo omap2_intc_info = {
|
||||||
.name = "omap2-intc",
|
.name = "omap2-intc",
|
||||||
|
.parent = TYPE_OMAP_INTC,
|
||||||
|
.class_init = omap2_intc_class_init,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const TypeInfo omap_intc_type_info = {
|
||||||
|
.name = TYPE_OMAP_INTC,
|
||||||
.parent = TYPE_SYS_BUS_DEVICE,
|
.parent = TYPE_SYS_BUS_DEVICE,
|
||||||
.instance_size = sizeof(struct omap_intr_handler_s),
|
.instance_size = sizeof(struct omap_intr_handler_s),
|
||||||
.class_init = omap2_intc_class_init,
|
.abstract = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void omap_intc_register_types(void)
|
static void omap_intc_register_types(void)
|
||||||
{
|
{
|
||||||
|
type_register_static(&omap_intc_type_info);
|
||||||
type_register_static(&omap_intc_info);
|
type_register_static(&omap_intc_info);
|
||||||
type_register_static(&omap2_intc_info);
|
type_register_static(&omap2_intc_info);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue