2 * ARM RealView Emulation Baseboard Interrupt Controller
4 * Copyright (c) 2006-2007 CodeSourcery.
5 * Written by Paul Brook
7 * This code is licensed under the GPL.
10 #include "hw/sysbus.h"
12 #define TYPE_REALVIEW_GIC "realview_gic"
13 #define REALVIEW_GIC(obj) \
14 OBJECT_CHECK(RealViewGICState, (obj), TYPE_REALVIEW_GIC)
17 SysBusDevice parent_obj
;
20 MemoryRegion container
;
23 static void realview_gic_set_irq(void *opaque
, int irq
, int level
)
25 RealViewGICState
*s
= (RealViewGICState
*)opaque
;
26 qemu_set_irq(qdev_get_gpio_in(s
->gic
, irq
), level
);
29 static int realview_gic_init(SysBusDevice
*sbd
)
31 DeviceState
*dev
= DEVICE(sbd
);
32 RealViewGICState
*s
= REALVIEW_GIC(dev
);
34 /* The GICs on the RealView boards have a fixed nonconfigurable
35 * number of interrupt lines, so we don't need to expose this as
40 s
->gic
= qdev_create(NULL
, "arm_gic");
41 qdev_prop_set_uint32(s
->gic
, "num-cpu", 1);
42 qdev_prop_set_uint32(s
->gic
, "num-irq", numirq
);
43 qdev_init_nofail(s
->gic
);
44 busdev
= SYS_BUS_DEVICE(s
->gic
);
46 /* Pass through outbound IRQ lines from the GIC */
47 sysbus_pass_irq(sbd
, busdev
);
49 /* Pass through inbound GPIO lines to the GIC */
50 qdev_init_gpio_in(dev
, realview_gic_set_irq
, numirq
- 32);
52 memory_region_init(&s
->container
, OBJECT(s
),
53 "realview-gic-container", 0x2000);
54 memory_region_add_subregion(&s
->container
, 0,
55 sysbus_mmio_get_region(busdev
, 1));
56 memory_region_add_subregion(&s
->container
, 0x1000,
57 sysbus_mmio_get_region(busdev
, 0));
58 sysbus_init_mmio(sbd
, &s
->container
);
62 static void realview_gic_class_init(ObjectClass
*klass
, void *data
)
64 SysBusDeviceClass
*sdc
= SYS_BUS_DEVICE_CLASS(klass
);
66 sdc
->init
= realview_gic_init
;
69 static const TypeInfo realview_gic_info
= {
70 .name
= TYPE_REALVIEW_GIC
,
71 .parent
= TYPE_SYS_BUS_DEVICE
,
72 .instance_size
= sizeof(RealViewGICState
),
73 .class_init
= realview_gic_class_init
,
76 static void realview_gic_register_types(void)
78 type_register_static(&realview_gic_info
);
81 type_init(realview_gic_register_types
)