Lines Matching refs:xhci
35 static int xhci_create_usb3x_bos_desc(struct xhci_hcd *xhci, char *buf, in xhci_create_usb3x_bos_desc() argument
60 for (i = 0; i < xhci->num_port_caps; i++) { in xhci_create_usb3x_bos_desc()
61 u8 major = xhci->port_caps[i].maj_rev; in xhci_create_usb3x_bos_desc()
62 u8 minor = xhci->port_caps[i].min_rev; in xhci_create_usb3x_bos_desc()
67 port_cap = &xhci->port_caps[i]; in xhci_create_usb3x_bos_desc()
111 reg = readl(&xhci->cap_regs->hcc_params); in xhci_create_usb3x_bos_desc()
115 if ((xhci->quirks & XHCI_LPM_SUPPORT)) { in xhci_create_usb3x_bos_desc()
116 reg = readl(&xhci->cap_regs->hcs_params3); in xhci_create_usb3x_bos_desc()
255 static void xhci_common_hub_descriptor(struct xhci_hcd *xhci, in xhci_common_hub_descriptor() argument
265 if (HCC_PPC(xhci->hcc_params)) in xhci_common_hub_descriptor()
278 static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_usb2_hub_descriptor() argument
288 rhub = &xhci->usb2_rhub; in xhci_usb2_hub_descriptor()
290 xhci_common_hub_descriptor(xhci, desc, ports); in xhci_usb2_hub_descriptor()
333 static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_usb3_hub_descriptor() argument
342 rhub = &xhci->usb3_rhub; in xhci_usb3_hub_descriptor()
344 xhci_common_hub_descriptor(xhci, desc, ports); in xhci_usb3_hub_descriptor()
366 static void xhci_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_hub_descriptor() argument
371 xhci_usb3_hub_descriptor(hcd, xhci, desc); in xhci_hub_descriptor()
373 xhci_usb2_hub_descriptor(hcd, xhci, desc); in xhci_hub_descriptor()
447 int xhci_find_slot_id_by_port(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_find_slot_id_by_port() argument
456 if (!xhci->devs[i] || !xhci->devs[i]->udev) in xhci_find_slot_id_by_port()
458 speed = xhci->devs[i]->udev->speed; in xhci_find_slot_id_by_port()
460 && xhci->devs[i]->fake_port == port) { in xhci_find_slot_id_by_port()
475 static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend) in xhci_stop_device() argument
484 virt_dev = xhci->devs[slot_id]; in xhci_stop_device()
490 cmd = xhci_alloc_command(xhci, true, GFP_NOIO); in xhci_stop_device()
494 spin_lock_irqsave(&xhci->lock, flags); in xhci_stop_device()
500 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->out_ctx, i); in xhci_stop_device()
506 command = xhci_alloc_command(xhci, false, GFP_NOWAIT); in xhci_stop_device()
508 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_stop_device()
513 ret = xhci_queue_stop_endpoint(xhci, command, slot_id, in xhci_stop_device()
516 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_stop_device()
517 xhci_free_command(xhci, command); in xhci_stop_device()
522 ret = xhci_queue_stop_endpoint(xhci, cmd, slot_id, 0, suspend); in xhci_stop_device()
524 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_stop_device()
528 xhci_ring_cmd_db(xhci); in xhci_stop_device()
529 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_stop_device()
536 xhci_warn(xhci, "Timeout while waiting for stop endpoint command\n"); in xhci_stop_device()
541 xhci_free_command(xhci, cmd); in xhci_stop_device()
548 void xhci_ring_device(struct xhci_hcd *xhci, int slot_id) in xhci_ring_device() argument
554 ep = &xhci->devs[slot_id]->eps[i]; in xhci_ring_device()
558 xhci_ring_ep_doorbell(xhci, slot_id, i, s); in xhci_ring_device()
560 xhci_ring_ep_doorbell(xhci, slot_id, i, 0); in xhci_ring_device()
567 static void xhci_disable_port(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_disable_port() argument
572 xhci_dbg(xhci, "Ignoring request to disable " in xhci_disable_port()
577 if (xhci->quirks & XHCI_BROKEN_PORT_PED) { in xhci_disable_port()
578 xhci_dbg(xhci, in xhci_disable_port()
586 xhci_dbg(xhci, "disable port %d-%d, portsc: 0x%x\n", in xhci_disable_port()
590 static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue, in xhci_clear_port_change_bit() argument
637 xhci_dbg(xhci, "clear port%d %s change, portsc: 0x%x\n", in xhci_clear_port_change_bit()
643 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_get_rhub() local
646 return &xhci->usb3_rhub; in xhci_get_rhub()
647 return &xhci->usb2_rhub; in xhci_get_rhub()
655 static void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd, in xhci_set_port_power() argument
657 __must_hold(&xhci->lock) in xhci_set_port_power()
667 xhci_dbg(xhci, "set port power %d-%d %s, portsc: 0x%x\n", in xhci_set_port_power()
681 spin_unlock_irqrestore(&xhci->lock, *flags); in xhci_set_port_power()
687 spin_lock_irqsave(&xhci->lock, *flags); in xhci_set_port_power()
690 static void xhci_port_set_test_mode(struct xhci_hcd *xhci, in xhci_port_set_test_mode() argument
697 port = xhci->usb2_rhub.ports[wIndex]; in xhci_port_set_test_mode()
701 xhci->test_mode = test_mode; in xhci_port_set_test_mode()
703 xhci_start(xhci); in xhci_port_set_test_mode()
706 static int xhci_enter_test_mode(struct xhci_hcd *xhci, in xhci_enter_test_mode() argument
708 __must_hold(&xhci->lock) in xhci_enter_test_mode()
713 xhci_dbg(xhci, "Disable all slots\n"); in xhci_enter_test_mode()
714 spin_unlock_irqrestore(&xhci->lock, *flags); in xhci_enter_test_mode()
715 for (i = 1; i <= HCS_MAX_SLOTS(xhci->hcs_params1); i++) { in xhci_enter_test_mode()
716 if (!xhci->devs[i]) in xhci_enter_test_mode()
719 retval = xhci_disable_slot(xhci, i); in xhci_enter_test_mode()
720 xhci_free_virt_device(xhci, i); in xhci_enter_test_mode()
722 xhci_err(xhci, "Failed to disable slot %d, %d. Enter test mode anyway\n", in xhci_enter_test_mode()
725 spin_lock_irqsave(&xhci->lock, *flags); in xhci_enter_test_mode()
727 xhci_dbg(xhci, "Disable all port (PP = 0)\n"); in xhci_enter_test_mode()
729 for (i = 0; i < xhci->usb3_rhub.num_ports; i++) in xhci_enter_test_mode()
730 xhci_set_port_power(xhci, xhci->shared_hcd, i, false, flags); in xhci_enter_test_mode()
732 for (i = 0; i < xhci->usb2_rhub.num_ports; i++) in xhci_enter_test_mode()
733 xhci_set_port_power(xhci, xhci->main_hcd, i, false, flags); in xhci_enter_test_mode()
735 xhci_dbg(xhci, "Stop controller\n"); in xhci_enter_test_mode()
736 retval = xhci_halt(xhci); in xhci_enter_test_mode()
740 pm_runtime_forbid(xhci_to_hcd(xhci)->self.controller); in xhci_enter_test_mode()
743 xhci_dbg(xhci, "Enter Test Mode: %d, Port_id=%d\n", in xhci_enter_test_mode()
745 xhci_port_set_test_mode(xhci, test_mode, wIndex); in xhci_enter_test_mode()
749 static int xhci_exit_test_mode(struct xhci_hcd *xhci) in xhci_exit_test_mode() argument
753 if (!xhci->test_mode) { in xhci_exit_test_mode()
754 xhci_err(xhci, "Not in test mode, do nothing.\n"); in xhci_exit_test_mode()
757 if (xhci->test_mode == USB_TEST_FORCE_ENABLE && in xhci_exit_test_mode()
758 !(xhci->xhc_state & XHCI_STATE_HALTED)) { in xhci_exit_test_mode()
759 retval = xhci_halt(xhci); in xhci_exit_test_mode()
763 pm_runtime_allow(xhci_to_hcd(xhci)->self.controller); in xhci_exit_test_mode()
764 xhci->test_mode = 0; in xhci_exit_test_mode()
765 return xhci_reset(xhci, XHCI_RESET_SHORT_USEC); in xhci_exit_test_mode()
768 void xhci_set_link_state(struct xhci_hcd *xhci, struct xhci_port *port, in xhci_set_link_state() argument
780 xhci_dbg(xhci, "Set port %d-%d link state, portsc: 0x%x, write 0x%x", in xhci_set_link_state()
785 static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci, in xhci_set_remote_wake_mask() argument
812 void xhci_test_and_clear_bit(struct xhci_hcd *xhci, struct xhci_port *port, in xhci_test_and_clear_bit() argument
826 static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci, in xhci_hub_report_usb3_link_state() argument
870 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && in xhci_hub_report_usb3_link_state()
886 static void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status, in xhci_del_comp_mod_timer() argument
889 u32 all_ports_seen_u0 = ((1 << xhci->usb3_rhub.num_ports) - 1); in xhci_del_comp_mod_timer()
892 if (!(xhci->quirks & XHCI_COMP_MODE_QUIRK)) in xhci_del_comp_mod_timer()
895 if ((xhci->port_status_u0 != all_ports_seen_u0) && port_in_u0) { in xhci_del_comp_mod_timer()
896 xhci->port_status_u0 |= 1 << wIndex; in xhci_del_comp_mod_timer()
897 if (xhci->port_status_u0 == all_ports_seen_u0) { in xhci_del_comp_mod_timer()
898 del_timer_sync(&xhci->comp_mode_recovery_timer); in xhci_del_comp_mod_timer()
899 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_del_comp_mod_timer()
901 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_del_comp_mod_timer()
912 struct xhci_hcd *xhci; in xhci_handle_usb2_port_link_resume() local
919 xhci = hcd_to_xhci(hcd); in xhci_handle_usb2_port_link_resume()
952 xhci_dbg(xhci, "resume USB2 port %d-%d\n", in xhci_handle_usb2_port_link_resume()
960 xhci_test_and_clear_bit(xhci, port, PORT_PLC); in xhci_handle_usb2_port_link_resume()
961 xhci_set_link_state(xhci, port, XDEV_U0); in xhci_handle_usb2_port_link_resume()
963 spin_unlock_irqrestore(&xhci->lock, *flags); in xhci_handle_usb2_port_link_resume()
967 spin_lock_irqsave(&xhci->lock, *flags); in xhci_handle_usb2_port_link_resume()
970 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_handle_usb2_port_link_resume()
973 xhci_dbg(xhci, "slot_id is zero\n"); in xhci_handle_usb2_port_link_resume()
977 xhci_ring_device(xhci, slot_id); in xhci_handle_usb2_port_link_resume()
981 xhci_warn(xhci, "Port resume timed out, port %d-%d: 0x%x\n", in xhci_handle_usb2_port_link_resume()
1022 struct xhci_hcd *xhci; in xhci_get_usb3_port_status() local
1028 xhci = hcd_to_xhci(port->rhub->hcd); in xhci_get_usb3_port_status()
1065 xhci_hub_report_usb3_link_state(xhci, status, portsc); in xhci_get_usb3_port_status()
1066 xhci_del_comp_mod_timer(xhci, portsc, portnum); in xhci_get_usb3_port_status()
1139 __releases(&xhci->lock) in xhci_get_port_status()
1140 __acquires(&xhci->lock) in xhci_get_port_status()
1199 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_hub_control() local
1218 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1232 xhci_dbg(xhci, "Wrong hub descriptor type for " in xhci_hub_control()
1236 xhci_hub_descriptor(hcd, xhci, in xhci_hub_control()
1246 retval = xhci_create_usb3x_bos_desc(xhci, buf, wLength); in xhci_hub_control()
1247 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1255 xhci_hc_died(xhci); in xhci_hub_control()
1265 xhci_dbg(xhci, "Get port status %d-%d read: 0x%x, return 0x%x", in xhci_hub_control()
1274 xhci_err(xhci, "get ext port status invalid parameter\n"); in xhci_hub_control()
1298 xhci_hc_died(xhci); in xhci_hub_control()
1309 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1311 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1313 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1322 xhci_warn(xhci, "USB core suspending port %d-%d not in U0/U1/U2\n", in xhci_hub_control()
1327 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_hub_control()
1330 xhci_warn(xhci, "slot_id is zero\n"); in xhci_hub_control()
1334 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1335 xhci_stop_device(xhci, slot_id, 1); in xhci_hub_control()
1336 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1338 xhci_set_link_state(xhci, ports[wIndex], XDEV_U3); in xhci_hub_control()
1340 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1342 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1351 xhci_dbg(xhci, "Disable port %d-%d\n", in xhci_hub_control()
1368 xhci_dbg(xhci, "Enable port %d-%d\n", in xhci_hub_control()
1370 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1391 if (!HCC2_CTC(xhci->hcc_params2)) { in xhci_hub_control()
1392 xhci_dbg(xhci, "CTC flag is 0, port already supports entering compliance mode\n"); in xhci_hub_control()
1397 xhci_warn(xhci, "Can't set compliance mode when port is connected\n"); in xhci_hub_control()
1401 xhci_dbg(xhci, "Enable compliance mode transition for port %d-%d\n", in xhci_hub_control()
1403 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1416 xhci_warn(xhci, "Cannot set port %d-%d link state %d\n", in xhci_hub_control()
1443 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1450 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1453 xhci_dbg(xhci, "missing U0 port change event for port %d-%d\n", in xhci_hub_control()
1455 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1462 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_hub_control()
1467 spin_unlock_irqrestore(&xhci->lock, in xhci_hub_control()
1469 xhci_stop_device(xhci, slot_id, 1); in xhci_hub_control()
1470 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1472 xhci_set_link_state(xhci, ports[wIndex], USB_SS_PORT_LS_U3); in xhci_hub_control()
1473 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1480 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1492 xhci_set_port_power(xhci, hcd, wIndex, true, &flags); in xhci_hub_control()
1499 xhci_dbg(xhci, "set port reset, actual port %d-%d status = 0x%x\n", in xhci_hub_control()
1503 xhci_set_remote_wake_mask(xhci, ports[wIndex], in xhci_hub_control()
1506 xhci_dbg(xhci, "set port remote wake mask, actual port %d-%d status = 0x%x\n", in xhci_hub_control()
1537 retval = xhci_enter_test_mode(xhci, test_mode, wIndex, in xhci_hub_control()
1552 xhci_hc_died(xhci); in xhci_hub_control()
1561 xhci_dbg(xhci, "clear USB_PORT_FEAT_SUSPEND\n"); in xhci_hub_control()
1562 xhci_dbg(xhci, "PORTSC %04x\n", temp); in xhci_hub_control()
1571 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1573 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1575 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1576 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1583 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_hub_control()
1586 xhci_dbg(xhci, "slot_id is zero\n"); in xhci_hub_control()
1589 xhci_ring_device(xhci, slot_id); in xhci_hub_control()
1601 xhci_clear_port_change_bit(xhci, wValue, wIndex, in xhci_hub_control()
1605 xhci_disable_port(hcd, xhci, wIndex, in xhci_hub_control()
1609 xhci_set_port_power(xhci, hcd, wIndex, false, &flags); in xhci_hub_control()
1612 retval = xhci_exit_test_mode(xhci); in xhci_hub_control()
1623 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1641 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_hub_status_data() local
1661 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_status_data()
1671 xhci_hc_died(xhci); in xhci_hub_status_data()
1690 xhci_dbg(xhci, "%s: stopping usb%d port polling\n", in xhci_hub_status_data()
1694 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_status_data()
1702 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_bus_suspend() local
1717 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_suspend()
1722 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1723 xhci_dbg(xhci, "usb%d bus suspend to fail because a port is resuming\n", in xhci_bus_suspend()
1748 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1750 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_suspend()
1751 xhci_dbg(xhci, "port %d-%d polling in bus suspend, waiting\n", in xhci_bus_suspend()
1758 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1759 xhci_dbg(xhci, "Bus suspend bailout, port over-current detected\n"); in xhci_bus_suspend()
1766 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1767 xhci_dbg(xhci, "Bus suspend bailout, port connect change\n"); in xhci_bus_suspend()
1770 xhci_dbg(xhci, "port %d-%d not suspended\n", in xhci_bus_suspend()
1789 if ((xhci->quirks & XHCI_U2_DISABLE_WAKE) && in xhci_bus_suspend()
1811 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_bus_suspend()
1814 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1815 xhci_stop_device(xhci, slot_id, 1); in xhci_bus_suspend()
1816 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_suspend()
1823 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1861 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_bus_resume() local
1880 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_resume()
1882 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_resume()
1887 temp = readl(&xhci->op_regs->command); in xhci_bus_resume()
1889 writel(temp, &xhci->op_regs->command); in xhci_bus_resume()
1902 if ((xhci->quirks & XHCI_MISSING_CAS) && in xhci_bus_resume()
1905 xhci_dbg(xhci, "reset stuck port %d-%d\n", in xhci_bus_resume()
1935 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_resume()
1937 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_resume()
1942 xhci_test_and_clear_bit(xhci, ports[port_index], in xhci_bus_resume()
1944 xhci_set_link_state(xhci, ports[port_index], XDEV_U0); in xhci_bus_resume()
1953 xhci_warn(xhci, "port %d-%d resume PLC timeout\n", in xhci_bus_resume()
1957 xhci_test_and_clear_bit(xhci, ports[port_index], PORT_PLC); in xhci_bus_resume()
1958 slot_id = xhci_find_slot_id_by_port(hcd, xhci, port_index + 1); in xhci_bus_resume()
1960 xhci_ring_device(xhci, slot_id); in xhci_bus_resume()
1962 (void) readl(&xhci->op_regs->command); in xhci_bus_resume()
1966 temp = readl(&xhci->op_regs->command); in xhci_bus_resume()
1968 writel(temp, &xhci->op_regs->command); in xhci_bus_resume()
1969 temp = readl(&xhci->op_regs->command); in xhci_bus_resume()
1971 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_resume()