aboutsummaryrefslogtreecommitdiff
path: root/src/hw/usb.c
AgeCommit message (Collapse)AuthorFilesLines
2023-10-31parisc: USB OHCI endianess fixesHelge Deller1-8/+8
Signed-off-by: Helge Deller <deller@gmx.de>
2023-10-14parisc/usb: Fix usb host for big-endian machines (like parisc)Helge Deller1-7/+7
Signed-off-by: Helge Deller <deller@gmx.de>
2020-09-25usb.c: Fix devices using non-primary interface descriptorMatt DeVillier1-8/+19
A fair number of USB devices (keyboards in particular) use an interface descriptor other than the first available, making them non-functional currently. To correct this, iterate through all available interface descriptors until one with the correct class/subclass is found, then proceed to set the configuration and setup the driver. Tested on an ultimate hacking keyboard (UHK 60) Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
2016-10-26usb: Make usb_time_sigatt variable staticKevin O'Connor1-1/+1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-02-02usb: Eliminate USB controller setup threadKevin O'Connor1-11/+5
There are no longer any sleep or yield calls during the usb controller device scans, so there is no need to run these device scans in a separate thread. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-11-17usb: Allow configuration of sigatt time (in etc/usb-time-sigatt)Kevin O'Connor1-1/+5
Several users have reported devices that take more than 100ms to announce their presence on a USB port. Allow the sigatt timeout to be specified at runtime as a way to extend the default timeout. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-15stacks: Use macro wrappers for call32() and stack_hop_back()Kevin O'Connor1-3/+2
The C code only uses _cfuncX_ prefixes for parameters to the call32(), stack_hop_back(), and call32_params() functions. It's simpler to use macro wrappers around those functions which provide the required prefix. This also changes the parameter order of stack_hop() and stack_hop_back() to use the more natural (func, params) ordering. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-07-04Make sure all code checks for malloc failuresKevin O'Connor1-1/+3
This is the result of an audit of callers of the malloc_XXX() and memalign_XXX() calls. All callers need to check if these functions return NULL. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-01-07usb: Minor - properly free memory on get_device_config() error pathKevin O'Connor1-1/+3
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-01-07usb: Control transfers always have an 8 byte command sizeKevin O'Connor1-8/+8
There is no need to pass 'cmdsize' to the usb drivers as the cmdsize is always 8 bytes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-01-07usb: Use usb_send_pipe() now that all drivers have x_send_pipe()Kevin O'Connor1-25/+15
Now that all drivers have unified control and bulk transmit functions, unify the driver calling code in usb.c as well. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-01-07xhci: Merge xhci_send_control with xhci_send_bulkKevin O'Connor1-2/+2
Merge both the control and bulk pipe sending functions into one new function: xhci_send_pipe(). This makes the xhci interface similar to the other usb drivers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-01-07uhci: Merge uhci_send_control with uhci_send_bulkKevin O'Connor1-2/+2
Merge both the control and bulk pipe sending functions into one new function: uhci_send_pipe(). The two existing functions were similar, and by merging them the resulting code supports more flexible control transfers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-01-07ohci: Merge ohci_send_control with ohci_send_bulkKevin O'Connor1-2/+2
Merge both the control and bulk pipe sending functions into one new function: ohci_send_pipe(). The two existing functions were similar, and by merging them the resulting code supports more flexible control transfers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-01-07ehci: Merge ehci_send_control with ehci_send_bulkKevin O'Connor1-2/+2
Merge both the control and bulk pipe sending functions into one new function: ehci_send_pipe(). The two existing functions were similar, and by merging them the resulting code supports more flexible control transfers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-01-01usb: Add support for OHCI bulk transfersKevin O'Connor1-1/+4
Support bulk transfers (usb drives) on OHCI USB controllers. Now that there is support for 32bit only drive controllers, it is not that hard to support disks on OHCI controllers, and it may be useful for some old hardware. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-16usb: Use usb_realloc_pipe for pipe alloc, update, and free.Kevin O'Connor1-33/+27
Now that the usb controller drivers all support the realloc method, use that for all pipe allocations, reallocations, and freeing. This gives the driver more control over the pipe life cycle. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-16ehci: Export ehci_realloc_pipe() instead of ehci_alloc_pipe()Kevin O'Connor1-1/+1
Support alloc, update, and free from the single exported function. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-16ohci: Export ohci_realloc_pipe() instead of ohci_alloc_pipe()Kevin O'Connor1-1/+1
Support alloc, update, and free from the single exported function. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-16uhci: Export uhci_realloc_pipe() instead of uhci_alloc_pipe()Kevin O'Connor1-1/+1
Support alloc, update, and free from the single exported function. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-16xhci: Change xhci_update_pipe() to xhci_realloc_pipe() and use for alloc tooKevin O'Connor1-2/+2
Instead of exporting both xhci_alloc_pipe() and xhci_update_pipe(), export only xhci_realloc_pipe() and support alloc, update, and free from it. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-16usb: Clarify usb freelist manipulationsKevin O'Connor1-5/+20
Rename usb_getFreePipe() to usb_get_freelist(). Add usb_is_freelist() and usb_add_freelist() functions. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-16usb: Rename free_pipe() to usb_free_pipe()Kevin O'Connor1-4/+4
Also, pass in usbdev to usb_free_pipe(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-16usb: Rename send_default_control() to usb_send_default_control()Kevin O'Connor1-7/+7
This is just function renaming - no code implementation changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-16usb: Rename findEndPointDesc() to usb_find_desc()Kevin O'Connor1-2/+2
This is just function renaming - no code implementation changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-16usb: Rename usb_getFrameExp() to usb_get_period()Kevin O'Connor1-2/+2
This is just function renaming - no code implementation changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-16usb: Rename ?hci_control() to ?hci_send_control()Kevin O'Connor1-8/+8
This is just function renaming - no code implementation changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-09-16usb: Perform device detect polling on all usb controllers.Kevin O'Connor1-6/+15
Move the 100ms (USB_TIME_SIGATT) device detect polling from the ohci/uhci/usb-hub code to the generic usb_hub_port_setup() code. This extends the 100ms polling to ehci and xhci controllers. The code in usb_hub_port_setup() now compares USB_TIME_SIGATT to the start of usb_enumerate(), which may make boots faster when threads are disabled. This patch also changes the meaning of the return code for hub->op->detect() calls. Now 1 indicates device found, 0 indicates device not found, and -1 indicates permanent failure. Also, the xhci controller generic delay of 100ms is replaced with a 20ms root hub power stabilize time. This in combination with the 100ms for USB_TIME_SIGATT should be closer to the USB2 spec (the USB3 spec does not seem to declare an equivalent of USB_TIME_SIGATT). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-09-09usb: Fix usb_xfer_time() to work when called in 16bit mode.Kevin O'Connor1-1/+1
Make sure to wrap accesses to the usb_pipe struct with GET_LOWFLAT so that it works in 16bit mode. This bug impacts both ehci and uhci usb controllers (it should not impact ohci and xhci as those never call the function in 16bit mode). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-06-14xhci: Update the times for usb command timeouts.Kevin O'Connor1-0/+13
The xhci controller had a hardcoded 1 second timeout for both bulk and control transfers. The 1 second bulk timeout is too small for some real devices. Increase both times to 5.1 seconds - according to the USB spec, the maximum time a command should take is 5 seconds. However, have the set_address command only wait for 150ms (spec says set_address should take no more than 50ms). Introduce usb_xfer_time() to calculate maximum command time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-01-29usb: Move default pipe max packet size code from xhci to main code.Kevin O'Connor1-1/+8
Also, the max packet size for super speed devices is 512 bytes (not 256 bytes). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-01-29usb: USB 3 devices encode bMaxPacketSize0 field.Kevin O'Connor1-4/+7
A USB 3 device uses an exponential encoding of the max packet size for the default end point. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-01-29xhci: Run the XHCI driver entirely in 32bit mode.Kevin O'Connor1-2/+11
Since the XHCI driver needs to jump into 32bit mode anyway, it is simpler to just run all of the code in 32bit mode. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-01-29xhci: Move set_address code from xhci_control to xhci_alloc_pipe.Kevin O'Connor1-2/+2
It's easier to run the set_address from xhci_alloc_pipe as there is more information available there. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-27usb: Replace EHCI to UHCI/OHCI synchronization with new scheme.Kevin O'Connor1-47/+12
The previous code attempts to correlate which UHCI and OHCI controllers correlate with which EHCI controllers so that it can ensure high speed devices are handled by the EHCI code while low/full speed devices are handled by the UHCI/OHCI code. Replace this logic by initializing all EHCI controllers first, and then initializing all UHCI and OHCI controllers. This simplifies the code and improves support for some hardware devices that don't follow the OHCI/UHCI to EHCI correlation standard. Also, remove the unused usb->busid field. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-19usb: add xhci supportGerd Hoffmann1-0/+13
$subject says all. Support for usb3 streams is not implemented yet, otherwise it is fully functional. Tested all usb devices supported by qemu (keyboard, storage, usb hubs), except for usb attached scsi in usb3 mode (which needs streams). Tested on qemu only, tagged with QEMU_HARDWARE because of that. Testing with physical hardware to be done. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-19usb: add usb_update_pipe()Gerd Hoffmann1-5/+17
Preparation for better xhci support: allows to notify host controllers instead of going through a free+alloc cycle. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-18Move function definitions for output.c from util.h to new file output.h.Kevin O'Connor1-9/+10
Also, sort the order of include files in the c files. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18Move malloc code from pmm.c to new files malloc.c and malloc.h.Kevin O'Connor1-0/+1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18Rename util.c to string.c and introduce string.h.Kevin O'Connor1-0/+1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18Split x86 specific functions out of util.c/h to new files x86.c/h.Kevin O'Connor1-0/+1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-02Move code centered around specific hardware devices to src/hw/Kevin O'Connor1-0/+461
Move many C files from the src/ directory to the new src/hw/ directory. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>