Greg Kroah-Hartman | 5fd54ac | 2017-11-03 11:28:30 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 2 | /* |
| 3 | * xHCI host controller driver |
| 4 | * |
| 5 | * Copyright (C) 2008 Intel Corp. |
| 6 | * |
| 7 | * Author: Sarah Sharp |
| 8 | * Some code borrowed from the Linux EHCI driver. |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include "xhci.h" |
| 12 | |
| 13 | #define XHCI_INIT_VALUE 0x0 |
| 14 | |
| 15 | /* Add verbose debugging later, just print everything for now */ |
| 16 | |
| 17 | void xhci_dbg_regs(struct xhci_hcd *xhci) |
| 18 | { |
| 19 | u32 temp; |
| 20 | |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 21 | xhci_dbg(xhci, "// xHCI capability registers at %p:\n", |
| 22 | xhci->cap_regs); |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 23 | temp = readl(&xhci->cap_regs->hc_capbase); |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 24 | xhci_dbg(xhci, "// @%p = 0x%x (CAPLENGTH AND HCIVERSION)\n", |
| 25 | &xhci->cap_regs->hc_capbase, temp); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 26 | xhci_dbg(xhci, "// CAPLENGTH: 0x%x\n", |
| 27 | (unsigned int) HC_LENGTH(temp)); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 28 | xhci_dbg(xhci, "// HCIVERSION: 0x%x\n", |
| 29 | (unsigned int) HC_VERSION(temp)); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 30 | |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 31 | xhci_dbg(xhci, "// xHCI operational registers at %p:\n", xhci->op_regs); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 32 | |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 33 | temp = readl(&xhci->cap_regs->run_regs_off); |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 34 | xhci_dbg(xhci, "// @%p = 0x%x RTSOFF\n", |
| 35 | &xhci->cap_regs->run_regs_off, |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 36 | (unsigned int) temp & RTSOFF_MASK); |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 37 | xhci_dbg(xhci, "// xHCI runtime registers at %p:\n", xhci->run_regs); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 38 | |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 39 | temp = readl(&xhci->cap_regs->db_off); |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 40 | xhci_dbg(xhci, "// @%p = 0x%x DBOFF\n", &xhci->cap_regs->db_off, temp); |
| 41 | xhci_dbg(xhci, "// Doorbell array at %p:\n", xhci->dba); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 42 | } |
| 43 | |
Sarah Sharp | 23e3be1 | 2009-04-29 19:05:20 -0700 | [diff] [blame] | 44 | static void xhci_print_cap_regs(struct xhci_hcd *xhci) |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 45 | { |
| 46 | u32 temp; |
Lu Baolu | 04abb6d | 2015-10-01 18:40:31 +0300 | [diff] [blame] | 47 | u32 hci_version; |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 48 | |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 49 | xhci_dbg(xhci, "xHCI capability registers at %p:\n", xhci->cap_regs); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 50 | |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 51 | temp = readl(&xhci->cap_regs->hc_capbase); |
Lu Baolu | 04abb6d | 2015-10-01 18:40:31 +0300 | [diff] [blame] | 52 | hci_version = HC_VERSION(temp); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 53 | xhci_dbg(xhci, "CAPLENGTH AND HCIVERSION 0x%x:\n", |
| 54 | (unsigned int) temp); |
| 55 | xhci_dbg(xhci, "CAPLENGTH: 0x%x\n", |
| 56 | (unsigned int) HC_LENGTH(temp)); |
Lu Baolu | 04abb6d | 2015-10-01 18:40:31 +0300 | [diff] [blame] | 57 | xhci_dbg(xhci, "HCIVERSION: 0x%x\n", hci_version); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 58 | |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 59 | temp = readl(&xhci->cap_regs->hcs_params1); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 60 | xhci_dbg(xhci, "HCSPARAMS 1: 0x%x\n", |
| 61 | (unsigned int) temp); |
| 62 | xhci_dbg(xhci, " Max device slots: %u\n", |
| 63 | (unsigned int) HCS_MAX_SLOTS(temp)); |
| 64 | xhci_dbg(xhci, " Max interrupters: %u\n", |
| 65 | (unsigned int) HCS_MAX_INTRS(temp)); |
| 66 | xhci_dbg(xhci, " Max ports: %u\n", |
| 67 | (unsigned int) HCS_MAX_PORTS(temp)); |
| 68 | |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 69 | temp = readl(&xhci->cap_regs->hcs_params2); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 70 | xhci_dbg(xhci, "HCSPARAMS 2: 0x%x\n", |
| 71 | (unsigned int) temp); |
| 72 | xhci_dbg(xhci, " Isoc scheduling threshold: %u\n", |
| 73 | (unsigned int) HCS_IST(temp)); |
| 74 | xhci_dbg(xhci, " Maximum allowed segments in event ring: %u\n", |
| 75 | (unsigned int) HCS_ERST_MAX(temp)); |
| 76 | |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 77 | temp = readl(&xhci->cap_regs->hcs_params3); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 78 | xhci_dbg(xhci, "HCSPARAMS 3 0x%x:\n", |
| 79 | (unsigned int) temp); |
| 80 | xhci_dbg(xhci, " Worst case U1 device exit latency: %u\n", |
| 81 | (unsigned int) HCS_U1_LATENCY(temp)); |
| 82 | xhci_dbg(xhci, " Worst case U2 device exit latency: %u\n", |
| 83 | (unsigned int) HCS_U2_LATENCY(temp)); |
| 84 | |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 85 | temp = readl(&xhci->cap_regs->hcc_params); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 86 | xhci_dbg(xhci, "HCC PARAMS 0x%x:\n", (unsigned int) temp); |
| 87 | xhci_dbg(xhci, " HC generates %s bit addresses\n", |
| 88 | HCC_64BIT_ADDR(temp) ? "64" : "32"); |
Lu Baolu | 79b8094 | 2015-08-06 19:24:00 +0300 | [diff] [blame] | 89 | xhci_dbg(xhci, " HC %s Contiguous Frame ID Capability\n", |
| 90 | HCC_CFC(temp) ? "has" : "hasn't"); |
Lu Baolu | 40a3b77 | 2015-08-06 19:24:01 +0300 | [diff] [blame] | 91 | xhci_dbg(xhci, " HC %s generate Stopped - Short Package event\n", |
| 92 | HCC_SPC(temp) ? "can" : "can't"); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 93 | /* FIXME */ |
| 94 | xhci_dbg(xhci, " FIXME: more HCCPARAMS debugging\n"); |
| 95 | |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 96 | temp = readl(&xhci->cap_regs->run_regs_off); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 97 | xhci_dbg(xhci, "RTSOFF 0x%x:\n", temp & RTSOFF_MASK); |
Lu Baolu | 04abb6d | 2015-10-01 18:40:31 +0300 | [diff] [blame] | 98 | |
| 99 | /* xhci 1.1 controllers have the HCCPARAMS2 register */ |
Peter Chen | f95e60a | 2017-03-09 15:39:36 +0200 | [diff] [blame] | 100 | if (hci_version > 0x100) { |
Lu Baolu | 04abb6d | 2015-10-01 18:40:31 +0300 | [diff] [blame] | 101 | temp = readl(&xhci->cap_regs->hcc_params2); |
| 102 | xhci_dbg(xhci, "HCC PARAMS2 0x%x:\n", (unsigned int) temp); |
| 103 | xhci_dbg(xhci, " HC %s Force save context capability", |
| 104 | HCC2_FSC(temp) ? "supports" : "doesn't support"); |
| 105 | xhci_dbg(xhci, " HC %s Large ESIT Payload Capability", |
| 106 | HCC2_LEC(temp) ? "supports" : "doesn't support"); |
| 107 | xhci_dbg(xhci, " HC %s Extended TBC capability", |
| 108 | HCC2_ETC(temp) ? "supports" : "doesn't support"); |
| 109 | } |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Sarah Sharp | 23e3be1 | 2009-04-29 19:05:20 -0700 | [diff] [blame] | 112 | static void xhci_print_command_reg(struct xhci_hcd *xhci) |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 113 | { |
| 114 | u32 temp; |
| 115 | |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 116 | temp = readl(&xhci->op_regs->command); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 117 | xhci_dbg(xhci, "USBCMD 0x%x:\n", temp); |
| 118 | xhci_dbg(xhci, " HC is %s\n", |
| 119 | (temp & CMD_RUN) ? "running" : "being stopped"); |
| 120 | xhci_dbg(xhci, " HC has %sfinished hard reset\n", |
| 121 | (temp & CMD_RESET) ? "not " : ""); |
| 122 | xhci_dbg(xhci, " Event Interrupts %s\n", |
| 123 | (temp & CMD_EIE) ? "enabled " : "disabled"); |
| 124 | xhci_dbg(xhci, " Host System Error Interrupts %s\n", |
Alex He | bb334e9 | 2012-03-22 15:06:59 +0800 | [diff] [blame] | 125 | (temp & CMD_HSEIE) ? "enabled " : "disabled"); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 126 | xhci_dbg(xhci, " HC has %sfinished light reset\n", |
| 127 | (temp & CMD_LRESET) ? "not " : ""); |
| 128 | } |
| 129 | |
Sarah Sharp | 23e3be1 | 2009-04-29 19:05:20 -0700 | [diff] [blame] | 130 | static void xhci_print_status(struct xhci_hcd *xhci) |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 131 | { |
| 132 | u32 temp; |
| 133 | |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 134 | temp = readl(&xhci->op_regs->status); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 135 | xhci_dbg(xhci, "USBSTS 0x%x:\n", temp); |
| 136 | xhci_dbg(xhci, " Event ring is %sempty\n", |
| 137 | (temp & STS_EINT) ? "not " : ""); |
| 138 | xhci_dbg(xhci, " %sHost System Error\n", |
| 139 | (temp & STS_FATAL) ? "WARNING: " : "No "); |
| 140 | xhci_dbg(xhci, " HC is %s\n", |
| 141 | (temp & STS_HALT) ? "halted" : "running"); |
| 142 | } |
| 143 | |
Sarah Sharp | 23e3be1 | 2009-04-29 19:05:20 -0700 | [diff] [blame] | 144 | static void xhci_print_op_regs(struct xhci_hcd *xhci) |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 145 | { |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 146 | xhci_dbg(xhci, "xHCI operational registers at %p:\n", xhci->op_regs); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 147 | xhci_print_command_reg(xhci); |
| 148 | xhci_print_status(xhci); |
| 149 | } |
| 150 | |
Sarah Sharp | 23e3be1 | 2009-04-29 19:05:20 -0700 | [diff] [blame] | 151 | static void xhci_print_ports(struct xhci_hcd *xhci) |
Sarah Sharp | 0f2a793 | 2009-04-27 19:57:12 -0700 | [diff] [blame] | 152 | { |
Matt Evans | 28ccd29 | 2011-03-29 13:40:46 +1100 | [diff] [blame] | 153 | __le32 __iomem *addr; |
Sarah Sharp | 0f2a793 | 2009-04-27 19:57:12 -0700 | [diff] [blame] | 154 | int i, j; |
| 155 | int ports; |
| 156 | char *names[NUM_PORT_REGS] = { |
| 157 | "status", |
| 158 | "power", |
| 159 | "link", |
| 160 | "reserved", |
| 161 | }; |
| 162 | |
| 163 | ports = HCS_MAX_PORTS(xhci->hcs_params1); |
| 164 | addr = &xhci->op_regs->port_status_base; |
| 165 | for (i = 0; i < ports; i++) { |
Felipe Balbi | 98871e9 | 2017-01-23 14:20:04 +0200 | [diff] [blame] | 166 | for (j = 0; j < NUM_PORT_REGS; j++) { |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 167 | xhci_dbg(xhci, "%p port %s reg = 0x%x\n", |
| 168 | addr, names[j], |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 169 | (unsigned int) readl(addr)); |
Sarah Sharp | 0f2a793 | 2009-04-27 19:57:12 -0700 | [diff] [blame] | 170 | addr++; |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
Dmitry Torokhov | 09ece30 | 2011-02-08 16:29:33 -0800 | [diff] [blame] | 175 | void xhci_print_ir_set(struct xhci_hcd *xhci, int set_num) |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 176 | { |
Dmitry Torokhov | 09ece30 | 2011-02-08 16:29:33 -0800 | [diff] [blame] | 177 | struct xhci_intr_reg __iomem *ir_set = &xhci->run_regs->ir_set[set_num]; |
| 178 | void __iomem *addr; |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 179 | u32 temp; |
Sarah Sharp | 8e595a5 | 2009-07-27 12:03:31 -0700 | [diff] [blame] | 180 | u64 temp_64; |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 181 | |
| 182 | addr = &ir_set->irq_pending; |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 183 | temp = readl(addr); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 184 | if (temp == XHCI_INIT_VALUE) |
| 185 | return; |
| 186 | |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 187 | xhci_dbg(xhci, " %p: ir_set[%i]\n", ir_set, set_num); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 188 | |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 189 | xhci_dbg(xhci, " %p: ir_set.pending = 0x%x\n", addr, |
| 190 | (unsigned int)temp); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 191 | |
| 192 | addr = &ir_set->irq_control; |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 193 | temp = readl(addr); |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 194 | xhci_dbg(xhci, " %p: ir_set.control = 0x%x\n", addr, |
| 195 | (unsigned int)temp); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 196 | |
| 197 | addr = &ir_set->erst_size; |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 198 | temp = readl(addr); |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 199 | xhci_dbg(xhci, " %p: ir_set.erst_size = 0x%x\n", addr, |
| 200 | (unsigned int)temp); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 201 | |
| 202 | addr = &ir_set->rsvd; |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 203 | temp = readl(addr); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 204 | if (temp != XHCI_INIT_VALUE) |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 205 | xhci_dbg(xhci, " WARN: %p: ir_set.rsvd = 0x%x\n", |
| 206 | addr, (unsigned int)temp); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 207 | |
Sarah Sharp | 8e595a5 | 2009-07-27 12:03:31 -0700 | [diff] [blame] | 208 | addr = &ir_set->erst_base; |
Sarah Sharp | f7b2e40 | 2014-01-30 13:27:49 -0800 | [diff] [blame] | 209 | temp_64 = xhci_read_64(xhci, addr); |
Sarah Sharp | 8e595a5 | 2009-07-27 12:03:31 -0700 | [diff] [blame] | 210 | xhci_dbg(xhci, " %p: ir_set.erst_base = @%08llx\n", |
| 211 | addr, temp_64); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 212 | |
Sarah Sharp | 8e595a5 | 2009-07-27 12:03:31 -0700 | [diff] [blame] | 213 | addr = &ir_set->erst_dequeue; |
Sarah Sharp | f7b2e40 | 2014-01-30 13:27:49 -0800 | [diff] [blame] | 214 | temp_64 = xhci_read_64(xhci, addr); |
Sarah Sharp | 8e595a5 | 2009-07-27 12:03:31 -0700 | [diff] [blame] | 215 | xhci_dbg(xhci, " %p: ir_set.erst_dequeue = @%08llx\n", |
| 216 | addr, temp_64); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | void xhci_print_run_regs(struct xhci_hcd *xhci) |
| 220 | { |
| 221 | u32 temp; |
| 222 | int i; |
| 223 | |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 224 | xhci_dbg(xhci, "xHCI runtime registers at %p:\n", xhci->run_regs); |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 225 | temp = readl(&xhci->run_regs->microframe_index); |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 226 | xhci_dbg(xhci, " %p: Microframe index = 0x%x\n", |
| 227 | &xhci->run_regs->microframe_index, |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 228 | (unsigned int) temp); |
Felipe Balbi | 98871e9 | 2017-01-23 14:20:04 +0200 | [diff] [blame] | 229 | for (i = 0; i < 7; i++) { |
Xenia Ragiadakou | b0ba972 | 2013-11-15 05:34:06 +0200 | [diff] [blame] | 230 | temp = readl(&xhci->run_regs->rsvd[i]); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 231 | if (temp != XHCI_INIT_VALUE) |
Greg Kroah-Hartman | 700e205 | 2009-04-29 19:14:08 -0700 | [diff] [blame] | 232 | xhci_dbg(xhci, " WARN: %p: Rsvd[%i] = 0x%x\n", |
| 233 | &xhci->run_regs->rsvd[i], |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 234 | i, (unsigned int) temp); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | void xhci_print_registers(struct xhci_hcd *xhci) |
| 239 | { |
| 240 | xhci_print_cap_regs(xhci); |
| 241 | xhci_print_op_regs(xhci); |
Sarah Sharp | 0f2a793 | 2009-04-27 19:57:12 -0700 | [diff] [blame] | 242 | xhci_print_ports(xhci); |
Sarah Sharp | 74c6874 | 2009-04-27 19:52:22 -0700 | [diff] [blame] | 243 | } |
Sarah Sharp | 0ebbab3 | 2009-04-27 19:52:34 -0700 | [diff] [blame] | 244 | |
Sarah Sharp | 0ebbab3 | 2009-04-27 19:52:34 -0700 | [diff] [blame] | 245 | void xhci_dbg_erst(struct xhci_hcd *xhci, struct xhci_erst *erst) |
| 246 | { |
Matt Evans | 28ccd29 | 2011-03-29 13:40:46 +1100 | [diff] [blame] | 247 | u64 addr = erst->erst_dma_addr; |
Sarah Sharp | 0ebbab3 | 2009-04-27 19:52:34 -0700 | [diff] [blame] | 248 | int i; |
| 249 | struct xhci_erst_entry *entry; |
| 250 | |
Felipe Balbi | 98871e9 | 2017-01-23 14:20:04 +0200 | [diff] [blame] | 251 | for (i = 0; i < erst->num_entries; i++) { |
Sarah Sharp | 0ebbab3 | 2009-04-27 19:52:34 -0700 | [diff] [blame] | 252 | entry = &erst->entries[i]; |
Matt Evans | 28ccd29 | 2011-03-29 13:40:46 +1100 | [diff] [blame] | 253 | xhci_dbg(xhci, "@%016llx %08x %08x %08x %08x\n", |
| 254 | addr, |
| 255 | lower_32_bits(le64_to_cpu(entry->seg_addr)), |
| 256 | upper_32_bits(le64_to_cpu(entry->seg_addr)), |
Matt Evans | f5960b6 | 2011-06-01 10:22:55 +1000 | [diff] [blame] | 257 | le32_to_cpu(entry->seg_size), |
| 258 | le32_to_cpu(entry->rsvd)); |
Sarah Sharp | 0ebbab3 | 2009-04-27 19:52:34 -0700 | [diff] [blame] | 259 | addr += sizeof(*entry); |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci) |
| 264 | { |
Sarah Sharp | 8e595a5 | 2009-07-27 12:03:31 -0700 | [diff] [blame] | 265 | u64 val; |
Sarah Sharp | 0ebbab3 | 2009-04-27 19:52:34 -0700 | [diff] [blame] | 266 | |
Sarah Sharp | f7b2e40 | 2014-01-30 13:27:49 -0800 | [diff] [blame] | 267 | val = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); |
Sarah Sharp | 8e595a5 | 2009-07-27 12:03:31 -0700 | [diff] [blame] | 268 | xhci_dbg(xhci, "// xHC command ring deq ptr low bits + flags = @%08x\n", |
| 269 | lower_32_bits(val)); |
| 270 | xhci_dbg(xhci, "// xHC command ring deq ptr high bits = @%08x\n", |
| 271 | upper_32_bits(val)); |
Sarah Sharp | 0ebbab3 | 2009-04-27 19:52:34 -0700 | [diff] [blame] | 272 | } |
Sarah Sharp | 3ffbba9 | 2009-04-27 19:57:38 -0700 | [diff] [blame] | 273 | |
Sarah Sharp | 9c9a7dbf | 2010-01-04 12:20:17 -0800 | [diff] [blame] | 274 | char *xhci_get_slot_state(struct xhci_hcd *xhci, |
Sarah Sharp | 2a8f82c | 2009-12-09 15:59:13 -0800 | [diff] [blame] | 275 | struct xhci_container_ctx *ctx) |
| 276 | { |
| 277 | struct xhci_slot_ctx *slot_ctx = xhci_get_slot_ctx(xhci, ctx); |
Felipe Balbi | 5240772 | 2017-04-07 17:56:56 +0300 | [diff] [blame] | 278 | int state = GET_SLOT_STATE(le32_to_cpu(slot_ctx->dev_state)); |
Sarah Sharp | 2a8f82c | 2009-12-09 15:59:13 -0800 | [diff] [blame] | 279 | |
Felipe Balbi | 5240772 | 2017-04-07 17:56:56 +0300 | [diff] [blame] | 280 | return xhci_slot_state_string(state); |
Sarah Sharp | 2a8f82c | 2009-12-09 15:59:13 -0800 | [diff] [blame] | 281 | } |
| 282 | |
Xenia Ragiadakou | 84a99f6 | 2013-08-06 00:22:15 +0300 | [diff] [blame] | 283 | void xhci_dbg_trace(struct xhci_hcd *xhci, void (*trace)(struct va_format *), |
| 284 | const char *fmt, ...) |
| 285 | { |
| 286 | struct va_format vaf; |
| 287 | va_list args; |
| 288 | |
| 289 | va_start(args, fmt); |
| 290 | vaf.fmt = fmt; |
| 291 | vaf.va = &args; |
| 292 | xhci_dbg(xhci, "%pV\n", &vaf); |
| 293 | trace(&vaf); |
| 294 | va_end(args); |
| 295 | } |
Andrew Bresticker | 436e8c7 | 2014-10-03 11:35:28 +0300 | [diff] [blame] | 296 | EXPORT_SYMBOL_GPL(xhci_dbg_trace); |