aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2010-04-05 19:57:40 +0100
committerPaul Brook <paul@codesourcery.com>2010-04-05 19:57:40 +0100
commit61d3cf93e2676282ba1a8d568b2406257f208b26 (patch)
tree43fc3b106d24bdf1c474a23857873974e1b2235f /hw
parent4f78c9ad5a6076a37a944ededfbec508861103f7 (diff)
OHCI qdev conversion
Convert remaining OHCI devices to QDEV interface. Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/devices.h3
-rw-r--r--hw/pxa.h4
-rw-r--r--hw/pxa2xx.c6
-rw-r--r--hw/sm501.c12
-rw-r--r--hw/usb-ohci.c69
5 files changed, 47 insertions, 47 deletions
diff --git a/hw/devices.h b/hw/devices.h
index 0ac561d91b..c788373c8c 100644
--- a/hw/devices.h
+++ b/hw/devices.h
@@ -67,7 +67,4 @@ qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
void sm501_init(uint32_t base, uint32_t local_mem_bytes, qemu_irq irq,
CharDriverState *chr);
-/* usb-ohci.c */
-void usb_ohci_init_sm501(uint32_t mmio_base, uint32_t localmem_base,
- int num_ports, int devfn, qemu_irq irq);
#endif
diff --git a/hw/pxa.h b/hw/pxa.h
index 2ca36c2f6a..8d6a8c3348 100644
--- a/hw/pxa.h
+++ b/hw/pxa.h
@@ -213,8 +213,4 @@ struct PXA2xxI2SState {
PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision);
PXA2xxState *pxa255_init(unsigned int sdram_size);
-/* usb-ohci.c */
-void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, int devfn,
- qemu_irq irq);
-
#endif /* PXA_H */
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index ea62c0b002..909538653c 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -2128,7 +2128,8 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision)
}
if (usb_enabled) {
- usb_ohci_init_pxa(0x4c000000, 3, -1, s->pic[PXA2XX_PIC_USBH1]);
+ sysbus_create_simple("sysbus-ohci", 0x4c000000,
+ s->pic[PXA2XX_PIC_USBH1]);
}
s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000);
@@ -2247,7 +2248,8 @@ PXA2xxState *pxa255_init(unsigned int sdram_size)
}
if (usb_enabled) {
- usb_ohci_init_pxa(0x4c000000, 3, -1, s->pic[PXA2XX_PIC_USBH1]);
+ sysbus_create_simple("sysbus-ohci", 0x4c000000,
+ s->pic[PXA2XX_PIC_USBH1]);
}
s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000);
diff --git a/hw/sm501.c b/hw/sm501.c
index 1a342bdc58..931001479a 100644
--- a/hw/sm501.c
+++ b/hw/sm501.c
@@ -27,6 +27,8 @@
#include "pc.h"
#include "console.h"
#include "devices.h"
+#include "sysbus.h"
+#include "qdev-addr.h"
/*
* Status: 2008/11/02
@@ -1190,6 +1192,7 @@ void sm501_init(uint32_t base, uint32_t local_mem_bytes, qemu_irq irq,
CharDriverState *chr)
{
SM501State * s;
+ DeviceState *dev;
int sm501_system_config_index;
int sm501_disp_ctrl_index;
@@ -1222,8 +1225,13 @@ void sm501_init(uint32_t base, uint32_t local_mem_bytes, qemu_irq irq,
0x1000, sm501_disp_ctrl_index);
/* bridge to usb host emulation module */
- usb_ohci_init_sm501(base + MMIO_BASE_OFFSET + SM501_USB_HOST, base,
- 2, -1, irq);
+ dev = qdev_create(NULL, "sysbus-ohci");
+ qdev_prop_set_uint32(dev, "num-ports", 2);
+ qdev_prop_set_taddr(dev, "dma-offset", base);
+ qdev_init_nofail(dev);
+ sysbus_mmio_map(sysbus_from_qdev(dev), 0,
+ base + MMIO_BASE_OFFSET + SM501_USB_HOST);
+ sysbus_connect_irq(sysbus_from_qdev(dev), 0, irq);
/* bridge to serial emulation module */
if (chr) {
diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c
index ac23c44f65..034acd8e6d 100644
--- a/hw/usb-ohci.c
+++ b/hw/usb-ohci.c
@@ -30,9 +30,9 @@
#include "qemu-timer.h"
#include "usb.h"
#include "pci.h"
-#include "pxa.h"
-#include "devices.h"
#include "usb-ohci.h"
+#include "sysbus.h"
+#include "qdev-addr.h"
//#define DEBUG_OHCI
/* Dump packet contents. */
@@ -59,16 +59,9 @@ typedef struct OHCIPort {
uint32_t ctrl;
} OHCIPort;
-enum ohci_type {
- OHCI_TYPE_PCI,
- OHCI_TYPE_PXA,
- OHCI_TYPE_SM501,
-};
-
typedef struct {
USBBus bus;
qemu_irq irq;
- enum ohci_type type;
int mem;
int num_ports;
const char *name;
@@ -1662,9 +1655,7 @@ static CPUWriteMemoryFunc * const ohci_writefn[3]={
};
static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
- int num_ports, int devfn,
- qemu_irq irq, enum ohci_type type,
- const char *name, uint32_t localmem_base)
+ int num_ports, uint32_t localmem_base)
{
int i;
@@ -1686,10 +1677,8 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
ohci->mem = cpu_register_io_memory(ohci_readfn, ohci_writefn, ohci);
ohci->localmem_base = localmem_base;
- ohci->name = name;
- ohci->irq = irq;
- ohci->type = type;
+ ohci->name = dev->info->name;
usb_bus_new(&ohci->bus, dev);
ohci->num_ports = num_ports;
@@ -1726,9 +1715,8 @@ static int usb_ohci_initfn_pci(struct PCIDevice *dev)
/* TODO: RST# value should be 0. */
ohci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin 1 */
- usb_ohci_init(&ohci->state, &dev->qdev, num_ports,
- ohci->pci_dev.devfn, ohci->pci_dev.irq[0],
- OHCI_TYPE_PCI, ohci->pci_dev.name, 0);
+ usb_ohci_init(&ohci->state, &dev->qdev, num_ports, 0);
+ ohci->state.irq = ohci->pci_dev.irq[0];
/* TODO: avoid cast below by using dev */
pci_register_bar((struct PCIDevice *)ohci, 0, 256,
@@ -1741,37 +1729,46 @@ void usb_ohci_init_pci(struct PCIBus *bus, int devfn)
pci_create_simple(bus, devfn, "pci-ohci");
}
-void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, int devfn,
- qemu_irq irq)
-{
- OHCIState *ohci = (OHCIState *)qemu_mallocz(sizeof(OHCIState));
-
- usb_ohci_init(ohci, NULL /* FIXME */, num_ports, devfn, irq,
- OHCI_TYPE_PXA, "OHCI USB", 0);
-
- cpu_register_physical_memory(base, 0x1000, ohci->mem);
-}
+typedef struct {
+ SysBusDevice busdev;
+ OHCIState ohci;
+ uint32_t num_ports;
+ target_phys_addr_t dma_offset;
+} OHCISysBusState;
-void usb_ohci_init_sm501(uint32_t mmio_base, uint32_t localmem_base,
- int num_ports, int devfn, qemu_irq irq)
+static int ohci_init_pxa(SysBusDevice *dev)
{
- OHCIState *ohci = (OHCIState *)qemu_mallocz(sizeof(OHCIState));
+ OHCISysBusState *s = FROM_SYSBUS(OHCISysBusState, dev);
- usb_ohci_init(ohci, NULL /* FIXME */, num_ports, devfn, irq,
- OHCI_TYPE_SM501, "OHCI USB", localmem_base);
+ usb_ohci_init(&s->ohci, &dev->qdev, s->num_ports, s->dma_offset);
+ sysbus_init_irq(dev, &s->ohci.irq);
+ sysbus_init_mmio(dev, 0x1000, s->ohci.mem);
- cpu_register_physical_memory(mmio_base, 0x1000, ohci->mem);
+ return 0;
}
-static PCIDeviceInfo ohci_info = {
+static PCIDeviceInfo ohci_pci_info = {
.qdev.name = "pci-ohci",
.qdev.desc = "Apple USB Controller",
.qdev.size = sizeof(OHCIPCIState),
.init = usb_ohci_initfn_pci,
};
+static SysBusDeviceInfo ohci_sysbus_info = {
+ .init = ohci_init_pxa,
+ .qdev.name = "sysbus-ohci",
+ .qdev.desc = "OHCI USB Controller",
+ .qdev.size = sizeof(OHCISysBusState),
+ .qdev.props = (Property[]) {
+ DEFINE_PROP_UINT32("num-ports", OHCISysBusState, num_ports, 3),
+ DEFINE_PROP_TADDR("dma-offset", OHCISysBusState, dma_offset, 3),
+ DEFINE_PROP_END_OF_LIST(),
+ }
+};
+
static void ohci_register(void)
{
- pci_qdev_register(&ohci_info);
+ pci_qdev_register(&ohci_pci_info);
+ sysbus_register_withprop(&ohci_sysbus_info);
}
device_init(ohci_register);