24 #include <linux/pci.h>
25 #include <linux/slab.h>
44 seg = kzalloc(
sizeof *seg, flags);
56 if (cycle_state == 0) {
75 static void xhci_free_segments_for_ring(
struct xhci_hcd *xhci,
81 while (seg != first) {
83 xhci_segment_free(xhci, seg);
86 xhci_segment_free(xhci, first);
114 if (xhci_link_trb_quirk(xhci) ||
128 unsigned int num_segs)
132 if (!ring || !first || !last)
136 xhci_link_segments(xhci, ring->
enq_seg, first, ring->
type);
137 xhci_link_segments(xhci, last, next, ring->
type);
157 xhci_free_segments_for_ring(xhci, ring->
first_seg);
162 static void xhci_initialize_ring_info(
struct xhci_ring *ring,
163 unsigned int cycle_state)
190 static int xhci_alloc_segments_for_ring(
struct xhci_hcd *xhci,
192 unsigned int num_segs,
unsigned int cycle_state,
197 prev = xhci_segment_alloc(xhci, cycle_state, flags);
203 while (num_segs > 0) {
206 next = xhci_segment_alloc(xhci, cycle_state, flags);
208 xhci_free_segments_for_ring(xhci, *first);
211 xhci_link_segments(xhci, prev, next, type);
216 xhci_link_segments(xhci, prev, *first, type);
230 unsigned int num_segs,
unsigned int cycle_state,
236 ring = kzalloc(
sizeof *(ring), flags);
241 INIT_LIST_HEAD(&ring->
td_list);
246 ret = xhci_alloc_segments_for_ring(xhci, &ring->
first_seg,
247 &ring->
last_seg, num_segs, cycle_state, type, flags);
257 xhci_initialize_ring_info(ring, cycle_state);
277 "%d ring%s cached\n",
282 xhci_dbg(xhci,
"Ring cache full (%d rings), "
292 static void xhci_reinit_cached_ring(
struct xhci_hcd *xhci,
293 struct xhci_ring *ring,
unsigned int cycle_state,
302 if (cycle_state == 0) {
307 xhci_link_segments(xhci, seg, seg->
next, type);
311 xhci_initialize_ring_info(ring, cycle_state);
315 INIT_LIST_HEAD(&ring->
td_list);
324 unsigned int num_trbs,
gfp_t flags)
328 unsigned int num_segs;
329 unsigned int num_segs_needed;
336 num_segs = ring->
num_segs > num_segs_needed ?
339 ret = xhci_alloc_segments_for_ring(xhci, &first, &last,
344 xhci_link_rings(xhci, ring, first, last, num_segs);
345 xhci_dbg(xhci,
"ring expansion succeed, now has %d segments\n",
351 #define CTX_SIZE(_hcc) (HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32)
354 int type,
gfp_t flags)
371 static void xhci_free_container_ctx(
struct xhci_hcd *xhci,
413 static void xhci_free_stream_ctx(
struct xhci_hcd *xhci,
414 unsigned int num_stream_ctxs,
442 unsigned int num_stream_ctxs,
dma_addr_t *dma,
470 #ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
471 static struct xhci_ring *dma_to_stream_ring(
497 #ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
498 static int xhci_test_radix_tree(
struct xhci_hcd *xhci,
499 unsigned int num_streams,
506 for (cur_stream = 1; cur_stream < num_streams; cur_stream++) {
508 int trb_size =
sizeof(
union xhci_trb);
514 mapped_ring = dma_to_stream_ring(stream_info, addr);
515 if (cur_ring != mapped_ring) {
516 xhci_warn(xhci,
"WARN: DMA address 0x%08llx "
517 "didn't map to stream ID %u; "
518 "mapped to ring %p\n",
519 (
unsigned long long) addr,
529 mapped_ring = dma_to_stream_ring(stream_info, addr);
530 if (mapped_ring != cur_ring) {
532 addr = cur_ring->
first_seg->dma - trb_size;
533 mapped_ring = dma_to_stream_ring(stream_info, addr);
535 if (mapped_ring == cur_ring) {
536 xhci_warn(xhci,
"WARN: Bad DMA address 0x%08llx "
537 "mapped to valid stream ID %u; "
538 "mapped ring = %p\n",
539 (
unsigned long long) addr,
589 unsigned int num_stream_ctxs,
590 unsigned int num_streams,
gfp_t mem_flags)
599 xhci_dbg(xhci,
"Allocating %u streams and %u "
600 "stream context array entries.\n",
601 num_streams, num_stream_ctxs);
603 xhci_dbg(xhci,
"Command ring has no reserved TRBs available\n");
643 for (cur_stream = 1; cur_stream < num_streams; cur_stream++) {
645 xhci_ring_alloc(xhci, 2, 1,
TYPE_STREAM, mem_flags);
656 xhci_dbg(xhci,
"Setting stream %d ring ptr to 0x%08llx\n",
657 cur_stream, (
unsigned long long) addr);
659 key = (
unsigned long)
679 if (xhci_test_radix_tree(xhci, num_streams, stream_info))
686 for (cur_stream = 1; cur_stream < num_streams; cur_stream++) {
713 u32 max_primary_streams;
719 xhci_dbg(xhci,
"Setting number of stream ctx array entries to %u\n",
720 1 << (max_primary_streams + 1));
756 for (cur_stream = 1; cur_stream < stream_info->
num_streams;
770 xhci_free_stream_ctx(xhci,
783 static void xhci_init_endpoint_timer(
struct xhci_hcd *xhci,
792 static void xhci_free_tt_info(
struct xhci_hcd *xhci,
798 bool slot_found =
false;
812 if (tt_info->
slot_id == slot_id) {
816 }
else if (slot_found) {
824 struct usb_device *hdev,
825 struct usb_tt *
tt,
gfp_t mem_flags)
834 num_ports = hdev->maxchild;
836 for (i = 0; i < num_ports; i++, tt_info++) {
839 tt_info = kzalloc(
sizeof(*tt_info), mem_flags);
842 INIT_LIST_HEAD(&tt_info->
tt_list);
850 INIT_LIST_HEAD(&bw_table->
interval_bw[j].endpoints);
855 xhci_free_tt_info(xhci, virt_dev, virt_dev->
udev->slot_id);
869 int old_active_eps = 0;
872 if (slot_id == 0 || !xhci->
devs[slot_id])
875 dev = xhci->
devs[slot_id];
876 xhci->
dcbaa->dev_context_ptrs[slot_id] = 0;
881 old_active_eps = dev->
tt_info->active_eps;
883 for (i = 0; i < 31; ++
i) {
884 if (dev->
eps[i].ring)
886 if (dev->
eps[i].stream_info)
888 dev->
eps[i].stream_info);
894 if (!list_empty(&dev->
eps[i].bw_endpoint_list))
896 "not removed from BW list!\n",
900 xhci_free_tt_info(xhci, dev, slot_id);
911 xhci_free_container_ctx(xhci, dev->
in_ctx);
913 xhci_free_container_ctx(xhci, dev->
out_ctx);
926 if (slot_id == 0 || xhci->
devs[slot_id]) {
927 xhci_warn(xhci,
"Bad Slot ID %d\n", slot_id);
931 xhci->
devs[slot_id] = kzalloc(
sizeof(*xhci->
devs[slot_id]), flags);
932 if (!xhci->
devs[slot_id])
934 dev = xhci->
devs[slot_id];
941 xhci_dbg(xhci,
"Slot %d output ctx = 0x%llx (dma)\n", slot_id,
942 (
unsigned long long)dev->
out_ctx->dma);
949 xhci_dbg(xhci,
"Slot %d input ctx = 0x%llx (dma)\n", slot_id,
950 (
unsigned long long)dev->
in_ctx->dma);
953 for (i = 0; i < 31; i++) {
954 xhci_init_endpoint_timer(xhci, &dev->
eps[i]);
955 INIT_LIST_HEAD(&dev->
eps[i].cancelled_td_list);
956 INIT_LIST_HEAD(&dev->
eps[i].bw_endpoint_list);
960 dev->
eps[0].ring = xhci_ring_alloc(xhci, 2, 1,
TYPE_CTRL, flags);
961 if (!dev->
eps[0].ring)
978 xhci_dbg(xhci,
"Set slot id %d dcbaa entry %p to 0x%llx\n",
980 &xhci->
dcbaa->dev_context_ptrs[slot_id],
990 struct usb_device *
udev)
996 virt_dev = xhci->
devs[udev->slot_id];
998 ep_ring = virt_dev->
eps[0].ring;
1023 static u32 xhci_find_real_port_number(
struct xhci_hcd *xhci,
1024 struct usb_device *
udev)
1026 struct usb_device *top_dev;
1027 unsigned int num_similar_speed_ports;
1028 unsigned int faked_port_num;
1031 for (top_dev = udev; top_dev->parent && top_dev->parent->parent;
1032 top_dev = top_dev->parent)
1034 faked_port_num = top_dev->portnum;
1035 for (i = 0, num_similar_speed_ports = 0;
1052 num_similar_speed_ports++;
1053 if (num_similar_speed_ports == faked_port_num)
1067 struct usb_device *top_dev;
1069 dev = xhci->
devs[udev->slot_id];
1071 if (udev->slot_id == 0 || !dev) {
1072 xhci_warn(xhci,
"Slot ID %d is not assigned to this device\n",
1081 switch (udev->speed) {
1095 xhci_dbg(xhci,
"FIXME xHCI doesn't support wireless speeds\n");
1103 port_num = xhci_find_real_port_number(xhci, udev);
1108 for (top_dev = udev; top_dev->parent && top_dev->parent->parent;
1109 top_dev = top_dev->parent)
1113 xhci_dbg(xhci,
"Set root hub portnum to %d\n", port_num);
1122 if (!udev->tt || !udev->tt->hub->parent) {
1128 rh_bw = &xhci->
rh_bw[port_num - 1];
1131 if (tt_bw->
slot_id != udev->tt->hub->slot_id)
1134 if (!dev->
udev->tt->multi ||
1143 xhci_warn(xhci,
"WARN: Didn't find a matching TT\n");
1147 if (udev->tt && udev->tt->hub->parent) {
1149 (udev->ttport << 8));
1150 if (udev->tt->multi)
1153 xhci_dbg(xhci,
"udev->tt = %p\n", udev->tt);
1154 xhci_dbg(xhci,
"udev->ttport = 0x%x\n", udev->ttport);
1162 switch (udev->speed) {
1175 xhci_dbg(xhci,
"FIXME xHCI doesn't support wireless speeds\n");
1186 dev->
eps[0].ring->cycle_state);
1198 static unsigned int xhci_parse_exponent_interval(
struct usb_device *udev,
1199 struct usb_host_endpoint *ep)
1203 interval =
clamp_val(ep->desc.bInterval, 1, 16) - 1;
1204 if (interval != ep->desc.bInterval - 1)
1206 "ep %#x - rounding interval to %d %sframes\n",
1207 ep->desc.bEndpointAddress,
1227 static unsigned int xhci_microframes_to_exponent(
struct usb_device *udev,
1228 struct usb_host_endpoint *ep,
unsigned int desc_interval,
1229 unsigned int min_exponent,
unsigned int max_exponent)
1233 interval = fls(desc_interval) - 1;
1234 interval =
clamp_val(interval, min_exponent, max_exponent);
1235 if ((1 << interval) != desc_interval)
1237 "ep %#x - rounding interval to %d microframes, ep desc says %d microframes\n",
1238 ep->desc.bEndpointAddress,
1245 static unsigned int xhci_parse_microframe_interval(
struct usb_device *udev,
1246 struct usb_host_endpoint *ep)
1248 return xhci_microframes_to_exponent(udev, ep,
1249 ep->desc.bInterval, 0, 15);
1253 static unsigned int xhci_parse_frame_interval(
struct usb_device *udev,
1254 struct usb_host_endpoint *ep)
1256 return xhci_microframes_to_exponent(udev, ep,
1257 ep->desc.bInterval * 8, 3, 10);
1268 static unsigned int xhci_get_endpoint_interval(
struct usb_device *udev,
1269 struct usb_host_endpoint *ep)
1271 unsigned int interval = 0;
1273 switch (udev->speed) {
1276 if (usb_endpoint_xfer_control(&ep->desc) ||
1277 usb_endpoint_xfer_bulk(&ep->desc)) {
1278 interval = xhci_parse_microframe_interval(udev, ep);
1284 if (usb_endpoint_xfer_int(&ep->desc) ||
1285 usb_endpoint_xfer_isoc(&ep->desc)) {
1286 interval = xhci_parse_exponent_interval(udev, ep);
1291 if (usb_endpoint_xfer_isoc(&ep->desc)) {
1292 interval = xhci_parse_exponent_interval(udev, ep);
1302 if (usb_endpoint_xfer_int(&ep->desc) ||
1303 usb_endpoint_xfer_isoc(&ep->desc)) {
1305 interval = xhci_parse_frame_interval(udev, ep);
1320 static u32 xhci_get_endpoint_mult(
struct usb_device *udev,
1321 struct usb_host_endpoint *ep)
1324 !usb_endpoint_xfer_isoc(&ep->desc))
1326 return ep->ss_ep_comp.bmAttributes;
1329 static u32 xhci_get_endpoint_type(
struct usb_device *udev,
1330 struct usb_host_endpoint *ep)
1335 in = usb_endpoint_dir_in(&ep->desc);
1336 if (usb_endpoint_xfer_control(&ep->desc)) {
1338 }
else if (usb_endpoint_xfer_bulk(&ep->desc)) {
1343 }
else if (usb_endpoint_xfer_isoc(&ep->desc)) {
1348 }
else if (usb_endpoint_xfer_int(&ep->desc)) {
1363 static u32 xhci_get_max_esit_payload(
struct xhci_hcd *xhci,
1364 struct usb_device *udev,
1365 struct usb_host_endpoint *ep)
1371 if (usb_endpoint_xfer_control(&ep->desc) ||
1372 usb_endpoint_xfer_bulk(&ep->desc))
1376 return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
1379 max_burst = (usb_endpoint_maxp(&ep->desc) & 0x1800) >> 11;
1381 return max_packet * (max_burst + 1);
1389 struct usb_device *udev,
1390 struct usb_host_endpoint *ep,
1397 unsigned int max_burst;
1399 u32 max_esit_payload;
1404 type = usb_endpoint_type(&ep->desc);
1407 xhci_ring_alloc(xhci, 2, 1, type, mem_flags);
1408 if (!virt_dev->
eps[ep_index].new_ring) {
1416 xhci_reinit_cached_ring(xhci, virt_dev->
eps[ep_index].new_ring,
1424 |
EP_MULT(xhci_get_endpoint_mult(udev, ep)));
1431 if (!usb_endpoint_xfer_isoc(&ep->desc))
1439 switch (udev->speed) {
1441 max_packet = usb_endpoint_maxp(&ep->desc);
1444 max_packet = ep->ss_ep_comp.bMaxBurst;
1451 if (usb_endpoint_xfer_isoc(&ep->desc) ||
1452 usb_endpoint_xfer_int(&ep->desc)) {
1453 max_burst = (usb_endpoint_maxp(&ep->desc)
1466 max_esit_payload = xhci_get_max_esit_payload(xhci, udev, ep);
1487 if (usb_endpoint_xfer_control(&ep->desc) && xhci->
hci_version == 0x100)
1499 struct usb_host_endpoint *ep)
1533 unsigned int ep_type;
1536 for (i = 1; i < 31; ++
i) {
1537 bw_info = &virt_dev->
eps[
i].bw_info;
1573 bw_info->
type = ep_type;
1597 in_ep_ctx->
deq = out_ep_ctx->
deq;
1623 static int scratchpad_alloc(
struct xhci_hcd *xhci,
gfp_t flags)
1626 struct device *
dev = xhci_to_hcd(xhci)->self.controller;
1629 xhci_dbg(xhci,
"Allocating %d scratchpad buffers\n", num_sp);
1639 num_sp *
sizeof(
u64),
1644 xhci->
scratchpad->sp_buffers = kzalloc(
sizeof(
void *) * num_sp, flags);
1655 for (i = 0; i < num_sp; i++) {
1670 for (i = i - 1; i >= 0; i--) {
1693 static void scratchpad_free(
struct xhci_hcd *xhci)
1704 for (i = 0; i < num_sp; i++) {
1719 bool allocate_in_ctx,
bool allocate_completion,
1724 command = kzalloc(
sizeof(*command), mem_flags);
1728 if (allocate_in_ctx) {
1738 if (allocate_completion) {
1740 kzalloc(
sizeof(
struct completion), mem_flags);
1742 xhci_free_container_ctx(xhci, command->
in_ctx);
1750 INIT_LIST_HEAD(&command->
cmd_list);
1765 xhci_free_container_ctx(xhci,
1775 struct xhci_cd *cur_cd, *next_cd;
1776 unsigned long flags;
1782 if (xhci->
erst.entries)
1784 xhci->
erst.entries, xhci->
erst.erst_dma_addr);
1790 xhci_dbg(xhci,
"Freed event ring\n");
1798 xhci_dbg(xhci,
"Freed command ring\n");
1811 xhci_dbg(xhci,
"Freed segment pool\n");
1816 xhci_dbg(xhci,
"Freed device context pool\n");
1821 xhci_dbg(xhci,
"Freed small stream array pool\n");
1826 xhci_dbg(xhci,
"Freed medium stream array pool\n");
1833 scratchpad_free(xhci);
1840 spin_unlock_irqrestore(&xhci->
lock, flags);
1843 for (i = 0; i < num_ports; i++) {
1847 while (!list_empty(ep))
1848 list_del_init(ep->
next);
1852 for (i = 0; i < num_ports; i++) {
1874 static int xhci_test_trb_in_td(
struct xhci_hcd *xhci,
1880 char *test_name,
int test_number)
1882 unsigned long long start_dma;
1883 unsigned long long end_dma;
1889 seg =
trb_in_td(input_seg, start_trb, end_trb, input_dma);
1890 if (seg != result_seg) {
1891 xhci_warn(xhci,
"WARN: %s TRB math test %d failed!\n",
1892 test_name, test_number);
1893 xhci_warn(xhci,
"Tested TRB math w/ seg %p and "
1894 "input DMA 0x%llx\n",
1896 (
unsigned long long) input_dma);
1897 xhci_warn(xhci,
"starting TRB %p (0x%llx DMA), "
1898 "ending TRB %p (0x%llx DMA)\n",
1899 start_trb, start_dma,
1901 xhci_warn(xhci,
"Expected seg %p, got seg %p\n",
1909 static int xhci_check_trb_in_td_math(
struct xhci_hcd *xhci,
gfp_t mem_flags)
1914 } simple_test_vector [] = {
1939 } complex_test_vector [] = {
1942 .start_trb = xhci->
event_ring->first_seg->trbs,
1944 .input_dma = xhci->
cmd_ring->first_seg->dma,
1949 .start_trb = xhci->
event_ring->first_seg->trbs,
1951 .input_dma = xhci->
cmd_ring->first_seg->dma,
1956 .start_trb = xhci->
cmd_ring->first_seg->trbs,
1958 .input_dma = xhci->
cmd_ring->first_seg->dma,
1963 .start_trb = &xhci->
event_ring->first_seg->trbs[0],
1964 .end_trb = &xhci->
event_ring->first_seg->trbs[3],
1965 .input_dma = xhci->
event_ring->first_seg->dma + 4*16,
1970 .start_trb = &xhci->
event_ring->first_seg->trbs[3],
1971 .end_trb = &xhci->
event_ring->first_seg->trbs[6],
1972 .input_dma = xhci->
event_ring->first_seg->dma + 2*16,
1978 .end_trb = &xhci->
event_ring->first_seg->trbs[1],
1979 .input_dma = xhci->
event_ring->first_seg->dma + 2*16,
1985 .end_trb = &xhci->
event_ring->first_seg->trbs[1],
1992 .end_trb = &xhci->
event_ring->first_seg->trbs[1],
1993 .input_dma = xhci->
cmd_ring->first_seg->dma + 2*16,
1998 unsigned int num_tests;
2002 for (i = 0; i < num_tests; i++) {
2003 ret = xhci_test_trb_in_td(xhci,
2007 simple_test_vector[i].input_dma,
2008 simple_test_vector[i].result_seg,
2015 for (i = 0; i < num_tests; i++) {
2016 ret = xhci_test_trb_in_td(xhci,
2017 complex_test_vector[i].input_seg,
2018 complex_test_vector[i].start_trb,
2019 complex_test_vector[i].end_trb,
2020 complex_test_vector[i].input_dma,
2021 complex_test_vector[i].result_seg,
2026 xhci_dbg(xhci,
"TRB math tests passed.\n");
2030 static void xhci_set_hc_event_deq(
struct xhci_hcd *xhci)
2038 xhci_warn(xhci,
"WARN something wrong with SW event ring "
2041 temp = xhci_read_64(xhci, &xhci->
ir_set->erst_dequeue);
2047 xhci_dbg(xhci,
"// Write event ring dequeue pointer, "
2048 "preserving EHB bit\n");
2050 &xhci->
ir_set->erst_dequeue);
2053 static void xhci_add_in_port(
struct xhci_hcd *xhci,
unsigned int num_ports,
2059 if (major_revision > 0x03) {
2060 xhci_warn(xhci,
"Ignoring unknown port speed, "
2061 "Ext Cap %p, revision = 0x%x\n",
2062 addr, major_revision);
2068 temp = xhci_readl(xhci, addr + 2);
2071 xhci_dbg(xhci,
"Ext Cap %p, port offset = %u, "
2072 "count = %u, revision = 0x%x\n",
2073 addr, port_offset, port_count, major_revision);
2075 if (port_offset == 0 || (port_offset + port_count - 1) > num_ports)
2080 if ((xhci->
hci_version == 0x96) && (major_revision != 0x03) &&
2082 xhci_dbg(xhci,
"xHCI 0.96: support USB2 software lpm\n");
2086 if ((xhci->
hci_version >= 0x100) && (major_revision != 0x03)) {
2087 xhci_dbg(xhci,
"xHCI 1.0: support USB2 software lpm\n");
2090 xhci_dbg(xhci,
"xHCI 1.0: support USB2 hardware lpm\n");
2096 for (i = port_offset; i < (port_offset +
port_count); i++) {
2099 xhci_warn(xhci,
"Duplicate port entry, Ext Cap %p,"
2100 " port %u\n", addr, i);
2101 xhci_warn(xhci,
"Port was marked as USB %u, "
2102 "duplicated as USB %u\n",
2119 if (major_revision == 0x03)
2134 static int xhci_setup_port_arrays(
struct xhci_hcd *xhci,
gfp_t flags)
2138 unsigned int num_ports;
2139 int i,
j, port_index;
2141 addr = &xhci->
cap_regs->hcc_params;
2144 xhci_err(xhci,
"No Extended Capability registers, "
2145 "unable to set up roothub.\n");
2154 xhci->
rh_bw = kzalloc(
sizeof(*xhci->
rh_bw)*num_ports, flags);
2157 for (i = 0; i < num_ports; i++) {
2160 INIT_LIST_HEAD(&xhci->
rh_bw[i].tts);
2161 bw_table = &xhci->
rh_bw[
i].bw_table;
2163 INIT_LIST_HEAD(&bw_table->
interval_bw[j].endpoints);
2175 cap_id = xhci_readl(xhci, addr);
2177 xhci_add_in_port(xhci, num_ports, addr,
2191 xhci_warn(xhci,
"No ports on the roothubs?\n");
2194 xhci_dbg(xhci,
"Found %u USB 2.0 ports and %u USB 3.0 ports.\n",
2201 xhci_dbg(xhci,
"Limiting USB 3.0 roothub ports to 15.\n");
2205 xhci_dbg(xhci,
"Limiting USB 2.0 roothub ports to %u.\n",
2221 for (i = 0; i < num_ports; i++) {
2228 &xhci->
op_regs->port_status_base +
2230 xhci_dbg(xhci,
"USB 2.0 port at index %u, "
2245 for (i = 0; i < num_ports; i++)
2248 &xhci->
op_regs->port_status_base +
2250 xhci_dbg(xhci,
"USB 3.0 port at index %u, "
2264 struct device *dev = xhci_to_hcd(xhci)->self.controller;
2265 unsigned int val, val2;
2271 page_size = xhci_readl(xhci, &xhci->
op_regs->page_size);
2272 xhci_dbg(xhci,
"Supported page size register = 0x%x\n", page_size);
2273 for (i = 0; i < 16; i++) {
2274 if ((0x1 & page_size) != 0)
2276 page_size = page_size >> 1;
2279 xhci_dbg(xhci,
"Supported page size of %iK\n", (1 << (i+12)) / 1024);
2281 xhci_warn(xhci,
"WARN: no supported page size\n");
2292 xhci_dbg(xhci,
"// xHC can handle at most %d device slots.\n",
2293 (
unsigned int) val);
2294 val2 = xhci_readl(xhci, &xhci->
op_regs->config_reg);
2296 xhci_dbg(xhci,
"// Setting Max device slots reg = 0x%x.\n",
2297 (
unsigned int) val);
2298 xhci_writel(xhci, val, &xhci->
op_regs->config_reg);
2310 xhci_dbg(xhci,
"// Device context base array address = 0x%llx (DMA), %p (virt)\n",
2311 (
unsigned long long)xhci->
dcbaa->dma, xhci->
dcbaa);
2312 xhci_write_64(xhci, dma, &xhci->
op_regs->dcbaa_ptr);
2351 xhci_dbg(xhci,
"First segment DMA is 0x%llx\n",
2352 (
unsigned long long)xhci->
cmd_ring->first_seg->dma);
2355 val_64 = xhci_read_64(xhci, &xhci->
op_regs->cmd_ring);
2359 xhci_dbg(xhci,
"// Setting command ring address to 0x%x\n", val);
2360 xhci_write_64(xhci, val_64, &xhci->
op_regs->cmd_ring);
2373 val = xhci_readl(xhci, &xhci->
cap_regs->db_off);
2375 xhci_dbg(xhci,
"// Doorbell array is located at offset 0x%x"
2376 " from cap regs base addr\n", val);
2387 xhci_dbg(xhci,
"// Allocating event ring\n");
2392 if (xhci_check_trb_in_td_math(xhci, flags) < 0)
2398 if (!xhci->
erst.entries)
2400 xhci_dbg(xhci,
"// Allocated event ring segment table at 0x%llx\n",
2401 (
unsigned long long)dma);
2405 xhci->
erst.erst_dma_addr =
dma;
2406 xhci_dbg(xhci,
"Set ERST to 0; private num segs = %i, virt addr = %p, dma addr = 0x%llx\n",
2407 xhci->
erst.num_entries,
2409 (
unsigned long long)xhci->
erst.erst_dma_addr);
2412 for (val = 0, seg = xhci->
event_ring->first_seg; val < ERST_NUM_SEGS; val++) {
2421 val = xhci_readl(xhci, &xhci->
ir_set->erst_size);
2424 xhci_dbg(xhci,
"// Write ERST size = %i to ir_set 0 (some bits preserved)\n",
2426 xhci_writel(xhci, val, &xhci->
ir_set->erst_size);
2428 xhci_dbg(xhci,
"// Set ERST entries to point to event ring.\n");
2430 xhci_dbg(xhci,
"// Set ERST base address for ir_set 0 = 0x%llx\n",
2431 (
unsigned long long)xhci->
erst.erst_dma_addr);
2432 val_64 = xhci_read_64(xhci, &xhci->
ir_set->erst_base);
2435 xhci_write_64(xhci, val_64, &xhci->
ir_set->erst_base);
2438 xhci_set_hc_event_deq(xhci);
2439 xhci_dbg(xhci,
"Wrote ERST address to ir_set 0.\n");
2450 for (i = 0; i < USB_MAXCHILDREN; ++
i) {
2455 if (scratchpad_alloc(xhci, flags))
2457 if (xhci_setup_port_arrays(xhci, flags))
2466 temp = xhci_readl(xhci, &xhci->
op_regs->dev_notification);
2469 xhci_writel(xhci, temp, &xhci->
op_regs->dev_notification);
2474 xhci_warn(xhci,
"Couldn't initialize memory\n");