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, actual port %d status = 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
540 xhci_dbg(xhci, "clear port %s change, actual port %d status = 0x%x\n", in xhci_clear_port_change_bit()
546 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_get_rhub() local
549 return &xhci->usb3_rhub; in xhci_get_rhub()
550 return &xhci->usb2_rhub; in xhci_get_rhub()
558 static void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd, in xhci_set_port_power() argument
573 xhci_dbg(xhci, "set port power, actual port %d status = 0x%x\n", in xhci_set_port_power()
580 spin_unlock_irqrestore(&xhci->lock, *flags); in xhci_set_port_power()
586 spin_lock_irqsave(&xhci->lock, *flags); in xhci_set_port_power()
589 static void xhci_port_set_test_mode(struct xhci_hcd *xhci, in xhci_port_set_test_mode() argument
596 port = xhci->usb2_rhub.ports[wIndex]; in xhci_port_set_test_mode()
600 xhci->test_mode = test_mode; in xhci_port_set_test_mode()
602 xhci_start(xhci); in xhci_port_set_test_mode()
605 static int xhci_enter_test_mode(struct xhci_hcd *xhci, in xhci_enter_test_mode() argument
611 xhci_dbg(xhci, "Disable all slots\n"); in xhci_enter_test_mode()
612 spin_unlock_irqrestore(&xhci->lock, *flags); in xhci_enter_test_mode()
613 for (i = 1; i <= HCS_MAX_SLOTS(xhci->hcs_params1); i++) { in xhci_enter_test_mode()
614 if (!xhci->devs[i]) in xhci_enter_test_mode()
617 retval = xhci_disable_slot(xhci, i); in xhci_enter_test_mode()
619 xhci_err(xhci, "Failed to disable slot %d, %d. Enter test mode anyway\n", in xhci_enter_test_mode()
622 spin_lock_irqsave(&xhci->lock, *flags); in xhci_enter_test_mode()
624 xhci_dbg(xhci, "Disable all port (PP = 0)\n"); in xhci_enter_test_mode()
626 for (i = 0; i < xhci->usb3_rhub.num_ports; i++) in xhci_enter_test_mode()
627 xhci_set_port_power(xhci, xhci->shared_hcd, i, false, flags); in xhci_enter_test_mode()
629 for (i = 0; i < xhci->usb2_rhub.num_ports; i++) in xhci_enter_test_mode()
630 xhci_set_port_power(xhci, xhci->main_hcd, i, false, flags); in xhci_enter_test_mode()
632 xhci_dbg(xhci, "Stop controller\n"); in xhci_enter_test_mode()
633 retval = xhci_halt(xhci); in xhci_enter_test_mode()
637 pm_runtime_forbid(xhci_to_hcd(xhci)->self.controller); in xhci_enter_test_mode()
640 xhci_dbg(xhci, "Enter Test Mode: %d, Port_id=%d\n", in xhci_enter_test_mode()
642 xhci_port_set_test_mode(xhci, test_mode, wIndex); in xhci_enter_test_mode()
646 static int xhci_exit_test_mode(struct xhci_hcd *xhci) in xhci_exit_test_mode() argument
650 if (!xhci->test_mode) { in xhci_exit_test_mode()
651 xhci_err(xhci, "Not in test mode, do nothing.\n"); in xhci_exit_test_mode()
654 if (xhci->test_mode == TEST_FORCE_EN && in xhci_exit_test_mode()
655 !(xhci->xhc_state & XHCI_STATE_HALTED)) { in xhci_exit_test_mode()
656 retval = xhci_halt(xhci); in xhci_exit_test_mode()
660 pm_runtime_allow(xhci_to_hcd(xhci)->self.controller); in xhci_exit_test_mode()
661 xhci->test_mode = 0; in xhci_exit_test_mode()
662 return xhci_reset(xhci); in xhci_exit_test_mode()
665 void xhci_set_link_state(struct xhci_hcd *xhci, struct xhci_port *port, in xhci_set_link_state() argument
677 static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci, in xhci_set_remote_wake_mask() argument
704 void xhci_test_and_clear_bit(struct xhci_hcd *xhci, struct xhci_port *port, in xhci_test_and_clear_bit() argument
725 static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci, in xhci_hub_report_usb3_link_state() argument
768 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && in xhci_hub_report_usb3_link_state()
784 static void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status, in xhci_del_comp_mod_timer() argument
787 u32 all_ports_seen_u0 = ((1 << xhci->usb3_rhub.num_ports) - 1); in xhci_del_comp_mod_timer()
790 if (!(xhci->quirks & XHCI_COMP_MODE_QUIRK)) in xhci_del_comp_mod_timer()
793 if ((xhci->port_status_u0 != all_ports_seen_u0) && port_in_u0) { in xhci_del_comp_mod_timer()
794 xhci->port_status_u0 |= 1 << wIndex; in xhci_del_comp_mod_timer()
795 if (xhci->port_status_u0 == all_ports_seen_u0) { in xhci_del_comp_mod_timer()
796 del_timer_sync(&xhci->comp_mode_recovery_timer); in xhci_del_comp_mod_timer()
797 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_del_comp_mod_timer()
799 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_del_comp_mod_timer()
835 __releases(&xhci->lock) in xhci_get_port_status()
836 __acquires(&xhci->lock) in xhci_get_port_status()
838 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_get_port_status() local
909 xhci_dbg(xhci, "Resume USB2 port %d\n", in xhci_get_port_status()
916 xhci_test_and_clear_bit(xhci, port, PORT_PLC); in xhci_get_port_status()
917 xhci_set_link_state(xhci, port, XDEV_U0); in xhci_get_port_status()
919 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_get_port_status()
924 spin_lock_irqsave(&xhci->lock, flags); in xhci_get_port_status()
928 xhci, wIndex + 1); in xhci_get_port_status()
930 xhci_dbg(xhci, "slot_id is zero\n"); in xhci_get_port_status()
933 xhci_ring_device(xhci, slot_id); in xhci_get_port_status()
936 xhci_warn(xhci, "Port resume took longer than %i msec, port status = 0x%x\n", in xhci_get_port_status()
996 xhci_hub_report_usb3_link_state(xhci, &status, raw_port_status); in xhci_get_port_status()
1001 xhci_del_comp_mod_timer(xhci, raw_port_status, wIndex); in xhci_get_port_status()
1014 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_hub_control() local
1031 bus_state = &xhci->bus_state[hcd_index(hcd)]; in xhci_hub_control()
1033 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1047 xhci_dbg(xhci, "Wrong hub descriptor type for " in xhci_hub_control()
1051 xhci_hub_descriptor(hcd, xhci, in xhci_hub_control()
1061 retval = xhci_create_usb3_bos_desc(xhci, buf, wLength); in xhci_hub_control()
1062 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1070 xhci_hc_died(xhci); in xhci_hub_control()
1080 xhci_dbg(xhci, "get port status, actual port %d status = 0x%x\n", in xhci_hub_control()
1082 xhci_dbg(xhci, "Get port status returned 0x%x\n", status); in xhci_hub_control()
1090 xhci_err(xhci, "get ext port status invalid parameter\n"); in xhci_hub_control()
1114 xhci_hc_died(xhci); in xhci_hub_control()
1125 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1127 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1129 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1138 xhci_warn(xhci, "USB core suspending device not in U0/U1/U2.\n"); in xhci_hub_control()
1142 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_hub_control()
1145 xhci_warn(xhci, "slot_id is zero\n"); in xhci_hub_control()
1149 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1150 xhci_stop_device(xhci, slot_id, 1); in xhci_hub_control()
1151 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1153 xhci_set_link_state(xhci, ports[wIndex], XDEV_U3); in xhci_hub_control()
1155 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1157 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1166 xhci_dbg(xhci, "Disable port %d\n", wIndex); in xhci_hub_control()
1182 xhci_dbg(xhci, "Enable port %d\n", wIndex); in xhci_hub_control()
1183 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1204 if (!HCC2_CTC(xhci->hcc_params2)) { in xhci_hub_control()
1205 xhci_dbg(xhci, "CTC flag is 0, port already supports entering compliance mode\n"); in xhci_hub_control()
1210 xhci_warn(xhci, "Can't set compliance mode when port is connected\n"); in xhci_hub_control()
1214 xhci_dbg(xhci, "Enable compliance mode transition for port %d\n", in xhci_hub_control()
1216 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1229 xhci_warn(xhci, "Cannot set port %d link state %d\n", in xhci_hub_control()
1234 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_hub_control()
1239 spin_unlock_irqrestore(&xhci->lock, in xhci_hub_control()
1241 xhci_stop_device(xhci, slot_id, 1); in xhci_hub_control()
1242 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1246 xhci_set_link_state(xhci, ports[wIndex], link_state); in xhci_hub_control()
1248 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1250 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1263 xhci_set_port_power(xhci, hcd, wIndex, true, &flags); in xhci_hub_control()
1270 xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); in xhci_hub_control()
1273 xhci_set_remote_wake_mask(xhci, ports[wIndex], in xhci_hub_control()
1276 xhci_dbg(xhci, "set port remote wake mask, " in xhci_hub_control()
1307 retval = xhci_enter_test_mode(xhci, test_mode, wIndex, in xhci_hub_control()
1322 xhci_hc_died(xhci); in xhci_hub_control()
1331 xhci_dbg(xhci, "clear USB_PORT_FEAT_SUSPEND\n"); in xhci_hub_control()
1332 xhci_dbg(xhci, "PORTSC %04x\n", temp); in xhci_hub_control()
1340 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1342 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1344 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1345 xhci_set_link_state(xhci, ports[wIndex], in xhci_hub_control()
1351 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_hub_control()
1354 xhci_dbg(xhci, "slot_id is zero\n"); in xhci_hub_control()
1357 xhci_ring_device(xhci, slot_id); in xhci_hub_control()
1369 xhci_clear_port_change_bit(xhci, wValue, wIndex, in xhci_hub_control()
1373 xhci_disable_port(hcd, xhci, wIndex, in xhci_hub_control()
1377 xhci_set_port_power(xhci, hcd, wIndex, false, &flags); in xhci_hub_control()
1380 retval = xhci_exit_test_mode(xhci); in xhci_hub_control()
1391 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1409 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_hub_status_data() local
1419 bus_state = &xhci->bus_state[hcd_index(hcd)]; in xhci_hub_status_data()
1433 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_status_data()
1438 xhci_hc_died(xhci); in xhci_hub_status_data()
1455 xhci_dbg(xhci, "%s: stopping port polling.\n", __func__); in xhci_hub_status_data()
1458 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_status_data()
1466 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_bus_suspend() local
1476 bus_state = &xhci->bus_state[hcd_index(hcd)]; in xhci_bus_suspend()
1478 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_suspend()
1483 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1484 xhci_dbg(xhci, "suspend failed because a port is resuming\n"); in xhci_bus_suspend()
1500 xhci_dbg(xhci, "port %d not suspended\n", port_index); in xhci_bus_suspend()
1501 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_bus_suspend()
1504 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1505 xhci_stop_device(xhci, slot_id, 1); in xhci_bus_suspend()
1506 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_suspend()
1525 if ((xhci->quirks & XHCI_U2_DISABLE_WAKE) && in xhci_bus_suspend()
1540 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1574 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_bus_resume() local
1588 bus_state = &xhci->bus_state[hcd_index(hcd)]; in xhci_bus_resume()
1593 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_resume()
1595 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_resume()
1600 temp = readl(&xhci->op_regs->command); in xhci_bus_resume()
1602 writel(temp, &xhci->op_regs->command); in xhci_bus_resume()
1615 if ((xhci->quirks & XHCI_MISSING_CAS) && in xhci_bus_resume()
1618 xhci_dbg(xhci, "reset stuck port %d\n", port_index); in xhci_bus_resume()
1647 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_resume()
1649 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_resume()
1654 xhci_test_and_clear_bit(xhci, ports[port_index], in xhci_bus_resume()
1656 xhci_set_link_state(xhci, ports[port_index], XDEV_U0); in xhci_bus_resume()
1665 xhci_warn(xhci, "port %d resume PLC timeout\n", in xhci_bus_resume()
1669 xhci_test_and_clear_bit(xhci, ports[port_index], PORT_PLC); in xhci_bus_resume()
1670 slot_id = xhci_find_slot_id_by_port(hcd, xhci, port_index + 1); in xhci_bus_resume()
1672 xhci_ring_device(xhci, slot_id); in xhci_bus_resume()
1674 (void) readl(&xhci->op_regs->command); in xhci_bus_resume()
1678 temp = readl(&xhci->op_regs->command); in xhci_bus_resume()
1680 writel(temp, &xhci->op_regs->command); in xhci_bus_resume()
1681 temp = readl(&xhci->op_regs->command); in xhci_bus_resume()
1683 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_resume()
1689 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_get_resuming_ports() local
1692 bus_state = &xhci->bus_state[hcd_index(hcd)]; in xhci_get_resuming_ports()