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 void usb_ehci_sysbus_realize(DeviceState
*dev
, Error
**errp
)
37 SysBusDevice
*d
= SYS_BUS_DEVICE(dev
);
38 EHCISysBusState
*i
= SYS_BUS_EHCI(dev
);
39 EHCIState
*s
= &i
->ehci
;
41 usb_ehci_realize(s
, dev
, errp
);
42 sysbus_init_irq(d
, &s
->irq
);
45 static void ehci_sysbus_init(Object
*obj
)
47 SysBusDevice
*d
= SYS_BUS_DEVICE(obj
);
48 EHCISysBusState
*i
= SYS_BUS_EHCI(obj
);
49 SysBusEHCIClass
*sec
= SYS_BUS_EHCI_GET_CLASS(obj
);
50 EHCIState
*s
= &i
->ehci
;
52 s
->capsbase
= sec
->capsbase
;
53 s
->opregbase
= sec
->opregbase
;
54 s
->portscbase
= sec
->portscbase
;
55 s
->portnr
= sec
->portnr
;
56 s
->as
= &address_space_memory
;
58 usb_ehci_init(s
, DEVICE(obj
));
59 sysbus_init_mmio(d
, &s
->mem
);
62 static void ehci_sysbus_class_init(ObjectClass
*klass
, void *data
)
64 DeviceClass
*dc
= DEVICE_CLASS(klass
);
65 SysBusEHCIClass
*sec
= SYS_BUS_EHCI_CLASS(klass
);
67 sec
->portscbase
= 0x44;
68 sec
->portnr
= NB_PORTS
;
70 dc
->realize
= usb_ehci_sysbus_realize
;
71 dc
->vmsd
= &vmstate_ehci_sysbus
;
72 dc
->props
= ehci_sysbus_properties
;
75 static const TypeInfo ehci_type_info
= {
76 .name
= TYPE_SYS_BUS_EHCI
,
77 .parent
= TYPE_SYS_BUS_DEVICE
,
78 .instance_size
= sizeof(EHCISysBusState
),
79 .instance_init
= ehci_sysbus_init
,
81 .class_init
= ehci_sysbus_class_init
,
82 .class_size
= sizeof(SysBusEHCIClass
),
85 static void ehci_xlnx_class_init(ObjectClass
*oc
, void *data
)
87 SysBusEHCIClass
*sec
= SYS_BUS_EHCI_CLASS(oc
);
89 sec
->capsbase
= 0x100;
90 sec
->opregbase
= 0x140;
93 static const TypeInfo ehci_xlnx_type_info
= {
94 .name
= "xlnx,ps7-usb",
95 .parent
= TYPE_SYS_BUS_EHCI
,
96 .class_init
= ehci_xlnx_class_init
,
99 static void ehci_exynos4210_class_init(ObjectClass
*oc
, void *data
)
101 SysBusEHCIClass
*sec
= SYS_BUS_EHCI_CLASS(oc
);
104 sec
->opregbase
= 0x10;
107 static const TypeInfo ehci_exynos4210_type_info
= {
108 .name
= TYPE_EXYNOS4210_EHCI
,
109 .parent
= TYPE_SYS_BUS_EHCI
,
110 .class_init
= ehci_exynos4210_class_init
,
113 static void ehci_tegra2_class_init(ObjectClass
*oc
, void *data
)
115 SysBusEHCIClass
*sec
= SYS_BUS_EHCI_CLASS(oc
);
117 sec
->capsbase
= 0x100;
118 sec
->opregbase
= 0x140;
121 static const TypeInfo ehci_tegra2_type_info
= {
122 .name
= TYPE_TEGRA2_EHCI
,
123 .parent
= TYPE_SYS_BUS_EHCI
,
124 .class_init
= ehci_tegra2_class_init
,
127 static void ehci_sysbus_register_types(void)
129 type_register_static(&ehci_type_info
);
130 type_register_static(&ehci_xlnx_type_info
);
131 type_register_static(&ehci_exynos4210_type_info
);
132 type_register_static(&ehci_tegra2_type_info
);
135 type_init(ehci_sysbus_register_types
)