xhci: Add defines for hardcoded slot states
[linux-flexiantxendom0-natty.git] / drivers / usb / host / xhci-dbg.c
index 705e343..99ac7de 100644 (file)
@@ -169,9 +169,10 @@ static void xhci_print_ports(struct xhci_hcd *xhci)
        }
 }
 
-void xhci_print_ir_set(struct xhci_hcd *xhci, struct xhci_intr_reg *ir_set, int set_num)
+void xhci_print_ir_set(struct xhci_hcd *xhci, int set_num)
 {
-       void *addr;
+       struct xhci_intr_reg __iomem *ir_set = &xhci->run_regs->ir_set[set_num];
+       void __iomem *addr;
        u32 temp;
        u64 temp_64;
 
@@ -364,6 +365,30 @@ void xhci_debug_ring(struct xhci_hcd *xhci, struct xhci_ring *ring)
                xhci_debug_segment(xhci, seg);
 }
 
+void xhci_dbg_ep_rings(struct xhci_hcd *xhci,
+               unsigned int slot_id, unsigned int ep_index,
+               struct xhci_virt_ep *ep)
+{
+       int i;
+       struct xhci_ring *ring;
+
+       if (ep->ep_state & EP_HAS_STREAMS) {
+               for (i = 1; i < ep->stream_info->num_streams; i++) {
+                       ring = ep->stream_info->stream_rings[i];
+                       xhci_dbg(xhci, "Dev %d endpoint %d stream ID %d:\n",
+                               slot_id, ep_index, i);
+                       xhci_debug_segment(xhci, ring->deq_seg);
+               }
+       } else {
+               ring = ep->ring;
+               if (!ring)
+                       return;
+               xhci_dbg(xhci, "Dev %d endpoint ring %d:\n",
+                               slot_id, ep_index);
+               xhci_debug_segment(xhci, ring->deq_seg);
+       }
+}
+
 void xhci_dbg_erst(struct xhci_hcd *xhci, struct xhci_erst *erst)
 {
        u32 addr = (u32) erst->erst_dma_addr;
@@ -406,14 +431,34 @@ static void dbg_rsvd64(struct xhci_hcd *xhci, u64 *ctx, dma_addr_t dma)
        }
 }
 
-void xhci_dbg_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx)
+char *xhci_get_slot_state(struct xhci_hcd *xhci,
+               struct xhci_container_ctx *ctx)
+{
+       struct xhci_slot_ctx *slot_ctx = xhci_get_slot_ctx(xhci, ctx);
+
+       switch (GET_SLOT_STATE(le32_to_cpu(slot_ctx->dev_state))) {
+       case SLOT_STATE_ENABLED:
+               return "enabled/disabled";
+       case SLOT_STATE_DEFAULT:
+               return "default";
+       case SLOT_STATE_ADDRESSED:
+               return "addressed";
+       case SLOT_STATE_CONFIGURED:
+               return "configured";
+       default:
+               return "reserved";
+       }
+}
+
+static void xhci_dbg_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx)
 {
        /* Fields are 32 bits wide, DMA addresses are in bytes */
        int field_size = 32 / 8;
        int i;
 
        struct xhci_slot_ctx *slot_ctx = xhci_get_slot_ctx(xhci, ctx);
-       dma_addr_t dma = ctx->dma + ((unsigned long)slot_ctx - (unsigned long)ctx);
+       dma_addr_t dma = ctx->dma +
+               ((unsigned long)slot_ctx - (unsigned long)ctx->bytes);
        int csz = HCC_64BYTE_CONTEXT(xhci->hcc_params);
 
        xhci_dbg(xhci, "Slot Context:\n");
@@ -444,7 +489,7 @@ void xhci_dbg_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx)
                dbg_rsvd64(xhci, (u64 *)slot_ctx, dma);
 }
 
-void xhci_dbg_ep_ctx(struct xhci_hcd *xhci,
+static void xhci_dbg_ep_ctx(struct xhci_hcd *xhci,
                     struct xhci_container_ctx *ctx,
                     unsigned int last_ep)
 {
@@ -459,7 +504,7 @@ void xhci_dbg_ep_ctx(struct xhci_hcd *xhci,
        for (i = 0; i < last_ep_ctx; ++i) {
                struct xhci_ep_ctx *ep_ctx = xhci_get_ep_ctx(xhci, ctx, i);
                dma_addr_t dma = ctx->dma +
-                       ((unsigned long)ep_ctx - (unsigned long)ctx);
+                       ((unsigned long)ep_ctx - (unsigned long)ctx->bytes);
 
                xhci_dbg(xhci, "Endpoint %02d Context:\n", i);
                xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - ep_info\n",