]>
Commit | Line | Data |
---|---|---|
9ee6e8bb PB |
1 | /* |
2 | * ARM RealView Emulation Baseboard Interrupt Controller | |
3 | * | |
4 | * Copyright (c) 2006-2007 CodeSourcery. | |
5 | * Written by Paul Brook | |
6 | * | |
8e31bf38 | 7 | * This code is licensed under the GPL. |
9ee6e8bb PB |
8 | */ |
9 | ||
8ef94f0b | 10 | #include "qemu/osdep.h" |
da34e65c | 11 | #include "qapi/error.h" |
ce31825d | 12 | #include "hw/intc/realview_gic.h" |
fe7e8758 | 13 | |
fbbd05dc | 14 | static void realview_gic_set_irq(void *opaque, int irq, int level) |
9ee6e8bb | 15 | { |
fbbd05dc | 16 | RealViewGICState *s = (RealViewGICState *)opaque; |
612daf06 AF |
17 | |
18 | qemu_set_irq(qdev_get_gpio_in(DEVICE(&s->gic), irq), level); | |
fe7e8758 PB |
19 | } |
20 | ||
612daf06 | 21 | static void realview_gic_realize(DeviceState *dev, Error **errp) |
fe7e8758 | 22 | { |
612daf06 | 23 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); |
b09a6f7b | 24 | RealViewGICState *s = REALVIEW_GIC(dev); |
fbbd05dc | 25 | SysBusDevice *busdev; |
612daf06 | 26 | Error *err = NULL; |
a32134aa ML |
27 | /* The GICs on the RealView boards have a fixed nonconfigurable |
28 | * number of interrupt lines, so we don't need to expose this as | |
29 | * a qdev property. | |
30 | */ | |
fbbd05dc PM |
31 | int numirq = 96; |
32 | ||
612daf06 AF |
33 | qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", numirq); |
34 | object_property_set_bool(OBJECT(&s->gic), true, "realized", &err); | |
35 | if (err != NULL) { | |
36 | error_propagate(errp, err); | |
37 | return; | |
38 | } | |
39 | busdev = SYS_BUS_DEVICE(&s->gic); | |
fbbd05dc PM |
40 | |
41 | /* Pass through outbound IRQ lines from the GIC */ | |
b09a6f7b | 42 | sysbus_pass_irq(sbd, busdev); |
fbbd05dc PM |
43 | |
44 | /* Pass through inbound GPIO lines to the GIC */ | |
b09a6f7b | 45 | qdev_init_gpio_in(dev, realview_gic_set_irq, numirq - 32); |
fbbd05dc | 46 | |
fbbd05dc PM |
47 | memory_region_add_subregion(&s->container, 0, |
48 | sysbus_mmio_get_region(busdev, 1)); | |
49 | memory_region_add_subregion(&s->container, 0x1000, | |
50 | sysbus_mmio_get_region(busdev, 0)); | |
612daf06 AF |
51 | } |
52 | ||
53 | static void realview_gic_init(Object *obj) | |
54 | { | |
55 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | |
56 | RealViewGICState *s = REALVIEW_GIC(obj); | |
57 | DeviceState *gicdev; | |
58 | ||
59 | memory_region_init(&s->container, OBJECT(s), | |
60 | "realview-gic-container", 0x2000); | |
b09a6f7b | 61 | sysbus_init_mmio(sbd, &s->container); |
612daf06 AF |
62 | |
63 | object_initialize(&s->gic, sizeof(s->gic), TYPE_ARM_GIC); | |
64 | gicdev = DEVICE(&s->gic); | |
65 | qdev_set_parent_bus(gicdev, sysbus_get_default()); | |
66 | qdev_prop_set_uint32(gicdev, "num-cpu", 1); | |
9ee6e8bb | 67 | } |
fe7e8758 | 68 | |
612daf06 | 69 | static void realview_gic_class_init(ObjectClass *oc, void *data) |
999e12bb | 70 | { |
612daf06 | 71 | DeviceClass *dc = DEVICE_CLASS(oc); |
999e12bb | 72 | |
612daf06 | 73 | dc->realize = realview_gic_realize; |
999e12bb AL |
74 | } |
75 | ||
8c43a6f0 | 76 | static const TypeInfo realview_gic_info = { |
b09a6f7b | 77 | .name = TYPE_REALVIEW_GIC, |
39bffca2 AL |
78 | .parent = TYPE_SYS_BUS_DEVICE, |
79 | .instance_size = sizeof(RealViewGICState), | |
612daf06 | 80 | .instance_init = realview_gic_init, |
39bffca2 | 81 | .class_init = realview_gic_class_init, |
999e12bb AL |
82 | }; |
83 | ||
83f7d43a | 84 | static void realview_gic_register_types(void) |
fe7e8758 | 85 | { |
39bffca2 | 86 | type_register_static(&realview_gic_info); |
fe7e8758 PB |
87 | } |
88 | ||
83f7d43a | 89 | type_init(realview_gic_register_types) |