OHCI qdev conversion
Convert remaining OHCI devices to QDEV interface. Signed-off-by: Paul Brook <paul@codesourcery.com>
This commit is contained in:
parent
4f78c9ad5a
commit
61d3cf93e2
@ -195,7 +195,7 @@ hw-obj-y += lsi53c895a.o
|
||||
hw-obj-$(CONFIG_ESP) += esp.o
|
||||
|
||||
hw-obj-y += dma-helpers.o sysbus.o isa-bus.o
|
||||
hw-obj-$(CONFIG_QDEV_ADDR) += qdev-addr.o
|
||||
hw-obj-y += qdev-addr.o
|
||||
|
||||
# VGA
|
||||
hw-obj-$(CONFIG_VGA_PCI) += vga-pci.o
|
||||
|
@ -1,6 +1,5 @@
|
||||
# Default configuration for sparc-softmmu
|
||||
|
||||
CONFIG_QDEV_ADDR=y
|
||||
CONFIG_ECC=y
|
||||
CONFIG_ESP=y
|
||||
CONFIG_ESCC=y
|
||||
|
@ -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
|
||||
|
4
hw/pxa.h
4
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 */
|
||||
|
@ -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);
|
||||
|
12
hw/sm501.c
12
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) {
|
||||
|
@ -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)
|
||||
typedef struct {
|
||||
SysBusDevice busdev;
|
||||
OHCIState ohci;
|
||||
uint32_t num_ports;
|
||||
target_phys_addr_t dma_offset;
|
||||
} OHCISysBusState;
|
||||
|
||||
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_PXA, "OHCI USB", 0);
|
||||
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(base, 0x1000, ohci->mem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void usb_ohci_init_sm501(uint32_t mmio_base, uint32_t localmem_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_SM501, "OHCI USB", localmem_base);
|
||||
|
||||
cpu_register_physical_memory(mmio_base, 0x1000, ohci->mem);
|
||||
}
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user