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