FreeBSD kernel usb device Code
xhci.c File Reference
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <sys/unistd.h>
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_busdma.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_transfer.h>
#include <dev/usb/usb_device.h>
#include <dev/usb/usb_hub.h>
#include <dev/usb/usb_util.h>
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#include <dev/usb/controller/xhci.h>
#include <dev/usb/controller/xhcireg.h>
Include dependency graph for xhci.c:

Go to the source code of this file.

Data Structures

struct  xhci_std_temp
 

Macros

#define USB_DEBUG_VAR   xhcidebug
 
#define XHCI_BUS2SC(bus)    __containerof(bus, struct xhci_softc, sc_bus)
 
#define XHCI_GET_CTX(sc, which, field, ptr)
 
#define xhciroute   0
 
#define xhcidma32   0
 
#define xhcictlstep   0
 
#define XHCI_INTR_ENDPT   1
 
#define HSETW(ptr, val)   ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) }
 
#define C(x, y)   ((x) | ((y) << 8))
 

Functions

static SYSCTL_NODE (_hw_usb, OID_AUTO, xhci, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB XHCI")
 
 SYSCTL_INT (_hw_usb_xhci, OID_AUTO, streams, CTLFLAG_RWTUN, &xhcistreams, 0, "Set to enable streams mode support")
 
 SYSCTL_INT (_hw_usb_xhci, OID_AUTO, ctlquirk, CTLFLAG_RWTUN, &xhcictlquirk, 0, "Set to enable control endpoint quirk")
 
 SYSCTL_INT (_hw_usb_xhci, OID_AUTO, dcepquirk, CTLFLAG_RWTUN, &xhcidcepquirk, 0, "Set to disable endpoint deconfigure command")
 
static void xhci_do_poll (struct usb_bus *)
 
static void xhci_device_done (struct usb_xfer *, usb_error_t)
 
static void xhci_root_intr (struct xhci_softc *)
 
static void xhci_free_device_ext (struct usb_device *)
 
static struct xhci_endpoint_extxhci_get_endpoint_ext (struct usb_device *, struct usb_endpoint_descriptor *)
 
static usb_error_t xhci_configure_device (struct usb_device *)
 
static usb_error_t xhci_configure_endpoint (struct usb_device *, struct usb_endpoint_descriptor *, struct xhci_endpoint_ext *, uint16_t, uint8_t, uint8_t, uint8_t, uint16_t, uint16_t, uint8_t)
 
static usb_error_t xhci_configure_mask (struct usb_device *, uint32_t, uint8_t)
 
static usb_error_t xhci_cmd_evaluate_ctx (struct xhci_softc *, uint64_t, uint8_t)
 
static void xhci_endpoint_doorbell (struct usb_xfer *)
 
uint8_t xhci_use_polling (void)
 
static void xhci_iterate_hw_softc (struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb)
 
static int xhci_reset_command_queue_locked (struct xhci_softc *sc)
 
usb_error_t xhci_start_controller (struct xhci_softc *sc)
 
usb_error_t xhci_halt_controller (struct xhci_softc *sc)
 
usb_error_t xhci_reset_controller (struct xhci_softc *sc)
 
usb_error_t xhci_init (struct xhci_softc *sc, device_t self, uint8_t dma32)
 
void xhci_uninit (struct xhci_softc *sc)
 
static void xhci_set_hw_power_sleep (struct usb_bus *bus, uint32_t state)
 
static usb_error_t xhci_generic_done_sub (struct usb_xfer *xfer)
 
static void xhci_generic_done (struct usb_xfer *xfer)
 
static void xhci_activate_transfer (struct usb_xfer *xfer)
 
static void xhci_skip_transfer (struct usb_xfer *xfer)
 
static void xhci_check_transfer (struct xhci_softc *sc, struct xhci_trb *trb)
 
static int xhci_check_command (struct xhci_softc *sc, struct xhci_trb *trb)
 
static int xhci_interrupt_poll (struct xhci_softc *sc)
 
static usb_error_t xhci_do_command (struct xhci_softc *sc, struct xhci_trb *trb, uint16_t timeout_ms)
 
static usb_error_t xhci_cmd_enable_slot (struct xhci_softc *sc, uint8_t *pslot)
 
static usb_error_t xhci_cmd_disable_slot (struct xhci_softc *sc, uint8_t slot_id)
 
static usb_error_t xhci_cmd_set_address (struct xhci_softc *sc, uint64_t input_ctx, uint8_t bsr, uint8_t slot_id)
 
static usb_error_t xhci_set_address (struct usb_device *udev, struct mtx *mtx, uint16_t address)
 
static usb_error_t xhci_cmd_configure_ep (struct xhci_softc *sc, uint64_t input_ctx, uint8_t deconfigure, uint8_t slot_id)
 
static usb_error_t xhci_cmd_reset_ep (struct xhci_softc *sc, uint8_t preserve, uint8_t ep_id, uint8_t slot_id)
 
static usb_error_t xhci_cmd_set_tr_dequeue_ptr (struct xhci_softc *sc, uint64_t dequeue_ptr, uint16_t stream_id, uint8_t ep_id, uint8_t slot_id)
 
static usb_error_t xhci_cmd_stop_ep (struct xhci_softc *sc, uint8_t suspend, uint8_t ep_id, uint8_t slot_id)
 
static usb_error_t xhci_cmd_reset_dev (struct xhci_softc *sc, uint8_t slot_id)
 
void xhci_interrupt (struct xhci_softc *sc)
 
static void xhci_timeout (void *arg)
 
static void xhci_setup_generic_chain_sub (struct xhci_std_temp *temp)
 
static void xhci_setup_generic_chain (struct usb_xfer *xfer)
 
static void xhci_set_slot_pointer (struct xhci_softc *sc, uint8_t index, uint64_t dev_addr)
 
static usb_error_t xhci_configure_endpoint_by_xfer (struct usb_xfer *xfer)
 
static usb_error_t xhci_alloc_device_ext (struct usb_device *udev)
 
static void xhci_transfer_remove (struct usb_xfer *xfer, usb_error_t error)
 
static usb_error_t xhci_transfer_insert (struct usb_xfer *xfer)
 
static void xhci_device_generic_open (struct usb_xfer *xfer)
 
static void xhci_device_generic_close (struct usb_xfer *xfer)
 
static void xhci_device_generic_multi_enter (struct usb_endpoint *ep, usb_stream_t stream_id, struct usb_xfer *enter_xfer)
 
static void xhci_device_generic_enter (struct usb_xfer *xfer)
 
static void xhci_device_generic_start (struct usb_xfer *xfer)
 
static usb_error_t xhci_roothub_exec (struct usb_device *udev, struct usb_device_request *req, const void **pptr, uint16_t *plength)
 
static void xhci_xfer_setup (struct usb_setup_params *parm)
 
static uint8_t xhci_get_endpoint_state (struct usb_device *udev, uint8_t epno)
 
static usb_error_t xhci_configure_reset_endpoint (struct usb_xfer *xfer)
 
static void xhci_xfer_unsetup (struct usb_xfer *xfer)
 
static void xhci_start_dma_delay (struct usb_xfer *xfer)
 
static void xhci_configure_msg (struct usb_proc_msg *pm)
 
static void xhci_ep_init (struct usb_device *udev, struct usb_endpoint_descriptor *edesc, struct usb_endpoint *ep)
 
static void xhci_ep_uninit (struct usb_device *udev, struct usb_endpoint *ep)
 
static void xhci_ep_clear_stall (struct usb_device *udev, struct usb_endpoint *ep)
 
static usb_error_t xhci_device_init (struct usb_device *udev)
 
static void xhci_device_uninit (struct usb_device *udev)
 
static void xhci_get_dma_delay (struct usb_device *udev, uint32_t *pus)
 
static void xhci_device_resume (struct usb_device *udev)
 
static void xhci_device_suspend (struct usb_device *udev)
 
static void xhci_set_hw_power (struct usb_bus *bus)
 
static void xhci_device_state_change (struct usb_device *udev)
 
static usb_error_t xhci_set_endpoint_mode (struct usb_device *udev, struct usb_endpoint *ep, uint8_t ep_mode)
 

Variables

static int xhcistreams
 
static int xhcictlquirk = 1
 
static int xhcidcepquirk
 
static usb_proc_callback_t xhci_configure_msg
 
static const struct usb_bus_methods xhci_bus_methods
 
static const struct usb_pipe_methods xhci_device_generic_methods
 
static const struct usb_device_descriptor xhci_devd
 
static const struct xhci_bos_desc xhci_bosd
 
static const struct xhci_config_desc xhci_confd
 
static const struct usb_hub_ss_descriptor xhci_hubd
 

Macro Definition Documentation

◆ C

#define C (   x,
 
)    ((x) | ((y) << 8))

