diff options
author | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2009-04-27 22:58:01 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-06-16 00:44:49 -0400 |
commit | d0e96f5a71a032ced0c35f521c1cbd67e816922a (patch) | |
tree | 402e4d1ce20682fd2efd3ffd2ad23ffd097b1436 /drivers/usb/host/xhci.h | |
parent | 6d65b78a093552fb42448480d4c66bf093a6d4cf (diff) |
USB: xhci: Control transfer support.
Allow device drivers to enqueue URBs to control endpoints on devices under
an xHCI host controller. Each control transfer is represented by a
series of Transfer Descriptors (TDs) written to an endpoint ring. There
is one TD for the Setup phase, (optionally) one TD for the Data phase, and
one TD for the Status phase.
Enqueue these TDs onto the endpoint ring that represents the control
endpoint. The host controller hardware will return an event on the event
ring that points to the (DMA) address of one of the TDs on the endpoint
ring. If the transfer was successful, the transfer event TRB will have a
completion code of success, and it will point to the Status phase TD.
Anything else is considered an error.
This should work for control endpoints besides the default endpoint, but
that hasn't been tested.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/xhci.h')
-rw-r--r-- | drivers/usb/host/xhci.h | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 4ef6b9e88504..fc8dcd2aa770 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -448,6 +448,9 @@ struct xhci_doorbell_array { | |||
448 | #define DB_STREAM_ID_HOST 0x0 | 448 | #define DB_STREAM_ID_HOST 0x0 |
449 | #define DB_MASK (0xff << 8) | 449 | #define DB_MASK (0xff << 8) |
450 | 450 | ||
451 | /* Endpoint Target - bits 0:7 */ | ||
452 | #define EPI_TO_DB(p) (((p) + 1) & 0xff) | ||
453 | |||
451 | 454 | ||
452 | /** | 455 | /** |
453 | * struct xhci_slot_ctx | 456 | * struct xhci_slot_ctx |
@@ -552,13 +555,18 @@ struct xhci_ep_ctx { | |||
552 | * 4 - TRB error | 555 | * 4 - TRB error |
553 | * 5-7 - reserved | 556 | * 5-7 - reserved |
554 | */ | 557 | */ |
555 | #define EP_STATE (0xf) | 558 | #define EP_STATE_MASK (0xf) |
559 | #define EP_STATE_DISABLED 0 | ||
560 | #define EP_STATE_RUNNING 1 | ||
561 | #define EP_STATE_HALTED 2 | ||
562 | #define EP_STATE_STOPPED 3 | ||
563 | #define EP_STATE_ERROR 4 | ||
556 | /* Mult - Max number of burtst within an interval, in EP companion desc. */ | 564 | /* Mult - Max number of burtst within an interval, in EP companion desc. */ |
557 | #define EP_MULT(p) ((p & 0x3) << 8) | 565 | #define EP_MULT(p) ((p & 0x3) << 8) |
558 | /* bits 10:14 are Max Primary Streams */ | 566 | /* bits 10:14 are Max Primary Streams */ |
559 | /* bit 15 is Linear Stream Array */ | 567 | /* bit 15 is Linear Stream Array */ |
560 | /* Interval - period between requests to an endpoint - 125u increments. */ | 568 | /* Interval - period between requests to an endpoint - 125u increments. */ |
561 | #define EP_INTERVAL (0xff << 16) | 569 | #define EP_INTERVAL (0xff << 16) |
562 | 570 | ||
563 | /* ep_info2 bitmasks */ | 571 | /* ep_info2 bitmasks */ |
564 | /* | 572 | /* |
@@ -618,7 +626,6 @@ struct xhci_virt_device { | |||
618 | dma_addr_t in_ctx_dma; | 626 | dma_addr_t in_ctx_dma; |
619 | /* FIXME when stream support is added */ | 627 | /* FIXME when stream support is added */ |
620 | struct xhci_ring *ep_rings[31]; | 628 | struct xhci_ring *ep_rings[31]; |
621 | dma_addr_t ep_dma[31]; | ||
622 | /* Status of the last command issued for this device */ | 629 | /* Status of the last command issued for this device */ |
623 | u32 cmd_status; | 630 | u32 cmd_status; |
624 | }; | 631 | }; |
@@ -657,6 +664,9 @@ struct xhci_transfer_event { | |||
657 | u32 flags; | 664 | u32 flags; |
658 | } __attribute__ ((packed)); | 665 | } __attribute__ ((packed)); |
659 | 666 | ||
667 | /** Transfer Event bit fields **/ | ||
668 | #define TRB_TO_EP_ID(p) (((p) >> 16) & 0x1f) | ||
669 | |||
660 | /* Completion Code - only applicable for some types of TRBs */ | 670 | /* Completion Code - only applicable for some types of TRBs */ |
661 | #define COMP_CODE_MASK (0xff << 24) | 671 | #define COMP_CODE_MASK (0xff << 24) |
662 | #define GET_COMP_CODE(p) (((p) & COMP_CODE_MASK) >> 24) | 672 | #define GET_COMP_CODE(p) (((p) & COMP_CODE_MASK) >> 24) |
@@ -877,6 +887,12 @@ union xhci_trb { | |||
877 | #define TRBS_PER_SEGMENT 64 | 887 | #define TRBS_PER_SEGMENT 64 |
878 | #define SEGMENT_SIZE (TRBS_PER_SEGMENT*16) | 888 | #define SEGMENT_SIZE (TRBS_PER_SEGMENT*16) |
879 | 889 | ||
890 | struct xhci_td { | ||
891 | struct list_head td_list; | ||
892 | struct urb *urb; | ||
893 | union xhci_trb *last_trb; | ||
894 | }; | ||
895 | |||
880 | struct xhci_segment { | 896 | struct xhci_segment { |
881 | union xhci_trb *trbs; | 897 | union xhci_trb *trbs; |
882 | /* private to HCD */ | 898 | /* private to HCD */ |
@@ -892,6 +908,7 @@ struct xhci_ring { | |||
892 | union xhci_trb *dequeue; | 908 | union xhci_trb *dequeue; |
893 | struct xhci_segment *deq_seg; | 909 | struct xhci_segment *deq_seg; |
894 | unsigned int deq_updates; | 910 | unsigned int deq_updates; |
911 | struct list_head td_list; | ||
895 | /* | 912 | /* |
896 | * Write the cycle state into the TRB cycle field to give ownership of | 913 | * Write the cycle state into the TRB cycle field to give ownership of |
897 | * the TRB to the host controller (if we are the producer), or to check | 914 | * the TRB to the host controller (if we are the producer), or to check |
@@ -1042,6 +1059,8 @@ void xhci_print_ir_set(struct xhci_hcd *xhci, struct intr_reg *ir_set, int set_n | |||
1042 | void xhci_print_registers(struct xhci_hcd *xhci); | 1059 | void xhci_print_registers(struct xhci_hcd *xhci); |
1043 | void xhci_dbg_regs(struct xhci_hcd *xhci); | 1060 | void xhci_dbg_regs(struct xhci_hcd *xhci); |
1044 | void xhci_print_run_regs(struct xhci_hcd *xhci); | 1061 | void xhci_print_run_regs(struct xhci_hcd *xhci); |
1062 | void xhci_print_trb_offsets(struct xhci_hcd *xhci, union xhci_trb *trb); | ||
1063 | void xhci_debug_trb(struct xhci_hcd *xhci, union xhci_trb *trb); | ||
1045 | void xhci_debug_segment(struct xhci_hcd *xhci, struct xhci_segment *seg); | 1064 | void xhci_debug_segment(struct xhci_hcd *xhci, struct xhci_segment *seg); |
1046 | void xhci_debug_ring(struct xhci_hcd *xhci, struct xhci_ring *ring); | 1065 | void xhci_debug_ring(struct xhci_hcd *xhci, struct xhci_ring *ring); |
1047 | void xhci_dbg_erst(struct xhci_hcd *xhci, struct xhci_erst *erst); | 1066 | void xhci_dbg_erst(struct xhci_hcd *xhci, struct xhci_erst *erst); |
@@ -1055,6 +1074,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags); | |||
1055 | void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id); | 1074 | void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id); |
1056 | int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, struct usb_device *udev, gfp_t flags); | 1075 | int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, struct usb_device *udev, gfp_t flags); |
1057 | int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev); | 1076 | int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev); |
1077 | unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc); | ||
1058 | 1078 | ||
1059 | #ifdef CONFIG_PCI | 1079 | #ifdef CONFIG_PCI |
1060 | /* xHCI PCI glue */ | 1080 | /* xHCI PCI glue */ |
@@ -1074,6 +1094,8 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd); | |||
1074 | int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev); | 1094 | int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev); |
1075 | void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev); | 1095 | void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev); |
1076 | int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev); | 1096 | int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev); |
1097 | int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags); | ||
1098 | int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status); | ||
1077 | 1099 | ||
1078 | /* xHCI ring, segment, TRB, and TD functions */ | 1100 | /* xHCI ring, segment, TRB, and TD functions */ |
1079 | dma_addr_t trb_virt_to_dma(struct xhci_segment *seg, union xhci_trb *trb); | 1101 | dma_addr_t trb_virt_to_dma(struct xhci_segment *seg, union xhci_trb *trb); |
@@ -1083,6 +1105,7 @@ void handle_event(struct xhci_hcd *xhci); | |||
1083 | void set_hc_event_deq(struct xhci_hcd *xhci); | 1105 | void set_hc_event_deq(struct xhci_hcd *xhci); |
1084 | int queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id); | 1106 | int queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id); |
1085 | int queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, u32 slot_id); | 1107 | int queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, u32 slot_id); |
1108 | int queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, int slot_id, unsigned int ep_index); | ||
1086 | 1109 | ||
1087 | /* xHCI roothub code */ | 1110 | /* xHCI roothub code */ |
1088 | int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, | 1111 | int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, |