aboutsummaryrefslogtreecommitdiffstats
path: root/hw/usb-ohci.c
AgeCommit message (Collapse)AuthorFilesLines
2012-01-27pci: convert to QEMU Object ModelAnthony Liguori1-14/+23
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27qdev: don't access name through infoAnthony Liguori1-1/+1
We already have a QOM interface for this so let's use it. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27qdev: move qdev->info to classAnthony Liguori1-1/+1
Right now, DeviceInfo acts as the class for qdev. In order to switch to a proper ObjectClass derivative, we need to ween all of the callers off of interacting directly with the info pointer. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-17usb: link packets to endpoints not devicesGerd Hoffmann1-1/+3
Add USBEndpoint for the control endpoint to USBDevices. Link async packets to the USBEndpoint instead of the USBDevice. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-06usb-ohci: td.cbp incorrectly updated near page endAndriy Gapon1-3/+3
The current code that updates the cbp value after a transfer looks like this: td.cbp += ret; if ((td.cbp & 0xfff) + ret > 0xfff) { <handle page overflow> because the 'ret' value is effectively added twice the check may fire too early when the overflow hasn't happened yet. Below is one of the possible changes that correct the behavior: Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-11-28sysbus: rename sysbus_init_mmio_region() to sysbus_init_mmio()Avi Kivity1-1/+1
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-10-13hw/usb-ohci: Honour endpoint maximum packet sizePeter Maydell1-10/+27
Honour the maximum packet size for endpoints; this applies when sending non-isochronous data and means we transfer only as much as the endpoint allows, leaving the transfer descriptor on the list for another go next time around. This allows usb-net to work when connected to an OHCI controller model. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-10-13hw/usb-ohci: Fix OHCI_TD_T1 bit position definitionPeter Maydell1-1/+1
The OHCI Transfer Descriptor T (DataToggle) bits are 24 and 25; fix an error which accidentally overlaid them both on the same bit. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-10-13usb: fix port resetGerd Hoffmann1-1/+1
commit 891fb2cd4592b6fe76106a69e0ca40efbf82726a removed the implicit detach before (re-)attaching in usb_attach(). Some usb host controllers used that behavior though to do a port reset by a detach+attach sequence. This patch establishes old behavior by adding a new usb_reset() function for port resets and putting it into use, thereby also unifying port reset behavior of all host controllers. The patch also adds asserts to usb_attach() and usb_detach() to make sure the calls are symmetrical. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-19pci: interrupt pin documentation updateMichael S. Tsirkin1-2/+1
Fix up some erroneous comments in code: interrupt pins are named A-D, the interrupt pin register is always readonly and isn't zeroed out on reset. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-09-07usb: claim port at device initialization time.Gerd Hoffmann1-2/+2
This patch makes qemu assign a port when creating the device, not when attaching it. For most usb devices this isn't a noticable difference because they are in attached state all the time. The change affects usb-host devices which live in detached state while the real device is unplugged from the host. They have a fixed port assigned all the time now instead of getting grabbing one on attach and releasing it at detach, i.e. they stop floating around at the usb bus. The change also allows to simplify usb-hub. It doesn't need the handle_attach() callback any more to configure the downstream ports. This can be done at device initialitation time now. The changed initialization order (first grab upstream port, then register downstream ports) also fixes some icky corner cases. For example it is not possible any more to plug the hub into one of its own downstream ports. The usb host adapters must care too. USBPort->dev being non-NULL doesn't imply any more the device is in attached state. The host adapters must additionally check the USBPort->dev->attached flag. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-08-08pci: rename pci_register_bar_region() to pci_register_bar()Avi Kivity1-1/+1
Reviewed-by: Richard Henderson <rth@twiddle.net> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-04usb: use iovecs in USBPacketGerd Hoffmann1-12/+11
Zap data pointer from USBPacket, add a QEMUIOVector instead. Add a bunch of helper functions to manage USBPacket data. Switch over users to the new interface. Note that USBPacket->len was used for two purposes: First to pass in the buffer size and second to return the number of transfered bytes or the status code on async transfers. There is a new result variable for the latter. A new status code was added to catch uninitialized result. Nobody creates iovecs with more than one element (yet). Some users are (temporarely) limited to iovecs with a single element to keep the patch size as small as possible. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-29usb-ohci: convert to MemoryRegionAvi Kivity1-25/+17
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-08usb-ohci: raise interrupt on attachGerd Hoffmann1-1/+7
Got lost in commit 618c169b577db64ac6589ad48825d2e11760d1a6, add it back in. Also fix codestyle while we are at it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb-ohci: Add support for being a companion controllerHans de Goede1-12/+40
To use as a companion controller, use pci-ohci as device and set the masterbus and num-ports properties, ie: -device usb-ehci,addr=0b.1,multifunction=on,id=ehci0 -device pci-ohci,addr=0b.0,multifunction=on,masterbus=ehci0.0,num-ports=4 Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb: Replace device_destroy bus op with a child_detach port opHans de Goede1-4/+12
Note this fixes 2 things in one go, first of all the device_destroy bus op should be a device_detach bus op, as pending async packets from the device should be cancelled on detach not on destroy. Secondly having this as a bus op won't work with companion controllers, since then there will be 1 bus driven by the ehci controller and thus 1 set of bus ops, but the device being detached may be downstream of a handed over port. Making the detach of a downstream device a port op allows the ehci controller to forward this to the companion controller port for handed over ports. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb: Make port wakeup and complete ops take a USBPort instead of a DeviceHans de Goede1-7/+5
This makes them consistent with the attach and detach ops, and in general it makes sense to make portops take a port as argument. This also makes adding support for a companion controller easier / cleaner. [ kraxel: fix usb-musb.c build ] Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb: Move (initial) call of usb_port_location to usb_fill_portHans de Goede1-1/+0
Cleanup / preparation patch for companion controller support. Note that as a "side-effect" this patch also fixes the milkymist-softusb controller not having a port_location set for its ports. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-23hw/usb-ohci.c: Fix handling of remote wakeup corner casesPeter Maydell1-3/+14
Correct a number of minor errors in the OHCI wakeup implementation: * when the port is suspended but the controller is not, raise RHSC * when the controller is suspended but the port is not, raise RD * when the controller is suspended, move it to resume state These fix some edge cases where a USB device might not successfully get the attention of the guest OS if it tried to do so at the wrong time. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-22Merge remote-tracking branch 'mst/for_anthony' into stagingAnthony Liguori1-4/+3
Conflicts: hw/usb-uhci.c
2011-06-15Merge remote-tracking branch 'origin/master' into pciMichael S. Tsirkin1-8/+5
Conflicts: hw/virtio-pci.c
2011-06-14hw/usb-ohci.c: Implement remote wakeupPeter Maydell1-0/+17
Implement the wakeup callback in the OHCI USBPortOps, so that when a downstream device wakes up it correctly causes the OHCI controller to come out of suspend. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14hw/usb-ohci.c: Ignore writes to HcPeriodCurrentED registerPeter Maydell1-0/+4
HcPeriodCurrentED is read-only, but Linux writes to it anyway; silently ignore this rather than printing a warning message. (Specifically, drivers/usb/host/ohci-hub.c:ohci_rh_resume() writes a 0, in at least kernels 2.6.25 through 2.6.39.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14usb: cancel async packets on unplugGerd Hoffmann1-1/+15
This patch adds USBBusOps struct with (for now) only a single callback which is called when a device is about to be destroyed. The USB Host adapters are implementing this callback and use it to cancel any async requests which might be in flight before the device actually goes away. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-12hw/usb-ohci.c: convert to PCIDeviceInfo to initialize idsIsaku Yamahata1-4/+3
use PCIDeviceInfo to initialize ids. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-05-26usb: add usb_handle_packetGerd Hoffmann1-2/+2
Add a usb_handle_packet function, put it into use everywhere. Right now it just calls dev->info->handle_packet(), that will change in future patches though. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-05Merge remote-tracking branch 'mst/for_anthony' into stagingAnthony Liguori1-9/+1
2011-05-05Merge remote branch 'origin/master' into pciMichael S. Tsirkin1-8/+6
Conflicts: exec.c
2011-05-04usb: move complete callback to port opsGerd Hoffmann1-5/+2
2011-05-04ohci: get ohci state via container_of()Gerd Hoffmann1-1/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-04-12Replace cpu_physical_memory_rw were possibleStefan Weil1-8/+6
Using cpu_physical_memory_read, cpu_physical_memory_write and ldub_phys improves readability and allows removing some type casts. lduw_phys and ldl_phys were not used because both require aligned addresses. Therefore it is not possible to simply replace existing calls by one of these functions. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-07usb-ohci: convert to pci_register_bar_simple()Avi Kivity1-9/+1
Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-03-21change all other clock references to use nanosecond resolution accessorsPaolo Bonzini1-4/+4
This was done with: sed -i 's/qemu_get_clock\>/qemu_get_clock_ns/' \ $(git grep -l 'qemu_get_clock\>' ) sed -i 's/qemu_new_timer\>/qemu_new_timer_ns/' \ $(git grep -l 'qemu_new_timer\>' ) after checking that get_clock and new_timer never occur twice on the same line. There were no missed occurrences; however, even if there had been, they would have been caught by the compiler. There was exactly one false positive in qemu_run_timers: - current_time = qemu_get_clock (clock); + current_time = qemu_get_clock_ns (clock); which is of course not in this patch. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2011-01-12usb: zap pdev from usbportGerd Hoffmann1-1/+1
It isn't needed any more. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: keep track of physical port address.Gerd Hoffmann1-0/+1
Add a path string to USBPort. Add usb_port_location() function to set the physical location of the usb port. Update all drivers implementing usb ports to call it. Update the monitor commands to print it. Wind it up in qdev. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: add speed mask to portsGerd Hoffmann1-1/+2
Add a field to usb ports indicating the speed(s) they are able to handle. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: rework attach/detach workflowGerd Hoffmann1-42/+38
Add separate detach callback to USBPortOps, split uhci/ohci/musb/usbhub attach functions into two. Move common code to the usb_attach() function, only the hardware-specific bits remain in the attach/detach callbacks. Keep track of the port it is attached to for each usb device. [ v3: fix tyops in usb-musb.c ] Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: create USBPortOps, move attach there.Gerd Hoffmann1-1/+5
Create USBPortOps struct, move the attach function to that struct. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2010-12-11Record which USBDevice USBPort belongs too.Gleb Natapov1-1/+1
Ports on root hub will have NULL here. This is needed to reconstruct path from device to its root hub to build device path. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-12-11usb_ohci: Always use little endianAlexander Graf1-8/+1
This patch replaces explicit bswaps with endianness hints to the mmio layer. Because we don't depend on the target endianness anymore, we can also move the driver over to Makefile.objs. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-12-11Add endianness as io mem parameterAlexander Graf1-1/+2
As stated before, devices can be little, big or native endian. The target endianness is not of their concern, so we need to push things down a level. This patch adds a parameter to cpu_register_io_memory that allows a device to choose its endianness. For now, all devices simply choose native endian, because that's the same behavior as before. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-11-22pci: Replace unneeded type casts in calls of pci_register_barStefan Weil1-1/+1
There is no need for these type casts (as other existing code shows). So re-write the first argument without type cast (and remove a related TODO comment). Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2010-06-13OHCI address decoding fixPaul Brook1-0/+4
Ignore high address bits when PCI memory window is not mapped on a page boundary. Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-04-25usb: remove dead assignments, spotted by clang analyzerBlue Swirl1-0/+16
Value stored is never read. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-04-18Fix harmless if statements with empty body, spotted by clangBlue Swirl1-4/+6
These clang errors are harmless but worth fixing: CC ppc-softmmu/usb-ohci.o /src/qemu/hw/usb-ohci.c:1104:59: error: if statement has empty body [-Wempty-body] ohci->ctrl_head, ohci->ctrl_cur); /src/qemu/hw/usb-ohci.c:1371:57: error: if statement has empty body [-Wempty-body] DPRINTF("usb-ohci: port %d: SUSPEND\n", portnum); CC sparc64-softmmu/translate.o /src/qemu/target-sparc/translate.c:3173:37: error: if statement has empty body [-Wempty-body] ; // XXX Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-04-05OHCI qdev conversionPaul Brook1-36/+33
Convert remaining OHCI devices to QDEV interface. Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-04-04Revert "Compile usb-ohci only once"Paul Brook1-60/+26
This reverts commit f1698408f1dcb7548a21828a0b1e2b530fae3af3. PCI is always little-endian. Having a user-visible "be" property is just plain wrong.
2010-03-31usb: class specific interface requestsMax Reitz1-1/+1
Mass Storage Reset and Get Max LUN are class specific requests, but they were not marked as such in hw/usb-msd.c, moved therefore ClassInterfaceRequest and ClassInterfaceOutRequest from hw/usb-net.c to hw/usb.h. Furthermore there was a problem in hw/usb-ohci.c when using DEBUG concerning systems where size_t is a 32 bit integer (printf resulted in a segmentation fault). Signed-off-by: Max Reitz <max@tyndur.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-21Compile usb-ohci only onceBlue Swirl1-26/+60
Push TARGET_WORDS_BIGENDIAN dependency to board level. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>