diff options
Diffstat (limited to 'drivers/usb/host/xhci.h')
-rw-r--r-- | drivers/usb/host/xhci.h | 112 |
1 files changed, 101 insertions, 11 deletions
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index ea389e9a4931..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 | /* |
@@ -648,8 +653,50 @@ struct xhci_command { | |||
648 | /* add context bitmasks */ | 653 | /* add context bitmasks */ |
649 | #define ADD_EP(x) (0x1 << x) | 654 | #define ADD_EP(x) (0x1 << x) |
650 | 655 | ||
656 | struct 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 */ | ||
678 | struct 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 | |||
651 | struct xhci_virt_ep { | 696 | struct xhci_virt_ep { |
652 | 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; | ||
653 | /* Temporary storage in case the configure endpoint command fails and we | 700 | /* Temporary storage in case the configure endpoint command fails and we |
654 | * have to restore the device state to the previous state | 701 | * have to restore the device state to the previous state |
655 | */ | 702 | */ |
@@ -658,11 +705,17 @@ struct xhci_virt_ep { | |||
658 | #define SET_DEQ_PENDING (1 << 0) | 705 | #define SET_DEQ_PENDING (1 << 0) |
659 | #define EP_HALTED (1 << 1) /* For stall handling */ | 706 | #define EP_HALTED (1 << 1) /* For stall handling */ |
660 | #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) | ||
661 | /* ---- Related to URB cancellation ---- */ | 713 | /* ---- Related to URB cancellation ---- */ |
662 | struct list_head cancelled_td_list; | 714 | struct list_head cancelled_td_list; |
663 | /* The TRB that was last reported in a stopped endpoint ring */ | 715 | /* The TRB that was last reported in a stopped endpoint ring */ |
664 | union xhci_trb *stopped_trb; | 716 | union xhci_trb *stopped_trb; |
665 | struct xhci_td *stopped_td; | 717 | struct xhci_td *stopped_td; |
718 | unsigned int stopped_stream; | ||
666 | /* Watchdog timer for stop endpoint command to cancel URBs */ | 719 | /* Watchdog timer for stop endpoint command to cancel URBs */ |
667 | struct timer_list stop_cmd_timer; | 720 | struct timer_list stop_cmd_timer; |
668 | int stop_cmds_pending; | 721 | int stop_cmds_pending; |
@@ -710,14 +763,6 @@ struct xhci_device_context_array { | |||
710 | */ | 763 | */ |
711 | 764 | ||
712 | 765 | ||
713 | struct xhci_stream_ctx { | ||
714 | /* 64-bit stream ring address, cycle state, and stream type */ | ||
715 | u64 stream_ring; | ||
716 | /* offset 0x14 - 0x1f reserved for HC internal use */ | ||
717 | u32 reserved[2]; | ||
718 | }; | ||
719 | |||
720 | |||
721 | struct xhci_transfer_event { | 766 | struct xhci_transfer_event { |
722 | /* 64-bit buffer address, or immediate data */ | 767 | /* 64-bit buffer address, or immediate data */ |
723 | u64 buffer; | 768 | u64 buffer; |
@@ -828,6 +873,10 @@ struct xhci_event_cmd { | |||
828 | #define TRB_TO_EP_INDEX(p) ((((p) & (0x1f << 16)) >> 16) - 1) | 873 | #define TRB_TO_EP_INDEX(p) ((((p) & (0x1f << 16)) >> 16) - 1) |
829 | #define EP_ID_FOR_TRB(p) ((((p) + 1) & 0x1f) << 16) | 874 | #define EP_ID_FOR_TRB(p) ((((p) + 1) & 0x1f) << 16) |
830 | 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 | |||
831 | 880 | ||
832 | /* Port Status Change Event TRB fields */ | 881 | /* Port Status Change Event TRB fields */ |
833 | /* Port ID - bits 31:24 */ | 882 | /* Port ID - bits 31:24 */ |
@@ -952,6 +1001,10 @@ union xhci_trb { | |||
952 | /* 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 */ |
953 | #define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3) | 1002 | #define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3) |
954 | #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 | ||
955 | /* TRB buffer pointers can't cross 64KB boundaries */ | 1008 | /* TRB buffer pointers can't cross 64KB boundaries */ |
956 | #define TRB_MAX_BUFF_SHIFT 16 | 1009 | #define TRB_MAX_BUFF_SHIFT 16 |
957 | #define TRB_MAX_BUFF_SIZE (1 << TRB_MAX_BUFF_SHIFT) | 1010 | #define TRB_MAX_BUFF_SIZE (1 << TRB_MAX_BUFF_SHIFT) |
@@ -993,6 +1046,7 @@ struct xhci_ring { | |||
993 | * 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. |
994 | */ | 1047 | */ |
995 | u32 cycle_state; | 1048 | u32 cycle_state; |
1049 | unsigned int stream_id; | ||
996 | }; | 1050 | }; |
997 | 1051 | ||
998 | struct xhci_erst_entry { | 1052 | struct xhci_erst_entry { |
@@ -1088,6 +1142,8 @@ struct xhci_hcd { | |||
1088 | /* DMA pools */ | 1142 | /* DMA pools */ |
1089 | struct dma_pool *device_pool; | 1143 | struct dma_pool *device_pool; |
1090 | 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; | ||
1091 | 1147 | ||
1092 | #ifdef CONFIG_USB_XHCI_HCD_DEBUGGING | 1148 | #ifdef CONFIG_USB_XHCI_HCD_DEBUGGING |
1093 | /* Poll the rings - for debugging */ | 1149 | /* Poll the rings - for debugging */ |
@@ -1216,6 +1272,9 @@ void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring); | |||
1216 | void xhci_dbg_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int last_ep); | 1272 | void xhci_dbg_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int last_ep); |
1217 | char *xhci_get_slot_state(struct xhci_hcd *xhci, | 1273 | char *xhci_get_slot_state(struct xhci_hcd *xhci, |
1218 | struct xhci_container_ctx *ctx); | 1274 | struct xhci_container_ctx *ctx); |
1275 | void xhci_dbg_ep_rings(struct xhci_hcd *xhci, | ||
1276 | unsigned int slot_id, unsigned int ep_index, | ||
1277 | struct xhci_virt_ep *ep); | ||
1219 | 1278 | ||
1220 | /* xHCI memory management */ | 1279 | /* xHCI memory management */ |
1221 | void xhci_mem_cleanup(struct xhci_hcd *xhci); | 1280 | void xhci_mem_cleanup(struct xhci_hcd *xhci); |
@@ -1242,6 +1301,29 @@ void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring); | |||
1242 | void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, | 1301 | void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, |
1243 | struct xhci_virt_device *virt_dev, | 1302 | struct xhci_virt_device *virt_dev, |
1244 | unsigned int ep_index); | 1303 | unsigned int ep_index); |
1304 | struct 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); | ||
1307 | void xhci_free_stream_info(struct xhci_hcd *xhci, | ||
1308 | struct xhci_stream_info *stream_info); | ||
1309 | void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci, | ||
1310 | struct xhci_ep_ctx *ep_ctx, | ||
1311 | struct xhci_stream_info *stream_info); | ||
1312 | void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci, | ||
1313 | struct xhci_ep_ctx *ep_ctx, | ||
1314 | struct xhci_virt_ep *ep); | ||
1315 | struct xhci_ring *xhci_dma_to_transfer_ring( | ||
1316 | struct xhci_virt_ep *ep, | ||
1317 | u64 address); | ||
1318 | struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci, | ||
1319 | struct urb *urb); | ||
1320 | struct 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); | ||
1323 | struct xhci_ring *xhci_stream_id_to_ring( | ||
1324 | struct xhci_virt_device *dev, | ||
1325 | unsigned int ep_index, | ||
1326 | unsigned int stream_id); | ||
1245 | struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, | 1327 | struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, |
1246 | bool allocate_in_ctx, bool allocate_completion, | 1328 | bool allocate_in_ctx, bool allocate_completion, |
1247 | gfp_t mem_flags); | 1329 | gfp_t mem_flags); |
@@ -1266,6 +1348,12 @@ int xhci_get_frame(struct usb_hcd *hcd); | |||
1266 | irqreturn_t xhci_irq(struct usb_hcd *hcd); | 1348 | irqreturn_t xhci_irq(struct usb_hcd *hcd); |
1267 | int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev); | 1349 | int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev); |
1268 | void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev); | 1350 | void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev); |
1351 | int 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); | ||
1354 | int 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); | ||
1269 | int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev); | 1357 | int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev); |
1270 | int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev, | 1358 | int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev, |
1271 | struct usb_tt *tt, gfp_t mem_flags); | 1359 | struct usb_tt *tt, gfp_t mem_flags); |
@@ -1308,9 +1396,11 @@ int xhci_queue_reset_ep(struct xhci_hcd *xhci, int slot_id, | |||
1308 | int xhci_queue_reset_device(struct xhci_hcd *xhci, u32 slot_id); | 1396 | int xhci_queue_reset_device(struct xhci_hcd *xhci, u32 slot_id); |
1309 | void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, | 1397 | void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, |
1310 | unsigned int slot_id, unsigned int ep_index, | 1398 | unsigned int slot_id, unsigned int ep_index, |
1311 | 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); | ||
1312 | void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci, | 1401 | void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci, |
1313 | unsigned int slot_id, unsigned int ep_index, | 1402 | unsigned int slot_id, unsigned int ep_index, |
1403 | unsigned int stream_id, | ||
1314 | struct xhci_dequeue_state *deq_state); | 1404 | struct xhci_dequeue_state *deq_state); |
1315 | void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, | 1405 | void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, |
1316 | struct usb_device *udev, unsigned int ep_index); | 1406 | struct usb_device *udev, unsigned int ep_index); |