◆ HSETW

#define HSETW (   ptr,
  val 
)    ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) }

Definition at line 3117 of file xhci.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   xhcidebug

Definition at line 70 of file xhci.c.

◆ XHCI_BUS2SC

#define XHCI_BUS2SC (   bus)     __containerof(bus, struct xhci_softc, sc_bus)

Definition at line 88 of file xhci.c.

◆ XHCI_GET_CTX

#define XHCI_GET_CTX (   sc,
  which,
  field,
  ptr 
)
Value:
((sc)->sc_ctx_is_64_byte ? \
&((struct which##64 *)(ptr))->field.ctx : \
&((struct which *)(ptr))->field)

Definition at line 91 of file xhci.c.

◆ XHCI_INTR_ENDPT

#define XHCI_INTR_ENDPT   1

Definition at line 134 of file xhci.c.

◆ xhcictlstep

#define xhcictlstep   0

Definition at line 131 of file xhci.c.

◆ xhcidma32

#define xhcidma32   0

Definition at line 130 of file xhci.c.

◆ xhciroute

#define xhciroute   0

Definition at line 129 of file xhci.c.

Function Documentation

◆ SYSCTL_INT() [1/3]

SYSCTL_INT ( _hw_usb_xhci  ,
OID_AUTO  ,
ctlquirk  ,
CTLFLAG_RWTUN  ,
xhcictlquirk,
,
"Set to enable control endpoint quirk"   
)

◆ SYSCTL_INT() [2/3]

SYSCTL_INT ( _hw_usb_xhci  ,
OID_AUTO  ,
dcepquirk  ,
CTLFLAG_RWTUN  ,
xhcidcepquirk,
,
"Set to disable endpoint deconfigure command"   
)

◆ SYSCTL_INT() [3/3]

SYSCTL_INT ( _hw_usb_xhci  ,
OID_AUTO  ,
streams  ,
CTLFLAG_RWTUN  ,
xhcistreams,
,
"Set to enable streams mode support"   
)

◆ SYSCTL_NODE()

static SYSCTL_NODE ( _hw_usb  ,
OID_AUTO  ,
xhci  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
"USB XHCI"   
)
static

◆ xhci_activate_transfer()

static void xhci_activate_transfer ( struct usb_xfer xfer)
static

Definition at line 803 of file xhci.c.

References xhci_trb::dwTrb3, xhci_td::page_cache, usb_xfer::td_transfer_cache, xhci_td::td_trb, usb_pc_cpu_flush(), usb_pc_cpu_invalidate(), xhci_endpoint_doorbell(), and XHCI_TRB_3_CYCLE_BIT.

Referenced by xhci_check_transfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_alloc_device_ext()

◆ xhci_check_command()

static int xhci_check_command ( struct xhci_softc sc,
struct xhci_trb trb 
)
static

Definition at line 1019 of file xhci.c.

References DPRINTF, xhci_trb::dwTrb2, xhci_trb::dwTrb3, xhci_trb::qwTrb0, xhci_softc::sc_cmd_addr, xhci_softc::sc_cmd_cv, and xhci_softc::sc_cmd_result.

Referenced by xhci_interrupt_poll().

Here is the caller graph for this function:

◆ xhci_check_transfer()

◆ xhci_cmd_configure_ep()

static usb_error_t xhci_cmd_configure_ep ( struct xhci_softc sc,
uint64_t  input_ctx,
uint8_t  deconfigure,
uint8_t  slot_id 
)
static

Definition at line 1471 of file xhci.c.

References DPRINTF, xhci_trb::dwTrb2, xhci_trb::dwTrb3, xhci_trb::qwTrb0, xhci_softc::sc_no_deconfigure, xhci_do_command(), XHCI_TRB_3_DCEP_BIT, XHCI_TRB_3_SLOT_SET, XHCI_TRB_3_TYPE_SET, XHCI_TRB_TYPE_CONFIGURE_EP, and xhcidcepquirk.

Referenced by xhci_configure_reset_endpoint(), and xhci_device_state_change().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_cmd_disable_slot()

static usb_error_t xhci_cmd_disable_slot ( struct xhci_softc sc,
uint8_t  slot_id 
)
static

Definition at line 1303 of file xhci.c.

References DPRINTF, xhci_trb::dwTrb2, xhci_trb::dwTrb3, xhci_trb::qwTrb0, xhci_do_command(), XHCI_TRB_3_SLOT_SET, XHCI_TRB_3_TYPE_SET, and XHCI_TRB_TYPE_DISABLE_SLOT.

Referenced by xhci_device_uninit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_cmd_enable_slot()

static usb_error_t xhci_cmd_enable_slot ( struct xhci_softc sc,
uint8_t *  pslot 
)
static

Definition at line 1278 of file xhci.c.

References DPRINTF, xhci_trb::dwTrb2, xhci_trb::dwTrb3, xhci_trb::qwTrb0, xhci_do_command(), XHCI_TRB_3_SLOT_GET, XHCI_TRB_3_TYPE_SET, and XHCI_TRB_TYPE_ENABLE_SLOT.

Referenced by xhci_device_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_cmd_evaluate_ctx()

static usb_error_t xhci_cmd_evaluate_ctx ( struct xhci_softc sc,
uint64_t  input_ctx,
uint8_t  slot_id 
)
static

Definition at line 1496 of file xhci.c.

References DPRINTF, xhci_trb::dwTrb2, xhci_trb::dwTrb3, xhci_trb::qwTrb0, xhci_do_command(), XHCI_TRB_3_SLOT_SET, XHCI_TRB_3_TYPE_SET, and XHCI_TRB_TYPE_EVALUATE_CTX.

Referenced by xhci_configure_reset_endpoint(), and xhci_device_state_change().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_cmd_reset_dev()

static usb_error_t xhci_cmd_reset_dev ( struct xhci_softc sc,
uint8_t  slot_id 
)
static

Definition at line 1582 of file xhci.c.

References DPRINTF, xhci_trb::dwTrb2, xhci_trb::dwTrb3, xhci_trb::qwTrb0, xhci_do_command(), XHCI_TRB_3_SLOT_SET, XHCI_TRB_3_TYPE_SET, and XHCI_TRB_TYPE_RESET_DEVICE.

Referenced by xhci_device_state_change().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_cmd_reset_ep()

static usb_error_t xhci_cmd_reset_ep ( struct xhci_softc sc,
uint8_t  preserve,
uint8_t  ep_id,
uint8_t  slot_id 
)
static

Definition at line 1514 of file xhci.c.

References DPRINTF, xhci_trb::dwTrb2, xhci_trb::dwTrb3, xhci_trb::qwTrb0, xhci_do_command(), XHCI_TRB_3_EP_SET, XHCI_TRB_3_PRSV_BIT, XHCI_TRB_3_SLOT_SET, XHCI_TRB_3_TYPE_SET, and XHCI_TRB_TYPE_RESET_EP.

Referenced by xhci_configure_reset_endpoint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_cmd_set_address()

static usb_error_t xhci_cmd_set_address ( struct xhci_softc sc,
uint64_t  input_ctx,
uint8_t  bsr,
uint8_t  slot_id 
)
static

Definition at line 1321 of file xhci.c.

References DPRINTF, xhci_trb::dwTrb2, xhci_trb::dwTrb3, xhci_trb::qwTrb0, xhci_do_command(), XHCI_TRB_3_BSR_BIT, XHCI_TRB_3_SLOT_SET, XHCI_TRB_3_TYPE_SET, and XHCI_TRB_TYPE_ADDRESS_DEVICE.

Referenced by xhci_set_address().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_cmd_set_tr_dequeue_ptr()

static usb_error_t xhci_cmd_set_tr_dequeue_ptr ( struct xhci_softc sc,
uint64_t  dequeue_ptr,
uint16_t  stream_id,
uint8_t  ep_id,
uint8_t  slot_id 
)
static

Definition at line 1537 of file xhci.c.

References DPRINTF, xhci_trb::dwTrb2, xhci_trb::dwTrb3, xhci_trb::qwTrb0, xhci_do_command(), XHCI_TRB_2_STREAM_SET, XHCI_TRB_3_EP_SET, XHCI_TRB_3_SLOT_SET, XHCI_TRB_3_TYPE_SET, and XHCI_TRB_TYPE_SET_TR_DEQUEUE.

Referenced by xhci_configure_reset_endpoint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_cmd_stop_ep()

static usb_error_t xhci_cmd_stop_ep ( struct xhci_softc sc,
uint8_t  suspend,
uint8_t  ep_id,
uint8_t  slot_id 
)
static

Definition at line 1559 of file xhci.c.

References DPRINTF, xhci_trb::dwTrb2, xhci_trb::dwTrb3, xhci_trb::qwTrb0, xhci_do_command(), XHCI_TRB_3_EP_SET, XHCI_TRB_3_SLOT_SET, XHCI_TRB_3_SUSP_EP_BIT, XHCI_TRB_3_TYPE_SET, and XHCI_TRB_TYPE_STOP_EP.

Referenced by xhci_configure_reset_endpoint(), and xhci_device_suspend().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_configure_device()

◆ xhci_configure_endpoint()

static usb_error_t xhci_configure_endpoint ( struct usb_device udev,
struct usb_endpoint_descriptor edesc,
struct xhci_endpoint_ext pepext,
uint16_t  interval,
uint8_t  max_packet_count,
uint8_t  mult,
uint8_t  fps_shift,
uint16_t  max_packet_size,
uint16_t  max_frame_size,
uint8_t  ep_mode 
)
static

◆ xhci_configure_endpoint_by_xfer()

◆ xhci_configure_mask()

static usb_error_t xhci_configure_mask ( struct usb_device udev,
uint32_t  mask,
uint8_t  drop 
)
static

◆ xhci_configure_msg()

◆ xhci_configure_reset_endpoint()

◆ xhci_device_done()

static void xhci_device_done ( struct usb_xfer xfer,
usb_error_t  error 
)
static

Definition at line 3007 of file xhci.c.

References usb_xfer::endpoint, error, usbd_transfer_done(), and xhci_transfer_remove().

Referenced by xhci_configure_msg(), xhci_device_generic_close(), xhci_generic_done(), and xhci_timeout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_device_generic_close()

static void xhci_device_generic_close ( struct usb_xfer xfer)
static

Definition at line 3029 of file xhci.c.

References DPRINTF, USB_ERR_CANCELLED, and xhci_device_done().

Here is the call graph for this function:

◆ xhci_device_generic_enter()

static void xhci_device_generic_enter ( struct usb_xfer xfer)
static

Definition at line 3073 of file xhci.c.

References DPRINTF, usb_xfer::endpoint, usb_xfer::stream_id, xhci_device_generic_multi_enter(), and xhci_setup_generic_chain().

Here is the call graph for this function:

◆ xhci_device_generic_multi_enter()

static void xhci_device_generic_multi_enter ( struct usb_endpoint ep,
usb_stream_t  stream_id,
struct usb_xfer enter_xfer 
)
static

Definition at line 3037 of file xhci.c.

References usb_xfer_flags_int::bandwidth_reclaimed, usb_xfer_queue::curr, usb_endpoint::endpoint_q, usb_xfer::flags_int, usb_xfer::stream_id, and xhci_transfer_insert().

Referenced by xhci_configure_msg(), xhci_device_generic_enter(), and xhci_device_generic_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_device_generic_open()

static void xhci_device_generic_open ( struct usb_xfer xfer)
static

Definition at line 3023 of file xhci.c.

References DPRINTF.

◆ xhci_device_generic_start()

static void xhci_device_generic_start ( struct usb_xfer xfer)
static

◆ xhci_device_init()

◆ xhci_device_resume()

◆ xhci_device_state_change()

◆ xhci_device_suspend()

static void xhci_device_suspend ( struct usb_device udev)
static

Definition at line 4161 of file xhci.c.

References usb_device::bus, usb_device::controller_slot_id, DPRINTF, index, n, usb_device::parent_hub, XHCI_BUS2SC, XHCI_CMD_LOCK, xhci_cmd_stop_ep(), XHCI_CMD_UNLOCK, and XHCI_MAX_ENDPOINTS.

Here is the call graph for this function:

◆ xhci_device_uninit()

◆ xhci_do_command()

◆ xhci_do_poll()

static void xhci_do_poll ( struct usb_bus bus)
static

Definition at line 1668 of file xhci.c.

References bus, xhci_softc::sc_bus, USB_BUS_LOCK, USB_BUS_UNLOCK, XHCI_BUS2SC, and xhci_interrupt_poll().

Referenced by xhci_start_controller().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_endpoint_doorbell()

◆ xhci_ep_clear_stall()

static void xhci_ep_clear_stall ( struct usb_device udev,
struct usb_endpoint ep 
)
static

◆ xhci_ep_init()

◆ xhci_ep_uninit()

static void xhci_ep_uninit ( struct usb_device udev,
struct usb_endpoint ep 
)
static

Definition at line 4001 of file xhci.c.

◆ xhci_free_device_ext()

static void xhci_free_device_ext ( struct usb_device udev)
static

◆ xhci_generic_done()

static void xhci_generic_done ( struct usb_xfer xfer)
static

◆ xhci_generic_done_sub()

◆ xhci_get_dma_delay()

static void xhci_get_dma_delay ( struct usb_device udev,
uint32_t *  pus 
)
static

Definition at line 4117 of file xhci.c.

◆ xhci_get_endpoint_ext()

◆ xhci_get_endpoint_state()

static uint8_t xhci_get_endpoint_state ( struct usb_device udev,
uint8_t  epno 
)
static

◆ xhci_halt_controller()

usb_error_t xhci_halt_controller ( struct xhci_softc sc)

◆ xhci_init()

usb_error_t xhci_init ( struct xhci_softc sc,
device_t  self,
uint8_t  dma32 
)

◆ xhci_interrupt()

void xhci_interrupt ( struct xhci_softc sc)

Definition at line 1603 of file xhci.c.

References xhci_softc::sc_bus, status, USB_BUS_LOCK, USB_BUS_UNLOCK, XHCI_IMAN, XHCI_IMAN_INTR_PEND, xhci_interrupt_poll(), xhci_root_intr(), XHCI_STS_HCE, XHCI_STS_HCH, XHCI_STS_HSE, XHCI_STS_PCD, XHCI_USBSTS, XREAD4, and XWRITE4.

Referenced by generic_xhci_attach(), snps_dwc3_attach_xhci(), xhci_interrupt_poll(), and xhci_pci_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_interrupt_poll()

◆ xhci_iterate_hw_softc()

static void xhci_iterate_hw_softc ( struct usb_bus bus,
usb_bus_mem_sub_cb_t cb 
)
static

◆ xhci_reset_command_queue_locked()

◆ xhci_reset_controller()

usb_error_t xhci_reset_controller ( struct xhci_softc sc)

Definition at line 484 of file xhci.c.

References DPRINTF, usb_bus::parent, xhci_softc::sc_bus, USB_ERR_IOERROR, usb_pause_mtx(), XHCI_CMD_HCRST, XHCI_STS_CNR, XHCI_USBCMD, XHCI_USBSTS, XREAD4, and XWRITE4.

Referenced by xhci_pci_detach(), xhci_set_hw_power_sleep(), and xhci_start_controller().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_root_intr()

static void xhci_root_intr ( struct xhci_softc sc)
static

Definition at line 2976 of file xhci.c.

References DPRINTF, xhci_softc::sc_bus, xhci_softc::sc_hub_idata, xhci_softc::sc_noport, uhub_root_intr(), USB_BUS_LOCK_ASSERT, XHCI_PORTSC, XHCI_PS_CEC, XHCI_PS_CSC, XHCI_PS_OCC, XHCI_PS_PEC, XHCI_PS_PLC, XHCI_PS_PRC, XHCI_PS_WRC, and XREAD4.

Referenced by xhci_interrupt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_roothub_exec()

static usb_error_t xhci_roothub_exec ( struct usb_device udev,
struct usb_device_request req,
const void **  pptr,
uint16_t *  plength 
)
static

Definition at line 3214 of file xhci.c.

References usb_hub_ss_descriptor::bLength, usb_hub_ss_descriptor::bNbrPorts, usb_hub_ss_descriptor::bPwrOn2PwrGood, usb_device::bus, usb_bus::bus_mtx, C, xhci_hub_desc::hubd, index, len, pptr, xhci_hub_desc::ps, req, xhci_softc::sc_bus, xhci_softc::sc_conf, xhci_softc::sc_hub_desc, xhci_softc::sc_noport, xhci_softc::sc_vendor, xhci_hub_desc::stat, xhci_hub_desc::temp, UDESC_BOS, UDESC_CONFIG, UDESC_DEVICE, UDESC_STRING, UDS_SELF_POWERED, UGETW, UHD_OC_INDIVIDUAL, UHD_PORT_IND, UHD_PWR_GANGED, UHD_PWR_INDIVIDUAL, UHF_BH_PORT_RESET, UHF_C_BH_PORT_RESET, UHF_C_PORT_CONFIG_ERROR, UHF_C_PORT_CONNECTION, UHF_C_PORT_ENABLE, UHF_C_PORT_LINK_STATE, UHF_C_PORT_OVER_CURRENT, UHF_C_PORT_RESET, UHF_C_PORT_SUSPEND, UHF_PORT_ENABLE, UHF_PORT_INDICATOR, UHF_PORT_LINK_STATE, UHF_PORT_POWER, UHF_PORT_RESET, UHF_PORT_SUSPEND, UHF_PORT_TEST, UHF_PORT_U1_TIMEOUT, UHF_PORT_U2_TIMEOUT, UPS_C_BH_PORT_RESET, UPS_C_CONNECT_STATUS, UPS_C_OVERCURRENT_INDICATOR, UPS_C_PORT_CONFIG_ERROR, UPS_C_PORT_ENABLED, UPS_C_PORT_LINK_STATE, UPS_C_PORT_RESET, UPS_CURRENT_CONNECT_STATUS, UPS_HIGH_SPEED, UPS_LOW_SPEED, UPS_OTHER_SPEED, UPS_OVERCURRENT_INDICATOR, UPS_PORT_ENABLED, UPS_PORT_LINK_STATE_SET, UPS_RESET, UR_CLEAR_FEATURE, UR_CLEAR_TT_BUFFER, UR_GET_CONFIG, UR_GET_DESCRIPTOR, UR_GET_INTERFACE, UR_GET_STATUS, UR_GET_TT_STATE, UR_RESET_TT, UR_SET_ADDRESS, UR_SET_CONFIG, UR_SET_DESCRIPTOR, UR_SET_FEATURE, UR_SET_INTERFACE, UR_STOP_TT, UR_SYNCH_FRAME, USB_BUS_LOCK_ASSERT, USB_ERR_IOERROR, usb_make_str_desc(), usb_pause_mtx(), USETW, UT_READ_CLASS_DEVICE, UT_READ_CLASS_OTHER, UT_READ_DEVICE, UT_READ_ENDPOINT, UT_READ_INTERFACE, UT_WRITE_CLASS_DEVICE, UT_WRITE_CLASS_OTHER, UT_WRITE_DEVICE, UT_WRITE_ENDPOINT, UT_WRITE_INTERFACE, value, usb_hub_ss_descriptor::wHubCharacteristics, usb_port_status::wPortChange, usb_port_status::wPortStatus, usb_status::wStatus, xhci_bosd, XHCI_BUS2SC, xhci_confd, xhci_devd, XHCI_HCS0_PIND, XHCI_HCS0_PPC, XHCI_HCSPARAMS0, xhci_hubd, XHCI_MAX_DEVICES, XHCI_PM3_U1TO_SET, XHCI_PM3_U2TO_SET, XHCI_PORTPMSC, XHCI_PORTSC, XHCI_PS_CCS, XHCI_PS_CEC, XHCI_PS_CSC, XHCI_PS_DR, XHCI_PS_LWS, XHCI_PS_OCA, XHCI_PS_OCC, XHCI_PS_PEC, XHCI_PS_PED, XHCI_PS_PIC_SET, XHCI_PS_PLC, XHCI_PS_PLS_GET, XHCI_PS_PLS_SET, XHCI_PS_PP, XHCI_PS_PR, XHCI_PS_PRC, XHCI_PS_SPEED_GET, XHCI_PS_WPR, XHCI_PS_WRC, XREAD4, and XWRITE4.

Here is the call graph for this function:

◆ xhci_set_address()

◆ xhci_set_endpoint_mode()

static usb_error_t xhci_set_endpoint_mode ( struct usb_device udev,
struct usb_endpoint ep,
uint8_t  ep_mode 
)
static

◆ xhci_set_hw_power()

static void xhci_set_hw_power ( struct usb_bus bus)
static

Definition at line 4192 of file xhci.c.

References DPRINTF.

◆ xhci_set_hw_power_sleep()

static void xhci_set_hw_power_sleep ( struct usb_bus bus,
uint32_t  state 
)
static

◆ xhci_set_slot_pointer()

static void xhci_set_slot_pointer ( struct xhci_softc sc,
uint8_t  index,
uint64_t  dev_addr 
)
static

Definition at line 2233 of file xhci.c.

References usb_page_search::buffer, xhci_hw_softc::ctx_pc, DPRINTF, index, xhci_dev_ctx_addr::qwBaaDevCtxAddr, xhci_softc::sc_hw, usb_pc_cpu_flush(), and usbd_get_page().

Referenced by xhci_alloc_device_ext(), and xhci_free_device_ext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_setup_generic_chain()

static void xhci_setup_generic_chain ( struct usb_xfer xfer)
static

Definition at line 1980 of file xhci.c.

References xhci_std_temp::average, usb_endpoint_ss_comp_descriptor::bmAttributes, usb_xfer_root::bus, usb_xfer_flags_int::control_act, usb_xfer_flags_int::control_did_data, usb_xfer_flags_int::control_hdr, usb_xfer_flags_int::control_xfr, usb_xfer_flags_int::curr_dma_set, xhci_std_temp::direction, xhci_std_temp::do_isoc_sync, DPRINTF, usb_endpoint::ecomp, usb_endpoint::edesc, usb_xfer::endpoint, usb_xfer::endpointno, usb_xfer::flags, usb_xfer::flags_int, usb_xfer_flags::force_short_xfer, usb_xfer::frbuffers, usb_xfer::frlengths, xhci_std_temp::isoc_delta, xhci_std_temp::isoc_frame, usb_xfer_flags_int::isochronous_xfr, xhci_std_temp::last_frame, xhci_std_temp::len, usb_xfer::max_frame_size, usb_xfer::max_hc_frame_size, xhci_std_temp::max_packet_size, usb_xfer::max_packet_size, xhci_std_temp::multishort, usb_xfer::nframes, xhci_std_temp::offset, xhci_std_temp::pc, xhci_std_temp::sc, xhci_softc::sc_ctlstep, xhci_softc::sc_ist, usb_xfer_flags_int::short_frames_ok, xhci_std_temp::shortpkt, xhci_std_temp::step_td, xhci_std_temp::tbc, xhci_std_temp::td, xhci_std_temp::td_next, usb_xfer::td_start, usb_xfer::td_transfer_cache, usb_xfer::td_transfer_first, usb_xfer::td_transfer_last, xhci_std_temp::tlbpc, xhci_std_temp::trb_type, usb_xfer_root::udev, UE_DIR_IN, UE_GET_DIR, UE_GET_SS_ISO_MULT, USB_SPEED_FULL, usbd_get_speed(), usbd_xfer_get_fps_shift(), usbd_xfer_get_isochronous_start_frame(), XHCI_BUS2SC, XHCI_MFINDEX, XHCI_MFINDEX_GET, xhci_setup_generic_chain_sub(), XHCI_TRB_TYPE_DATA_STAGE, XHCI_TRB_TYPE_ISOCH, XHCI_TRB_TYPE_NORMAL, XHCI_TRB_TYPE_SETUP_STAGE, XHCI_TRB_TYPE_STATUS_STAGE, xhcictlstep, XREAD4, and usb_xfer::xroot.

Referenced by xhci_device_generic_enter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_setup_generic_chain_sub()

◆ xhci_skip_transfer()

static void xhci_skip_transfer ( struct usb_xfer xfer)
static

◆ xhci_start_controller()

◆ xhci_start_dma_delay()

static void xhci_start_dma_delay ( struct usb_xfer xfer)
static

Definition at line 3870 of file xhci.c.

References usb_xfer_root::bus, usb_bus::intr_q, xhci_softc::sc_bus, xhci_softc::sc_config_msg, usb_proc_msignal(), usbd_transfer_enqueue(), XHCI_BUS2SC, and usb_xfer::xroot.

Here is the call graph for this function:

◆ xhci_timeout()

static void xhci_timeout ( void *  arg)
static

Definition at line 1655 of file xhci.c.

References usb_xfer_root::bus, DPRINTF, USB_BUS_LOCK_ASSERT, USB_ERR_TIMEOUT, xhci_device_done(), and usb_xfer::xroot.

Referenced by xhci_device_generic_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_transfer_insert()

◆ xhci_transfer_remove()

static void xhci_transfer_remove ( struct usb_xfer xfer,
usb_error_t  error 
)
static

◆ xhci_uninit()

void xhci_uninit ( struct xhci_softc sc)

Definition at line 644 of file xhci.c.

References xhci_softc::sc_bus, xhci_softc::sc_cmd_cv, xhci_softc::sc_cmd_sx, usb_bus_mem_free_all(), and xhci_iterate_hw_softc().

Referenced by generic_xhci_detach(), and xhci_pci_detach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xhci_use_polling()

uint8_t xhci_use_polling ( void  )

Definition at line 213 of file xhci.c.

Referenced by xhci_pci_attach().

Here is the caller graph for this function:

◆ xhci_xfer_setup()

◆ xhci_xfer_unsetup()

static void xhci_xfer_unsetup ( struct usb_xfer xfer)
static

Definition at line 3864 of file xhci.c.

Variable Documentation

◆ xhci_bosd

const struct xhci_bos_desc xhci_bosd
static

Definition at line 3139 of file xhci.c.

Referenced by xhci_roothub_exec().

◆ xhci_bus_methods

static const struct usb_bus_methods xhci_bus_methods
static
Initial value:
= {
.endpoint_init = xhci_ep_init,
.endpoint_uninit = xhci_ep_uninit,
.xfer_setup = xhci_xfer_setup,
.xfer_unsetup = xhci_xfer_unsetup,
.get_dma_delay = xhci_get_dma_delay,
.device_init = xhci_device_init,
.device_uninit = xhci_device_uninit,
.device_resume = xhci_device_resume,
.device_suspend = xhci_device_suspend,
.set_hw_power = xhci_set_hw_power,
.roothub_exec = xhci_roothub_exec,
.xfer_poll = xhci_do_poll,
.start_dma_delay = xhci_start_dma_delay,
.set_address = xhci_set_address,
.clear_stall = xhci_ep_clear_stall,
.device_state_change = xhci_device_state_change,
.set_hw_power_sleep = xhci_set_hw_power_sleep,
.set_endpoint_mode = xhci_set_endpoint_mode,
}
static void xhci_device_suspend(struct usb_device *udev)
Definition: xhci.c:4161
static usb_error_t xhci_device_init(struct usb_device *udev)
Definition: xhci.c:4031
static void xhci_set_hw_power(struct usb_bus *bus)
Definition: xhci.c:4192
static void xhci_get_dma_delay(struct usb_device *udev, uint32_t *pus)
Definition: xhci.c:4117
static void xhci_set_hw_power_sleep(struct usb_bus *bus, uint32_t state)
Definition: xhci.c:659
static void xhci_ep_clear_stall(struct usb_device *udev, struct usb_endpoint *ep)
Definition: xhci.c:4007
static usb_error_t xhci_roothub_exec(struct usb_device *udev, struct usb_device_request *req, const void **pptr, uint16_t *plength)
Definition: xhci.c:3214
static void xhci_xfer_unsetup(struct usb_xfer *xfer)
Definition: xhci.c:3864
static void xhci_device_state_change(struct usb_device *udev)
Definition: xhci.c:4198
static usb_error_t xhci_set_endpoint_mode(struct usb_device *udev, struct usb_endpoint *ep, uint8_t ep_mode)
Definition: xhci.c:4303
static void xhci_do_poll(struct usb_bus *)
Definition: xhci.c:1668
static void xhci_xfer_setup(struct usb_setup_params *parm)
Definition: xhci.c:3638
static void xhci_ep_uninit(struct usb_device *udev, struct usb_endpoint *ep)
Definition: xhci.c:4001
static usb_error_t xhci_set_address(struct usb_device *udev, struct mtx *mtx, uint16_t address)
Definition: xhci.c:1343
static void xhci_device_uninit(struct usb_device *udev)
Definition: xhci.c:4092
static void xhci_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *edesc, struct usb_endpoint *ep)
Definition: xhci.c:3962
static void xhci_start_dma_delay(struct usb_xfer *xfer)
Definition: xhci.c:3870
static void xhci_device_resume(struct usb_device *udev)
Definition: xhci.c:4127

Definition at line 176 of file xhci.c.

Referenced by xhci_init().

◆ xhci_confd

const struct xhci_config_desc xhci_confd
static

Definition at line 3172 of file xhci.c.

Referenced by xhci_roothub_exec().

◆ xhci_configure_msg

usb_proc_callback_t xhci_configure_msg
static

Definition at line 164 of file xhci.c.

Referenced by xhci_init().

◆ xhci_devd

const struct usb_device_descriptor xhci_devd
static
Initial value:
=
{
.bLength = sizeof(xhci_devd),
.bDescriptorType = UDESC_DEVICE,
HSETW(.bcdUSB, 0x0300),
.bDeviceClass = UDCLASS_HUB,
.bDeviceSubClass = UDSUBCLASS_HUB,
.bDeviceProtocol = UDPROTO_SSHUB,
.bMaxPacketSize = 9,
HSETW(.idVendor, 0x0000),
HSETW(.idProduct, 0x0000),
HSETW(.bcdDevice, 0x0100),
.iManufacturer = 1,
.iProduct = 2,
.iSerialNumber = 0,
.bNumConfigurations = 1,
}
#define UDSUBCLASS_HUB
Definition: usb.h:374
#define UDCLASS_HUB
Definition: usb.h:373
#define UDPROTO_SSHUB
Definition: usb.h:378
#define UDESC_DEVICE
Definition: usb.h:195
uint16_t idProduct
Definition: usbdi.h:35
uint16_t idVendor
Definition: usbdi.h:34
#define HSETW(ptr, val)
Definition: xhci.c:3117
static const struct usb_device_descriptor xhci_devd
Definition: xhci.c:3120

Definition at line 3120 of file xhci.c.

Referenced by xhci_roothub_exec().

◆ xhci_device_generic_methods

const struct usb_pipe_methods xhci_device_generic_methods
static
Initial value:
=
{
}
static void xhci_device_generic_close(struct usb_xfer *xfer)
Definition: xhci.c:3029
static void xhci_device_generic_enter(struct usb_xfer *xfer)
Definition: xhci.c:3073
static void xhci_device_generic_open(struct usb_xfer *xfer)
Definition: xhci.c:3023
static void xhci_device_generic_start(struct usb_xfer *xfer)
Definition: xhci.c:3085

Definition at line 3104 of file xhci.c.

Referenced by xhci_ep_init().

◆ xhci_hubd

const struct usb_hub_ss_descriptor xhci_hubd
static
Initial value:
= {
.bLength = sizeof(xhci_hubd),
.bDescriptorType = UDESC_SS_HUB,
}
#define UDESC_SS_HUB
Definition: usb.h:215
static const struct usb_hub_ss_descriptor xhci_hubd
Definition: xhci.c:3208

Definition at line 3208 of file xhci.c.

Referenced by xhci_roothub_exec().

◆ xhcictlquirk

int xhcictlquirk = 1
static

Definition at line 103 of file xhci.c.

Referenced by xhci_init().

◆ xhcidcepquirk

int xhcidcepquirk
static

Definition at line 107 of file xhci.c.

Referenced by xhci_cmd_configure_ep().

◆ xhcistreams

int xhcistreams
static

Definition at line 99 of file xhci.c.

Referenced by xhci_set_endpoint_mode().