aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/xhci.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host/xhci.h')
-rw-r--r--drivers/usb/host/xhci.h116
1 files changed, 105 insertions, 11 deletions
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index e5eb09b2f38e..dada2fb59261 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -26,8 +26,8 @@
26#include <linux/usb.h> 26#include <linux/usb.h>
27#include <linux/timer.h> 27#include <linux/timer.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/usb/hcd.h>
29 30
30#include "../core/hcd.h"
31/* Code sharing between pci-quirks and xhci hcd */ 31/* Code sharing between pci-quirks and xhci hcd */
32#include "xhci-ext-caps.h" 32#include "xhci-ext-caps.h"
33 33
@@ -117,7 +117,7 @@ struct xhci_cap_regs {
117/* true: no secondary Stream ID Support */ 117/* true: no secondary Stream ID Support */
118#define HCC_NSS(p) ((p) & (1 << 7)) 118#define HCC_NSS(p) ((p) & (1 << 7))
119/* Max size for Primary Stream Arrays - 2^(n+1), where n is bits 12:15 */ 119/* Max size for Primary Stream Arrays - 2^(n+1), where n is bits 12:15 */
120#define HCC_MAX_PSA (1 << ((((p) >> 12) & 0xf) + 1)) 120#define HCC_MAX_PSA(p) (1 << ((((p) >> 12) & 0xf) + 1))
121/* Extended Capabilities pointer from PCI base - section 5.3.6 */ 121/* Extended Capabilities pointer from PCI base - section 5.3.6 */
122#define HCC_EXT_CAPS(p) XHCI_HCC_EXT_CAPS(p) 122#define HCC_EXT_CAPS(p) XHCI_HCC_EXT_CAPS(p)
123 123
@@ -444,6 +444,7 @@ struct xhci_doorbell_array {
444 444
445/* Endpoint Target - bits 0:7 */ 445/* Endpoint Target - bits 0:7 */
446#define EPI_TO_DB(p) (((p) + 1) & 0xff) 446#define EPI_TO_DB(p) (((p) + 1) & 0xff)
447#define STREAM_ID_TO_DB(p) (((p) & 0xffff) << 16)
447 448
448 449
449/** 450/**
@@ -585,6 +586,10 @@ struct xhci_ep_ctx {
585/* Interval - period between requests to an endpoint - 125u increments. */ 586/* Interval - period between requests to an endpoint - 125u increments. */
586#define EP_INTERVAL(p) ((p & 0xff) << 16) 587#define EP_INTERVAL(p) ((p & 0xff) << 16)
587#define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) >> 16) & 0xff)) 588#define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) >> 16) & 0xff))
589#define EP_MAXPSTREAMS_MASK (0x1f << 10)
590#define EP_MAXPSTREAMS(p) (((p) << 10) & EP_MAXPSTREAMS_MASK)
591/* Endpoint is set up with a Linear Stream Array (vs. Secondary Stream Array) */
592#define EP_HAS_LSA (1 << 15)
588 593
589/* ep_info2 bitmasks */ 594/* ep_info2 bitmasks */
590/* 595/*
@@ -609,6 +614,10 @@ struct xhci_ep_ctx {
609#define MAX_PACKET_MASK (0xffff << 16) 614#define MAX_PACKET_MASK (0xffff << 16)
610#define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff) 615#define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff)
611 616
617/* tx_info bitmasks */
618#define AVG_TRB_LENGTH_FOR_EP(p) ((p) & 0xffff)
619#define MAX_ESIT_PAYLOAD_FOR_EP(p) (((p) & 0xffff) << 16)
620
612 621
613/** 622/**
614 * struct xhci_input_control_context 623 * struct xhci_input_control_context
@@ -644,8 +653,50 @@ struct xhci_command {
644/* add context bitmasks */ 653/* add context bitmasks */
645#define ADD_EP(x) (0x1 << x) 654#define ADD_EP(x) (0x1 << x)
646 655
656struct xhci_stream_ctx {
657 /* 64-bit stream ring address, cycle state, and stream type */
658 u64 stream_ring;
659 /* offset 0x14 - 0x1f reserved for HC internal use */
660 u32 reserved[2];
661};
662
663/* Stream Context Types (section 6.4.1) - bits 3:1 of stream ctx deq ptr */
664#define SCT_FOR_CTX(p) (((p) << 1) & 0x7)
665/* Secondary stream array type, dequeue pointer is to a transfer ring */
666#define SCT_SEC_TR 0
667/* Primary stream array type, dequeue pointer is to a transfer ring */
668#define SCT_PRI_TR 1
669/* Dequeue pointer is for a secondary stream array (SSA) with 8 entries */
670#define SCT_SSA_8 2
671#define SCT_SSA_16 3
672#define SCT_SSA_32 4
673#define SCT_SSA_64 5
674#define SCT_SSA_128 6
675#define SCT_SSA_256 7
676
677/* Assume no secondary streams for now */
678struct xhci_stream_info {
679 struct xhci_ring **stream_rings;
680 /* Number of streams, including stream 0 (which drivers can't use) */
681 unsigned int num_streams;
682 /* The stream context array may be bigger than
683 * the number of streams the driver asked for
684 */
685 struct xhci_stream_ctx *stream_ctx_array;
686 unsigned int num_stream_ctxs;
687 dma_addr_t ctx_array_dma;
688 /* For mapping physical TRB addresses to segments in stream rings */
689 struct radix_tree_root trb_address_map;
690 struct xhci_command *free_streams_command;
691};
692
693#define SMALL_STREAM_ARRAY_SIZE 256
694#define MEDIUM_STREAM_ARRAY_SIZE 1024
695
647struct xhci_virt_ep { 696struct xhci_virt_ep {
648 struct xhci_ring *ring; 697 struct xhci_ring *ring;
698 /* Related to endpoints that are configured to use stream IDs only */
699 struct xhci_stream_info *stream_info;
649 /* Temporary storage in case the configure endpoint command fails and we 700 /* Temporary storage in case the configure endpoint command fails and we
650 * have to restore the device state to the previous state 701 * have to restore the device state to the previous state
651 */ 702 */
@@ -654,11 +705,17 @@ struct xhci_virt_ep {
654#define SET_DEQ_PENDING (1 << 0) 705#define SET_DEQ_PENDING (1 << 0)
655#define EP_HALTED (1 << 1) /* For stall handling */ 706#define EP_HALTED (1 << 1) /* For stall handling */
656#define EP_HALT_PENDING (1 << 2) /* For URB cancellation */ 707#define EP_HALT_PENDING (1 << 2) /* For URB cancellation */
708/* Transitioning the endpoint to using streams, don't enqueue URBs */
709#define EP_GETTING_STREAMS (1 << 3)
710#define EP_HAS_STREAMS (1 << 4)
711/* Transitioning the endpoint to not using streams, don't enqueue URBs */
712#define EP_GETTING_NO_STREAMS (1 << 5)
657 /* ---- Related to URB cancellation ---- */ 713 /* ---- Related to URB cancellation ---- */
658 struct list_head cancelled_td_list; 714 struct list_head cancelled_td_list;
659 /* The TRB that was last reported in a stopped endpoint ring */ 715 /* The TRB that was last reported in a stopped endpoint ring */
660 union xhci_trb *stopped_trb; 716 union xhci_trb *stopped_trb;
661 struct xhci_td *stopped_td; 717 struct xhci_td *stopped_td;
718 unsigned int stopped_stream;
662 /* Watchdog timer for stop endpoint command to cancel URBs */ 719 /* Watchdog timer for stop endpoint command to cancel URBs */
663 struct timer_list stop_cmd_timer; 720 struct timer_list stop_cmd_timer;
664 int stop_cmds_pending; 721 int stop_cmds_pending;
@@ -706,14 +763,6 @@ struct xhci_device_context_array {
706 */ 763 */
707 764
708 765
709struct xhci_stream_ctx {
710 /* 64-bit stream ring address, cycle state, and stream type */
711 u64 stream_ring;
712 /* offset 0x14 - 0x1f reserved for HC internal use */
713 u32 reserved[2];
714};
715
716
717struct xhci_transfer_event { 766struct xhci_transfer_event {
718 /* 64-bit buffer address, or immediate data */ 767 /* 64-bit buffer address, or immediate data */
719 u64 buffer; 768 u64 buffer;
@@ -824,6 +873,10 @@ struct xhci_event_cmd {
824#define TRB_TO_EP_INDEX(p) ((((p) & (0x1f << 16)) >> 16) - 1) 873#define TRB_TO_EP_INDEX(p) ((((p) & (0x1f << 16)) >> 16) - 1)
825#define EP_ID_FOR_TRB(p) ((((p) + 1) & 0x1f) << 16) 874#define EP_ID_FOR_TRB(p) ((((p) + 1) & 0x1f) << 16)
826 875
876/* Set TR Dequeue Pointer command TRB fields */
877#define TRB_TO_STREAM_ID(p) ((((p) & (0xffff << 16)) >> 16))
878#define STREAM_ID_FOR_TRB(p) ((((p)) & 0xffff) << 16)
879
827 880
828/* Port Status Change Event TRB fields */ 881/* Port Status Change Event TRB fields */
829/* Port ID - bits 31:24 */ 882/* Port ID - bits 31:24 */
@@ -948,6 +1001,10 @@ union xhci_trb {
948/* Allow two commands + a link TRB, along with any reserved command TRBs */ 1001/* Allow two commands + a link TRB, along with any reserved command TRBs */
949#define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3) 1002#define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3)
950#define SEGMENT_SIZE (TRBS_PER_SEGMENT*16) 1003#define SEGMENT_SIZE (TRBS_PER_SEGMENT*16)
1004/* SEGMENT_SHIFT should be log2(SEGMENT_SIZE).
1005 * Change this if you change TRBS_PER_SEGMENT!
1006 */
1007#define SEGMENT_SHIFT 10
951/* TRB buffer pointers can't cross 64KB boundaries */ 1008/* TRB buffer pointers can't cross 64KB boundaries */
952#define TRB_MAX_BUFF_SHIFT 16 1009#define TRB_MAX_BUFF_SHIFT 16
953#define TRB_MAX_BUFF_SIZE (1 << TRB_MAX_BUFF_SHIFT) 1010#define TRB_MAX_BUFF_SIZE (1 << TRB_MAX_BUFF_SHIFT)
@@ -989,6 +1046,7 @@ struct xhci_ring {
989 * if we own the TRB (if we are the consumer). See section 4.9.1. 1046 * if we own the TRB (if we are the consumer). See section 4.9.1.
990 */ 1047 */
991 u32 cycle_state; 1048 u32 cycle_state;
1049 unsigned int stream_id;
992}; 1050};
993 1051
994struct xhci_erst_entry { 1052struct xhci_erst_entry {
@@ -1084,6 +1142,8 @@ struct xhci_hcd {
1084 /* DMA pools */ 1142 /* DMA pools */
1085 struct dma_pool *device_pool; 1143 struct dma_pool *device_pool;
1086 struct dma_pool *segment_pool; 1144 struct dma_pool *segment_pool;
1145 struct dma_pool *small_streams_pool;
1146 struct dma_pool *medium_streams_pool;
1087 1147
1088#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING 1148#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
1089 /* Poll the rings - for debugging */ 1149 /* Poll the rings - for debugging */
@@ -1212,6 +1272,9 @@ void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring);
1212void xhci_dbg_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int last_ep); 1272void xhci_dbg_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int last_ep);
1213char *xhci_get_slot_state(struct xhci_hcd *xhci, 1273char *xhci_get_slot_state(struct xhci_hcd *xhci,
1214 struct xhci_container_ctx *ctx); 1274 struct xhci_container_ctx *ctx);
1275void xhci_dbg_ep_rings(struct xhci_hcd *xhci,
1276 unsigned int slot_id, unsigned int ep_index,
1277 struct xhci_virt_ep *ep);
1215 1278
1216/* xHCI memory management */ 1279/* xHCI memory management */
1217void xhci_mem_cleanup(struct xhci_hcd *xhci); 1280void xhci_mem_cleanup(struct xhci_hcd *xhci);
@@ -1238,6 +1301,29 @@ void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring);
1238void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, 1301void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci,
1239 struct xhci_virt_device *virt_dev, 1302 struct xhci_virt_device *virt_dev,
1240 unsigned int ep_index); 1303 unsigned int ep_index);
1304struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci,
1305 unsigned int num_stream_ctxs,
1306 unsigned int num_streams, gfp_t flags);
1307void xhci_free_stream_info(struct xhci_hcd *xhci,
1308 struct xhci_stream_info *stream_info);
1309void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci,
1310 struct xhci_ep_ctx *ep_ctx,
1311 struct xhci_stream_info *stream_info);
1312void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci,
1313 struct xhci_ep_ctx *ep_ctx,
1314 struct xhci_virt_ep *ep);
1315struct xhci_ring *xhci_dma_to_transfer_ring(
1316 struct xhci_virt_ep *ep,
1317 u64 address);
1318struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci,
1319 struct urb *urb);
1320struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci,
1321 unsigned int slot_id, unsigned int ep_index,
1322 unsigned int stream_id);
1323struct xhci_ring *xhci_stream_id_to_ring(
1324 struct xhci_virt_device *dev,
1325 unsigned int ep_index,
1326 unsigned int stream_id);
1241struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, 1327struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
1242 bool allocate_in_ctx, bool allocate_completion, 1328 bool allocate_in_ctx, bool allocate_completion,
1243 gfp_t mem_flags); 1329 gfp_t mem_flags);
@@ -1262,6 +1348,12 @@ int xhci_get_frame(struct usb_hcd *hcd);
1262irqreturn_t xhci_irq(struct usb_hcd *hcd); 1348irqreturn_t xhci_irq(struct usb_hcd *hcd);
1263int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev); 1349int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev);
1264void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev); 1350void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev);
1351int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
1352 struct usb_host_endpoint **eps, unsigned int num_eps,
1353 unsigned int num_streams, gfp_t mem_flags);
1354int xhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
1355 struct usb_host_endpoint **eps, unsigned int num_eps,
1356 gfp_t mem_flags);
1265int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev); 1357int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev);
1266int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev, 1358int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev,
1267 struct usb_tt *tt, gfp_t mem_flags); 1359 struct usb_tt *tt, gfp_t mem_flags);
@@ -1304,9 +1396,11 @@ int xhci_queue_reset_ep(struct xhci_hcd *xhci, int slot_id,
1304int xhci_queue_reset_device(struct xhci_hcd *xhci, u32 slot_id); 1396int xhci_queue_reset_device(struct xhci_hcd *xhci, u32 slot_id);
1305void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, 1397void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
1306 unsigned int slot_id, unsigned int ep_index, 1398 unsigned int slot_id, unsigned int ep_index,
1307 struct xhci_td *cur_td, struct xhci_dequeue_state *state); 1399 unsigned int stream_id, struct xhci_td *cur_td,
1400 struct xhci_dequeue_state *state);
1308void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci, 1401void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci,
1309 unsigned int slot_id, unsigned int ep_index, 1402 unsigned int slot_id, unsigned int ep_index,
1403 unsigned int stream_id,
1310 struct xhci_dequeue_state *deq_state); 1404 struct xhci_dequeue_state *deq_state);
1311void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, 1405void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci,
1312 struct usb_device *udev, unsigned int ep_index); 1406 struct usb_device *udev, unsigned int ep_index);