]> git.proxmox.com Git - mirror_qemu.git/blob - hw/usb/hcd-ehci-sysbus.c
usb/ehci: Clean up SysBus and PCI EHCI split
[mirror_qemu.git] / hw / usb / hcd-ehci-sysbus.c
1 /*
2 * QEMU USB EHCI Emulation
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or(at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "hw/usb/hcd-ehci.h"
19
20 static const VMStateDescription vmstate_ehci_sysbus = {
21 .name = "ehci-sysbus",
22 .version_id = 2,
23 .minimum_version_id = 1,
24 .fields = (VMStateField[]) {
25 VMSTATE_STRUCT(ehci, EHCISysBusState, 2, vmstate_ehci, EHCIState),
26 VMSTATE_END_OF_LIST()
27 }
28 };
29
30 static Property ehci_sysbus_properties[] = {
31 DEFINE_PROP_UINT32("maxframes", EHCISysBusState, ehci.maxframes, 128),
32 DEFINE_PROP_END_OF_LIST(),
33 };
34
35 static int usb_ehci_sysbus_initfn(SysBusDevice *dev)
36 {
37 EHCISysBusState *i = SYS_BUS_EHCI(dev);
38 EHCIState *s = &i->ehci;
39
40 s->capsbase = 0x100;
41 s->opregbase = 0x140;
42 s->dma = &dma_context_memory;
43
44 usb_ehci_initfn(s, DEVICE(dev));
45 sysbus_init_irq(dev, &s->irq);
46 sysbus_init_mmio(dev, &s->mem);
47 return 0;
48 }
49
50 static void ehci_sysbus_class_init(ObjectClass *klass, void *data)
51 {
52 DeviceClass *dc = DEVICE_CLASS(klass);
53 SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
54
55 k->init = usb_ehci_sysbus_initfn;
56 dc->vmsd = &vmstate_ehci_sysbus;
57 dc->props = ehci_sysbus_properties;
58 }
59
60 static const TypeInfo ehci_type_info = {
61 .name = TYPE_SYS_BUS_EHCI,
62 .parent = TYPE_SYS_BUS_DEVICE,
63 .instance_size = sizeof(EHCISysBusState),
64 .abstract = true,
65 .class_init = ehci_sysbus_class_init,
66 };
67
68 static const TypeInfo ehci_xlnx_type_info = {
69 .name = "xlnx,ps7-usb",
70 .parent = TYPE_SYS_BUS_EHCI,
71 };
72
73 static void ehci_sysbus_register_types(void)
74 {
75 type_register_static(&ehci_type_info);
76 type_register_static(&ehci_xlnx_type_info);
77 }
78
79 type_init(ehci_sysbus_register_types)