pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * QEMU Uninorth PCI host (for all Mac99 and newer machines) |
| 3 | * |
| 4 | * Copyright (c) 2006 Fabrice Bellard |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 5 | * |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to deal |
| 8 | * in the Software without restriction, including without limitation the rights |
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | * copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | * THE SOFTWARE. |
| 23 | */ |
Markus Armbruster | 0b8fa32 | 2019-05-23 16:35:07 +0200 | [diff] [blame] | 24 | |
Peter Maydell | 0d75590 | 2016-01-26 18:16:58 +0000 | [diff] [blame] | 25 | #include "qemu/osdep.h" |
Markus Armbruster | 64552b6 | 2019-08-12 07:23:42 +0200 | [diff] [blame] | 26 | #include "hw/irq.h" |
Markus Armbruster | a27bd6c | 2019-08-12 07:23:51 +0200 | [diff] [blame] | 27 | #include "hw/qdev-properties.h" |
Markus Armbruster | 0b8fa32 | 2019-05-23 16:35:07 +0200 | [diff] [blame] | 28 | #include "qemu/module.h" |
Markus Armbruster | edf5ca5 | 2022-12-22 11:03:28 +0100 | [diff] [blame] | 29 | #include "hw/pci/pci_device.h" |
Paolo Bonzini | 83c9f4c | 2013-02-04 15:40:22 +0100 | [diff] [blame] | 30 | #include "hw/pci/pci_host.h" |
Mark Cave-Ayland | 5d2eaa0 | 2018-03-06 20:30:49 +0000 | [diff] [blame] | 31 | #include "hw/pci-host/uninorth.h" |
Mark Cave-Ayland | 0b0c5e9 | 2018-01-26 09:20:28 +0000 | [diff] [blame] | 32 | #include "trace.h" |
blueswir1 | f390238 | 2009-02-05 20:22:07 +0000 | [diff] [blame] | 33 | |
pbrook | d2b5931 | 2006-09-24 00:16:34 +0000 | [diff] [blame] | 34 | static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num) |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 35 | { |
Benjamin Herrenschmidt | 39d97e1 | 2016-11-21 00:12:31 +1000 | [diff] [blame] | 36 | return (irq_num + (pci_dev->devfn >> 3)) & 3; |
pbrook | d2b5931 | 2006-09-24 00:16:34 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Juan Quintela | 5d4e84c | 2009-08-28 15:28:17 +0200 | [diff] [blame] | 39 | static void pci_unin_set_irq(void *opaque, int irq_num, int level) |
pbrook | d2b5931 | 2006-09-24 00:16:34 +0000 | [diff] [blame] | 40 | { |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 41 | UNINHostState *s = opaque; |
Juan Quintela | 5d4e84c | 2009-08-28 15:28:17 +0200 | [diff] [blame] | 42 | |
Mark Cave-Ayland | 40a0deb | 2020-10-13 12:49:22 +0100 | [diff] [blame] | 43 | trace_unin_set_irq(irq_num, level); |
Mark Cave-Ayland | e7755cc | 2018-03-06 20:30:58 +0000 | [diff] [blame] | 44 | qemu_set_irq(s->irqs[irq_num], level); |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 47 | static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr) |
| 48 | { |
| 49 | uint32_t retval; |
| 50 | |
| 51 | if (reg & (1u << 31)) { |
| 52 | /* XXX OpenBIOS compatibility hack */ |
| 53 | retval = reg | (addr & 3); |
| 54 | } else if (reg & 1) { |
| 55 | /* CFA1 style */ |
| 56 | retval = (reg & ~7u) | (addr & 7); |
| 57 | } else { |
| 58 | uint32_t slot, func; |
| 59 | |
| 60 | /* Grab CFA0 style values */ |
Stefan Hajnoczi | 5863d37 | 2015-03-23 15:29:25 +0000 | [diff] [blame] | 61 | slot = ctz32(reg & 0xfffff800); |
| 62 | if (slot == 32) { |
| 63 | slot = -1; /* XXX: should this be 0? */ |
| 64 | } |
Philippe Mathieu-Daudé | d08b9c1 | 2020-10-11 17:22:04 +0200 | [diff] [blame] | 65 | func = PCI_FUNC(reg >> 8); |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 66 | |
| 67 | /* ... and then convert them to x86 format */ |
| 68 | /* config pointer */ |
| 69 | retval = (reg & (0xff - 7)) | (addr & 7); |
Philippe Mathieu-Daudé | 4934e47 | 2020-10-12 08:36:41 +0200 | [diff] [blame] | 70 | /* slot, fn */ |
| 71 | retval |= PCI_DEVFN(slot, func) << 8; |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 72 | } |
| 73 | |
Mark Cave-Ayland | 0b0c5e9 | 2018-01-26 09:20:28 +0000 | [diff] [blame] | 74 | trace_unin_get_config_reg(reg, addr, retval); |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 75 | |
| 76 | return retval; |
| 77 | } |
| 78 | |
Avi Kivity | a8170e5 | 2012-10-23 12:30:10 +0200 | [diff] [blame] | 79 | static void unin_data_write(void *opaque, hwaddr addr, |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 80 | uint64_t val, unsigned len) |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 81 | { |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 82 | UNINHostState *s = opaque; |
Andreas Färber | 67c332f | 2012-08-20 19:08:09 +0200 | [diff] [blame] | 83 | PCIHostState *phb = PCI_HOST_BRIDGE(s); |
Mark Cave-Ayland | 0b0c5e9 | 2018-01-26 09:20:28 +0000 | [diff] [blame] | 84 | trace_unin_data_write(addr, len, val); |
Andreas Färber | 67c332f | 2012-08-20 19:08:09 +0200 | [diff] [blame] | 85 | pci_data_write(phb->bus, |
| 86 | unin_get_config_reg(phb->config_reg, addr), |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 87 | val, len); |
| 88 | } |
| 89 | |
Avi Kivity | a8170e5 | 2012-10-23 12:30:10 +0200 | [diff] [blame] | 90 | static uint64_t unin_data_read(void *opaque, hwaddr addr, |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 91 | unsigned len) |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 92 | { |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 93 | UNINHostState *s = opaque; |
Andreas Färber | 67c332f | 2012-08-20 19:08:09 +0200 | [diff] [blame] | 94 | PCIHostState *phb = PCI_HOST_BRIDGE(s); |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 95 | uint32_t val; |
| 96 | |
Andreas Färber | 67c332f | 2012-08-20 19:08:09 +0200 | [diff] [blame] | 97 | val = pci_data_read(phb->bus, |
| 98 | unin_get_config_reg(phb->config_reg, addr), |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 99 | len); |
Mark Cave-Ayland | 0b0c5e9 | 2018-01-26 09:20:28 +0000 | [diff] [blame] | 100 | trace_unin_data_read(addr, len, val); |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 101 | return val; |
| 102 | } |
| 103 | |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 104 | static const MemoryRegionOps unin_data_ops = { |
| 105 | .read = unin_data_read, |
| 106 | .write = unin_data_write, |
| 107 | .endianness = DEVICE_LITTLE_ENDIAN, |
| 108 | }; |
| 109 | |
Mark Cave-Ayland | 03756c8 | 2018-08-29 17:59:10 +0100 | [diff] [blame] | 110 | static char *pci_unin_main_ofw_unit_address(const SysBusDevice *dev) |
| 111 | { |
| 112 | UNINHostState *s = UNI_NORTH_PCI_HOST_BRIDGE(dev); |
| 113 | |
| 114 | return g_strdup_printf("%x", s->ofw_addr); |
| 115 | } |
| 116 | |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 117 | static void pci_unin_main_realize(DeviceState *dev, Error **errp) |
| 118 | { |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 119 | UNINHostState *s = UNI_NORTH_PCI_HOST_BRIDGE(dev); |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 120 | PCIHostState *h = PCI_HOST_BRIDGE(dev); |
| 121 | |
| 122 | h->bus = pci_register_root_bus(dev, NULL, |
| 123 | pci_unin_set_irq, pci_unin_map_irq, |
Mark Cave-Ayland | e7755cc | 2018-03-06 20:30:58 +0000 | [diff] [blame] | 124 | s, |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 125 | &s->pci_mmio, |
Mark Cave-Ayland | e226efb | 2018-03-06 20:30:59 +0000 | [diff] [blame] | 126 | &s->pci_io, |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 127 | PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); |
| 128 | |
Mark Cave-Ayland | c1d66d3 | 2018-03-06 20:30:54 +0000 | [diff] [blame] | 129 | pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-pci"); |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 130 | |
Igor Mammedov | b1fbf24 | 2022-11-29 11:13:40 +0100 | [diff] [blame] | 131 | /* |
| 132 | * DEC 21154 bridge was unused for many years, this comment is |
| 133 | * a placeholder for whoever wishes to resurrect it |
| 134 | */ |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 135 | } |
| 136 | |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 137 | static void pci_unin_main_init(Object *obj) |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 138 | { |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 139 | UNINHostState *s = UNI_NORTH_PCI_HOST_BRIDGE(obj); |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 140 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
| 141 | PCIHostState *h = PCI_HOST_BRIDGE(obj); |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 142 | |
| 143 | /* Use values found on a real PowerMac */ |
| 144 | /* Uninorth main bus */ |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 145 | memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, |
Mark Cave-Ayland | 132e990 | 2018-03-06 20:30:51 +0000 | [diff] [blame] | 146 | obj, "unin-pci-conf-idx", 0x1000); |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 147 | memory_region_init_io(&h->data_mem, OBJECT(h), &unin_data_ops, obj, |
Mark Cave-Ayland | 132e990 | 2018-03-06 20:30:51 +0000 | [diff] [blame] | 148 | "unin-pci-conf-data", 0x1000); |
| 149 | |
| 150 | memory_region_init(&s->pci_mmio, OBJECT(s), "unin-pci-mmio", |
| 151 | 0x100000000ULL); |
Mark Cave-Ayland | e226efb | 2018-03-06 20:30:59 +0000 | [diff] [blame] | 152 | memory_region_init_io(&s->pci_io, OBJECT(s), &unassigned_io_ops, obj, |
| 153 | "unin-pci-isa-mmio", 0x00800000); |
Mark Cave-Ayland | 132e990 | 2018-03-06 20:30:51 +0000 | [diff] [blame] | 154 | |
Mark Cave-Ayland | 7b19318 | 2018-03-06 20:30:56 +0000 | [diff] [blame] | 155 | memory_region_init_alias(&s->pci_hole, OBJECT(s), |
| 156 | "unin-pci-hole", &s->pci_mmio, |
| 157 | 0x80000000ULL, 0x10000000ULL); |
| 158 | |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 159 | sysbus_init_mmio(sbd, &h->conf_mem); |
| 160 | sysbus_init_mmio(sbd, &h->data_mem); |
Mark Cave-Ayland | 7b19318 | 2018-03-06 20:30:56 +0000 | [diff] [blame] | 161 | sysbus_init_mmio(sbd, &s->pci_hole); |
Mark Cave-Ayland | e226efb | 2018-03-06 20:30:59 +0000 | [diff] [blame] | 162 | sysbus_init_mmio(sbd, &s->pci_io); |
Mark Cave-Ayland | 40a0deb | 2020-10-13 12:49:22 +0100 | [diff] [blame] | 163 | |
| 164 | qdev_init_gpio_out(DEVICE(obj), s->irqs, ARRAY_SIZE(s->irqs)); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 165 | } |
| 166 | |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 167 | static void pci_u3_agp_realize(DeviceState *dev, Error **errp) |
| 168 | { |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 169 | UNINHostState *s = U3_AGP_HOST_BRIDGE(dev); |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 170 | PCIHostState *h = PCI_HOST_BRIDGE(dev); |
| 171 | |
| 172 | h->bus = pci_register_root_bus(dev, NULL, |
| 173 | pci_unin_set_irq, pci_unin_map_irq, |
Mark Cave-Ayland | e7755cc | 2018-03-06 20:30:58 +0000 | [diff] [blame] | 174 | s, |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 175 | &s->pci_mmio, |
Mark Cave-Ayland | e226efb | 2018-03-06 20:30:59 +0000 | [diff] [blame] | 176 | &s->pci_io, |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 177 | PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); |
| 178 | |
| 179 | pci_create_simple(h->bus, PCI_DEVFN(11, 0), "u3-agp"); |
| 180 | } |
| 181 | |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 182 | static void pci_u3_agp_init(Object *obj) |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 183 | { |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 184 | UNINHostState *s = U3_AGP_HOST_BRIDGE(obj); |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 185 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
| 186 | PCIHostState *h = PCI_HOST_BRIDGE(obj); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 187 | |
| 188 | /* Uninorth U3 AGP bus */ |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 189 | memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, |
Mark Cave-Ayland | 132e990 | 2018-03-06 20:30:51 +0000 | [diff] [blame] | 190 | obj, "unin-pci-conf-idx", 0x1000); |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 191 | memory_region_init_io(&h->data_mem, OBJECT(h), &unin_data_ops, obj, |
Mark Cave-Ayland | 132e990 | 2018-03-06 20:30:51 +0000 | [diff] [blame] | 192 | "unin-pci-conf-data", 0x1000); |
| 193 | |
| 194 | memory_region_init(&s->pci_mmio, OBJECT(s), "unin-pci-mmio", |
| 195 | 0x100000000ULL); |
Mark Cave-Ayland | e226efb | 2018-03-06 20:30:59 +0000 | [diff] [blame] | 196 | memory_region_init_io(&s->pci_io, OBJECT(s), &unassigned_io_ops, obj, |
| 197 | "unin-pci-isa-mmio", 0x00800000); |
Mark Cave-Ayland | 132e990 | 2018-03-06 20:30:51 +0000 | [diff] [blame] | 198 | |
Mark Cave-Ayland | 8ce3f74 | 2018-03-06 20:30:57 +0000 | [diff] [blame] | 199 | memory_region_init_alias(&s->pci_hole, OBJECT(s), |
| 200 | "unin-pci-hole", &s->pci_mmio, |
| 201 | 0x80000000ULL, 0x70000000ULL); |
| 202 | |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 203 | sysbus_init_mmio(sbd, &h->conf_mem); |
| 204 | sysbus_init_mmio(sbd, &h->data_mem); |
Mark Cave-Ayland | 8ce3f74 | 2018-03-06 20:30:57 +0000 | [diff] [blame] | 205 | sysbus_init_mmio(sbd, &s->pci_hole); |
Mark Cave-Ayland | e226efb | 2018-03-06 20:30:59 +0000 | [diff] [blame] | 206 | sysbus_init_mmio(sbd, &s->pci_io); |
Mark Cave-Ayland | 40a0deb | 2020-10-13 12:49:22 +0100 | [diff] [blame] | 207 | |
| 208 | qdev_init_gpio_out(DEVICE(obj), s->irqs, ARRAY_SIZE(s->irqs)); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 209 | } |
| 210 | |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 211 | static void pci_unin_agp_realize(DeviceState *dev, Error **errp) |
| 212 | { |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 213 | UNINHostState *s = UNI_NORTH_AGP_HOST_BRIDGE(dev); |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 214 | PCIHostState *h = PCI_HOST_BRIDGE(dev); |
| 215 | |
| 216 | h->bus = pci_register_root_bus(dev, NULL, |
| 217 | pci_unin_set_irq, pci_unin_map_irq, |
Mark Cave-Ayland | e7755cc | 2018-03-06 20:30:58 +0000 | [diff] [blame] | 218 | s, |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 219 | &s->pci_mmio, |
Mark Cave-Ayland | e226efb | 2018-03-06 20:30:59 +0000 | [diff] [blame] | 220 | &s->pci_io, |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 221 | PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); |
Mark Cave-Ayland | c1d66d3 | 2018-03-06 20:30:54 +0000 | [diff] [blame] | 222 | |
| 223 | pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-agp"); |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 224 | } |
| 225 | |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 226 | static void pci_unin_agp_init(Object *obj) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 227 | { |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 228 | UNINHostState *s = UNI_NORTH_AGP_HOST_BRIDGE(obj); |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 229 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
| 230 | PCIHostState *h = PCI_HOST_BRIDGE(obj); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 231 | |
| 232 | /* Uninorth AGP bus */ |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 233 | memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, |
Mark Cave-Ayland | 132e990 | 2018-03-06 20:30:51 +0000 | [diff] [blame] | 234 | obj, "unin-agp-conf-idx", 0x1000); |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 235 | memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops, |
Mark Cave-Ayland | 132e990 | 2018-03-06 20:30:51 +0000 | [diff] [blame] | 236 | obj, "unin-agp-conf-data", 0x1000); |
Mark Cave-Ayland | e7755cc | 2018-03-06 20:30:58 +0000 | [diff] [blame] | 237 | |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 238 | sysbus_init_mmio(sbd, &h->conf_mem); |
| 239 | sysbus_init_mmio(sbd, &h->data_mem); |
Mark Cave-Ayland | 40a0deb | 2020-10-13 12:49:22 +0100 | [diff] [blame] | 240 | |
| 241 | qdev_init_gpio_out(DEVICE(obj), s->irqs, ARRAY_SIZE(s->irqs)); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 242 | } |
| 243 | |
Mark Cave-Ayland | 1ff861d | 2018-03-06 20:30:55 +0000 | [diff] [blame] | 244 | static void pci_unin_internal_realize(DeviceState *dev, Error **errp) |
| 245 | { |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 246 | UNINHostState *s = UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE(dev); |
Mark Cave-Ayland | 1ff861d | 2018-03-06 20:30:55 +0000 | [diff] [blame] | 247 | PCIHostState *h = PCI_HOST_BRIDGE(dev); |
| 248 | |
| 249 | h->bus = pci_register_root_bus(dev, NULL, |
| 250 | pci_unin_set_irq, pci_unin_map_irq, |
Mark Cave-Ayland | e7755cc | 2018-03-06 20:30:58 +0000 | [diff] [blame] | 251 | s, |
Mark Cave-Ayland | 1ff861d | 2018-03-06 20:30:55 +0000 | [diff] [blame] | 252 | &s->pci_mmio, |
Mark Cave-Ayland | e226efb | 2018-03-06 20:30:59 +0000 | [diff] [blame] | 253 | &s->pci_io, |
Mark Cave-Ayland | 1ff861d | 2018-03-06 20:30:55 +0000 | [diff] [blame] | 254 | PCI_DEVFN(14, 0), 4, TYPE_PCI_BUS); |
| 255 | |
| 256 | pci_create_simple(h->bus, PCI_DEVFN(14, 0), "uni-north-internal-pci"); |
| 257 | } |
| 258 | |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 259 | static void pci_unin_internal_init(Object *obj) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 260 | { |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 261 | UNINHostState *s = UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE(obj); |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 262 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
| 263 | PCIHostState *h = PCI_HOST_BRIDGE(obj); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 264 | |
| 265 | /* Uninorth internal bus */ |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 266 | memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, |
Mark Cave-Ayland | 132e990 | 2018-03-06 20:30:51 +0000 | [diff] [blame] | 267 | obj, "unin-pci-conf-idx", 0x1000); |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 268 | memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops, |
Mark Cave-Ayland | 132e990 | 2018-03-06 20:30:51 +0000 | [diff] [blame] | 269 | obj, "unin-pci-conf-data", 0x1000); |
Mark Cave-Ayland | e7755cc | 2018-03-06 20:30:58 +0000 | [diff] [blame] | 270 | |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 271 | sysbus_init_mmio(sbd, &h->conf_mem); |
| 272 | sysbus_init_mmio(sbd, &h->data_mem); |
Mark Cave-Ayland | 40a0deb | 2020-10-13 12:49:22 +0100 | [diff] [blame] | 273 | |
| 274 | qdev_init_gpio_out(DEVICE(obj), s->irqs, ARRAY_SIZE(s->irqs)); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 275 | } |
| 276 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 277 | static void unin_main_pci_host_realize(PCIDevice *d, Error **errp) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 278 | { |
Philippe Mathieu-Daudé | 8a8c9c3 | 2023-01-05 18:37:02 +0100 | [diff] [blame] | 279 | d->config[PCI_CACHE_LINE_SIZE] = 0x08; |
| 280 | d->config[PCI_LATENCY_TIMER] = 0x10; |
| 281 | d->config[PCI_CAPABILITY_LIST] = 0x00; |
Mark Cave-Ayland | 4d309c9 | 2018-03-06 20:30:45 +0000 | [diff] [blame] | 282 | |
Programmingkid | 98ae3b2 | 2016-01-22 11:09:23 -0500 | [diff] [blame] | 283 | /* |
| 284 | * Set kMacRISCPCIAddressSelect (0x48) register to indicate PCI |
| 285 | * memory space with base 0x80000000, size 0x10000000 for Apple's |
| 286 | * AppleMacRiscPCI driver |
| 287 | */ |
| 288 | d->config[0x48] = 0x0; |
| 289 | d->config[0x49] = 0x0; |
| 290 | d->config[0x4a] = 0x0; |
| 291 | d->config[0x4b] = 0x1; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 292 | } |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 293 | |
Mark Cave-Ayland | c1d66d3 | 2018-03-06 20:30:54 +0000 | [diff] [blame] | 294 | static void unin_agp_pci_host_realize(PCIDevice *d, Error **errp) |
| 295 | { |
Philippe Mathieu-Daudé | 8a8c9c3 | 2023-01-05 18:37:02 +0100 | [diff] [blame] | 296 | d->config[PCI_CACHE_LINE_SIZE] = 0x08; |
| 297 | d->config[PCI_LATENCY_TIMER] = 0x10; |
| 298 | /* d->config[PCI_CAPABILITY_LIST] = 0x80; */ |
Mark Cave-Ayland | c1d66d3 | 2018-03-06 20:30:54 +0000 | [diff] [blame] | 299 | } |
| 300 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 301 | static void u3_agp_pci_host_realize(PCIDevice *d, Error **errp) |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 302 | { |
Philippe Mathieu-Daudé | 8a8c9c3 | 2023-01-05 18:37:02 +0100 | [diff] [blame] | 303 | d->config[PCI_CACHE_LINE_SIZE] = 0x08; |
| 304 | d->config[PCI_LATENCY_TIMER] = 0x10; |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 305 | } |
| 306 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 307 | static void unin_internal_pci_host_realize(PCIDevice *d, Error **errp) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 308 | { |
Philippe Mathieu-Daudé | 8a8c9c3 | 2023-01-05 18:37:02 +0100 | [diff] [blame] | 309 | d->config[PCI_CACHE_LINE_SIZE] = 0x08; |
| 310 | d->config[PCI_LATENCY_TIMER] = 0x10; |
| 311 | d->config[PCI_CAPABILITY_LIST] = 0x00; |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 312 | } |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 313 | |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 314 | static void unin_main_pci_host_class_init(ObjectClass *klass, void *data) |
| 315 | { |
| 316 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 317 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 318 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 319 | k->realize = unin_main_pci_host_realize; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 320 | k->vendor_id = PCI_VENDOR_ID_APPLE; |
| 321 | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_PCI; |
| 322 | k->revision = 0x00; |
| 323 | k->class_id = PCI_CLASS_BRIDGE_HOST; |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 324 | /* |
| 325 | * PCI-facing part of the host bridge, not usable without the |
| 326 | * host-facing part, which can't be device_add'ed, yet. |
| 327 | */ |
Eduardo Habkost | e90f2a8 | 2017-05-03 17:35:44 -0300 | [diff] [blame] | 328 | dc->user_creatable = false; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 329 | } |
| 330 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 331 | static const TypeInfo unin_main_pci_host_info = { |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 332 | .name = "uni-north-pci", |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 333 | .parent = TYPE_PCI_DEVICE, |
| 334 | .instance_size = sizeof(PCIDevice), |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 335 | .class_init = unin_main_pci_host_class_init, |
Eduardo Habkost | fd3b02c | 2017-09-27 16:56:34 -0300 | [diff] [blame] | 336 | .interfaces = (InterfaceInfo[]) { |
| 337 | { INTERFACE_CONVENTIONAL_PCI_DEVICE }, |
| 338 | { }, |
| 339 | }, |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 340 | }; |
| 341 | |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 342 | static void u3_agp_pci_host_class_init(ObjectClass *klass, void *data) |
| 343 | { |
| 344 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 345 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 346 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 347 | k->realize = u3_agp_pci_host_realize; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 348 | k->vendor_id = PCI_VENDOR_ID_APPLE; |
| 349 | k->device_id = PCI_DEVICE_ID_APPLE_U3_AGP; |
| 350 | k->revision = 0x00; |
| 351 | k->class_id = PCI_CLASS_BRIDGE_HOST; |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 352 | /* |
| 353 | * PCI-facing part of the host bridge, not usable without the |
| 354 | * host-facing part, which can't be device_add'ed, yet. |
| 355 | */ |
Eduardo Habkost | e90f2a8 | 2017-05-03 17:35:44 -0300 | [diff] [blame] | 356 | dc->user_creatable = false; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 357 | } |
| 358 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 359 | static const TypeInfo u3_agp_pci_host_info = { |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 360 | .name = "u3-agp", |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 361 | .parent = TYPE_PCI_DEVICE, |
| 362 | .instance_size = sizeof(PCIDevice), |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 363 | .class_init = u3_agp_pci_host_class_init, |
Eduardo Habkost | fd3b02c | 2017-09-27 16:56:34 -0300 | [diff] [blame] | 364 | .interfaces = (InterfaceInfo[]) { |
| 365 | { INTERFACE_CONVENTIONAL_PCI_DEVICE }, |
| 366 | { }, |
| 367 | }, |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 368 | }; |
| 369 | |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 370 | static void unin_agp_pci_host_class_init(ObjectClass *klass, void *data) |
| 371 | { |
| 372 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 373 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 374 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 375 | k->realize = unin_agp_pci_host_realize; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 376 | k->vendor_id = PCI_VENDOR_ID_APPLE; |
| 377 | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_AGP; |
| 378 | k->revision = 0x00; |
| 379 | k->class_id = PCI_CLASS_BRIDGE_HOST; |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 380 | /* |
| 381 | * PCI-facing part of the host bridge, not usable without the |
| 382 | * host-facing part, which can't be device_add'ed, yet. |
| 383 | */ |
Eduardo Habkost | e90f2a8 | 2017-05-03 17:35:44 -0300 | [diff] [blame] | 384 | dc->user_creatable = false; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 385 | } |
| 386 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 387 | static const TypeInfo unin_agp_pci_host_info = { |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 388 | .name = "uni-north-agp", |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 389 | .parent = TYPE_PCI_DEVICE, |
| 390 | .instance_size = sizeof(PCIDevice), |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 391 | .class_init = unin_agp_pci_host_class_init, |
Eduardo Habkost | fd3b02c | 2017-09-27 16:56:34 -0300 | [diff] [blame] | 392 | .interfaces = (InterfaceInfo[]) { |
| 393 | { INTERFACE_CONVENTIONAL_PCI_DEVICE }, |
| 394 | { }, |
| 395 | }, |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 396 | }; |
| 397 | |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 398 | static void unin_internal_pci_host_class_init(ObjectClass *klass, void *data) |
| 399 | { |
| 400 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 401 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 402 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 403 | k->realize = unin_internal_pci_host_realize; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 404 | k->vendor_id = PCI_VENDOR_ID_APPLE; |
| 405 | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_I_PCI; |
| 406 | k->revision = 0x00; |
| 407 | k->class_id = PCI_CLASS_BRIDGE_HOST; |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 408 | /* |
| 409 | * PCI-facing part of the host bridge, not usable without the |
| 410 | * host-facing part, which can't be device_add'ed, yet. |
| 411 | */ |
Eduardo Habkost | e90f2a8 | 2017-05-03 17:35:44 -0300 | [diff] [blame] | 412 | dc->user_creatable = false; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 413 | } |
| 414 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 415 | static const TypeInfo unin_internal_pci_host_info = { |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 416 | .name = "uni-north-internal-pci", |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 417 | .parent = TYPE_PCI_DEVICE, |
| 418 | .instance_size = sizeof(PCIDevice), |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 419 | .class_init = unin_internal_pci_host_class_init, |
Eduardo Habkost | fd3b02c | 2017-09-27 16:56:34 -0300 | [diff] [blame] | 420 | .interfaces = (InterfaceInfo[]) { |
| 421 | { INTERFACE_CONVENTIONAL_PCI_DEVICE }, |
| 422 | { }, |
| 423 | }, |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 424 | }; |
| 425 | |
Mark Cave-Ayland | 03756c8 | 2018-08-29 17:59:10 +0100 | [diff] [blame] | 426 | static Property pci_unin_main_pci_host_props[] = { |
| 427 | DEFINE_PROP_UINT32("ofw-addr", UNINHostState, ofw_addr, -1), |
| 428 | DEFINE_PROP_END_OF_LIST() |
| 429 | }; |
| 430 | |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 431 | static void pci_unin_main_class_init(ObjectClass *klass, void *data) |
| 432 | { |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 433 | DeviceClass *dc = DEVICE_CLASS(klass); |
Mark Cave-Ayland | 03756c8 | 2018-08-29 17:59:10 +0100 | [diff] [blame] | 434 | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 435 | |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 436 | dc->realize = pci_unin_main_realize; |
Marc-André Lureau | 4f67d30 | 2020-01-10 19:30:32 +0400 | [diff] [blame] | 437 | device_class_set_props(dc, pci_unin_main_pci_host_props); |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 438 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
Mark Cave-Ayland | 03756c8 | 2018-08-29 17:59:10 +0100 | [diff] [blame] | 439 | dc->fw_name = "pci"; |
| 440 | sbc->explicit_ofw_unit_address = pci_unin_main_ofw_unit_address; |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 441 | } |
| 442 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 443 | static const TypeInfo pci_unin_main_info = { |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 444 | .name = TYPE_UNI_NORTH_PCI_HOST_BRIDGE, |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 445 | .parent = TYPE_PCI_HOST_BRIDGE, |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 446 | .instance_size = sizeof(UNINHostState), |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 447 | .instance_init = pci_unin_main_init, |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 448 | .class_init = pci_unin_main_class_init, |
Andreas Färber | 70f9c98 | 2012-01-19 07:40:16 +0000 | [diff] [blame] | 449 | }; |
| 450 | |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 451 | static void pci_u3_agp_class_init(ObjectClass *klass, void *data) |
| 452 | { |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 453 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 454 | |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 455 | dc->realize = pci_u3_agp_realize; |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 456 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 457 | } |
| 458 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 459 | static const TypeInfo pci_u3_agp_info = { |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 460 | .name = TYPE_U3_AGP_HOST_BRIDGE, |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 461 | .parent = TYPE_PCI_HOST_BRIDGE, |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 462 | .instance_size = sizeof(UNINHostState), |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 463 | .instance_init = pci_u3_agp_init, |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 464 | .class_init = pci_u3_agp_class_init, |
Andreas Färber | 70f9c98 | 2012-01-19 07:40:16 +0000 | [diff] [blame] | 465 | }; |
| 466 | |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 467 | static void pci_unin_agp_class_init(ObjectClass *klass, void *data) |
| 468 | { |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 469 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 470 | |
Mark Cave-Ayland | 32cde61 | 2018-03-06 20:30:53 +0000 | [diff] [blame] | 471 | dc->realize = pci_unin_agp_realize; |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 472 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 473 | } |
| 474 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 475 | static const TypeInfo pci_unin_agp_info = { |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 476 | .name = TYPE_UNI_NORTH_AGP_HOST_BRIDGE, |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 477 | .parent = TYPE_PCI_HOST_BRIDGE, |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 478 | .instance_size = sizeof(UNINHostState), |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 479 | .instance_init = pci_unin_agp_init, |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 480 | .class_init = pci_unin_agp_class_init, |
Andreas Färber | 70f9c98 | 2012-01-19 07:40:16 +0000 | [diff] [blame] | 481 | }; |
| 482 | |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 483 | static void pci_unin_internal_class_init(ObjectClass *klass, void *data) |
| 484 | { |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 485 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 486 | |
Mark Cave-Ayland | 1ff861d | 2018-03-06 20:30:55 +0000 | [diff] [blame] | 487 | dc->realize = pci_unin_internal_realize; |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 488 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 489 | } |
| 490 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 491 | static const TypeInfo pci_unin_internal_info = { |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 492 | .name = TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE, |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 493 | .parent = TYPE_PCI_HOST_BRIDGE, |
Mark Cave-Ayland | c90c393 | 2018-03-06 20:31:00 +0000 | [diff] [blame] | 494 | .instance_size = sizeof(UNINHostState), |
Mark Cave-Ayland | 0203459 | 2018-03-06 20:30:47 +0000 | [diff] [blame] | 495 | .instance_init = pci_unin_internal_init, |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 496 | .class_init = pci_unin_internal_class_init, |
Andreas Färber | 70f9c98 | 2012-01-19 07:40:16 +0000 | [diff] [blame] | 497 | }; |
| 498 | |
Mark Cave-Ayland | 0662946 | 2018-05-03 21:24:39 +0100 | [diff] [blame] | 499 | /* UniN device */ |
| 500 | static void unin_write(void *opaque, hwaddr addr, uint64_t value, |
| 501 | unsigned size) |
| 502 | { |
| 503 | trace_unin_write(addr, value); |
Mark Cave-Ayland | 0662946 | 2018-05-03 21:24:39 +0100 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | static uint64_t unin_read(void *opaque, hwaddr addr, unsigned size) |
| 507 | { |
| 508 | uint32_t value; |
| 509 | |
Mark Cave-Ayland | 0662946 | 2018-05-03 21:24:39 +0100 | [diff] [blame] | 510 | switch (addr) { |
| 511 | case 0: |
Mark Cave-Ayland | 45fefe7 | 2018-05-06 15:20:05 +0100 | [diff] [blame] | 512 | value = UNINORTH_VERSION_10A; |
| 513 | break; |
| 514 | default: |
| 515 | value = 0; |
Mark Cave-Ayland | 0662946 | 2018-05-03 21:24:39 +0100 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | trace_unin_read(addr, value); |
| 519 | |
| 520 | return value; |
| 521 | } |
| 522 | |
| 523 | static const MemoryRegionOps unin_ops = { |
| 524 | .read = unin_read, |
| 525 | .write = unin_write, |
| 526 | .endianness = DEVICE_BIG_ENDIAN, |
| 527 | }; |
| 528 | |
| 529 | static void unin_init(Object *obj) |
| 530 | { |
| 531 | UNINState *s = UNI_NORTH(obj); |
| 532 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
| 533 | |
Mark Cave-Ayland | 45fefe7 | 2018-05-06 15:20:05 +0100 | [diff] [blame] | 534 | memory_region_init_io(&s->mem, obj, &unin_ops, s, "unin", 0x1000); |
Mark Cave-Ayland | 0662946 | 2018-05-03 21:24:39 +0100 | [diff] [blame] | 535 | |
| 536 | sysbus_init_mmio(sbd, &s->mem); |
| 537 | } |
| 538 | |
| 539 | static void unin_class_init(ObjectClass *klass, void *data) |
| 540 | { |
| 541 | DeviceClass *dc = DEVICE_CLASS(klass); |
| 542 | |
| 543 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
| 544 | } |
| 545 | |
| 546 | static const TypeInfo unin_info = { |
| 547 | .name = TYPE_UNI_NORTH, |
| 548 | .parent = TYPE_SYS_BUS_DEVICE, |
| 549 | .instance_size = sizeof(UNINState), |
| 550 | .instance_init = unin_init, |
| 551 | .class_init = unin_class_init, |
| 552 | }; |
| 553 | |
Andreas Färber | 83f7d43 | 2012-02-09 15:20:55 +0100 | [diff] [blame] | 554 | static void unin_register_types(void) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 555 | { |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 556 | type_register_static(&unin_main_pci_host_info); |
| 557 | type_register_static(&u3_agp_pci_host_info); |
| 558 | type_register_static(&unin_agp_pci_host_info); |
| 559 | type_register_static(&unin_internal_pci_host_info); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 560 | |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 561 | type_register_static(&pci_unin_main_info); |
| 562 | type_register_static(&pci_u3_agp_info); |
| 563 | type_register_static(&pci_unin_agp_info); |
| 564 | type_register_static(&pci_unin_internal_info); |
Mark Cave-Ayland | 0662946 | 2018-05-03 21:24:39 +0100 | [diff] [blame] | 565 | |
| 566 | type_register_static(&unin_info); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 567 | } |
| 568 | |
Andreas Färber | 83f7d43 | 2012-02-09 15:20:55 +0100 | [diff] [blame] | 569 | type_init(unin_register_types) |