25 #define XHCI_INIT_VALUE 0x0
33 xhci_dbg(xhci,
"// xHCI capability registers at %p:\n",
35 temp = xhci_readl(xhci, &xhci->
cap_regs->hc_capbase);
36 xhci_dbg(xhci,
"// @%p = 0x%x (CAPLENGTH AND HCIVERSION)\n",
38 xhci_dbg(xhci,
"// CAPLENGTH: 0x%x\n",
41 xhci_dbg(xhci,
"// HCIVERSION: 0x%x\n",
45 xhci_dbg(xhci,
"// xHCI operational registers at %p:\n", xhci->
op_regs);
47 temp = xhci_readl(xhci, &xhci->
cap_regs->run_regs_off);
48 xhci_dbg(xhci,
"// @%p = 0x%x RTSOFF\n",
53 temp = xhci_readl(xhci, &xhci->
cap_regs->db_off);
55 xhci_dbg(xhci,
"// Doorbell array at %p:\n", xhci->
dba);
58 static void xhci_print_cap_regs(
struct xhci_hcd *xhci)
64 temp = xhci_readl(xhci, &xhci->
cap_regs->hc_capbase);
65 xhci_dbg(xhci,
"CAPLENGTH AND HCIVERSION 0x%x:\n",
72 temp = xhci_readl(xhci, &xhci->
cap_regs->hcs_params1);
73 xhci_dbg(xhci,
"HCSPARAMS 1: 0x%x\n",
75 xhci_dbg(xhci,
" Max device slots: %u\n",
77 xhci_dbg(xhci,
" Max interrupters: %u\n",
82 temp = xhci_readl(xhci, &xhci->
cap_regs->hcs_params2);
83 xhci_dbg(xhci,
"HCSPARAMS 2: 0x%x\n",
85 xhci_dbg(xhci,
" Isoc scheduling threshold: %u\n",
87 xhci_dbg(xhci,
" Maximum allowed segments in event ring: %u\n",
90 temp = xhci_readl(xhci, &xhci->
cap_regs->hcs_params3);
91 xhci_dbg(xhci,
"HCSPARAMS 3 0x%x:\n",
93 xhci_dbg(xhci,
" Worst case U1 device exit latency: %u\n",
95 xhci_dbg(xhci,
" Worst case U2 device exit latency: %u\n",
98 temp = xhci_readl(xhci, &xhci->
cap_regs->hcc_params);
99 xhci_dbg(xhci,
"HCC PARAMS 0x%x:\n", (
unsigned int) temp);
100 xhci_dbg(xhci,
" HC generates %s bit addresses\n",
103 xhci_dbg(xhci,
" FIXME: more HCCPARAMS debugging\n");
105 temp = xhci_readl(xhci, &xhci->
cap_regs->run_regs_off);
109 static void xhci_print_command_reg(
struct xhci_hcd *xhci)
113 temp = xhci_readl(xhci, &xhci->
op_regs->command);
114 xhci_dbg(xhci,
"USBCMD 0x%x:\n", temp);
116 (temp &
CMD_RUN) ?
"running" :
"being stopped");
117 xhci_dbg(xhci,
" HC has %sfinished hard reset\n",
119 xhci_dbg(xhci,
" Event Interrupts %s\n",
120 (temp &
CMD_EIE) ?
"enabled " :
"disabled");
121 xhci_dbg(xhci,
" Host System Error Interrupts %s\n",
122 (temp &
CMD_HSEIE) ?
"enabled " :
"disabled");
123 xhci_dbg(xhci,
" HC has %sfinished light reset\n",
127 static void xhci_print_status(
struct xhci_hcd *xhci)
131 temp = xhci_readl(xhci, &xhci->
op_regs->status);
132 xhci_dbg(xhci,
"USBSTS 0x%x:\n", temp);
133 xhci_dbg(xhci,
" Event ring is %sempty\n",
135 xhci_dbg(xhci,
" %sHost System Error\n",
136 (temp &
STS_FATAL) ?
"WARNING: " :
"No ");
138 (temp &
STS_HALT) ?
"halted" :
"running");
141 static void xhci_print_op_regs(
struct xhci_hcd *xhci)
144 xhci_print_command_reg(xhci);
145 xhci_print_status(xhci);
148 static void xhci_print_ports(
struct xhci_hcd *xhci)
161 addr = &xhci->
op_regs->port_status_base;
162 for (i = 0; i < ports; i++) {
164 xhci_dbg(xhci,
"%p port %s reg = 0x%x\n",
166 (
unsigned int) xhci_readl(xhci, addr));
180 temp = xhci_readl(xhci, addr);
184 xhci_dbg(xhci,
" %p: ir_set[%i]\n", ir_set, set_num);
186 xhci_dbg(xhci,
" %p: ir_set.pending = 0x%x\n", addr,
190 temp = xhci_readl(xhci, addr);
191 xhci_dbg(xhci,
" %p: ir_set.control = 0x%x\n", addr,
195 temp = xhci_readl(xhci, addr);
196 xhci_dbg(xhci,
" %p: ir_set.erst_size = 0x%x\n", addr,
199 addr = &ir_set->
rsvd;
200 temp = xhci_readl(xhci, addr);
202 xhci_dbg(xhci,
" WARN: %p: ir_set.rsvd = 0x%x\n",
203 addr, (
unsigned int)temp);
206 temp_64 = xhci_read_64(xhci, addr);
207 xhci_dbg(xhci,
" %p: ir_set.erst_base = @%08llx\n",
211 temp_64 = xhci_read_64(xhci, addr);
212 xhci_dbg(xhci,
" %p: ir_set.erst_dequeue = @%08llx\n",
222 temp = xhci_readl(xhci, &xhci->
run_regs->microframe_index);
223 xhci_dbg(xhci,
" %p: Microframe index = 0x%x\n",
225 (
unsigned int) temp);
226 for (i = 0; i < 7; ++
i) {
227 temp = xhci_readl(xhci, &xhci->
run_regs->rsvd[i]);
229 xhci_dbg(xhci,
" WARN: %p: Rsvd[%i] = 0x%x\n",
231 i, (
unsigned int) temp);
237 xhci_print_cap_regs(xhci);
238 xhci_print_op_regs(xhci);
239 xhci_print_ports(xhci);
245 for (i = 0; i < 4; ++
i)
246 xhci_dbg(xhci,
"Offset 0x%x = 0x%x\n",
264 xhci_dbg(xhci,
"Next ring segment DMA address = 0x%llx\n", address);
266 xhci_dbg(xhci,
"Interrupter target = 0x%x\n",
270 xhci_dbg(xhci,
"Toggle cycle bit = %u\n",
272 xhci_dbg(xhci,
"No Snoop bit = %u\n",
281 xhci_dbg(xhci,
"DMA address or buffer contents= %llu\n", address);
285 xhci_dbg(xhci,
"Command TRB pointer = %llu\n", address);
286 xhci_dbg(xhci,
"Completion status = %u\n",
292 xhci_dbg(xhci,
"Unknown TRB with TRB type ID %u\n",
293 (
unsigned int) type>>10);
320 xhci_dbg(xhci,
"@%016llx %08x %08x %08x %08x\n", addr,
325 addr +=
sizeof(*trb);
331 xhci_dbg(xhci,
"Ring deq = %p (virt), 0x%llx (dma)\n",
335 xhci_dbg(xhci,
"Ring deq updated %u times\n",
337 xhci_dbg(xhci,
"Ring enq = %p (virt), 0x%llx (dma)\n",
341 xhci_dbg(xhci,
"Ring enq updated %u times\n",
362 xhci_dbg(xhci,
" Ring has not been updated\n");
365 for (seg = first_seg->
next; seg != first_seg; seg = seg->
next)
370 unsigned int slot_id,
unsigned int ep_index,
377 for (i = 1; i < ep->
stream_info->num_streams; i++) {
379 xhci_dbg(xhci,
"Dev %d endpoint %d stream ID %d:\n",
380 slot_id, ep_index, i);
387 xhci_dbg(xhci,
"Dev %d endpoint ring %d:\n",
401 xhci_dbg(xhci,
"@%016llx %08x %08x %08x %08x\n",
407 addr +=
sizeof(*entry);
415 val = xhci_read_64(xhci, &xhci->
op_regs->cmd_ring);
416 xhci_dbg(xhci,
"// xHC command ring deq ptr low bits + flags = @%08x\n",
418 xhci_dbg(xhci,
"// xHC command ring deq ptr high bits = @%08x\n",
426 for (i = 0; i < 4; ++
i) {
427 xhci_dbg(xhci,
"@%p (virt) @%08llx "
428 "(dma) %#08llx - rsvd64[%d]\n",
429 &ctx[4 + i], (
unsigned long long)dma,
442 return "enabled/disabled";
457 int field_size = 32 / 8;
462 ((
unsigned long)slot_ctx - (
unsigned long)ctx->
bytes);
466 xhci_dbg(xhci,
"@%p (virt) @%08llx (dma) %#08x - dev_info\n",
468 (
unsigned long long)dma, slot_ctx->
dev_info);
470 xhci_dbg(xhci,
"@%p (virt) @%08llx (dma) %#08x - dev_info2\n",
472 (
unsigned long long)dma, slot_ctx->
dev_info2);
474 xhci_dbg(xhci,
"@%p (virt) @%08llx (dma) %#08x - tt_info\n",
476 (
unsigned long long)dma, slot_ctx->
tt_info);
478 xhci_dbg(xhci,
"@%p (virt) @%08llx (dma) %#08x - dev_state\n",
480 (
unsigned long long)dma, slot_ctx->
dev_state);
482 for (i = 0; i < 4; ++
i) {
483 xhci_dbg(xhci,
"@%p (virt) @%08llx (dma) %#08x - rsvd[%d]\n",
484 &slot_ctx->
reserved[i], (
unsigned long long)dma,
490 dbg_rsvd64(xhci, (
u64 *)slot_ctx, dma);
493 static void xhci_dbg_ep_ctx(
struct xhci_hcd *xhci,
495 unsigned int last_ep)
498 int last_ep_ctx = 31;
500 int field_size = 32 / 8;
504 last_ep_ctx = last_ep + 1;
505 for (i = 0; i < last_ep_ctx; ++
i) {
508 ((
unsigned long)ep_ctx - (
unsigned long)ctx->
bytes);
510 xhci_dbg(xhci,
"Endpoint %02d Context:\n", i);
511 xhci_dbg(xhci,
"@%p (virt) @%08llx (dma) %#08x - ep_info\n",
513 (
unsigned long long)dma, ep_ctx->
ep_info);
515 xhci_dbg(xhci,
"@%p (virt) @%08llx (dma) %#08x - ep_info2\n",
517 (
unsigned long long)dma, ep_ctx->
ep_info2);
519 xhci_dbg(xhci,
"@%p (virt) @%08llx (dma) %#08llx - deq\n",
521 (
unsigned long long)dma, ep_ctx->
deq);
523 xhci_dbg(xhci,
"@%p (virt) @%08llx (dma) %#08x - tx_info\n",
525 (
unsigned long long)dma, ep_ctx->
tx_info);
527 for (j = 0; j < 3; ++
j) {
528 xhci_dbg(xhci,
"@%p (virt) @%08llx (dma) %#08x - rsvd[%d]\n",
530 (
unsigned long long)dma,
536 dbg_rsvd64(xhci, (
u64 *)ep_ctx, dma);
542 unsigned int last_ep)
546 int field_size = 32 / 8;
553 xhci_dbg(xhci,
"@%p (virt) @%08llx (dma) %#08x - drop flags\n",
554 &ctrl_ctx->
drop_flags, (
unsigned long long)dma,
557 xhci_dbg(xhci,
"@%p (virt) @%08llx (dma) %#08x - add flags\n",
558 &ctrl_ctx->
add_flags, (
unsigned long long)dma,
561 for (i = 0; i < 6; ++
i) {
562 xhci_dbg(xhci,
"@%p (virt) @%08llx (dma) %#08x - rsvd2[%d]\n",
563 &ctrl_ctx->
rsvd2[i], (
unsigned long long)dma,
564 ctrl_ctx->
rsvd2[i], i);
569 dbg_rsvd64(xhci, (
u64 *)ctrl_ctx, dma);
572 xhci_dbg_slot_ctx(xhci, ctx);
573 xhci_dbg_ep_ctx(xhci, ctx, last_ep);