2 * QEMU USB EHCI Emulation
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.
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.
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/>.
18 #include "hw/usb/hcd-ehci.h"
20 static const VMStateDescription vmstate_ehci_sysbus
= {
21 .name
= "ehci-sysbus",
23 .minimum_version_id
= 1,
24 .fields
= (VMStateField
[]) {
25 VMSTATE_STRUCT(ehci
, EHCISysBusState
, 2, vmstate_ehci
, EHCIState
),
30 static Property ehci_sysbus_properties
[] = {
31 DEFINE_PROP_UINT32("maxframes", EHCISysBusState
, ehci
.maxframes
, 128),
32 DEFINE_PROP_END_OF_LIST(),
35 static int usb_ehci_sysbus_initfn(SysBusDevice
*dev
)
37 EHCISysBusState
*i
= SYS_BUS_EHCI(dev
);
38 SysBusEHCIClass
*sec
= SYS_BUS_EHCI_GET_CLASS(dev
);
39 EHCIState
*s
= &i
->ehci
;
41 s
->capsbase
= sec
->capsbase
;
42 s
->opregbase
= sec
->opregbase
;
43 s
->dma
= &dma_context_memory
;
45 usb_ehci_initfn(s
, DEVICE(dev
));
46 sysbus_init_irq(dev
, &s
->irq
);
47 sysbus_init_mmio(dev
, &s
->mem
);
51 static void ehci_sysbus_class_init(ObjectClass
*klass
, void *data
)
53 DeviceClass
*dc
= DEVICE_CLASS(klass
);
54 SysBusDeviceClass
*k
= SYS_BUS_DEVICE_CLASS(klass
);
56 k
->init
= usb_ehci_sysbus_initfn
;
57 dc
->vmsd
= &vmstate_ehci_sysbus
;
58 dc
->props
= ehci_sysbus_properties
;
61 static const TypeInfo ehci_type_info
= {
62 .name
= TYPE_SYS_BUS_EHCI
,
63 .parent
= TYPE_SYS_BUS_DEVICE
,
64 .instance_size
= sizeof(EHCISysBusState
),
66 .class_init
= ehci_sysbus_class_init
,
67 .class_size
= sizeof(SysBusEHCIClass
),
70 static void ehci_xlnx_class_init(ObjectClass
*oc
, void *data
)
72 SysBusEHCIClass
*sec
= SYS_BUS_EHCI_CLASS(oc
);
74 sec
->capsbase
= 0x100;
75 sec
->opregbase
= 0x140;
78 static const TypeInfo ehci_xlnx_type_info
= {
79 .name
= "xlnx,ps7-usb",
80 .parent
= TYPE_SYS_BUS_EHCI
,
81 .class_init
= ehci_xlnx_class_init
,
84 static void ehci_exynos4210_class_init(ObjectClass
*oc
, void *data
)
86 SysBusEHCIClass
*sec
= SYS_BUS_EHCI_CLASS(oc
);
89 sec
->opregbase
= 0x10;
92 static const TypeInfo ehci_exynos4210_type_info
= {
93 .name
= TYPE_EXYNOS4210_EHCI
,
94 .parent
= TYPE_SYS_BUS_EHCI
,
95 .class_init
= ehci_exynos4210_class_init
,
98 static void ehci_sysbus_register_types(void)
100 type_register_static(&ehci_type_info
);
101 type_register_static(&ehci_xlnx_type_info
);
102 type_register_static(&ehci_exynos4210_type_info
);
105 type_init(ehci_sysbus_register_types
)