iPXE
|
USB eXtensible Host Controller Interface (xHCI) driver. More...
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/malloc.h>
#include <ipxe/pci.h>
#include <ipxe/usb.h>
#include <ipxe/init.h>
#include <ipxe/profile.h>
#include "xhci.h"
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static void | xhci_init (struct xhci_device *xhci, void *regs) |
Initialise device. More... | |
static unsigned int | xhci_extended_capability (struct xhci_device *xhci, unsigned int id, unsigned int offset) |
Find extended capability. More... | |
static int | xhci_writeq (struct xhci_device *xhci, physaddr_t value, void *reg) |
Write potentially 64-bit register. More... | |
static size_t | xhci_align (size_t len) |
Calculate buffer alignment. More... | |
static size_t | xhci_device_context_offset (struct xhci_device *xhci, unsigned int ctx) |
Calculate device context offset. More... | |
static size_t | xhci_input_context_offset (struct xhci_device *xhci, unsigned int ctx) |
Calculate input context offset. More... | |
static void | xhci_dump (struct xhci_device *xhci) |
Dump host controller registers. More... | |
static void | xhci_dump_port (struct xhci_device *xhci, unsigned int port) |
Dump port registers. More... | |
static void | xhci_legacy_init (struct xhci_device *xhci) |
Initialise USB legacy support. More... | |
static void | xhci_legacy_claim (struct xhci_device *xhci) |
Claim ownership from BIOS. More... | |
static void | xhci_legacy_release (struct xhci_device *xhci) |
Release ownership back to BIOS. More... | |
static const char * | xhci_speed_name (uint32_t psi) |
Transcribe port speed (for debugging) More... | |
static unsigned int | xhci_supported_protocol (struct xhci_device *xhci, unsigned int port) |
Find supported protocol extended capability for a port. More... | |
static unsigned int | xhci_port_protocol (struct xhci_device *xhci, unsigned int port) |
Find port protocol. More... | |
static int | xhci_port_slot_type (struct xhci_device *xhci, unsigned int port) |
Find port slot type. More... | |
static int | xhci_port_speed (struct xhci_device *xhci, unsigned int port, unsigned int psiv) |
Find port speed. More... | |
static int | xhci_port_psiv (struct xhci_device *xhci, unsigned int port, unsigned int speed) |
Find protocol speed ID value. More... | |
static int | xhci_dcbaa_alloc (struct xhci_device *xhci) |
Allocate device context base address array. More... | |
static void | xhci_dcbaa_free (struct xhci_device *xhci) |
Free device context base address array. More... | |
static int | xhci_scratchpad_alloc (struct xhci_device *xhci) |
Allocate scratchpad buffers. More... | |
static void | xhci_scratchpad_free (struct xhci_device *xhci) |
Free scratchpad buffers. More... | |
static void | xhci_run (struct xhci_device *xhci) |
Start xHCI device. More... | |
static int | xhci_stop (struct xhci_device *xhci) |
Stop xHCI device. More... | |
static int | xhci_reset (struct xhci_device *xhci) |
Reset xHCI device. More... | |
static int | xhci_fail (struct xhci_device *xhci) |
Mark xHCI device as permanently failed. More... | |
static int | xhci_ring_alloc (struct xhci_device *xhci, struct xhci_trb_ring *ring, unsigned int shift, unsigned int slot, unsigned int target, unsigned int stream) |
Allocate transfer request block ring. More... | |
static void | xhci_ring_reset (struct xhci_trb_ring *ring) |
Reset transfer request block ring. More... | |
static void | xhci_ring_free (struct xhci_trb_ring *ring) |
Free transfer request block ring. More... | |
static int | xhci_enqueue (struct xhci_trb_ring *ring, struct io_buffer *iobuf, const union xhci_trb *trb) |
Enqueue a transfer request block. More... | |
static struct io_buffer * | xhci_dequeue (struct xhci_trb_ring *ring) |
Dequeue a transfer request block. More... | |
static int | xhci_enqueue_multi (struct xhci_trb_ring *ring, struct io_buffer *iobuf, const union xhci_trb *trbs, unsigned int count) |
Enqueue multiple transfer request blocks. More... | |
static struct io_buffer * | xhci_dequeue_multi (struct xhci_trb_ring *ring) |
Dequeue multiple transfer request blocks. More... | |
static void | xhci_doorbell (struct xhci_trb_ring *ring) |
Ring doorbell register. More... | |
static int | xhci_command_alloc (struct xhci_device *xhci) |
Allocate command ring. More... | |
static void | xhci_command_free (struct xhci_device *xhci) |
Free command ring. More... | |
static int | xhci_event_alloc (struct xhci_device *xhci) |
Allocate event ring. More... | |
static void | xhci_event_free (struct xhci_device *xhci) |
Free event ring. More... | |
static void | xhci_transfer (struct xhci_device *xhci, struct xhci_trb_transfer *trb) |
Handle transfer event. More... | |
static void | xhci_complete (struct xhci_device *xhci, struct xhci_trb_complete *trb) |
Handle command completion event. More... | |
static void | xhci_port_status (struct xhci_device *xhci, struct xhci_trb_port_status *trb) |
Handle port status event. More... | |
static void | xhci_host_controller (struct xhci_device *xhci, struct xhci_trb_host_controller *trb) |
Handle host controller event. More... | |
static void | xhci_event_poll (struct xhci_device *xhci) |
Poll event ring. More... | |
static void | xhci_abort (struct xhci_device *xhci) |
Abort command. More... | |
static int | xhci_command (struct xhci_device *xhci, union xhci_trb *trb) |
Issue command and wait for completion. More... | |
static int | xhci_nop (struct xhci_device *xhci) |
Issue NOP and wait for completion. More... | |
static int | xhci_enable_slot (struct xhci_device *xhci, unsigned int type) |
Enable slot. More... | |
static int | xhci_disable_slot (struct xhci_device *xhci, unsigned int slot) |
Disable slot. More... | |
static int | xhci_context (struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint, unsigned int type, void(*populate)(struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint, void *input)) |
Issue context-based command and wait for completion. More... | |
static void | xhci_address_device_input (struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint, void *input) |
Populate address device input context. More... | |
static int | xhci_address_device (struct xhci_device *xhci, struct xhci_slot *slot) |
Address device. More... | |
static void | xhci_configure_endpoint_input (struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint, void *input) |
Populate configure endpoint input context. More... | |
static int | xhci_configure_endpoint (struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint) |
Configure endpoint. More... | |
static void | xhci_deconfigure_endpoint_input (struct xhci_device *xhci __unused, struct xhci_slot *slot __unused, struct xhci_endpoint *endpoint, void *input) |
Populate deconfigure endpoint input context. More... | |
static int | xhci_deconfigure_endpoint (struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint) |
Deconfigure endpoint. More... | |
static void | xhci_evaluate_context_input (struct xhci_device *xhci, struct xhci_slot *slot __unused, struct xhci_endpoint *endpoint, void *input) |
Populate evaluate context input context. More... | |
static int | xhci_evaluate_context (struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint) |
Evaluate context. More... | |
static int | xhci_reset_endpoint (struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint) |
Reset endpoint. More... | |
static int | xhci_stop_endpoint (struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint) |
Stop endpoint. More... | |
static int | xhci_set_tr_dequeue_pointer (struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint) |
Set transfer ring dequeue pointer. More... | |
static int | xhci_endpoint_open (struct usb_endpoint *ep) |
Open endpoint. More... | |
static void | xhci_endpoint_close (struct usb_endpoint *ep) |
Close endpoint. More... | |
static int | xhci_endpoint_reset (struct usb_endpoint *ep) |
Reset endpoint. More... | |
static int | xhci_endpoint_mtu (struct usb_endpoint *ep) |
Update MTU. More... | |
static int | xhci_endpoint_message (struct usb_endpoint *ep, struct io_buffer *iobuf) |
Enqueue message transfer. More... | |
static unsigned int | xhci_endpoint_count (size_t len, int zlp) |
Calculate number of TRBs. More... | |
static int | xhci_endpoint_stream (struct usb_endpoint *ep, struct io_buffer *iobuf, int zlp) |
Enqueue stream transfer. More... | |
static int | xhci_device_open (struct usb_device *usb) |
Open device. More... | |
static void | xhci_device_close (struct usb_device *usb) |
Close device. More... | |
static int | xhci_device_address (struct usb_device *usb) |
Assign device address. More... | |
static int | xhci_bus_open (struct usb_bus *bus) |
Open USB bus. More... | |
static void | xhci_bus_close (struct usb_bus *bus) |
Close USB bus. More... | |
static void | xhci_bus_poll (struct usb_bus *bus) |
Poll USB bus. More... | |
static int | xhci_hub_open (struct usb_hub *hub) |
Open hub. More... | |
static void | xhci_hub_close (struct usb_hub *hub __unused) |
Close hub. More... | |
static int | xhci_root_open (struct usb_hub *hub) |
Open root hub. More... | |
static void | xhci_root_close (struct usb_hub *hub __unused) |
Close root hub. More... | |
static int | xhci_root_enable (struct usb_hub *hub, struct usb_port *port) |
Enable port. More... | |
static int | xhci_root_disable (struct usb_hub *hub, struct usb_port *port) |
Disable port. More... | |
static int | xhci_root_speed (struct usb_hub *hub, struct usb_port *port) |
Update root hub port speed. More... | |
static int | xhci_root_clear_tt (struct usb_hub *hub, struct usb_port *port, struct usb_endpoint *ep) |
Clear transaction translator buffer. More... | |
static void | xhci_pch_fix (struct xhci_device *xhci, struct pci_device *pci) |
Fix Intel PCH-specific quirks. More... | |
static void | xhci_pch_undo (struct xhci_device *xhci, struct pci_device *pci) |
Undo Intel PCH-specific quirk fixes. More... | |
static int | xhci_probe (struct pci_device *pci) |
Probe PCI device. More... | |
static void | xhci_remove (struct pci_device *pci) |
Remove PCI device. More... | |
static void | xhci_shutdown (int booting) |
Prepare for exit. More... | |
struct startup_fn xhci_startup | __startup_fn (STARTUP_LATE) |
Startup/shutdown function. More... | |
Variables | |
static struct profiler xhci_message_profiler | __profiler |
Message transfer profiler. More... | |
static int | xhci_legacy_prevent_release |
Prevent the release of ownership back to BIOS. More... | |
static struct usb_host_operations | xhci_operations |
USB host controller operations. More... | |
static struct pci_device_id | xhci_ids [] |
XHCI PCI device IDs. More... | |
struct pci_driver xhci_driver | __pci_driver |
XHCI PCI driver. More... | |
USB eXtensible Host Controller Interface (xHCI) driver.
Definition in file xhci.c.
#define EIO_DATA __einfo_error ( EINFO_EIO_DATA ) |
#define EINFO_EIO_DATA |
#define EIO_BABBLE __einfo_error ( EINFO_EIO_BABBLE ) |
#define EINFO_EIO_BABBLE |
#define EIO_USB __einfo_error ( EINFO_EIO_USB ) |
#define EINFO_EIO_USB |
#define EIO_TRB __einfo_error ( EINFO_EIO_TRB ) |
#define EINFO_EIO_TRB |
#define EIO_STALL __einfo_error ( EINFO_EIO_STALL ) |
#define EINFO_EIO_STALL |
#define EIO_RESOURCE __einfo_error ( EINFO_EIO_RESOURCE ) |
#define EINFO_EIO_RESOURCE |
#define EIO_BANDWIDTH __einfo_error ( EINFO_EIO_BANDWIDTH ) |
#define EINFO_EIO_BANDWIDTH |
#define EIO_NO_SLOTS __einfo_error ( EINFO_EIO_NO_SLOTS ) |
#define EINFO_EIO_NO_SLOTS |
#define EIO_STREAM_TYPE __einfo_error ( EINFO_EIO_STREAM_TYPE ) |
#define EINFO_EIO_STREAM_TYPE |
#define EIO_SLOT __einfo_error ( EINFO_EIO_SLOT ) |
#define EINFO_EIO_SLOT |
#define EIO_ENDPOINT __einfo_error ( EINFO_EIO_ENDPOINT ) |
#define EINFO_EIO_ENDPOINT |
#define EIO_SHORT __einfo_error ( EINFO_EIO_SHORT ) |
#define EINFO_EIO_SHORT |
#define EIO_UNDERRUN __einfo_error ( EINFO_EIO_UNDERRUN ) |
#define EINFO_EIO_UNDERRUN |
#define EIO_OVERRUN __einfo_error ( EINFO_EIO_OVERRUN ) |
#define EINFO_EIO_OVERRUN |
#define EIO_VF_RING_FULL __einfo_error ( EINFO_EIO_VF_RING_FULL ) |
#define EINFO_EIO_VF_RING_FULL |
#define EIO_PARAMETER __einfo_error ( EINFO_EIO_PARAMETER ) |
#define EINFO_EIO_PARAMETER |
#define EIO_BANDWIDTH_OVERRUN __einfo_error ( EINFO_EIO_BANDWIDTH_OVERRUN ) |
#define EINFO_EIO_BANDWIDTH_OVERRUN |
#define EIO_CONTEXT __einfo_error ( EINFO_EIO_CONTEXT ) |
#define EINFO_EIO_CONTEXT |
#define EIO_NO_PING __einfo_error ( EINFO_EIO_NO_PING ) |
#define EINFO_EIO_NO_PING |
#define EIO_RING_FULL __einfo_error ( EINFO_EIO_RING_FULL ) |
#define EINFO_EIO_RING_FULL |
#define EIO_INCOMPATIBLE __einfo_error ( EINFO_EIO_INCOMPATIBLE ) |
#define EINFO_EIO_INCOMPATIBLE |
#define EIO_MISSED __einfo_error ( EINFO_EIO_MISSED ) |
#define EINFO_EIO_MISSED |
#define EIO_CMD_STOPPED __einfo_error ( EINFO_EIO_CMD_STOPPED ) |
#define EINFO_EIO_CMD_STOPPED |
#define EIO_CMD_ABORTED __einfo_error ( EINFO_EIO_CMD_ABORTED ) |
#define EINFO_EIO_CMD_ABORTED |
#define EIO_STOP __einfo_error ( EINFO_EIO_STOP ) |
#define EINFO_EIO_STOP |
#define EIO_STOP_LEN __einfo_error ( EINFO_EIO_STOP_LEN ) |
#define EINFO_EIO_STOP_LEN |
#define EIO_STOP_SHORT __einfo_error ( EINFO_EIO_STOP_SHORT ) |
#define EINFO_EIO_STOP_SHORT |
#define EIO_LATENCY __einfo_error ( EINFO_EIO_LATENCY ) |
#define EINFO_EIO_LATENCY |
#define EIO_ISOCH __einfo_error ( EINFO_EIO_ISOCH ) |
#define EINFO_EIO_ISOCH |
#define EPROTO_LOST __einfo_error ( EINFO_EPROTO_LOST ) |
#define EINFO_EPROTO_LOST |
#define EPROTO_UNDEFINED __einfo_error ( EINFO_EPROTO_UNDEFINED ) |
#define EINFO_EPROTO_UNDEFINED |
#define EPROTO_STREAM_ID __einfo_error ( EINFO_EPROTO_STREAM_ID ) |
#define EINFO_EPROTO_STREAM_ID |
#define EPROTO_SECONDARY __einfo_error ( EINFO_EPROTO_SECONDARY ) |
#define EINFO_EPROTO_SECONDARY |
#define EPROTO_SPLIT __einfo_error ( EINFO_EPROTO_SPLIT ) |
#define EINFO_EPROTO_SPLIT |
#define ECODE | ( | code | ) |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Initialise device.
xhci | xHCI device |
regs | MMIO registers |
Definition at line 264 of file xhci.c.
References xhci_device::addr64, assert(), xhci_device::cap, xhci_scratchpad::count, xhci_device::csz_shift, xhci_device::db, DBGC, DBGC2, xhci_device::intrs, xhci_device::name, xhci_device::op, xhci_device::pagesize, xhci_device::ports, readb(), readl(), regs, xhci_device::run, xhci_device::scratch, xhci_device::slots, virt_to_phys(), xhci_device::xecp, XHCI_CAP_CAPLENGTH, XHCI_CAP_DBOFF, XHCI_CAP_HCCPARAMS1, XHCI_CAP_HCSPARAMS1, XHCI_CAP_HCSPARAMS2, XHCI_CAP_RTSOFF, XHCI_HCCPARAMS1_ADDR64, XHCI_HCCPARAMS1_CSZ_SHIFT, XHCI_HCCPARAMS1_XECP, XHCI_HCSPARAMS1_INTRS, XHCI_HCSPARAMS1_PORTS, XHCI_HCSPARAMS1_SLOTS, XHCI_HCSPARAMS2_SCRATCHPADS, XHCI_OP_PAGESIZE, and XHCI_PAGESIZE.
Referenced by xhci_probe().
|
static |
Find extended capability.
xhci | xHCI device |
id | Capability ID |
offset | Offset to previous extended capability instance, or zero |
offset | Offset to extended capability, or zero if not found |
Definition at line 323 of file xhci.c.
References xhci_device::cap, next, offset, readl(), xhci_device::xecp, XHCI_XECP_ID, and XHCI_XECP_NEXT.
Referenced by xhci_legacy_init(), and xhci_supported_protocol().
|
inlinestatic |
Write potentially 64-bit register.
xhci | xHCI device |
value | Value |
reg | Register address |
rc | Return status code |
Definition at line 359 of file xhci.c.
References xhci_device::addr64, DBGC, ENOTSUP, xhci_device::name, reg, value, writel(), and writeq().
Referenced by xhci_abort(), xhci_command_alloc(), xhci_command_free(), xhci_dcbaa_alloc(), xhci_dcbaa_free(), xhci_event_alloc(), xhci_event_free(), and xhci_event_poll().
Calculate buffer alignment.
len | Length |
align | Buffer alignment |
Determine alignment required for a buffer which must be aligned to at least XHCI_MIN_ALIGN and which must not cross a page boundary.
Definition at line 393 of file xhci.c.
References align, fls, len, and XHCI_MIN_ALIGN.
Referenced by xhci_context(), xhci_dcbaa_alloc(), xhci_device_open(), xhci_event_alloc(), xhci_ring_alloc(), and xhci_scratchpad_alloc().
|
inlinestatic |
Calculate device context offset.
xhci | xHCI device |
ctx | Context index |
Definition at line 412 of file xhci.c.
References xhci_device::csz_shift, ctx, and XHCI_DCI.
Referenced by xhci_address_device(), xhci_device_close(), xhci_device_open(), and xhci_endpoint_open().
|
inlinestatic |
Calculate input context offset.
xhci | xHCI device |
ctx | Context index |
Definition at line 424 of file xhci.c.
References xhci_device::csz_shift, ctx, and XHCI_ICI.
Referenced by xhci_address_device_input(), xhci_configure_endpoint_input(), xhci_context(), xhci_deconfigure_endpoint_input(), and xhci_evaluate_context_input().
|
inlinestatic |
Dump host controller registers.
xhci | xHCI device |
Definition at line 442 of file xhci.c.
References DBG_LOG, DBGC, xhci_device::name, xhci_device::op, readl(), XHCI_OP_CONFIG, XHCI_OP_DNCTRL, XHCI_OP_PAGESIZE, XHCI_OP_USBCMD, XHCI_OP_USBSTS, XHCI_USBCMD_HCRST, XHCI_USBCMD_RUN, and XHCI_USBSTS_HCH.
|
inlinestatic |
Dump port registers.
xhci | xHCI device |
port | Port number |
Definition at line 483 of file xhci.c.
References DBG_LOG, DBGC, xhci_device::name, xhci_device::op, port, readl(), XHCI_OP_PORTHLPMC, XHCI_OP_PORTLI, XHCI_OP_PORTPMSC, XHCI_OP_PORTSC, XHCI_PORTSC_CCS, XHCI_PORTSC_PED, XHCI_PORTSC_PP, XHCI_PORTSC_PR, and XHCI_PORTSC_PSIV.
|
static |
Initialise USB legacy support.
xhci | xHCI device |
Definition at line 533 of file xhci.c.
References xhci_device::cap, DBGC, xhci_device::legacy, xhci_device::name, readb(), xhci_extended_capability(), XHCI_USBLEGSUP_BIOS, XHCI_USBLEGSUP_BIOS_OWNED, and XHCI_XECP_ID_LEGACY.
Referenced by xhci_probe().
|
static |
Claim ownership from BIOS.
xhci | xHCI device |
Definition at line 564 of file xhci.c.
References xhci_device::cap, DBGC, xhci_device::legacy, mdelay(), xhci_device::name, readb(), readl(), writeb(), writel(), XHCI_USBLEGSUP_BIOS, XHCI_USBLEGSUP_BIOS_OWNED, XHCI_USBLEGSUP_CTLSTS, XHCI_USBLEGSUP_MAX_WAIT_MS, XHCI_USBLEGSUP_OS, and XHCI_USBLEGSUP_OS_OWNED.
Referenced by xhci_probe().
|
static |
Release ownership back to BIOS.
xhci | xHCI device |
Definition at line 611 of file xhci.c.
References xhci_device::cap, DBGC, xhci_device::legacy, xhci_device::name, writeb(), xhci_legacy_prevent_release, and XHCI_USBLEGSUP_OS.
Referenced by xhci_probe(), and xhci_remove().
|
inlinestatic |
Transcribe port speed (for debugging)
psi | Protocol speed ID |
speed | Transcribed speed |
Definition at line 642 of file xhci.c.
References snprintf(), XHCI_SUPPORTED_PSI_EXPONENT, and XHCI_SUPPORTED_PSI_MANTISSA.
Referenced by xhci_port_protocol().
|
static |
Find supported protocol extended capability for a port.
xhci | xHCI device |
port | Port number |
supported | Offset to extended capability, or zero if not found |
Definition at line 665 of file xhci.c.
References xhci_device::cap, count, DBGC, xhci_device::name, offset, port, readl(), supported, xhci_extended_capability(), XHCI_SUPPORTED_PORTS, XHCI_SUPPORTED_PORTS_COUNT, XHCI_SUPPORTED_PORTS_OFFSET, and XHCI_XECP_ID_SUPPORTED.
Referenced by xhci_port_protocol(), xhci_port_psiv(), xhci_port_slot_type(), and xhci_port_speed().
|
static |
Find port protocol.
xhci | xHCI device |
port | Port number |
protocol | USB protocol, or zero if not found |
Definition at line 699 of file xhci.c.
References xhci_device::cap, cpu_to_le32, DBG_EXTRA, DBGC2, xhci_device::name, name, port, protocol, xhci_device::quirks, raw, readl(), revision, slot, supported, type, XHCI_BAD_PSIV, xhci_speed_name(), XHCI_SUPPORTED_NAME, XHCI_SUPPORTED_PORTS, XHCI_SUPPORTED_PORTS_PSIC, xhci_supported_protocol(), XHCI_SUPPORTED_PSI, XHCI_SUPPORTED_PSI_VALUE, XHCI_SUPPORTED_REVISION, XHCI_SUPPORTED_REVISION_VER, XHCI_SUPPORTED_SLOT, and XHCI_SUPPORTED_SLOT_TYPE.
Referenced by xhci_probe().
|
static |
Find port slot type.
xhci | xHCI device |
port | Port number |
type | Slot type, or negative error |
Definition at line 760 of file xhci.c.
References xhci_device::cap, ENOTSUP, port, readl(), slot, supported, type, xhci_supported_protocol(), XHCI_SUPPORTED_SLOT, and XHCI_SUPPORTED_SLOT_TYPE.
Referenced by xhci_device_open().
|
static |
Find port speed.
xhci | xHCI device |
port | Port number |
psiv | Protocol speed ID value |
speed | Port speed, or negative error |
Definition at line 784 of file xhci.c.
References xhci_device::cap, DBGC, ENOTSUP, xhci_device::name, port, xhci_device::quirks, readl(), supported, USB_SPEED, USB_SPEED_FULL, USB_SPEED_HIGH, USB_SPEED_LOW, USB_SPEED_SUPER, XHCI_BAD_PSIV, XHCI_SPEED_FULL, XHCI_SPEED_HIGH, XHCI_SPEED_LOW, XHCI_SPEED_SUPER, XHCI_SUPPORTED_PORTS, XHCI_SUPPORTED_PORTS_PSIC, xhci_supported_protocol(), XHCI_SUPPORTED_PSI, XHCI_SUPPORTED_PSI_EXPONENT, XHCI_SUPPORTED_PSI_MANTISSA, and XHCI_SUPPORTED_PSI_VALUE.
Referenced by xhci_root_speed().
|
static |
Find protocol speed ID value.
xhci | xHCI device |
port | Port number |
speed | USB speed |
psiv | Protocol speed ID value, or negative error |
Definition at line 848 of file xhci.c.
References xhci_device::cap, DBGC, ENOENT, ENOTSUP, xhci_device::name, port, xhci_device::quirks, readl(), supported, USB_SPEED, USB_SPEED_FULL, USB_SPEED_HIGH, USB_SPEED_LOW, USB_SPEED_SUPER, XHCI_BAD_PSIV, XHCI_SPEED_FULL, XHCI_SPEED_HIGH, XHCI_SPEED_LOW, XHCI_SPEED_SUPER, XHCI_SUPPORTED_PORTS, XHCI_SUPPORTED_PORTS_PSIC, xhci_supported_protocol(), XHCI_SUPPORTED_PSI, XHCI_SUPPORTED_PSI_EXPONENT, XHCI_SUPPORTED_PSI_MANTISSA, and XHCI_SUPPORTED_PSI_VALUE.
Referenced by xhci_device_address().
|
static |
Allocate device context base address array.
xhci | xHCI device |
rc | Return status code |
Definition at line 910 of file xhci.c.
References xhci_dcbaa::context, DBGC, DBGC2, xhci_device::dcbaa, dma(), xhci_device::dma, dma_alloc(), dma_free(), ENOMEM, len, xhci_dcbaa::map, memset(), xhci_device::name, xhci_device::op, rc, xhci_device::slots, virt_to_phys(), xhci_align(), XHCI_OP_DCBAAP, and xhci_writeq().
Referenced by xhci_bus_open().
|
static |
Free device context base address array.
xhci | xHCI device |
Definition at line 952 of file xhci.c.
References assert(), xhci_dcbaa::context, xhci_device::dcbaa, dma_free(), len, xhci_dcbaa::map, xhci_device::op, xhci_device::slots, XHCI_OP_DCBAAP, and xhci_writeq().
Referenced by xhci_bus_close(), and xhci_bus_open().
|
static |
Allocate scratchpad buffers.
xhci | xHCI device |
rc | Return status code |
Definition at line 981 of file xhci.c.
References addr, xhci_scratchpad::array, xhci_scratchpad::array_map, assert(), xhci_scratchpad::buffer, xhci_scratchpad::buffer_map, xhci_dcbaa::context, xhci_scratchpad::count, cpu_to_le64, DBGC, DBGC2, xhci_device::dcbaa, dma(), xhci_device::dma, dma_alloc(), dma_free(), dma_phys(), dma_ufree(), dma_umalloc(), ENOMEM, memset_user(), xhci_device::name, NULL, xhci_device::pagesize, rc, xhci_device::scratch, user_to_phys(), virt_to_phys(), and xhci_align().
Referenced by xhci_bus_open().
|
static |
Free scratchpad buffers.
xhci | xHCI device |
Definition at line 1048 of file xhci.c.
References xhci_scratchpad::array, xhci_scratchpad::array_map, assert(), xhci_scratchpad::buffer, xhci_scratchpad::buffer_map, xhci_dcbaa::context, xhci_scratchpad::count, xhci_device::dcbaa, dma_free(), dma_ufree(), NULL, xhci_device::pagesize, and xhci_device::scratch.
Referenced by xhci_bus_close(), and xhci_bus_open().
|
static |
Start xHCI device.
xhci | xHCI device |
Definition at line 1082 of file xhci.c.
References xhci_device::op, readl(), xhci_device::slots, writel(), XHCI_CONFIG_MAX_SLOTS_EN, XHCI_CONFIG_MAX_SLOTS_EN_MASK, XHCI_OP_CONFIG, XHCI_OP_USBCMD, and XHCI_USBCMD_RUN.
Referenced by xhci_bus_open().
|
static |
Stop xHCI device.
xhci | xHCI device |
rc | Return status code |
Definition at line 1104 of file xhci.c.
References DBGC, ETIMEDOUT, mdelay(), xhci_device::name, xhci_device::op, readl(), writel(), XHCI_OP_USBCMD, XHCI_OP_USBSTS, XHCI_STOP_MAX_WAIT_MS, XHCI_USBCMD_RUN, and XHCI_USBSTS_HCH.
Referenced by xhci_bus_close(), xhci_bus_open(), and xhci_reset().
|
static |
Reset xHCI device.
xhci | xHCI device |
rc | Return status code |
Definition at line 1136 of file xhci.c.
References DBGC, ETIMEDOUT, mdelay(), xhci_device::name, xhci_device::op, rc, readl(), writel(), XHCI_OP_USBCMD, XHCI_RESET_MAX_WAIT_MS, xhci_stop(), and XHCI_USBCMD_HCRST.
Referenced by xhci_fail(), xhci_probe(), and xhci_remove().
|
static |
Mark xHCI device as permanently failed.
xhci | xHCI device |
rc | Return status code |
Definition at line 1174 of file xhci.c.
References assert(), xhci_dcbaa::context, xhci_device::dcbaa, xhci_device::failed, len, memset(), NULL, rc, xhci_device::slots, and xhci_reset().
Referenced by xhci_abort(), and xhci_remove().
|
static |
Allocate transfer request block ring.
xhci | xHCI device |
ring | TRB ring |
shift | Ring size (log2) |
slot | Device slot |
target | Doorbell target |
stream | Doorbell stream ID |
rc | Return status code |
Definition at line 1211 of file xhci.c.
References assert(), count, cpu_to_le64, xhci_trb_ring::db, xhci_device::db, xhci_trb_ring::dbval, dma(), xhci_device::dma, dma_alloc(), dma_free(), ENOMEM, free, xhci_trb_ring::iobuf, xhci_trb_ring::len, link, xhci_trb::link, xhci_trb_ring::link, xhci_trb_ring::map, xhci_trb_ring::mask, memset(), rc, xhci_trb_ring::shift, slot, xhci_trb_ring::trb, xhci_align(), XHCI_DBVAL, XHCI_TRB_LINK, XHCI_TRB_TC, and zalloc().
Referenced by xhci_command_alloc(), and xhci_endpoint_open().
|
static |
Reset transfer request block ring.
ring | TRB ring |
Definition at line 1268 of file xhci.c.
References xhci_trb_ring::cons, count, memset(), xhci_trb_ring::prod, xhci_trb_ring::shift, and xhci_trb_ring::trb.
Referenced by xhci_abort().
|
static |
Free transfer request block ring.
ring | TRB ring |
Definition at line 1284 of file xhci.c.
References assert(), xhci_trb_ring::cons, count, dma_free(), free, xhci_trb_ring::iobuf, xhci_trb_ring::len, xhci_trb_ring::map, NULL, xhci_trb_ring::prod, xhci_trb_ring::shift, and xhci_trb_ring::trb.
Referenced by xhci_command_alloc(), xhci_command_free(), xhci_endpoint_close(), and xhci_endpoint_open().
|
static |
Enqueue a transfer request block.
ring | TRB ring |
iobuf | I/O buffer (if any) |
trb | Transfer request block (with empty Cycle flag) |
rc | Return status code |
This operation does not implicitly ring the doorbell register.
Definition at line 1310 of file xhci.c.
References assert(), xhci_trb::common, xhci_trb_template::control, cpu_to_le32, dest, ENOBUFS, xhci_trb_common::flags, xhci_trb_link::flags, index, xhci_trb_ring::iobuf, xhci_trb_ring::link, xhci_trb_ring::mask, xhci_trb_template::parameter, xhci_trb_ring::prod, xhci_trb_ring::shift, xhci_trb_template::status, xhci_trb::template, xhci_trb_ring::trb, wmb(), xhci_ring_remaining(), XHCI_TRB_C, and XHCI_TRB_TC.
Referenced by xhci_command(), and xhci_enqueue_multi().
|
static |
Dequeue a transfer request block.
ring | TRB ring |
iobuf | I/O buffer |
Definition at line 1353 of file xhci.c.
References assert(), cons, xhci_trb_ring::cons, index, xhci_trb_ring::iobuf, xhci_trb_ring::mask, NULL, and xhci_ring_fill().
Referenced by xhci_complete(), and xhci_dequeue_multi().
|
static |
Enqueue multiple transfer request blocks.
ring | TRB ring |
iobuf | I/O buffer |
trbs | Transfer request blocks (with empty Cycle flag) |
count | Number of transfer request blocks |
rc | Return status code |
This operation does not implicitly ring the doorbell register.
Definition at line 1385 of file xhci.c.
References assert(), count, ENOBUFS, NULL, rc, xhci_enqueue(), and xhci_ring_remaining().
Referenced by xhci_endpoint_message(), and xhci_endpoint_stream().
|
static |
Dequeue multiple transfer request blocks.
ring | TRB ring |
iobuf | I/O buffer |
Definition at line 1414 of file xhci.c.
References NULL, and xhci_dequeue().
Referenced by xhci_endpoint_close(), and xhci_transfer().
|
inlinestatic |
Ring doorbell register.
ring | TRB ring |
Definition at line 1431 of file xhci.c.
References xhci_trb_ring::db, xhci_trb_ring::dbval, wmb(), and writel().
Referenced by xhci_command(), xhci_endpoint_message(), xhci_endpoint_reset(), and xhci_endpoint_stream().
|
static |
Allocate command ring.
xhci | xHCI device |
rc | Return status code |
Definition at line 1450 of file xhci.c.
References xhci_device::command, DBGC2, dma(), xhci_trb_ring::len, xhci_trb_ring::map, xhci_device::name, xhci_device::op, rc, xhci_trb_ring::trb, virt_to_phys(), XHCI_CMD_TRBS_LOG2, XHCI_CRCR_RCS, XHCI_OP_CRCR, xhci_ring_alloc(), xhci_ring_free(), and xhci_writeq().
Referenced by xhci_bus_open().
|
static |
Free command ring.
xhci | xHCI device |
Definition at line 1481 of file xhci.c.
References assert(), xhci_device::command, xhci_device::op, readl(), XHCI_CRCR_CRR, XHCI_OP_CRCR, xhci_ring_free(), and xhci_writeq().
Referenced by xhci_bus_close(), and xhci_bus_open().
|
static |
Allocate event ring.
xhci | xHCI device |
rc | Return status code |
Definition at line 1499 of file xhci.c.
References count, cpu_to_le32, cpu_to_le64, DBGC2, dma(), xhci_device::dma, dma_alloc(), dma_free(), ENOMEM, xhci_device::event, len, memset(), xhci_device::name, rc, xhci_device::run, virt_to_phys(), writel(), xhci_align(), XHCI_EVENT_TRBS_LOG2, XHCI_RUN_ERDP, XHCI_RUN_ERSTBA, XHCI_RUN_ERSTSZ, and xhci_writeq().
Referenced by xhci_bus_open().
|
static |
Free event ring.
xhci | xHCI device |
Definition at line 1564 of file xhci.c.
References count, dma_free(), xhci_device::event, len, xhci_device::run, writel(), XHCI_EVENT_TRBS_LOG2, XHCI_RUN_ERDP, XHCI_RUN_ERSTBA, XHCI_RUN_ERSTSZ, and xhci_writeq().
Referenced by xhci_bus_close(), and xhci_bus_open().
|
static |
Handle transfer event.
xhci | xHCI device |
trb | Transfer event TRB |
Definition at line 1590 of file xhci.c.
References assert(), xhci_trb_transfer::code, xhci_endpoint::context, xhci_endpoint::ctx, DBGC, DBGC_HDA, ECODE, xhci_trb_transfer::endpoint, xhci_endpoint::ep, iob_unmap(), iob_unput, le16_to_cpu, le64_to_cpu, xhci_device::name, NULL, profile_start(), profile_stop(), rc, xhci_trb_transfer::residual, xhci_endpoint::ring, slot, xhci_trb_transfer::slot, xhci_device::slot, xhci_device::slots, xhci_endpoint_context::state, strerror(), xhci_trb_transfer::transfer, usb_complete(), usb_complete_err(), XHCI_CMPLT_SHORT, XHCI_CMPLT_SUCCESS, XHCI_CTX_END, xhci_dequeue_multi(), XHCI_ENDPOINT_RUNNING, XHCI_ENDPOINT_STATE_MASK, and xhci_ring_consumed().
Referenced by xhci_event_poll().
|
static |
Handle command completion event.
xhci | xHCI device |
trb | Command completion event |
Definition at line 1663 of file xhci.c.
References assert(), xhci_trb_complete::code, xhci_trb_complete::command, xhci_device::command, DBGC, DBGC2, DBGC_HDA, ECODE, le64_to_cpu, memcpy(), xhci_device::name, NULL, xhci_device::pending, rc, strerror(), XHCI_CMPLT_CMD_STOPPED, xhci_dequeue(), and xhci_ring_consumed().
Referenced by xhci_event_poll().
|
static |
Handle port status event.
xhci | xHCI device |
trb | Port status event |
Definition at line 1700 of file xhci.c.
References assert(), xhci_device::bus, usb_bus::hub, xhci_device::op, port, xhci_trb_port_status::port, xhci_device::ports, readl(), usb_port(), usb_port_changed(), writel(), XHCI_OP_PORTSC, XHCI_PORTSC_CHANGE, XHCI_PORTSC_CSC, and XHCI_PORTSC_PRESERVE.
Referenced by xhci_event_poll().
|
static |
Handle host controller event.
xhci | xHCI device |
trb | Host controller event |
Definition at line 1724 of file xhci.c.
References xhci_trb_host_controller::code, DBGC, ECODE, xhci_device::name, rc, and strerror().
Referenced by xhci_event_poll().
|
static |
Poll event ring.
xhci | xHCI device |
Definition at line 1739 of file xhci.c.
References xhci_trb::common, xhci_trb::complete, count, DBGC, DBGC_HDA, dma(), xhci_device::event, xhci_device::failed, xhci_trb_common::flags, xhci_trb::host, xhci_device::name, xhci_trb::port, profile_start(), profile_stop(), rmb, xhci_device::run, xhci_trb::transfer, type, xhci_trb_common::type, virt_to_phys(), xhci_complete(), XHCI_EVENT_TRBS_LOG2, xhci_host_controller(), xhci_port_status(), XHCI_RUN_ERDP, xhci_transfer(), XHCI_TRB_C, XHCI_TRB_COMPLETE, XHCI_TRB_HOST_CONTROLLER, XHCI_TRB_PORT_STATUS, XHCI_TRB_TRANSFER, XHCI_TRB_TYPE_MASK, and xhci_writeq().
Referenced by xhci_abort(), xhci_bus_poll(), and xhci_command().
|
static |
Abort command.
xhci | xHCI device |
Definition at line 1808 of file xhci.c.
References xhci_device::command, DBGC, DBGC2, dma(), xhci_trb_ring::map, mdelay(), xhci_device::name, xhci_device::op, readl(), xhci_trb_ring::trb, XHCI_COMMAND_ABORT_DELAY_MS, XHCI_CRCR_CA, XHCI_CRCR_CRR, XHCI_CRCR_RCS, xhci_event_poll(), xhci_fail(), XHCI_OP_CRCR, xhci_ring_reset(), and xhci_writeq().
Referenced by xhci_command().
|
static |
Issue command and wait for completion.
xhci | xHCI device |
trb | Transfer request block (with empty Cycle flag) |
rc | Return status code |
On a successful completion, the TRB will be overwritten with the completion.
Definition at line 1851 of file xhci.c.
References xhci_trb_complete::code, xhci_device::command, xhci_trb::complete, DBGC, DBGC_HDA, EBUSY, ECODE, EPIPE, ETIMEDOUT, xhci_device::failed, mdelay(), xhci_device::name, NULL, xhci_device::pending, rc, strerror(), xhci_abort(), XHCI_CMPLT_SUCCESS, XHCI_COMMAND_MAX_WAIT_MS, xhci_doorbell(), xhci_enqueue(), and xhci_event_poll().
Referenced by xhci_context(), xhci_disable_slot(), xhci_enable_slot(), xhci_nop(), xhci_reset_endpoint(), xhci_set_tr_dequeue_pointer(), and xhci_stop_endpoint().
|
inlinestatic |
Issue NOP and wait for completion.
xhci | xHCI device |
rc | Return status code |
Definition at line 1922 of file xhci.c.
References xhci_trb::common, DBGC, DBGC2, memset(), xhci_device::name, nop, rc, strerror(), xhci_command(), XHCI_TRB_IOC, and XHCI_TRB_NOP_CMD.
|
inlinestatic |
Enable slot.
xhci | xHCI device |
type | Slot type |
slot | Device slot ID, or negative error |
Definition at line 1950 of file xhci.c.
References xhci_trb::complete, DBGC, DBGC2, xhci_trb::enable, enabled, memset(), xhci_device::name, rc, slot, xhci_trb_enable_slot::slot, strerror(), type, xhci_trb_enable_slot::type, xhci_command(), and XHCI_TRB_ENABLE_SLOT.
Referenced by xhci_device_open().
|
inlinestatic |
Disable slot.
xhci | xHCI device |
slot | Device slot |
rc | Return status code |
Definition at line 1984 of file xhci.c.
References DBGC, DBGC2, xhci_trb::disable, memset(), xhci_device::name, rc, slot, xhci_trb_disable_slot::slot, strerror(), xhci_trb_disable_slot::type, xhci_command(), and XHCI_TRB_DISABLE_SLOT.
Referenced by xhci_device_close(), and xhci_device_open().
|
static |
Issue context-based command and wait for completion.
xhci | xHCI device |
slot | Device slot |
endpoint | Endpoint |
type | TRB type |
populate | Input context populater |
rc | Return status code |
Definition at line 2016 of file xhci.c.
References xhci_trb::context, cpu_to_le64, dma(), xhci_device::dma, dma_alloc(), dma_free(), ENOMEM, xhci_trb_context::input, len, map, memset(), rc, slot, xhci_trb_context::slot, type, xhci_trb_context::type, xhci_align(), xhci_command(), XHCI_CTX_END, and xhci_input_context_offset().
Referenced by xhci_address_device(), xhci_configure_endpoint(), xhci_deconfigure_endpoint(), and xhci_evaluate_context().
|
static |
Populate address device input context.
xhci | xHCI device |
slot | Device slot |
endpoint | Endpoint |
input | Input context |
Definition at line 2066 of file xhci.c.
References xhci_control_context::add, assert(), usb_endpoint::burst, xhci_endpoint_context::burst, cpu_to_le16, cpu_to_le32, cpu_to_le64, xhci_endpoint::ctx, xhci_endpoint_context::dequeue, dma(), xhci_endpoint::ep, xhci_slot_context::info, xhci_trb_ring::map, usb_endpoint::mtu, xhci_endpoint_context::mtu, xhci_slot_context::port, xhci_endpoint::ring, slot, xhci_trb_ring::trb, xhci_endpoint_context::trb_len, xhci_slot_context::tt_id, xhci_slot_context::tt_port, xhci_endpoint_context::type, XHCI_CTX_EP0, XHCI_CTX_SLOT, XHCI_EP0_TRB_LEN, XHCI_EP_DCS, XHCI_EP_TYPE_CONTROL, xhci_input_context_offset(), and XHCI_SLOT_INFO.
Referenced by xhci_address_device().
|
inlinestatic |
Address device.
xhci | xHCI device |
slot | Device slot |
rc | Return status code |
Definition at line 2108 of file xhci.c.
References usb_device::address, xhci_slot_context::address, DBGC, DBGC2, usb_device::name, xhci_device::name, rc, slot, strerror(), xhci_address_device_input(), xhci_context(), XHCI_CTX_EP0, XHCI_CTX_SLOT, xhci_device_context_offset(), and XHCI_TRB_ADDRESS_DEVICE.
Referenced by xhci_device_address().
|
static |
Populate configure endpoint input context.
xhci | xHCI device |
slot | Device slot |
endpoint | Endpoint |
input | Input context |
Definition at line 2141 of file xhci.c.
References xhci_control_context::add, usb_endpoint::burst, xhci_endpoint_context::burst, cpu_to_le16, cpu_to_le32, cpu_to_le64, xhci_endpoint::ctx, xhci_endpoint_context::dequeue, dma(), xhci_endpoint::ep, xhci_slot_context::info, xhci_endpoint_context::interval, xhci_endpoint::interval, xhci_trb_ring::map, usb_endpoint::mtu, xhci_endpoint_context::mtu, xhci_slot_context::ports, xhci_endpoint::ring, slot, xhci_trb_ring::trb, xhci_endpoint_context::trb_len, xhci_endpoint_context::type, xhci_endpoint::type, XHCI_CTX_END, XHCI_CTX_SLOT, XHCI_EP_DCS, xhci_input_context_offset(), and XHCI_SLOT_INFO.
Referenced by xhci_configure_endpoint().
|
inlinestatic |
Configure endpoint.
xhci | xHCI device |
slot | Device slot |
endpoint | Endpoint |
rc | Return status code |
Definition at line 2181 of file xhci.c.
References xhci_endpoint::ctx, DBGC, DBGC2, xhci_device::name, rc, slot, strerror(), xhci_configure_endpoint_input(), xhci_context(), and XHCI_TRB_CONFIGURE_ENDPOINT.
Referenced by xhci_endpoint_open().
|
static |
Populate deconfigure endpoint input context.
xhci | xHCI device |
slot | Device slot |
endpoint | Endpoint |
input | Input context |
Definition at line 2209 of file xhci.c.
References xhci_control_context::add, cpu_to_le32, xhci_endpoint::ctx, xhci_control_context::drop, xhci_slot_context::info, XHCI_CTX_END, XHCI_CTX_SLOT, xhci_input_context_offset(), and XHCI_SLOT_INFO.
Referenced by xhci_deconfigure_endpoint().
|
inlinestatic |
Deconfigure endpoint.
xhci | xHCI device |
slot | Device slot |
endpoint | Endpoint |
rc | Return status code |
Definition at line 2235 of file xhci.c.
References xhci_endpoint::ctx, DBGC, DBGC2, xhci_device::name, rc, slot, strerror(), xhci_context(), xhci_deconfigure_endpoint_input(), and XHCI_TRB_CONFIGURE_ENDPOINT.
Referenced by xhci_endpoint_close(), and xhci_endpoint_open().
|
static |
Populate evaluate context input context.
xhci | xHCI device |
slot | Device slot |
endpoint | Endpoint |
input | Input context |
Definition at line 2263 of file xhci.c.
References xhci_control_context::add, cpu_to_le16, cpu_to_le32, xhci_endpoint::ctx, xhci_endpoint::ep, xhci_slot_context::info, usb_endpoint::mtu, xhci_endpoint_context::mtu, XHCI_CTX_END, XHCI_CTX_SLOT, xhci_input_context_offset(), and XHCI_SLOT_INFO.
Referenced by xhci_evaluate_context().
|
inlinestatic |
Evaluate context.
xhci | xHCI device |
slot | Device slot |
endpoint | Endpoint |
rc | Return status code |
Definition at line 2294 of file xhci.c.
References xhci_endpoint::ctx, DBGC, DBGC2, xhci_device::name, rc, slot, strerror(), xhci_context(), xhci_evaluate_context_input(), and XHCI_TRB_EVALUATE_CONTEXT.
Referenced by xhci_endpoint_mtu().
|
inlinestatic |
Reset endpoint.
xhci | xHCI device |
slot | Device slot |
endpoint | Endpoint |
rc | Return status code |
Definition at line 2322 of file xhci.c.
References DBGC, xhci_trb_reset_endpoint::endpoint, memset(), xhci_device::name, rc, xhci_trb::reset, slot, xhci_trb_reset_endpoint::slot, strerror(), xhci_trb_reset_endpoint::type, xhci_command(), and XHCI_TRB_RESET_ENDPOINT.
Referenced by xhci_endpoint_reset().
|
inlinestatic |