blob: 2b309dfe82f4fa0c3a180b2d0f1e91ec56db9378 [file] [log] [blame]
pbrook502a5392006-05-13 16:11:23 +00001/*
2 * QEMU Uninorth PCI host (for all Mac99 and newer machines)
3 *
4 * Copyright (c) 2006 Fabrice Bellard
ths5fafdf22007-09-16 21:08:06 +00005 *
pbrook502a5392006-05-13 16:11:23 +00006 * 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 */
pbrook87ecb682007-11-17 17:14:51 +000024#include "hw.h"
25#include "ppc_mac.h"
26#include "pci.h"
Isaku Yamahata4f5e19e2009-10-30 21:21:06 +090027#include "pci_host.h"
pbrook87ecb682007-11-17 17:14:51 +000028
blueswir1f3902382009-02-05 20:22:07 +000029/* debug UniNorth */
30//#define DEBUG_UNIN
31
32#ifdef DEBUG_UNIN
Blue Swirl001faf32009-05-13 17:53:17 +000033#define UNIN_DPRINTF(fmt, ...) \
34 do { printf("UNIN: " fmt , ## __VA_ARGS__); } while (0)
blueswir1f3902382009-02-05 20:22:07 +000035#else
Blue Swirl001faf32009-05-13 17:53:17 +000036#define UNIN_DPRINTF(fmt, ...)
blueswir1f3902382009-02-05 20:22:07 +000037#endif
38
Alexander Graffa0be692010-02-09 17:37:04 +010039static const int unin_irq_line[] = { 0x1b, 0x1c, 0x1d, 0x1e };
40
Blue Swirl2e29bd02009-07-31 20:23:28 +000041typedef struct UNINState {
Blue Swirl2e29bd02009-07-31 20:23:28 +000042 PCIHostState host_state;
Blue Swirl46f30692011-09-17 20:30:50 +000043 MemoryRegion pci_mmio;
44 MemoryRegion pci_hole;
Blue Swirl2e29bd02009-07-31 20:23:28 +000045} UNINState;
pbrook502a5392006-05-13 16:11:23 +000046
pbrookd2b59312006-09-24 00:16:34 +000047static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
pbrook502a5392006-05-13 16:11:23 +000048{
Alexander Graffa0be692010-02-09 17:37:04 +010049 int retval;
50 int devfn = pci_dev->devfn & 0x00FFFFFF;
51
52 retval = (((devfn >> 11) & 0x1F) + irq_num) & 3;
53
54 return retval;
pbrookd2b59312006-09-24 00:16:34 +000055}
56
Juan Quintela5d4e84c2009-08-28 15:28:17 +020057static void pci_unin_set_irq(void *opaque, int irq_num, int level)
pbrookd2b59312006-09-24 00:16:34 +000058{
Juan Quintela5d4e84c2009-08-28 15:28:17 +020059 qemu_irq *pic = opaque;
60
Alexander Graffa0be692010-02-09 17:37:04 +010061 UNIN_DPRINTF("%s: setting INT %d = %d\n", __func__,
62 unin_irq_line[irq_num], level);
63 qemu_set_irq(pic[unin_irq_line[irq_num]], level);
pbrook502a5392006-05-13 16:11:23 +000064}
65
Alexander Grafd86f0e32010-02-09 17:37:01 +010066static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
67{
68 uint32_t retval;
69
70 if (reg & (1u << 31)) {
71 /* XXX OpenBIOS compatibility hack */
72 retval = reg | (addr & 3);
73 } else if (reg & 1) {
74 /* CFA1 style */
75 retval = (reg & ~7u) | (addr & 7);
76 } else {
77 uint32_t slot, func;
78
79 /* Grab CFA0 style values */
80 slot = ffs(reg & 0xfffff800) - 1;
81 func = (reg >> 8) & 7;
82
83 /* ... and then convert them to x86 format */
84 /* config pointer */
85 retval = (reg & (0xff - 7)) | (addr & 7);
86 /* slot */
87 retval |= slot << 11;
88 /* fn */
89 retval |= func << 8;
90 }
91
92
93 UNIN_DPRINTF("Converted config space accessor %08x/%08x -> %08x\n",
94 reg, addr, retval);
95
96 return retval;
97}
98
Avi Kivityd0ed8072011-07-24 17:47:18 +030099static void unin_data_write(void *opaque, target_phys_addr_t addr,
100 uint64_t val, unsigned len)
Alexander Grafd86f0e32010-02-09 17:37:01 +0100101{
Avi Kivityd0ed8072011-07-24 17:47:18 +0300102 UNINState *s = opaque;
103 UNIN_DPRINTF("write addr %" TARGET_FMT_plx " len %d val %"PRIx64"\n",
104 addr, len, val);
Alexander Grafd86f0e32010-02-09 17:37:01 +0100105 pci_data_write(s->host_state.bus,
106 unin_get_config_reg(s->host_state.config_reg, addr),
107 val, len);
108}
109
Avi Kivityd0ed8072011-07-24 17:47:18 +0300110static uint64_t unin_data_read(void *opaque, target_phys_addr_t addr,
111 unsigned len)
Alexander Grafd86f0e32010-02-09 17:37:01 +0100112{
Avi Kivityd0ed8072011-07-24 17:47:18 +0300113 UNINState *s = opaque;
Alexander Grafd86f0e32010-02-09 17:37:01 +0100114 uint32_t val;
115
116 val = pci_data_read(s->host_state.bus,
117 unin_get_config_reg(s->host_state.config_reg, addr),
118 len);
Avi Kivityd0ed8072011-07-24 17:47:18 +0300119 UNIN_DPRINTF("read addr %" TARGET_FMT_plx " len %d val %x\n",
120 addr, len, val);
Alexander Grafd86f0e32010-02-09 17:37:01 +0100121 return val;
122}
123
Avi Kivityd0ed8072011-07-24 17:47:18 +0300124static const MemoryRegionOps unin_data_ops = {
125 .read = unin_data_read,
126 .write = unin_data_write,
127 .endianness = DEVICE_LITTLE_ENDIAN,
128};
129
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200130static int pci_unin_main_init_device(SysBusDevice *dev)
pbrook502a5392006-05-13 16:11:23 +0000131{
Andreas Färberff452ac2012-01-19 07:40:17 +0000132 PCIHostState *h;
pbrook502a5392006-05-13 16:11:23 +0000133 UNINState *s;
pbrook502a5392006-05-13 16:11:23 +0000134
135 /* Use values found on a real PowerMac */
136 /* Uninorth main bus */
Andreas Färberff452ac2012-01-19 07:40:17 +0000137 h = FROM_SYSBUS(PCIHostState, dev);
138 s = DO_UPCAST(UNINState, host_state, h);
pbrook502a5392006-05-13 16:11:23 +0000139
Avi Kivityd0ed8072011-07-24 17:47:18 +0300140 memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops,
141 &s->host_state, "pci-conf-idx", 0x1000);
142 memory_region_init_io(&s->host_state.data_mem, &unin_data_ops, s,
143 "pci-conf-data", 0x1000);
Avi Kivity750ecd42011-11-27 11:38:10 +0200144 sysbus_init_mmio(dev, &s->host_state.conf_mem);
145 sysbus_init_mmio(dev, &s->host_state.data_mem);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000146
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200147 return 0;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000148}
149
Avi Kivityd0ed8072011-07-24 17:47:18 +0300150
Alexander Graf0f921192010-02-09 17:37:02 +0100151static int pci_u3_agp_init_device(SysBusDevice *dev)
152{
Andreas Färberff452ac2012-01-19 07:40:17 +0000153 PCIHostState *h;
Alexander Graf0f921192010-02-09 17:37:02 +0100154 UNINState *s;
Alexander Graf0f921192010-02-09 17:37:02 +0100155
156 /* Uninorth U3 AGP bus */
Andreas Färberff452ac2012-01-19 07:40:17 +0000157 h = FROM_SYSBUS(PCIHostState, dev);
158 s = DO_UPCAST(UNINState, host_state, h);
Alexander Graf0f921192010-02-09 17:37:02 +0100159
Avi Kivityd0ed8072011-07-24 17:47:18 +0300160 memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops,
161 &s->host_state, "pci-conf-idx", 0x1000);
162 memory_region_init_io(&s->host_state.data_mem, &unin_data_ops, s,
163 "pci-conf-data", 0x1000);
Avi Kivity750ecd42011-11-27 11:38:10 +0200164 sysbus_init_mmio(dev, &s->host_state.conf_mem);
165 sysbus_init_mmio(dev, &s->host_state.data_mem);
Alexander Graf0f921192010-02-09 17:37:02 +0100166
Alexander Graf0f921192010-02-09 17:37:02 +0100167 return 0;
168}
169
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200170static int pci_unin_agp_init_device(SysBusDevice *dev)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000171{
Andreas Färberff452ac2012-01-19 07:40:17 +0000172 PCIHostState *h;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000173 UNINState *s;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000174
175 /* Uninorth AGP bus */
Andreas Färberff452ac2012-01-19 07:40:17 +0000176 h = FROM_SYSBUS(PCIHostState, dev);
177 s = DO_UPCAST(UNINState, host_state, h);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000178
Avi Kivityd0ed8072011-07-24 17:47:18 +0300179 memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops,
180 &s->host_state, "pci-conf-idx", 0x1000);
181 memory_region_init_io(&s->host_state.data_mem, &pci_host_data_le_ops,
182 &s->host_state, "pci-conf-data", 0x1000);
Avi Kivity750ecd42011-11-27 11:38:10 +0200183 sysbus_init_mmio(dev, &s->host_state.conf_mem);
184 sysbus_init_mmio(dev, &s->host_state.data_mem);
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200185 return 0;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000186}
187
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200188static int pci_unin_internal_init_device(SysBusDevice *dev)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000189{
Andreas Färberff452ac2012-01-19 07:40:17 +0000190 PCIHostState *h;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000191 UNINState *s;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000192
193 /* Uninorth internal bus */
Andreas Färberff452ac2012-01-19 07:40:17 +0000194 h = FROM_SYSBUS(PCIHostState, dev);
195 s = DO_UPCAST(UNINState, host_state, h);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000196
Avi Kivityd0ed8072011-07-24 17:47:18 +0300197 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);
Avi Kivity750ecd42011-11-27 11:38:10 +0200201 sysbus_init_mmio(dev, &s->host_state.conf_mem);
202 sysbus_init_mmio(dev, &s->host_state.data_mem);
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200203 return 0;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000204}
205
Avi Kivityaee97b82011-08-08 16:09:04 +0300206PCIBus *pci_pmac_init(qemu_irq *pic,
207 MemoryRegion *address_space_mem,
208 MemoryRegion *address_space_io)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000209{
210 DeviceState *dev;
211 SysBusDevice *s;
Andreas Färberff452ac2012-01-19 07:40:17 +0000212 PCIHostState *h;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000213 UNINState *d;
214
215 /* Use values found on a real PowerMac */
216 /* Uninorth main bus */
Andreas Färber70f9c982012-01-19 07:40:16 +0000217 dev = qdev_create(NULL, "uni-north-pci-pcihost");
Markus Armbrustere23a1b32009-10-07 01:15:58 +0200218 qdev_init_nofail(dev);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000219 s = sysbus_from_qdev(dev);
Andreas Färberff452ac2012-01-19 07:40:17 +0000220 h = FROM_SYSBUS(PCIHostState, s);
221 d = DO_UPCAST(UNINState, host_state, h);
Blue Swirl46f30692011-09-17 20:30:50 +0000222 memory_region_init(&d->pci_mmio, "pci-mmio", 0x100000000ULL);
223 memory_region_init_alias(&d->pci_hole, "pci-hole", &d->pci_mmio,
224 0x80000000ULL, 0x70000000ULL);
225 memory_region_add_subregion(address_space_mem, 0x80000000ULL,
226 &d->pci_hole);
227
Andreas Färberff452ac2012-01-19 07:40:17 +0000228 d->host_state.bus = pci_register_bus(dev, "pci",
Blue Swirl2e29bd02009-07-31 20:23:28 +0000229 pci_unin_set_irq, pci_unin_map_irq,
Avi Kivityaee97b82011-08-08 16:09:04 +0300230 pic,
Blue Swirl46f30692011-09-17 20:30:50 +0000231 &d->pci_mmio,
Avi Kivityaee97b82011-08-08 16:09:04 +0300232 address_space_io,
Avi Kivity1e391012011-07-26 14:26:19 +0300233 PCI_DEVFN(11, 0), 4);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000234
Blue Swirl60398742009-11-15 14:30:56 +0000235#if 0
Isaku Yamahata520128b2010-06-23 16:15:25 +0900236 pci_create_simple(d->host_state.bus, PCI_DEVFN(11, 0), "uni-north");
Blue Swirl60398742009-11-15 14:30:56 +0000237#endif
Blue Swirl2e29bd02009-07-31 20:23:28 +0000238
239 sysbus_mmio_map(s, 0, 0xf2800000);
240 sysbus_mmio_map(s, 1, 0xf2c00000);
241
242 /* DEC 21154 bridge */
243#if 0
244 /* XXX: not activated as PPC BIOS doesn't handle multiple buses properly */
Isaku Yamahata520128b2010-06-23 16:15:25 +0900245 pci_create_simple(d->host_state.bus, PCI_DEVFN(12, 0), "dec-21154");
Blue Swirl2e29bd02009-07-31 20:23:28 +0000246#endif
247
248 /* Uninorth AGP bus */
Isaku Yamahata520128b2010-06-23 16:15:25 +0900249 pci_create_simple(d->host_state.bus, PCI_DEVFN(11, 0), "uni-north-agp");
Andreas Färber70f9c982012-01-19 07:40:16 +0000250 dev = qdev_create(NULL, "uni-north-agp-pcihost");
Blue Swirld27d06f2009-11-15 17:42:17 +0000251 qdev_init_nofail(dev);
252 s = sysbus_from_qdev(dev);
253 sysbus_mmio_map(s, 0, 0xf0800000);
254 sysbus_mmio_map(s, 1, 0xf0c00000);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000255
256 /* Uninorth internal bus */
257#if 0
258 /* XXX: not needed for now */
Andreas Färber70f9c982012-01-19 07:40:16 +0000259 pci_create_simple(d->host_state.bus, PCI_DEVFN(14, 0),
260 "uni-north-internal-pci");
261 dev = qdev_create(NULL, "uni-north-internal-pci-pcihost");
Blue Swirld27d06f2009-11-15 17:42:17 +0000262 qdev_init_nofail(dev);
263 s = sysbus_from_qdev(dev);
264 sysbus_mmio_map(s, 0, 0xf4800000);
265 sysbus_mmio_map(s, 1, 0xf4c00000);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000266#endif
267
268 return d->host_state.bus;
269}
270
Avi Kivityaee97b82011-08-08 16:09:04 +0300271PCIBus *pci_pmac_u3_init(qemu_irq *pic,
272 MemoryRegion *address_space_mem,
273 MemoryRegion *address_space_io)
Alexander Graf0f921192010-02-09 17:37:02 +0100274{
275 DeviceState *dev;
276 SysBusDevice *s;
Andreas Färberff452ac2012-01-19 07:40:17 +0000277 PCIHostState *h;
Alexander Graf0f921192010-02-09 17:37:02 +0100278 UNINState *d;
279
280 /* Uninorth AGP bus */
281
Andreas Färber70f9c982012-01-19 07:40:16 +0000282 dev = qdev_create(NULL, "u3-agp-pcihost");
Alexander Graf0f921192010-02-09 17:37:02 +0100283 qdev_init_nofail(dev);
284 s = sysbus_from_qdev(dev);
Andreas Färberff452ac2012-01-19 07:40:17 +0000285 h = FROM_SYSBUS(PCIHostState, s);
286 d = DO_UPCAST(UNINState, host_state, h);
Alexander Graf0f921192010-02-09 17:37:02 +0100287
Blue Swirl46f30692011-09-17 20:30:50 +0000288 memory_region_init(&d->pci_mmio, "pci-mmio", 0x100000000ULL);
289 memory_region_init_alias(&d->pci_hole, "pci-hole", &d->pci_mmio,
290 0x80000000ULL, 0x70000000ULL);
291 memory_region_add_subregion(address_space_mem, 0x80000000ULL,
292 &d->pci_hole);
293
Andreas Färberff452ac2012-01-19 07:40:17 +0000294 d->host_state.bus = pci_register_bus(dev, "pci",
Alexander Graf0f921192010-02-09 17:37:02 +0100295 pci_unin_set_irq, pci_unin_map_irq,
Avi Kivityaee97b82011-08-08 16:09:04 +0300296 pic,
Blue Swirl46f30692011-09-17 20:30:50 +0000297 &d->pci_mmio,
Avi Kivityaee97b82011-08-08 16:09:04 +0300298 address_space_io,
Avi Kivity1e391012011-07-26 14:26:19 +0300299 PCI_DEVFN(11, 0), 4);
Alexander Graf0f921192010-02-09 17:37:02 +0100300
301 sysbus_mmio_map(s, 0, 0xf0800000);
302 sysbus_mmio_map(s, 1, 0xf0c00000);
303
304 pci_create_simple(d->host_state.bus, 11 << 3, "u3-agp");
305
306 return d->host_state.bus;
307}
308
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200309static int unin_main_pci_host_init(PCIDevice *d)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000310{
pbrook502a5392006-05-13 16:11:23 +0000311 d->config[0x0C] = 0x08; // cache_line_size
312 d->config[0x0D] = 0x10; // latency_timer
pbrook502a5392006-05-13 16:11:23 +0000313 d->config[0x34] = 0x00; // capabilities_pointer
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200314 return 0;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000315}
pbrook502a5392006-05-13 16:11:23 +0000316
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200317static int unin_agp_pci_host_init(PCIDevice *d)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000318{
pbrook502a5392006-05-13 16:11:23 +0000319 d->config[0x0C] = 0x08; // cache_line_size
320 d->config[0x0D] = 0x10; // latency_timer
pbrook502a5392006-05-13 16:11:23 +0000321 // d->config[0x34] = 0x80; // capabilities_pointer
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200322 return 0;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000323}
pbrook502a5392006-05-13 16:11:23 +0000324
Alexander Graf0f921192010-02-09 17:37:02 +0100325static int u3_agp_pci_host_init(PCIDevice *d)
326{
Alexander Graf0f921192010-02-09 17:37:02 +0100327 /* cache line size */
328 d->config[0x0C] = 0x08;
329 /* latency timer */
330 d->config[0x0D] = 0x10;
Alexander Graf0f921192010-02-09 17:37:02 +0100331 return 0;
332}
333
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200334static int unin_internal_pci_host_init(PCIDevice *d)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000335{
pbrook502a5392006-05-13 16:11:23 +0000336 d->config[0x0C] = 0x08; // cache_line_size
337 d->config[0x0D] = 0x10; // latency_timer
pbrook502a5392006-05-13 16:11:23 +0000338 d->config[0x34] = 0x00; // capabilities_pointer
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200339 return 0;
pbrook502a5392006-05-13 16:11:23 +0000340}
Blue Swirl2e29bd02009-07-31 20:23:28 +0000341
Anthony Liguori40021f02011-12-04 12:22:06 -0600342static void unin_main_pci_host_class_init(ObjectClass *klass, void *data)
343{
344 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
345
346 k->init = unin_main_pci_host_init;
347 k->vendor_id = PCI_VENDOR_ID_APPLE;
348 k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_PCI;
349 k->revision = 0x00;
350 k->class_id = PCI_CLASS_BRIDGE_HOST;
351}
352
Andreas Färber4240abf2012-08-20 19:07:56 +0200353static const TypeInfo unin_main_pci_host_info = {
Anthony Liguori40021f02011-12-04 12:22:06 -0600354 .name = "uni-north-pci",
Anthony Liguori39bffca2011-12-07 21:34:16 -0600355 .parent = TYPE_PCI_DEVICE,
356 .instance_size = sizeof(PCIDevice),
Anthony Liguori40021f02011-12-04 12:22:06 -0600357 .class_init = unin_main_pci_host_class_init,
Blue Swirl2e29bd02009-07-31 20:23:28 +0000358};
359
Anthony Liguori40021f02011-12-04 12:22:06 -0600360static void u3_agp_pci_host_class_init(ObjectClass *klass, void *data)
361{
362 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
363
364 k->init = u3_agp_pci_host_init;
365 k->vendor_id = PCI_VENDOR_ID_APPLE;
366 k->device_id = PCI_DEVICE_ID_APPLE_U3_AGP;
367 k->revision = 0x00;
368 k->class_id = PCI_CLASS_BRIDGE_HOST;
369}
370
Andreas Färber4240abf2012-08-20 19:07:56 +0200371static const TypeInfo u3_agp_pci_host_info = {
Anthony Liguori40021f02011-12-04 12:22:06 -0600372 .name = "u3-agp",
Anthony Liguori39bffca2011-12-07 21:34:16 -0600373 .parent = TYPE_PCI_DEVICE,
374 .instance_size = sizeof(PCIDevice),
Anthony Liguori40021f02011-12-04 12:22:06 -0600375 .class_init = u3_agp_pci_host_class_init,
Alexander Graf0f921192010-02-09 17:37:02 +0100376};
377
Anthony Liguori40021f02011-12-04 12:22:06 -0600378static void unin_agp_pci_host_class_init(ObjectClass *klass, void *data)
379{
380 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
381
382 k->init = unin_agp_pci_host_init;
383 k->vendor_id = PCI_VENDOR_ID_APPLE;
384 k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_AGP;
385 k->revision = 0x00;
386 k->class_id = PCI_CLASS_BRIDGE_HOST;
387}
388
Andreas Färber4240abf2012-08-20 19:07:56 +0200389static const TypeInfo unin_agp_pci_host_info = {
Anthony Liguori40021f02011-12-04 12:22:06 -0600390 .name = "uni-north-agp",
Anthony Liguori39bffca2011-12-07 21:34:16 -0600391 .parent = TYPE_PCI_DEVICE,
392 .instance_size = sizeof(PCIDevice),
Anthony Liguori40021f02011-12-04 12:22:06 -0600393 .class_init = unin_agp_pci_host_class_init,
Blue Swirl2e29bd02009-07-31 20:23:28 +0000394};
395
Anthony Liguori40021f02011-12-04 12:22:06 -0600396static void unin_internal_pci_host_class_init(ObjectClass *klass, void *data)
397{
398 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
399
400 k->init = unin_internal_pci_host_init;
401 k->vendor_id = PCI_VENDOR_ID_APPLE;
402 k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_I_PCI;
403 k->revision = 0x00;
404 k->class_id = PCI_CLASS_BRIDGE_HOST;
405}
406
Andreas Färber4240abf2012-08-20 19:07:56 +0200407static const TypeInfo unin_internal_pci_host_info = {
Anthony Liguori40021f02011-12-04 12:22:06 -0600408 .name = "uni-north-internal-pci",
Anthony Liguori39bffca2011-12-07 21:34:16 -0600409 .parent = TYPE_PCI_DEVICE,
410 .instance_size = sizeof(PCIDevice),
Anthony Liguori40021f02011-12-04 12:22:06 -0600411 .class_init = unin_internal_pci_host_class_init,
Blue Swirl2e29bd02009-07-31 20:23:28 +0000412};
413
Anthony Liguori999e12b2012-01-24 13:12:29 -0600414static void pci_unin_main_class_init(ObjectClass *klass, void *data)
415{
416 SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
417
418 sbc->init = pci_unin_main_init_device;
419}
420
Andreas Färber4240abf2012-08-20 19:07:56 +0200421static const TypeInfo pci_unin_main_info = {
Anthony Liguori39bffca2011-12-07 21:34:16 -0600422 .name = "uni-north-pci-pcihost",
423 .parent = TYPE_SYS_BUS_DEVICE,
424 .instance_size = sizeof(UNINState),
425 .class_init = pci_unin_main_class_init,
Andreas Färber70f9c982012-01-19 07:40:16 +0000426};
427
Anthony Liguori999e12b2012-01-24 13:12:29 -0600428static void pci_u3_agp_class_init(ObjectClass *klass, void *data)
429{
430 SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
431
432 sbc->init = pci_u3_agp_init_device;
433}
434
Andreas Färber4240abf2012-08-20 19:07:56 +0200435static const TypeInfo pci_u3_agp_info = {
Anthony Liguori39bffca2011-12-07 21:34:16 -0600436 .name = "u3-agp-pcihost",
437 .parent = TYPE_SYS_BUS_DEVICE,
438 .instance_size = sizeof(UNINState),
439 .class_init = pci_u3_agp_class_init,
Andreas Färber70f9c982012-01-19 07:40:16 +0000440};
441
Anthony Liguori999e12b2012-01-24 13:12:29 -0600442static void pci_unin_agp_class_init(ObjectClass *klass, void *data)
443{
444 SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
445
446 sbc->init = pci_unin_agp_init_device;
447}
448
Andreas Färber4240abf2012-08-20 19:07:56 +0200449static const TypeInfo pci_unin_agp_info = {
Anthony Liguori39bffca2011-12-07 21:34:16 -0600450 .name = "uni-north-agp-pcihost",
451 .parent = TYPE_SYS_BUS_DEVICE,
452 .instance_size = sizeof(UNINState),
453 .class_init = pci_unin_agp_class_init,
Andreas Färber70f9c982012-01-19 07:40:16 +0000454};
455
Anthony Liguori999e12b2012-01-24 13:12:29 -0600456static void pci_unin_internal_class_init(ObjectClass *klass, void *data)
457{
458 SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
459
460 sbc->init = pci_unin_internal_init_device;
461}
462
Andreas Färber4240abf2012-08-20 19:07:56 +0200463static const TypeInfo pci_unin_internal_info = {
Anthony Liguori39bffca2011-12-07 21:34:16 -0600464 .name = "uni-north-internal-pci-pcihost",
465 .parent = TYPE_SYS_BUS_DEVICE,
466 .instance_size = sizeof(UNINState),
467 .class_init = pci_unin_internal_class_init,
Andreas Färber70f9c982012-01-19 07:40:16 +0000468};
469
Andreas Färber83f7d432012-02-09 15:20:55 +0100470static void unin_register_types(void)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000471{
Anthony Liguori39bffca2011-12-07 21:34:16 -0600472 type_register_static(&unin_main_pci_host_info);
473 type_register_static(&u3_agp_pci_host_info);
474 type_register_static(&unin_agp_pci_host_info);
475 type_register_static(&unin_internal_pci_host_info);
Anthony Liguori999e12b2012-01-24 13:12:29 -0600476
Anthony Liguori39bffca2011-12-07 21:34:16 -0600477 type_register_static(&pci_unin_main_info);
478 type_register_static(&pci_u3_agp_info);
479 type_register_static(&pci_unin_agp_info);
480 type_register_static(&pci_unin_internal_info);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000481}
482
Andreas Färber83f7d432012-02-09 15:20:55 +0100483type_init(unin_register_types)