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 | */ |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 24 | #include "hw.h" |
| 25 | #include "ppc_mac.h" |
| 26 | #include "pci.h" |
Isaku Yamahata | 4f5e19e | 2009-10-30 21:21:06 +0900 | [diff] [blame] | 27 | #include "pci_host.h" |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 28 | |
blueswir1 | f390238 | 2009-02-05 20:22:07 +0000 | [diff] [blame] | 29 | /* debug UniNorth */ |
| 30 | //#define DEBUG_UNIN |
| 31 | |
| 32 | #ifdef DEBUG_UNIN |
Blue Swirl | 001faf3 | 2009-05-13 17:53:17 +0000 | [diff] [blame] | 33 | #define UNIN_DPRINTF(fmt, ...) \ |
| 34 | do { printf("UNIN: " fmt , ## __VA_ARGS__); } while (0) |
blueswir1 | f390238 | 2009-02-05 20:22:07 +0000 | [diff] [blame] | 35 | #else |
Blue Swirl | 001faf3 | 2009-05-13 17:53:17 +0000 | [diff] [blame] | 36 | #define UNIN_DPRINTF(fmt, ...) |
blueswir1 | f390238 | 2009-02-05 20:22:07 +0000 | [diff] [blame] | 37 | #endif |
| 38 | |
Alexander Graf | fa0be69 | 2010-02-09 17:37:04 +0100 | [diff] [blame] | 39 | static const int unin_irq_line[] = { 0x1b, 0x1c, 0x1d, 0x1e }; |
| 40 | |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 41 | typedef struct UNINState { |
| 42 | SysBusDevice busdev; |
| 43 | PCIHostState host_state; |
Blue Swirl | 46f3069 | 2011-09-17 20:30:50 +0000 | [diff] [blame] | 44 | MemoryRegion pci_mmio; |
| 45 | MemoryRegion pci_hole; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 46 | } UNINState; |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 47 | |
pbrook | d2b5931 | 2006-09-24 00:16:34 +0000 | [diff] [blame] | 48 | static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num) |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 49 | { |
Alexander Graf | fa0be69 | 2010-02-09 17:37:04 +0100 | [diff] [blame] | 50 | int retval; |
| 51 | int devfn = pci_dev->devfn & 0x00FFFFFF; |
| 52 | |
| 53 | retval = (((devfn >> 11) & 0x1F) + irq_num) & 3; |
| 54 | |
| 55 | return retval; |
pbrook | d2b5931 | 2006-09-24 00:16:34 +0000 | [diff] [blame] | 56 | } |
| 57 | |
Juan Quintela | 5d4e84c | 2009-08-28 15:28:17 +0200 | [diff] [blame] | 58 | static void pci_unin_set_irq(void *opaque, int irq_num, int level) |
pbrook | d2b5931 | 2006-09-24 00:16:34 +0000 | [diff] [blame] | 59 | { |
Juan Quintela | 5d4e84c | 2009-08-28 15:28:17 +0200 | [diff] [blame] | 60 | qemu_irq *pic = opaque; |
| 61 | |
Alexander Graf | fa0be69 | 2010-02-09 17:37:04 +0100 | [diff] [blame] | 62 | UNIN_DPRINTF("%s: setting INT %d = %d\n", __func__, |
| 63 | unin_irq_line[irq_num], level); |
| 64 | qemu_set_irq(pic[unin_irq_line[irq_num]], level); |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 65 | } |
| 66 | |
blueswir1 | f390238 | 2009-02-05 20:22:07 +0000 | [diff] [blame] | 67 | static void pci_unin_reset(void *opaque) |
| 68 | { |
| 69 | } |
| 70 | |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 71 | static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr) |
| 72 | { |
| 73 | uint32_t retval; |
| 74 | |
| 75 | if (reg & (1u << 31)) { |
| 76 | /* XXX OpenBIOS compatibility hack */ |
| 77 | retval = reg | (addr & 3); |
| 78 | } else if (reg & 1) { |
| 79 | /* CFA1 style */ |
| 80 | retval = (reg & ~7u) | (addr & 7); |
| 81 | } else { |
| 82 | uint32_t slot, func; |
| 83 | |
| 84 | /* Grab CFA0 style values */ |
| 85 | slot = ffs(reg & 0xfffff800) - 1; |
| 86 | func = (reg >> 8) & 7; |
| 87 | |
| 88 | /* ... and then convert them to x86 format */ |
| 89 | /* config pointer */ |
| 90 | retval = (reg & (0xff - 7)) | (addr & 7); |
| 91 | /* slot */ |
| 92 | retval |= slot << 11; |
| 93 | /* fn */ |
| 94 | retval |= func << 8; |
| 95 | } |
| 96 | |
| 97 | |
| 98 | UNIN_DPRINTF("Converted config space accessor %08x/%08x -> %08x\n", |
| 99 | reg, addr, retval); |
| 100 | |
| 101 | return retval; |
| 102 | } |
| 103 | |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 104 | static void unin_data_write(void *opaque, target_phys_addr_t addr, |
| 105 | uint64_t val, unsigned len) |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 106 | { |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 107 | UNINState *s = opaque; |
| 108 | UNIN_DPRINTF("write addr %" TARGET_FMT_plx " len %d val %"PRIx64"\n", |
| 109 | addr, len, val); |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 110 | pci_data_write(s->host_state.bus, |
| 111 | unin_get_config_reg(s->host_state.config_reg, addr), |
| 112 | val, len); |
| 113 | } |
| 114 | |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 115 | static uint64_t unin_data_read(void *opaque, target_phys_addr_t addr, |
| 116 | unsigned len) |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 117 | { |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 118 | UNINState *s = opaque; |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 119 | uint32_t val; |
| 120 | |
| 121 | val = pci_data_read(s->host_state.bus, |
| 122 | unin_get_config_reg(s->host_state.config_reg, addr), |
| 123 | len); |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 124 | UNIN_DPRINTF("read addr %" TARGET_FMT_plx " len %d val %x\n", |
| 125 | addr, len, val); |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 126 | return val; |
| 127 | } |
| 128 | |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 129 | static const MemoryRegionOps unin_data_ops = { |
| 130 | .read = unin_data_read, |
| 131 | .write = unin_data_write, |
| 132 | .endianness = DEVICE_LITTLE_ENDIAN, |
| 133 | }; |
| 134 | |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 135 | static int pci_unin_main_init_device(SysBusDevice *dev) |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 136 | { |
| 137 | UNINState *s; |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 138 | |
| 139 | /* Use values found on a real PowerMac */ |
| 140 | /* Uninorth main bus */ |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 141 | s = FROM_SYSBUS(UNINState, dev); |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 142 | |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 143 | memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops, |
| 144 | &s->host_state, "pci-conf-idx", 0x1000); |
| 145 | memory_region_init_io(&s->host_state.data_mem, &unin_data_ops, s, |
| 146 | "pci-conf-data", 0x1000); |
| 147 | sysbus_init_mmio_region(dev, &s->host_state.conf_mem); |
| 148 | sysbus_init_mmio_region(dev, &s->host_state.data_mem); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 149 | |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 150 | qemu_register_reset(pci_unin_reset, &s->host_state); |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 151 | return 0; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 152 | } |
| 153 | |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 154 | |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 155 | static int pci_u3_agp_init_device(SysBusDevice *dev) |
| 156 | { |
| 157 | UNINState *s; |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 158 | |
| 159 | /* Uninorth U3 AGP bus */ |
| 160 | s = FROM_SYSBUS(UNINState, dev); |
| 161 | |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 162 | memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops, |
| 163 | &s->host_state, "pci-conf-idx", 0x1000); |
| 164 | memory_region_init_io(&s->host_state.data_mem, &unin_data_ops, s, |
| 165 | "pci-conf-data", 0x1000); |
| 166 | sysbus_init_mmio_region(dev, &s->host_state.conf_mem); |
| 167 | sysbus_init_mmio_region(dev, &s->host_state.data_mem); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 168 | |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 169 | qemu_register_reset(pci_unin_reset, &s->host_state); |
| 170 | |
| 171 | return 0; |
| 172 | } |
| 173 | |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 174 | static int pci_unin_agp_init_device(SysBusDevice *dev) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 175 | { |
| 176 | UNINState *s; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 177 | |
| 178 | /* Uninorth AGP bus */ |
| 179 | s = FROM_SYSBUS(UNINState, dev); |
| 180 | |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 181 | memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops, |
| 182 | &s->host_state, "pci-conf-idx", 0x1000); |
| 183 | memory_region_init_io(&s->host_state.data_mem, &pci_host_data_le_ops, |
| 184 | &s->host_state, "pci-conf-data", 0x1000); |
| 185 | sysbus_init_mmio_region(dev, &s->host_state.conf_mem); |
| 186 | sysbus_init_mmio_region(dev, &s->host_state.data_mem); |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 187 | return 0; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 188 | } |
| 189 | |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 190 | static int pci_unin_internal_init_device(SysBusDevice *dev) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 191 | { |
| 192 | UNINState *s; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 193 | |
| 194 | /* Uninorth internal bus */ |
| 195 | s = FROM_SYSBUS(UNINState, dev); |
| 196 | |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 197 | memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops, |
| 198 | &s->host_state, "pci-conf-idx", 0x1000); |
| 199 | memory_region_init_io(&s->host_state.data_mem, &pci_host_data_le_ops, |
| 200 | &s->host_state, "pci-conf-data", 0x1000); |
| 201 | sysbus_init_mmio_region(dev, &s->host_state.conf_mem); |
| 202 | sysbus_init_mmio_region(dev, &s->host_state.data_mem); |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 203 | return 0; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 204 | } |
| 205 | |
Avi Kivity | aee97b8 | 2011-08-08 16:09:04 +0300 | [diff] [blame] | 206 | PCIBus *pci_pmac_init(qemu_irq *pic, |
| 207 | MemoryRegion *address_space_mem, |
| 208 | MemoryRegion *address_space_io) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 209 | { |
| 210 | DeviceState *dev; |
| 211 | SysBusDevice *s; |
| 212 | UNINState *d; |
| 213 | |
| 214 | /* Use values found on a real PowerMac */ |
| 215 | /* Uninorth main bus */ |
Markus Armbruster | 18dd19a | 2009-12-14 10:41:21 +0100 | [diff] [blame] | 216 | dev = qdev_create(NULL, "uni-north"); |
Markus Armbruster | e23a1b3 | 2009-10-07 01:15:58 +0200 | [diff] [blame] | 217 | qdev_init_nofail(dev); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 218 | s = sysbus_from_qdev(dev); |
| 219 | d = FROM_SYSBUS(UNINState, s); |
Blue Swirl | 46f3069 | 2011-09-17 20:30:50 +0000 | [diff] [blame] | 220 | memory_region_init(&d->pci_mmio, "pci-mmio", 0x100000000ULL); |
| 221 | memory_region_init_alias(&d->pci_hole, "pci-hole", &d->pci_mmio, |
| 222 | 0x80000000ULL, 0x70000000ULL); |
| 223 | memory_region_add_subregion(address_space_mem, 0x80000000ULL, |
| 224 | &d->pci_hole); |
| 225 | |
Blue Swirl | cdd0935 | 2009-09-19 17:59:10 +0000 | [diff] [blame] | 226 | d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci", |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 227 | pci_unin_set_irq, pci_unin_map_irq, |
Avi Kivity | aee97b8 | 2011-08-08 16:09:04 +0300 | [diff] [blame] | 228 | pic, |
Blue Swirl | 46f3069 | 2011-09-17 20:30:50 +0000 | [diff] [blame] | 229 | &d->pci_mmio, |
Avi Kivity | aee97b8 | 2011-08-08 16:09:04 +0300 | [diff] [blame] | 230 | address_space_io, |
Avi Kivity | 1e39101 | 2011-07-26 14:26:19 +0300 | [diff] [blame] | 231 | PCI_DEVFN(11, 0), 4); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 232 | |
Blue Swirl | 6039874 | 2009-11-15 14:30:56 +0000 | [diff] [blame] | 233 | #if 0 |
Isaku Yamahata | 520128b | 2010-06-23 16:15:25 +0900 | [diff] [blame] | 234 | pci_create_simple(d->host_state.bus, PCI_DEVFN(11, 0), "uni-north"); |
Blue Swirl | 6039874 | 2009-11-15 14:30:56 +0000 | [diff] [blame] | 235 | #endif |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 236 | |
| 237 | sysbus_mmio_map(s, 0, 0xf2800000); |
| 238 | sysbus_mmio_map(s, 1, 0xf2c00000); |
| 239 | |
| 240 | /* DEC 21154 bridge */ |
| 241 | #if 0 |
| 242 | /* XXX: not activated as PPC BIOS doesn't handle multiple buses properly */ |
Isaku Yamahata | 520128b | 2010-06-23 16:15:25 +0900 | [diff] [blame] | 243 | pci_create_simple(d->host_state.bus, PCI_DEVFN(12, 0), "dec-21154"); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 244 | #endif |
| 245 | |
| 246 | /* Uninorth AGP bus */ |
Isaku Yamahata | 520128b | 2010-06-23 16:15:25 +0900 | [diff] [blame] | 247 | pci_create_simple(d->host_state.bus, PCI_DEVFN(11, 0), "uni-north-agp"); |
Markus Armbruster | 18dd19a | 2009-12-14 10:41:21 +0100 | [diff] [blame] | 248 | dev = qdev_create(NULL, "uni-north-agp"); |
Blue Swirl | d27d06f | 2009-11-15 17:42:17 +0000 | [diff] [blame] | 249 | qdev_init_nofail(dev); |
| 250 | s = sysbus_from_qdev(dev); |
| 251 | sysbus_mmio_map(s, 0, 0xf0800000); |
| 252 | sysbus_mmio_map(s, 1, 0xf0c00000); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 253 | |
| 254 | /* Uninorth internal bus */ |
| 255 | #if 0 |
| 256 | /* XXX: not needed for now */ |
Isaku Yamahata | 520128b | 2010-06-23 16:15:25 +0900 | [diff] [blame] | 257 | pci_create_simple(d->host_state.bus, PCI_DEVFN(14, 0), "uni-north-pci"); |
Markus Armbruster | 18dd19a | 2009-12-14 10:41:21 +0100 | [diff] [blame] | 258 | dev = qdev_create(NULL, "uni-north-pci"); |
Blue Swirl | d27d06f | 2009-11-15 17:42:17 +0000 | [diff] [blame] | 259 | qdev_init_nofail(dev); |
| 260 | s = sysbus_from_qdev(dev); |
| 261 | sysbus_mmio_map(s, 0, 0xf4800000); |
| 262 | sysbus_mmio_map(s, 1, 0xf4c00000); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 263 | #endif |
| 264 | |
| 265 | return d->host_state.bus; |
| 266 | } |
| 267 | |
Avi Kivity | aee97b8 | 2011-08-08 16:09:04 +0300 | [diff] [blame] | 268 | PCIBus *pci_pmac_u3_init(qemu_irq *pic, |
| 269 | MemoryRegion *address_space_mem, |
| 270 | MemoryRegion *address_space_io) |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 271 | { |
| 272 | DeviceState *dev; |
| 273 | SysBusDevice *s; |
| 274 | UNINState *d; |
| 275 | |
| 276 | /* Uninorth AGP bus */ |
| 277 | |
| 278 | dev = qdev_create(NULL, "u3-agp"); |
| 279 | qdev_init_nofail(dev); |
| 280 | s = sysbus_from_qdev(dev); |
| 281 | d = FROM_SYSBUS(UNINState, s); |
| 282 | |
Blue Swirl | 46f3069 | 2011-09-17 20:30:50 +0000 | [diff] [blame] | 283 | memory_region_init(&d->pci_mmio, "pci-mmio", 0x100000000ULL); |
| 284 | memory_region_init_alias(&d->pci_hole, "pci-hole", &d->pci_mmio, |
| 285 | 0x80000000ULL, 0x70000000ULL); |
| 286 | memory_region_add_subregion(address_space_mem, 0x80000000ULL, |
| 287 | &d->pci_hole); |
| 288 | |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 289 | d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci", |
| 290 | pci_unin_set_irq, pci_unin_map_irq, |
Avi Kivity | aee97b8 | 2011-08-08 16:09:04 +0300 | [diff] [blame] | 291 | pic, |
Blue Swirl | 46f3069 | 2011-09-17 20:30:50 +0000 | [diff] [blame] | 292 | &d->pci_mmio, |
Avi Kivity | aee97b8 | 2011-08-08 16:09:04 +0300 | [diff] [blame] | 293 | address_space_io, |
Avi Kivity | 1e39101 | 2011-07-26 14:26:19 +0300 | [diff] [blame] | 294 | PCI_DEVFN(11, 0), 4); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 295 | |
| 296 | sysbus_mmio_map(s, 0, 0xf0800000); |
| 297 | sysbus_mmio_map(s, 1, 0xf0c00000); |
| 298 | |
| 299 | pci_create_simple(d->host_state.bus, 11 << 3, "u3-agp"); |
| 300 | |
| 301 | return d->host_state.bus; |
| 302 | } |
| 303 | |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 304 | static int unin_main_pci_host_init(PCIDevice *d) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 305 | { |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 306 | d->config[0x0C] = 0x08; // cache_line_size |
| 307 | d->config[0x0D] = 0x10; // latency_timer |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 308 | d->config[0x34] = 0x00; // capabilities_pointer |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 309 | return 0; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 310 | } |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 311 | |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 312 | static int unin_agp_pci_host_init(PCIDevice *d) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 313 | { |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 314 | d->config[0x0C] = 0x08; // cache_line_size |
| 315 | d->config[0x0D] = 0x10; // latency_timer |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 316 | // d->config[0x34] = 0x80; // capabilities_pointer |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 317 | return 0; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 318 | } |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 319 | |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 320 | static int u3_agp_pci_host_init(PCIDevice *d) |
| 321 | { |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 322 | /* cache line size */ |
| 323 | d->config[0x0C] = 0x08; |
| 324 | /* latency timer */ |
| 325 | d->config[0x0D] = 0x10; |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 326 | return 0; |
| 327 | } |
| 328 | |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 329 | static int unin_internal_pci_host_init(PCIDevice *d) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 330 | { |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 331 | d->config[0x0C] = 0x08; // cache_line_size |
| 332 | d->config[0x0D] = 0x10; // latency_timer |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 333 | d->config[0x34] = 0x00; // capabilities_pointer |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 334 | return 0; |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 335 | } |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 336 | |
| 337 | static PCIDeviceInfo unin_main_pci_host_info = { |
Markus Armbruster | 18dd19a | 2009-12-14 10:41:21 +0100 | [diff] [blame] | 338 | .qdev.name = "uni-north", |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 339 | .qdev.size = sizeof(PCIDevice), |
| 340 | .init = unin_main_pci_host_init, |
Isaku Yamahata | d7b61ec | 2011-05-25 10:58:28 +0900 | [diff] [blame] | 341 | .vendor_id = PCI_VENDOR_ID_APPLE, |
| 342 | .device_id = PCI_DEVICE_ID_APPLE_UNI_N_PCI, |
| 343 | .revision = 0x00, |
| 344 | .class_id = PCI_CLASS_BRIDGE_HOST, |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 345 | }; |
| 346 | |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 347 | static PCIDeviceInfo u3_agp_pci_host_info = { |
| 348 | .qdev.name = "u3-agp", |
| 349 | .qdev.size = sizeof(PCIDevice), |
| 350 | .init = u3_agp_pci_host_init, |
Isaku Yamahata | d7b61ec | 2011-05-25 10:58:28 +0900 | [diff] [blame] | 351 | .vendor_id = PCI_VENDOR_ID_APPLE, |
| 352 | .device_id = PCI_DEVICE_ID_APPLE_U3_AGP, |
| 353 | .revision = 0x00, |
| 354 | .class_id = PCI_CLASS_BRIDGE_HOST, |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 355 | }; |
| 356 | |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 357 | static PCIDeviceInfo unin_agp_pci_host_info = { |
Markus Armbruster | 18dd19a | 2009-12-14 10:41:21 +0100 | [diff] [blame] | 358 | .qdev.name = "uni-north-agp", |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 359 | .qdev.size = sizeof(PCIDevice), |
| 360 | .init = unin_agp_pci_host_init, |
Isaku Yamahata | d7b61ec | 2011-05-25 10:58:28 +0900 | [diff] [blame] | 361 | .vendor_id = PCI_VENDOR_ID_APPLE, |
| 362 | .device_id = PCI_DEVICE_ID_APPLE_UNI_N_AGP, |
| 363 | .revision = 0x00, |
| 364 | .class_id = PCI_CLASS_BRIDGE_HOST, |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 365 | }; |
| 366 | |
| 367 | static PCIDeviceInfo unin_internal_pci_host_info = { |
Markus Armbruster | 18dd19a | 2009-12-14 10:41:21 +0100 | [diff] [blame] | 368 | .qdev.name = "uni-north-pci", |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 369 | .qdev.size = sizeof(PCIDevice), |
| 370 | .init = unin_internal_pci_host_init, |
Isaku Yamahata | d7b61ec | 2011-05-25 10:58:28 +0900 | [diff] [blame] | 371 | .vendor_id = PCI_VENDOR_ID_APPLE, |
| 372 | .device_id = PCI_DEVICE_ID_APPLE_UNI_N_I_PCI, |
| 373 | .revision = 0x00, |
| 374 | .class_id = PCI_CLASS_BRIDGE_HOST, |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 375 | }; |
| 376 | |
| 377 | static void unin_register_devices(void) |
| 378 | { |
Markus Armbruster | 18dd19a | 2009-12-14 10:41:21 +0100 | [diff] [blame] | 379 | sysbus_register_dev("uni-north", sizeof(UNINState), |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 380 | pci_unin_main_init_device); |
| 381 | pci_qdev_register(&unin_main_pci_host_info); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 382 | sysbus_register_dev("u3-agp", sizeof(UNINState), |
| 383 | pci_u3_agp_init_device); |
| 384 | pci_qdev_register(&u3_agp_pci_host_info); |
Markus Armbruster | 18dd19a | 2009-12-14 10:41:21 +0100 | [diff] [blame] | 385 | sysbus_register_dev("uni-north-agp", sizeof(UNINState), |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 386 | pci_unin_agp_init_device); |
| 387 | pci_qdev_register(&unin_agp_pci_host_info); |
Markus Armbruster | 18dd19a | 2009-12-14 10:41:21 +0100 | [diff] [blame] | 388 | sysbus_register_dev("uni-north-pci", sizeof(UNINState), |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 389 | pci_unin_internal_init_device); |
| 390 | pci_qdev_register(&unin_internal_pci_host_info); |
| 391 | } |
| 392 | |
| 393 | device_init(unin_register_devices) |