Revision 61d3cf93 hw/usb-ohci.c
b/hw/usb-ohci.c | ||
---|---|---|
30 | 30 |
#include "qemu-timer.h" |
31 | 31 |
#include "usb.h" |
32 | 32 |
#include "pci.h" |
33 |
#include "pxa.h" |
|
34 |
#include "devices.h" |
|
35 | 33 |
#include "usb-ohci.h" |
34 |
#include "sysbus.h" |
|
35 |
#include "qdev-addr.h" |
|
36 | 36 |
|
37 | 37 |
//#define DEBUG_OHCI |
38 | 38 |
/* Dump packet contents. */ |
... | ... | |
59 | 59 |
uint32_t ctrl; |
60 | 60 |
} OHCIPort; |
61 | 61 |
|
62 |
enum ohci_type { |
|
63 |
OHCI_TYPE_PCI, |
|
64 |
OHCI_TYPE_PXA, |
|
65 |
OHCI_TYPE_SM501, |
|
66 |
}; |
|
67 |
|
|
68 | 62 |
typedef struct { |
69 | 63 |
USBBus bus; |
70 | 64 |
qemu_irq irq; |
71 |
enum ohci_type type; |
|
72 | 65 |
int mem; |
73 | 66 |
int num_ports; |
74 | 67 |
const char *name; |
... | ... | |
1662 | 1655 |
}; |
1663 | 1656 |
|
1664 | 1657 |
static void usb_ohci_init(OHCIState *ohci, DeviceState *dev, |
1665 |
int num_ports, int devfn, |
|
1666 |
qemu_irq irq, enum ohci_type type, |
|
1667 |
const char *name, uint32_t localmem_base) |
|
1658 |
int num_ports, uint32_t localmem_base) |
|
1668 | 1659 |
{ |
1669 | 1660 |
int i; |
1670 | 1661 |
|
... | ... | |
1686 | 1677 |
|
1687 | 1678 |
ohci->mem = cpu_register_io_memory(ohci_readfn, ohci_writefn, ohci); |
1688 | 1679 |
ohci->localmem_base = localmem_base; |
1689 |
ohci->name = name; |
|
1690 | 1680 |
|
1691 |
ohci->irq = irq; |
|
1692 |
ohci->type = type; |
|
1681 |
ohci->name = dev->info->name; |
|
1693 | 1682 |
|
1694 | 1683 |
usb_bus_new(&ohci->bus, dev); |
1695 | 1684 |
ohci->num_ports = num_ports; |
... | ... | |
1726 | 1715 |
/* TODO: RST# value should be 0. */ |
1727 | 1716 |
ohci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin 1 */ |
1728 | 1717 |
|
1729 |
usb_ohci_init(&ohci->state, &dev->qdev, num_ports, |
|
1730 |
ohci->pci_dev.devfn, ohci->pci_dev.irq[0], |
|
1731 |
OHCI_TYPE_PCI, ohci->pci_dev.name, 0); |
|
1718 |
usb_ohci_init(&ohci->state, &dev->qdev, num_ports, 0); |
|
1719 |
ohci->state.irq = ohci->pci_dev.irq[0]; |
|
1732 | 1720 |
|
1733 | 1721 |
/* TODO: avoid cast below by using dev */ |
1734 | 1722 |
pci_register_bar((struct PCIDevice *)ohci, 0, 256, |
... | ... | |
1741 | 1729 |
pci_create_simple(bus, devfn, "pci-ohci"); |
1742 | 1730 |
} |
1743 | 1731 |
|
1744 |
void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, int devfn, |
|
1745 |
qemu_irq irq) |
|
1746 |
{ |
|
1747 |
OHCIState *ohci = (OHCIState *)qemu_mallocz(sizeof(OHCIState)); |
|
1748 |
|
|
1749 |
usb_ohci_init(ohci, NULL /* FIXME */, num_ports, devfn, irq, |
|
1750 |
OHCI_TYPE_PXA, "OHCI USB", 0); |
|
1751 |
|
|
1752 |
cpu_register_physical_memory(base, 0x1000, ohci->mem); |
|
1753 |
} |
|
1732 |
typedef struct { |
|
1733 |
SysBusDevice busdev; |
|
1734 |
OHCIState ohci; |
|
1735 |
uint32_t num_ports; |
|
1736 |
target_phys_addr_t dma_offset; |
|
1737 |
} OHCISysBusState; |
|
1754 | 1738 |
|
1755 |
void usb_ohci_init_sm501(uint32_t mmio_base, uint32_t localmem_base, |
|
1756 |
int num_ports, int devfn, qemu_irq irq) |
|
1739 |
static int ohci_init_pxa(SysBusDevice *dev) |
|
1757 | 1740 |
{ |
1758 |
OHCIState *ohci = (OHCIState *)qemu_mallocz(sizeof(OHCIState));
|
|
1741 |
OHCISysBusState *s = FROM_SYSBUS(OHCISysBusState, dev);
|
|
1759 | 1742 |
|
1760 |
usb_ohci_init(ohci, NULL /* FIXME */, num_ports, devfn, irq, |
|
1761 |
OHCI_TYPE_SM501, "OHCI USB", localmem_base); |
|
1743 |
usb_ohci_init(&s->ohci, &dev->qdev, s->num_ports, s->dma_offset); |
|
1744 |
sysbus_init_irq(dev, &s->ohci.irq); |
|
1745 |
sysbus_init_mmio(dev, 0x1000, s->ohci.mem); |
|
1762 | 1746 |
|
1763 |
cpu_register_physical_memory(mmio_base, 0x1000, ohci->mem);
|
|
1747 |
return 0;
|
|
1764 | 1748 |
} |
1765 | 1749 |
|
1766 |
static PCIDeviceInfo ohci_info = { |
|
1750 |
static PCIDeviceInfo ohci_pci_info = {
|
|
1767 | 1751 |
.qdev.name = "pci-ohci", |
1768 | 1752 |
.qdev.desc = "Apple USB Controller", |
1769 | 1753 |
.qdev.size = sizeof(OHCIPCIState), |
1770 | 1754 |
.init = usb_ohci_initfn_pci, |
1771 | 1755 |
}; |
1772 | 1756 |
|
1757 |
static SysBusDeviceInfo ohci_sysbus_info = { |
|
1758 |
.init = ohci_init_pxa, |
|
1759 |
.qdev.name = "sysbus-ohci", |
|
1760 |
.qdev.desc = "OHCI USB Controller", |
|
1761 |
.qdev.size = sizeof(OHCISysBusState), |
|
1762 |
.qdev.props = (Property[]) { |
|
1763 |
DEFINE_PROP_UINT32("num-ports", OHCISysBusState, num_ports, 3), |
|
1764 |
DEFINE_PROP_TADDR("dma-offset", OHCISysBusState, dma_offset, 3), |
|
1765 |
DEFINE_PROP_END_OF_LIST(), |
|
1766 |
} |
|
1767 |
}; |
|
1768 |
|
|
1773 | 1769 |
static void ohci_register(void) |
1774 | 1770 |
{ |
1775 |
pci_qdev_register(&ohci_info); |
|
1771 |
pci_qdev_register(&ohci_pci_info); |
|
1772 |
sysbus_register_withprop(&ohci_sysbus_info); |
|
1776 | 1773 |
} |
1777 | 1774 |
device_init(ohci_register); |
Also available in: Unified diff