]>
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 | ||
83c9f4ca | 10 | #include "hw/sysbus.h" |
9ee6e8bb | 11 | |
fe7e8758 | 12 | typedef struct { |
fbbd05dc PM |
13 | SysBusDevice busdev; |
14 | DeviceState *gic; | |
755c0802 | 15 | MemoryRegion container; |
fe7e8758 PB |
16 | } RealViewGICState; |
17 | ||
fbbd05dc | 18 | static void realview_gic_set_irq(void *opaque, int irq, int level) |
9ee6e8bb | 19 | { |
fbbd05dc PM |
20 | RealViewGICState *s = (RealViewGICState *)opaque; |
21 | qemu_set_irq(qdev_get_gpio_in(s->gic, irq), level); | |
fe7e8758 PB |
22 | } |
23 | ||
81a322d4 | 24 | static int realview_gic_init(SysBusDevice *dev) |
fe7e8758 | 25 | { |
fbbd05dc PM |
26 | RealViewGICState *s = FROM_SYSBUS(RealViewGICState, dev); |
27 | SysBusDevice *busdev; | |
a32134aa ML |
28 | /* The GICs on the RealView boards have a fixed nonconfigurable |
29 | * number of interrupt lines, so we don't need to expose this as | |
30 | * a qdev property. | |
31 | */ | |
fbbd05dc PM |
32 | int numirq = 96; |
33 | ||
34 | s->gic = qdev_create(NULL, "arm_gic"); | |
35 | qdev_prop_set_uint32(s->gic, "num-cpu", 1); | |
36 | qdev_prop_set_uint32(s->gic, "num-irq", numirq); | |
37 | qdev_init_nofail(s->gic); | |
1356b98d | 38 | busdev = SYS_BUS_DEVICE(s->gic); |
fbbd05dc PM |
39 | |
40 | /* Pass through outbound IRQ lines from the GIC */ | |
41 | sysbus_pass_irq(dev, busdev); | |
42 | ||
43 | /* Pass through inbound GPIO lines to the GIC */ | |
44 | qdev_init_gpio_in(&s->busdev.qdev, realview_gic_set_irq, numirq - 32); | |
45 | ||
1437c94b PB |
46 | memory_region_init(&s->container, OBJECT(s), |
47 | "realview-gic-container", 0x2000); | |
fbbd05dc PM |
48 | memory_region_add_subregion(&s->container, 0, |
49 | sysbus_mmio_get_region(busdev, 1)); | |
50 | memory_region_add_subregion(&s->container, 0x1000, | |
51 | sysbus_mmio_get_region(busdev, 0)); | |
750ecd44 | 52 | sysbus_init_mmio(dev, &s->container); |
81a322d4 | 53 | return 0; |
9ee6e8bb | 54 | } |
fe7e8758 | 55 | |
999e12bb AL |
56 | static void realview_gic_class_init(ObjectClass *klass, void *data) |
57 | { | |
58 | SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); | |
59 | ||
60 | sdc->init = realview_gic_init; | |
61 | } | |
62 | ||
8c43a6f0 | 63 | static const TypeInfo realview_gic_info = { |
39bffca2 AL |
64 | .name = "realview_gic", |
65 | .parent = TYPE_SYS_BUS_DEVICE, | |
66 | .instance_size = sizeof(RealViewGICState), | |
67 | .class_init = realview_gic_class_init, | |
999e12bb AL |
68 | }; |
69 | ||
83f7d43a | 70 | static void realview_gic_register_types(void) |
fe7e8758 | 71 | { |
39bffca2 | 72 | type_register_static(&realview_gic_info); |
fe7e8758 PB |
73 | } |
74 | ||
83f7d43a | 75 | type_init(realview_gic_register_types) |