Add QOM class definition helpers for sysbus attached EHCI implementations. Signed-off-by: Peter Crosthwaite <peter.crosthwa...@xilinx.com> --- changed from v1: Dont create a QOM definition for Sysbus EHCI, rather just add all the bits and pieces. (Multiple) sysbus EHCI defs can be created by adding to the type_info[] table. Use dma_context_memory for sysbus DMA (PMM review)
hw/usb/hcd-ehci.c | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 1c5e5ed..50a85d5 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -35,6 +35,8 @@ #include "trace.h" #include "dma.h" #include "sysemu.h" +#include "hw/sysbus.h" +#include "exec-memory.h" #define EHCI_DEBUG 0 @@ -448,6 +450,7 @@ struct EHCIState { typedef struct EHCItfState { union { PCIDevice pcidev; + SysBusDevice busdev; }; struct EHCIState ehci; } EHCIItfState; @@ -2546,6 +2549,7 @@ static const MemoryRegionOps ehci_mmio_port_ops = { }; static int usb_ehci_pci_initfn(PCIDevice *dev); +static int usb_ehci_sysbus_initfn(SysBusDevice *dev); static USBPortOps ehci_port_ops = { .attach = ehci_attach, @@ -2652,6 +2656,16 @@ static const VMStateDescription vmstate_ehci_pci = { } }; +static const VMStateDescription vmstate_ehci_sysbus = { + .name = "ehci-sysbus", + .version_id = 2, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_STRUCT(ehci, EHCIItfState, 2, vmstate_ehci, EHCIState), + VMSTATE_END_OF_LIST() + } +}; + static Property ehci_properties[] = { DEFINE_PROP_UINT32("maxframes", EHCIItfState, ehci.maxframes, 128), DEFINE_PROP_END_OF_LIST(), @@ -2660,6 +2674,7 @@ static Property ehci_properties[] = { typedef struct EHCIClass { union { PCIDeviceClass pci; + SysBusDeviceClass sysbus; }; uint16_t capabase; @@ -2694,6 +2709,14 @@ static void ehci_pci_class_init(ObjectClass *klass, void *data) ehci_class_init(klass, data); } +static void ehci_sysbus_class_init(ObjectClass *klass, void *data) +{ + SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); + + k->init = usb_ehci_sysbus_initfn; + ehci_class_init(klass, data); +} + static TypeInfo ehci_info[] = { { .name = "usb-ehci", @@ -2726,7 +2749,6 @@ static TypeInfo ehci_info[] = { }, { .name = NULL } }; - static void usb_ehci_initfn(EHCIState *s, DeviceState *dev) { EHCIClass *c = (EHCIClass *)object_get_class(OBJECT(dev)); @@ -2778,6 +2800,20 @@ static void usb_ehci_initfn(EHCIState *s, DeviceState *dev) &s->mem_ports); } +static int usb_ehci_sysbus_initfn(SysBusDevice *dev) +{ + EHCIItfState *i = FROM_SYSBUS(EHCIItfState, dev); + EHCIState *s = &i->ehci; + + s->dma = &dma_context_memory; + + usb_ehci_initfn(s, DEVICE(dev)); + sysbus_init_irq(dev, &s->irq); + sysbus_init_mmio(dev, &s->mem); + + return 0; +} + static int usb_ehci_pci_initfn(PCIDevice *dev) { EHCIItfState *i = DO_UPCAST(EHCIItfState, pcidev, dev); -- 1.7.0.4