21
#include "qemu/osdep.h"
23
#include "qapi/error.h"
24
#include "qemu/module.h"
25
#include "qemu/timer.h"
27
#include "migration/vmstate.h"
29
#include "hw/qdev-dma.h"
30
#include "hw/qdev-properties.h"
35
static void ohci_sysbus_realize(DeviceState *dev, Error **errp)
37
OHCISysBusState *s = SYSBUS_OHCI(dev);
38
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
41
usb_ohci_init(&s->ohci, dev, s->num_ports, s->dma_offset,
42
s->masterbus, s->firstport,
43
&address_space_memory, ohci_sysbus_die, &err);
45
error_propagate(errp, err);
48
sysbus_init_irq(sbd, &s->ohci.irq);
49
sysbus_init_mmio(sbd, &s->ohci.mem);
52
static void ohci_sysbus_reset(DeviceState *dev)
54
OHCISysBusState *s = SYSBUS_OHCI(dev);
55
OHCIState *ohci = &s->ohci;
57
ohci_hard_reset(ohci);
60
static Property ohci_sysbus_properties[] = {
61
DEFINE_PROP_STRING("masterbus", OHCISysBusState, masterbus),
62
DEFINE_PROP_UINT32("num-ports", OHCISysBusState, num_ports, 3),
63
DEFINE_PROP_UINT32("firstport", OHCISysBusState, firstport, 0),
64
DEFINE_PROP_DMAADDR("dma-offset", OHCISysBusState, dma_offset, 0),
65
DEFINE_PROP_END_OF_LIST(),
68
static void ohci_sysbus_class_init(ObjectClass *klass, void *data)
70
DeviceClass *dc = DEVICE_CLASS(klass);
72
dc->realize = ohci_sysbus_realize;
73
set_bit(DEVICE_CATEGORY_USB, dc->categories);
74
dc->desc = "OHCI USB Controller";
75
device_class_set_props(dc, ohci_sysbus_properties);
76
dc->reset = ohci_sysbus_reset;
79
static const TypeInfo ohci_sysbus_types[] = {
81
.name = TYPE_SYSBUS_OHCI,
82
.parent = TYPE_SYS_BUS_DEVICE,
83
.instance_size = sizeof(OHCISysBusState),
84
.class_init = ohci_sysbus_class_init,
88
DEFINE_TYPES(ohci_sysbus_types);