USB: xhci: Endpoint representation refactoring.
[safe/jmp/linux-2.6] / drivers / usb / host / xhci.h
index 79ea627..6270922 100644 (file)
@@ -581,6 +581,7 @@ struct xhci_ep_ctx {
 /* bit 15 is Linear Stream Array */
 /* Interval - period between requests to an endpoint - 125u increments. */
 #define EP_INTERVAL(p)         ((p & 0xff) << 16)
+#define EP_INTERVAL_TO_UFRAMES(p)              (1 << (((p) >> 16) & 0xff))
 
 /* ep_info2 bitmasks */
 /*
@@ -589,6 +590,7 @@ struct xhci_ep_ctx {
  */
 #define        FORCE_EVENT     (0x1)
 #define ERROR_COUNT(p) (((p) & 0x3) << 1)
+#define CTX_TO_EP_TYPE(p)      (((p) >> 3) & 0x7)
 #define EP_TYPE(p)     ((p) << 3)
 #define ISOC_OUT_EP    1
 #define BULK_OUT_EP    2
@@ -601,6 +603,8 @@ struct xhci_ep_ctx {
 /* bit 7 is Host Initiate Disable - for disabling stream selection */
 #define MAX_BURST(p)   (((p)&0xff) << 8)
 #define MAX_PACKET(p)  (((p)&0xffff) << 16)
+#define MAX_PACKET_MASK                (0xffff << 16)
+#define MAX_PACKET_DECODED(p)  (((p) >> 16) & 0xffff)
 
 
 /**
@@ -621,6 +625,23 @@ struct xhci_input_control_ctx {
 /* add context bitmasks */
 #define        ADD_EP(x)       (0x1 << x)
 
+struct xhci_virt_ep {
+       struct xhci_ring                *ring;
+       /* Temporary storage in case the configure endpoint command fails and we
+        * have to restore the device state to the previous state
+        */
+       struct xhci_ring                *new_ring;
+       unsigned int                    ep_state;
+#define SET_DEQ_PENDING                (1 << 0)
+#define EP_HALTED              (1 << 1)
+       /* ----  Related to URB cancellation ---- */
+       struct list_head        cancelled_td_list;
+       unsigned int            cancels_pending;
+       /* The TRB that was last reported in a stopped endpoint ring */
+       union xhci_trb          *stopped_trb;
+       struct xhci_td          *stopped_td;
+};
+
 struct xhci_virt_device {
        /*
         * Commands to the hardware are passed an "input context" that
@@ -633,13 +654,7 @@ struct xhci_virt_device {
        struct xhci_container_ctx       *out_ctx;
        /* Used for addressing devices and configuration changes */
        struct xhci_container_ctx       *in_ctx;
-
-       /* FIXME when stream support is added */
-       struct xhci_ring                *ep_rings[31];
-       /* Temporary storage in case the configure endpoint command fails and we
-        * have to restore the device state to the previous state
-        */
-       struct xhci_ring                *new_ep_rings[31];
+       struct xhci_virt_ep             eps[31];
        struct completion               cmd_completion;
        /* Status of the last command issued for this device */
        u32                             cmd_status;
@@ -926,6 +941,12 @@ struct xhci_td {
        union xhci_trb          *last_trb;
 };
 
+struct xhci_dequeue_state {
+       struct xhci_segment *new_deq_seg;
+       union xhci_trb *new_deq_ptr;
+       int new_cycle_state;
+};
+
 struct xhci_ring {
        struct xhci_segment     *first_seg;
        union  xhci_trb         *enqueue;
@@ -935,15 +956,6 @@ struct xhci_ring {
        struct xhci_segment     *deq_seg;
        unsigned int            deq_updates;
        struct list_head        td_list;
-       /* ----  Related to URB cancellation ---- */
-       struct list_head        cancelled_td_list;
-       unsigned int            cancels_pending;
-       unsigned int            state;
-#define SET_DEQ_PENDING                (1 << 0)
-#define EP_HALTED              (1 << 1)
-       /* The TRB that was last reported in a stopped endpoint ring */
-       union xhci_trb          *stopped_trb;
-       struct xhci_td          *stopped_td;
        /*
         * Write the cycle state into the TRB cycle field to give ownership of
         * the TRB to the host controller (if we are the producer), or to check
@@ -952,12 +964,6 @@ struct xhci_ring {
        u32                     cycle_state;
 };
 
-struct xhci_dequeue_state {
-       struct xhci_segment *new_deq_seg;
-       union xhci_trb *new_deq_ptr;
-       int new_cycle_state;
-};
-
 struct xhci_erst_entry {
        /* 64-bit event ring segment address */
        u64     seg_addr;
@@ -1060,6 +1066,7 @@ struct xhci_hcd {
        int                     error_bitmask;
        unsigned int            quirks;
 #define        XHCI_LINK_TRB_QUIRK     (1 << 0)
+#define XHCI_RESET_EP_QUIRK    (1 << 1)
 };
 
 /* For testing purposes */
@@ -1167,7 +1174,12 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, struct usb_device
 int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev);
 unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc);
 unsigned int xhci_get_endpoint_flag(struct usb_endpoint_descriptor *desc);
+unsigned int xhci_get_endpoint_flag_from_index(unsigned int ep_index);
+unsigned int xhci_last_valid_endpoint(u32 added_ctxs);
 void xhci_endpoint_zero(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, struct usb_host_endpoint *ep);
+void xhci_endpoint_copy(struct xhci_hcd *xhci,
+               struct xhci_virt_device *vdev, unsigned int ep_index);
+void xhci_slot_copy(struct xhci_hcd *xhci, struct xhci_virt_device *vdev);
 int xhci_endpoint_init(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev,
                struct usb_device *udev, struct usb_host_endpoint *ep,
                gfp_t mem_flags);
@@ -1214,16 +1226,25 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb,
                int slot_id, unsigned int ep_index);
 int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb,
                int slot_id, unsigned int ep_index);
+int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb,
+               int slot_id, unsigned int ep_index);
 int xhci_queue_configure_endpoint(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
                u32 slot_id);
+int xhci_queue_evaluate_context(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
+               u32 slot_id);
 int xhci_queue_reset_ep(struct xhci_hcd *xhci, int slot_id,
                unsigned int ep_index);
 void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
                unsigned int slot_id, unsigned int ep_index,
                struct xhci_td *cur_td, struct xhci_dequeue_state *state);
 void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci,
-               struct xhci_ring *ep_ring, unsigned int slot_id,
-               unsigned int ep_index, struct xhci_dequeue_state *deq_state);
+               unsigned int slot_id, unsigned int ep_index,
+               struct xhci_dequeue_state *deq_state);
+void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci,
+               struct usb_device *udev, unsigned int ep_index);
+void xhci_queue_config_ep_quirk(struct xhci_hcd *xhci,
+               unsigned int slot_id, unsigned int ep_index,
+               struct xhci_dequeue_state *deq_state);
 
 /* xHCI roothub code */
 int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex,