Lines Matching refs:xhci
55 static int xhci_create_usb3_bos_desc(struct xhci_hcd *xhci, char *buf, in xhci_create_usb3_bos_desc() argument
67 if (xhci->usb3_rhub.min_rev >= 0x01) { in xhci_create_usb3_bos_desc()
69 if (xhci->usb3_rhub.psi_count) { in xhci_create_usb3_bos_desc()
71 ssa_count = xhci->usb3_rhub.psi_uid_count * 2; in xhci_create_usb3_bos_desc()
90 temp = readl(&xhci->cap_regs->hcc_params); in xhci_create_usb3_bos_desc()
95 if ((xhci->quirks & XHCI_LPM_SUPPORT)) { in xhci_create_usb3_bos_desc()
96 temp = readl(&xhci->cap_regs->hcs_params3); in xhci_create_usb3_bos_desc()
102 if (usb3_1 && xhci->usb3_rhub.psi_count) { in xhci_create_usb3_bos_desc()
114 bm_attrib |= (xhci->usb3_rhub.psi_uid_count - 1) << 5; in xhci_create_usb3_bos_desc()
127 for (i = 0; i < xhci->usb3_rhub.psi_count; i++) { in xhci_create_usb3_bos_desc()
128 psi = xhci->usb3_rhub.psi[i]; in xhci_create_usb3_bos_desc()
160 static void xhci_common_hub_descriptor(struct xhci_hcd *xhci, in xhci_common_hub_descriptor() argument
171 if (HCC_PPC(xhci->hcc_params)) in xhci_common_hub_descriptor()
184 static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_usb2_hub_descriptor() argument
194 rhub = &xhci->usb2_rhub; in xhci_usb2_hub_descriptor()
196 xhci_common_hub_descriptor(xhci, desc, ports); in xhci_usb2_hub_descriptor()
238 static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_usb3_hub_descriptor() argument
247 rhub = &xhci->usb3_rhub; in xhci_usb3_hub_descriptor()
249 xhci_common_hub_descriptor(xhci, desc, ports); in xhci_usb3_hub_descriptor()
270 static void xhci_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_hub_descriptor() argument
275 xhci_usb3_hub_descriptor(hcd, xhci, desc); in xhci_hub_descriptor()
277 xhci_usb2_hub_descriptor(hcd, xhci, desc); in xhci_hub_descriptor()
351 int xhci_find_slot_id_by_port(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_find_slot_id_by_port() argument
360 if (!xhci->devs[i] || !xhci->devs[i]->udev) in xhci_find_slot_id_by_port()
362 speed = xhci->devs[i]->udev->speed; in xhci_find_slot_id_by_port()
364 && xhci->devs[i]->fake_port == port) { in xhci_find_slot_id_by_port()
379 static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend) in xhci_stop_device() argument
388 virt_dev = xhci->devs[slot_id]; in xhci_stop_device()
394 cmd = xhci_alloc_command(xhci, true, GFP_NOIO); in xhci_stop_device()
398 spin_lock_irqsave(&xhci->lock, flags); in xhci_stop_device()
404 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->out_ctx, i); in xhci_stop_device()
410 command = xhci_alloc_command(xhci, false, GFP_NOWAIT); in xhci_stop_device()
412 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_stop_device()
417 ret = xhci_queue_stop_endpoint(xhci, command, slot_id, in xhci_stop_device()
420 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_stop_device()
421 xhci_free_command(xhci, command); in xhci_stop_device()
426 ret = xhci_queue_stop_endpoint(xhci, cmd, slot_id, 0, suspend); in xhci_stop_device()
428 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_stop_device()
432 xhci_ring_cmd_db(xhci); in xhci_stop_device()
433 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_stop_device()
440 xhci_warn(xhci, "Timeout while waiting for stop endpoint command\n"); in xhci_stop_device()
445 xhci_free_command(xhci, cmd); in xhci_stop_device()
452 void xhci_ring_device(struct xhci_hcd *xhci, int slot_id) in xhci_ring_device() argument
458 ep = &xhci->devs[slot_id]->eps[i]; in xhci_ring_device()
462 xhci_ring_ep_doorbell(xhci, slot_id, i, s); in xhci_ring_device()
464 xhci_ring_ep_doorbell(xhci, slot_id, i, 0); in xhci_ring_device()
471 static void xhci_disable_port(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_disable_port() argument
476 xhci_dbg(xhci, "Ignoring request to disable " in xhci_disable_port()
481 if (xhci->quirks & XHCI_BROKEN_PORT_PED) { in xhci_disable_port()
482 xhci_dbg(xhci, in xhci_disable_port()
490 xhci_dbg(xhci, "disable port %d-%d, portsc: 0x%x\n", in xhci_disable_port()
494 static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue, in xhci_clear_port_change_bit() argument
541 xhci_dbg(xhci, "clear port%d %s change, portsc: 0x%x\n", in xhci_clear_port_change_bit()
547 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_get_rhub() local
550 return &xhci->usb3_rhub; in xhci_get_rhub()
551 return &xhci->usb2_rhub; in xhci_get_rhub()
559 static void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd, in xhci_set_port_power() argument
570 xhci_dbg(xhci, "set port power %d-%d %s, portsc: 0x%x\n", in xhci_set_port_power()
584 spin_unlock_irqrestore(&xhci->lock, *flags); in xhci_set_port_power()
590 spin_lock_irqsave(&xhci->lock, *flags); in xhci_set_port_power()
593 static void xhci_port_set_test_mode(struct xhci_hcd *xhci, in xhci_port_set_test_mode() argument
600 port = xhci->usb2_rhub.ports[wIndex]; in xhci_port_set_test_mode()
604 xhci->test_mode = test_mode; in xhci_port_set_test_mode()
606 xhci_start(xhci); in xhci_port_set_test_mode()
609 static int xhci_enter_test_mode(struct xhci_hcd *xhci, in xhci_enter_test_mode() argument
615 xhci_dbg(xhci, "Disable all slots\n"); in xhci_enter_test_mode()
616 spin_unlock_irqrestore(&xhci->lock, *flags); in xhci_enter_test_mode()
617 for (i = 1; i <= HCS_MAX_SLOTS(xhci->hcs_params1); i++) { in xhci_enter_test_mode()
618 if (!xhci->devs[i]) in xhci_enter_test_mode()
621 retval = xhci_disable_slot(xhci, i); in xhci_enter_test_mode()
623 xhci_err(xhci, "Failed to disable slot %d, %d. Enter test mode anyway\n", in xhci_enter_test_mode()
626 spin_lock_irqsave(&xhci->lock, *flags); in xhci_enter_test_mode()
628 xhci_dbg(xhci, "Disable all port (PP = 0)\n"); in xhci_enter_test_mode()
630 for (i = 0; i < xhci->usb3_rhub.num_ports; i++) in xhci_enter_test_mode()
631 xhci_set_port_power(xhci, xhci->shared_hcd, i, false, flags); in xhci_enter_test_mode()
633 for (i = 0; i < xhci->usb2_rhub.num_ports; i++) in xhci_enter_test_mode()
634 xhci_set_port_power(xhci, xhci->main_hcd, i, false, flags); in xhci_enter_test_mode()
636 xhci_dbg(xhci, "Stop controller\n"); in xhci_enter_test_mode()
637 retval = xhci_halt(xhci); in xhci_enter_test_mode()
641 pm_runtime_forbid(xhci_to_hcd(xhci)->self.controller); in xhci_enter_test_mode()
644 xhci_dbg(xhci, "Enter Test Mode: %d, Port_id=%d\n", in xhci_enter_test_mode()
646 xhci_port_set_test_mode(xhci, test_mode, wIndex); in xhci_enter_test_mode()
650 static int xhci_exit_test_mode(struct xhci_hcd *xhci) in xhci_exit_test_mode() argument
654 if (!xhci->test_mode) { in xhci_exit_test_mode()
655 xhci_err(xhci, "Not in test mode, do nothing.\n"); in xhci_exit_test_mode()
658 if (xhci->test_mode == TEST_FORCE_EN && in xhci_exit_test_mode()
659 !(xhci->xhc_state & XHCI_STATE_HALTED)) { in xhci_exit_test_mode()
660 retval = xhci_halt(xhci); in xhci_exit_test_mode()
664 pm_runtime_allow(xhci_to_hcd(xhci)->self.controller); in xhci_exit_test_mode()
665 xhci->test_mode = 0; in xhci_exit_test_mode()
666 return xhci_reset(xhci); in xhci_exit_test_mode()
669 void xhci_set_link_state(struct xhci_hcd *xhci, struct xhci_port *port, in xhci_set_link_state() argument
681 xhci_dbg(xhci, "Set port %d-%d link state, portsc: 0x%x, write 0x%x", in xhci_set_link_state()
686 static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci, in xhci_set_remote_wake_mask() argument
713 void xhci_test_and_clear_bit(struct xhci_hcd *xhci, struct xhci_port *port, in xhci_test_and_clear_bit() argument
727 static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci, in xhci_hub_report_usb3_link_state() argument
770 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && in xhci_hub_report_usb3_link_state()
786 static void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status, in xhci_del_comp_mod_timer() argument
789 u32 all_ports_seen_u0 = ((1 << xhci->usb3_rhub.num_ports) - 1); in xhci_del_comp_mod_timer()
792 if (!(xhci->quirks & XHCI_COMP_MODE_QUIRK)) in xhci_del_comp_mod_timer()
795 if ((xhci->port_status_u0 != all_ports_seen_u0) && port_in_u0) { in xhci_del_comp_mod_timer()
796 xhci->port_status_u0 |= 1 << wIndex; in xhci_del_comp_mod_timer()
797 if (xhci->port_status_u0 == all_ports_seen_u0) { in xhci_del_comp_mod_timer()
798 del_timer_sync(&xhci->comp_mode_recovery_timer); in xhci_del_comp_mod_timer()
799 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_del_comp_mod_timer()
801 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_del_comp_mod_timer()
812 struct xhci_hcd *xhci; in xhci_handle_usb2_port_link_resume() local
819 xhci = hcd_to_xhci(hcd); in xhci_handle_usb2_port_link_resume()
852 xhci_dbg(xhci, "resume USB2 port %d-%d\n", in xhci_handle_usb2_port_link_resume()
860 xhci_test_and_clear_bit(xhci, port, PORT_PLC); in xhci_handle_usb2_port_link_resume()
861 xhci_set_link_state(xhci, port, XDEV_U0); in xhci_handle_usb2_port_link_resume()
863 spin_unlock_irqrestore(&xhci->lock, *flags); in xhci_handle_usb2_port_link_resume()
867 spin_lock_irqsave(&xhci->lock, *flags); in xhci_handle_usb2_port_link_resume()
870 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_handle_usb2_port_link_resume()
873 xhci_dbg(xhci, "slot_id is zero\n"); in xhci_handle_usb2_port_link_resume()
877 xhci_ring_device(xhci, slot_id); in xhci_handle_usb2_port_link_resume()
881 xhci_warn(xhci, "Port resume timed out, port %d-%d: 0x%x\n", in xhci_handle_usb2_port_link_resume()
922 struct xhci_hcd *xhci; in xhci_get_usb3_port_status() local
928 xhci = hcd_to_xhci(port->rhub->hcd); in xhci_get_usb3_port_status()
965 xhci_hub_report_usb3_link_state(xhci, status, portsc); in xhci_get_usb3_port_status()
966 xhci_del_comp_mod_timer(xhci, portsc, portnum); in xhci_get_usb3_port_status()
1021 __releases(&xhci->lock) in xhci_get_port_status()
1022 __acquires(&xhci->lock) in xhci_get_port_status()
1081 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_hub_control() local
1100 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1114 xhci_dbg(xhci, "Wrong hub descriptor type for " in xhci_hub_control()
1118 xhci_hub_descriptor(hcd, xhci, in xhci_hub_control()
1128 retval = xhci_create_usb3_bos_desc(xhci, buf, wLength); in xhci_hub_control()
1129 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1137 xhci_hc_died(xhci); in xhci_hub_control()
1147 xhci_dbg(xhci, "Get port status %d-%d read: 0x%x, return 0x%x", in xhci_hub_control()
1156 xhci_err(xhci, "get ext port status invalid parameter\n"); in xhci_hub_control()
1180 xhci_hc_died(xhci); in xhci_hub_control()
1191 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1193 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1195 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1204 xhci_warn(xhci, "USB core suspending port %d-%d not in U0/U1/U2\n", in xhci_hub_control()
1209 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_hub_control()
1212 xhci_warn(xhci, "slot_id is zero\n"); in xhci_hub_control()
1216 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1217 xhci_stop_device(xhci, slot_id, 1); in xhci_hub_control()
1218 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1220 xhci_set_link_state(xhci, ports[wIndex], XDEV_U3); in xhci_hub_control()
1222 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1224 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1233 xhci_dbg(xhci, "Disable port %d\n", wIndex); in xhci_hub_control()
1249 xhci_dbg(xhci, "Enable port %d\n", wIndex); in xhci_hub_control()
1250 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1271 if (!HCC2_CTC(xhci->hcc_params2)) { in xhci_hub_control()
1272 xhci_dbg(xhci, "CTC flag is 0, port already supports entering compliance mode\n"); in xhci_hub_control()
1277 xhci_warn(xhci, "Can't set compliance mode when port is connected\n"); in xhci_hub_control()
1281 xhci_dbg(xhci, "Enable compliance mode transition for port %d\n", in xhci_hub_control()
1283 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1296 xhci_warn(xhci, "Cannot set port %d link state %d\n", in xhci_hub_control()
1301 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_hub_control()
1306 spin_unlock_irqrestore(&xhci->lock, in xhci_hub_control()
1308 xhci_stop_device(xhci, slot_id, 1); in xhci_hub_control()
1309 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1313 xhci_set_link_state(xhci, ports[wIndex], link_state); in xhci_hub_control()
1315 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1317 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1330 xhci_set_port_power(xhci, hcd, wIndex, true, &flags); in xhci_hub_control()
1337 xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); in xhci_hub_control()
1340 xhci_set_remote_wake_mask(xhci, ports[wIndex], in xhci_hub_control()
1343 xhci_dbg(xhci, "set port remote wake mask, " in xhci_hub_control()
1374 retval = xhci_enter_test_mode(xhci, test_mode, wIndex, in xhci_hub_control()
1389 xhci_hc_died(xhci); in xhci_hub_control()
1398 xhci_dbg(xhci, "clear USB_PORT_FEAT_SUSPEND\n"); in xhci_hub_control()
1399 xhci_dbg(xhci, "PORTSC %04x\n", temp); in xhci_hub_control()
1408 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1410 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1412 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1413 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1420 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_hub_control()
1423 xhci_dbg(xhci, "slot_id is zero\n"); in xhci_hub_control()
1426 xhci_ring_device(xhci, slot_id); in xhci_hub_control()
1438 xhci_clear_port_change_bit(xhci, wValue, wIndex, in xhci_hub_control()
1442 xhci_disable_port(hcd, xhci, wIndex, in xhci_hub_control()
1446 xhci_set_port_power(xhci, hcd, wIndex, false, &flags); in xhci_hub_control()
1449 retval = xhci_exit_test_mode(xhci); in xhci_hub_control()
1460 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1478 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_hub_status_data() local
1502 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_status_data()
1507 xhci_hc_died(xhci); in xhci_hub_status_data()
1524 xhci_dbg(xhci, "%s: stopping port polling.\n", __func__); in xhci_hub_status_data()
1527 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_status_data()
1535 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_bus_suspend() local
1550 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_suspend()
1555 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1556 xhci_dbg(xhci, "suspend failed because a port is resuming\n"); in xhci_bus_suspend()
1580 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1582 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_suspend()
1583 xhci_dbg(xhci, "port %d polling in bus suspend, waiting\n", in xhci_bus_suspend()
1591 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1592 xhci_dbg(xhci, "Bus suspend bailout, port connect change\n"); in xhci_bus_suspend()
1595 xhci_dbg(xhci, "port %d not suspended\n", port_index); in xhci_bus_suspend()
1613 if ((xhci->quirks & XHCI_U2_DISABLE_WAKE) && in xhci_bus_suspend()
1635 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_bus_suspend()
1638 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1639 xhci_stop_device(xhci, slot_id, 1); in xhci_bus_suspend()
1640 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_suspend()
1647 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1681 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_bus_resume() local
1700 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_resume()
1702 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_resume()
1707 temp = readl(&xhci->op_regs->command); in xhci_bus_resume()
1709 writel(temp, &xhci->op_regs->command); in xhci_bus_resume()
1722 if ((xhci->quirks & XHCI_MISSING_CAS) && in xhci_bus_resume()
1725 xhci_dbg(xhci, "reset stuck port %d\n", port_index); in xhci_bus_resume()
1754 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_resume()
1756 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_resume()
1761 xhci_test_and_clear_bit(xhci, ports[port_index], in xhci_bus_resume()
1763 xhci_set_link_state(xhci, ports[port_index], XDEV_U0); in xhci_bus_resume()
1772 xhci_warn(xhci, "port %d resume PLC timeout\n", in xhci_bus_resume()
1776 xhci_test_and_clear_bit(xhci, ports[port_index], PORT_PLC); in xhci_bus_resume()
1777 slot_id = xhci_find_slot_id_by_port(hcd, xhci, port_index + 1); in xhci_bus_resume()
1779 xhci_ring_device(xhci, slot_id); in xhci_bus_resume()
1781 (void) readl(&xhci->op_regs->command); in xhci_bus_resume()
1785 temp = readl(&xhci->op_regs->command); in xhci_bus_resume()
1787 writel(temp, &xhci->op_regs->command); in xhci_bus_resume()
1788 temp = readl(&xhci->op_regs->command); in xhci_bus_resume()
1790 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_resume()