Lines Matching refs:xhci
63 static int xhci_create_usb3_bos_desc(struct xhci_hcd *xhci, char *buf, in xhci_create_usb3_bos_desc() argument
75 if (xhci->usb3_rhub.min_rev >= 0x01 && xhci->usb3_rhub.psi_uid_count) { in xhci_create_usb3_bos_desc()
77 ssa_count = xhci->usb3_rhub.psi_uid_count * 2; in xhci_create_usb3_bos_desc()
94 temp = readl(&xhci->cap_regs->hcc_params); in xhci_create_usb3_bos_desc()
99 if ((xhci->quirks & XHCI_LPM_SUPPORT)) { in xhci_create_usb3_bos_desc()
100 temp = readl(&xhci->cap_regs->hcs_params3); in xhci_create_usb3_bos_desc()
117 bm_attrib |= (xhci->usb3_rhub.psi_uid_count - 1) << 5; in xhci_create_usb3_bos_desc()
130 for (i = 0; i < xhci->usb3_rhub.psi_count; i++) { in xhci_create_usb3_bos_desc()
131 psi = xhci->usb3_rhub.psi[i]; in xhci_create_usb3_bos_desc()
154 static void xhci_common_hub_descriptor(struct xhci_hcd *xhci, in xhci_common_hub_descriptor() argument
165 if (HCC_PPC(xhci->hcc_params)) in xhci_common_hub_descriptor()
178 static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_usb2_hub_descriptor() argument
187 ports = xhci->num_usb2_ports; in xhci_usb2_hub_descriptor()
189 xhci_common_hub_descriptor(xhci, desc, ports); in xhci_usb2_hub_descriptor()
199 portsc = readl(xhci->usb2_ports[i]); in xhci_usb2_hub_descriptor()
231 static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_usb3_hub_descriptor() argument
239 ports = xhci->num_usb3_ports; in xhci_usb3_hub_descriptor()
240 xhci_common_hub_descriptor(xhci, desc, ports); in xhci_usb3_hub_descriptor()
253 portsc = readl(xhci->usb3_ports[i]); in xhci_usb3_hub_descriptor()
261 static void xhci_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_hub_descriptor() argument
266 xhci_usb3_hub_descriptor(hcd, xhci, desc); in xhci_hub_descriptor()
268 xhci_usb2_hub_descriptor(hcd, xhci, desc); in xhci_hub_descriptor()
342 int xhci_find_slot_id_by_port(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_find_slot_id_by_port() argument
351 if (!xhci->devs[i]) in xhci_find_slot_id_by_port()
353 speed = xhci->devs[i]->udev->speed; in xhci_find_slot_id_by_port()
355 && xhci->devs[i]->fake_port == port) { in xhci_find_slot_id_by_port()
370 static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend) in xhci_stop_device() argument
379 virt_dev = xhci->devs[slot_id]; in xhci_stop_device()
380 cmd = xhci_alloc_command(xhci, false, true, GFP_NOIO); in xhci_stop_device()
382 xhci_dbg(xhci, "Couldn't allocate command structure.\n"); in xhci_stop_device()
386 spin_lock_irqsave(&xhci->lock, flags); in xhci_stop_device()
390 command = xhci_alloc_command(xhci, false, false, in xhci_stop_device()
393 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_stop_device()
394 xhci_free_command(xhci, cmd); in xhci_stop_device()
398 xhci_queue_stop_endpoint(xhci, command, slot_id, i, in xhci_stop_device()
402 xhci_queue_stop_endpoint(xhci, cmd, slot_id, 0, suspend); in xhci_stop_device()
403 xhci_ring_cmd_db(xhci); in xhci_stop_device()
404 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_stop_device()
410 xhci_warn(xhci, "Timeout while waiting for stop endpoint command\n"); in xhci_stop_device()
413 xhci_free_command(xhci, cmd); in xhci_stop_device()
420 void xhci_ring_device(struct xhci_hcd *xhci, int slot_id) in xhci_ring_device() argument
426 ep = &xhci->devs[slot_id]->eps[i]; in xhci_ring_device()
430 xhci_ring_ep_doorbell(xhci, slot_id, i, s); in xhci_ring_device()
432 xhci_ring_ep_doorbell(xhci, slot_id, i, 0); in xhci_ring_device()
439 static void xhci_disable_port(struct usb_hcd *hcd, struct xhci_hcd *xhci, in xhci_disable_port() argument
444 xhci_dbg(xhci, "Ignoring request to disable " in xhci_disable_port()
452 xhci_dbg(xhci, "disable port, actual port %d status = 0x%x\n", in xhci_disable_port()
456 static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue, in xhci_clear_port_change_bit() argument
502 xhci_dbg(xhci, "clear port %s change, actual port %d status = 0x%x\n", in xhci_clear_port_change_bit()
509 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_get_ports() local
512 max_ports = xhci->num_usb3_ports; in xhci_get_ports()
513 *port_array = xhci->usb3_ports; in xhci_get_ports()
515 max_ports = xhci->num_usb2_ports; in xhci_get_ports()
516 *port_array = xhci->usb2_ports; in xhci_get_ports()
522 void xhci_set_link_state(struct xhci_hcd *xhci, __le32 __iomem **port_array, in xhci_set_link_state() argument
534 static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci, in xhci_set_remote_wake_mask() argument
561 void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array, in xhci_test_and_clear_bit() argument
582 static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci, in xhci_hub_report_usb3_link_state() argument
625 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && in xhci_hub_report_usb3_link_state()
641 static void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status, in xhci_del_comp_mod_timer() argument
644 u32 all_ports_seen_u0 = ((1 << xhci->num_usb3_ports)-1); in xhci_del_comp_mod_timer()
647 if (!(xhci->quirks & XHCI_COMP_MODE_QUIRK)) in xhci_del_comp_mod_timer()
650 if ((xhci->port_status_u0 != all_ports_seen_u0) && port_in_u0) { in xhci_del_comp_mod_timer()
651 xhci->port_status_u0 |= 1 << wIndex; in xhci_del_comp_mod_timer()
652 if (xhci->port_status_u0 == all_ports_seen_u0) { in xhci_del_comp_mod_timer()
653 del_timer_sync(&xhci->comp_mode_recovery_timer); in xhci_del_comp_mod_timer()
654 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_del_comp_mod_timer()
656 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_del_comp_mod_timer()
693 __releases(&xhci->lock) in xhci_get_port_status()
694 __acquires(&xhci->lock) in xhci_get_port_status()
696 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_get_port_status() local
762 xhci_dbg(xhci, "Resume USB2 port %d\n", in xhci_get_port_status()
768 xhci_set_link_state(xhci, port_array, wIndex, in xhci_get_port_status()
771 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_get_port_status()
776 spin_lock_irqsave(&xhci->lock, flags); in xhci_get_port_status()
780 xhci, wIndex + 1); in xhci_get_port_status()
782 xhci_dbg(xhci, "slot_id is zero\n"); in xhci_get_port_status()
785 xhci_ring_device(xhci, slot_id); in xhci_get_port_status()
788 xhci_warn(xhci, "Port resume took longer than %i msec, port status = 0x%x\n", in xhci_get_port_status()
848 xhci_hub_report_usb3_link_state(xhci, &status, raw_port_status); in xhci_get_port_status()
853 xhci_del_comp_mod_timer(xhci, raw_port_status, wIndex); in xhci_get_port_status()
866 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_hub_control() local
879 bus_state = &xhci->bus_state[hcd_index(hcd)]; in xhci_hub_control()
881 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
895 xhci_dbg(xhci, "Wrong hub descriptor type for " in xhci_hub_control()
899 xhci_hub_descriptor(hcd, xhci, in xhci_hub_control()
909 retval = xhci_create_usb3_bos_desc(xhci, buf, wLength); in xhci_hub_control()
910 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
926 xhci_dbg(xhci, "get port status, actual port %d status = 0x%x\n", in xhci_hub_control()
928 xhci_dbg(xhci, "Get port status returned 0x%x\n", status); in xhci_hub_control()
936 xhci_err(xhci, "get ext port status invalid parameter\n"); in xhci_hub_control()
968 xhci_set_link_state(xhci, port_array, wIndex, in xhci_hub_control()
970 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
972 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
981 xhci_warn(xhci, "USB core suspending device " in xhci_hub_control()
986 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_hub_control()
989 xhci_warn(xhci, "slot_id is zero\n"); in xhci_hub_control()
993 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
994 xhci_stop_device(xhci, slot_id, 1); in xhci_hub_control()
995 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
997 xhci_set_link_state(xhci, port_array, wIndex, XDEV_U3); in xhci_hub_control()
999 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1001 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1011 xhci_dbg(xhci, "Disable port %d\n", wIndex); in xhci_hub_control()
1027 xhci_dbg(xhci, "Enable port %d\n", wIndex); in xhci_hub_control()
1028 xhci_set_link_state(xhci, port_array, wIndex, in xhci_hub_control()
1040 xhci_warn(xhci, "Cannot set link state.\n"); in xhci_hub_control()
1045 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_hub_control()
1050 spin_unlock_irqrestore(&xhci->lock, in xhci_hub_control()
1052 xhci_stop_device(xhci, slot_id, 1); in xhci_hub_control()
1053 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1057 xhci_set_link_state(xhci, port_array, wIndex, in xhci_hub_control()
1060 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1062 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1078 xhci_dbg(xhci, "set port power, actual port %d status = 0x%x\n", wIndex, temp); in xhci_hub_control()
1080 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1086 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1093 xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); in xhci_hub_control()
1096 xhci_set_remote_wake_mask(xhci, port_array, in xhci_hub_control()
1099 xhci_dbg(xhci, "set port remote wake mask, " in xhci_hub_control()
1145 xhci_dbg(xhci, "clear USB_PORT_FEAT_SUSPEND\n"); in xhci_hub_control()
1146 xhci_dbg(xhci, "PORTSC %04x\n", temp); in xhci_hub_control()
1154 xhci_set_link_state(xhci, port_array, wIndex, in xhci_hub_control()
1156 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1158 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1159 xhci_set_link_state(xhci, port_array, wIndex, in xhci_hub_control()
1165 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_hub_control()
1168 xhci_dbg(xhci, "slot_id is zero\n"); in xhci_hub_control()
1171 xhci_ring_device(xhci, slot_id); in xhci_hub_control()
1182 xhci_clear_port_change_bit(xhci, wValue, wIndex, in xhci_hub_control()
1186 xhci_disable_port(hcd, xhci, wIndex, in xhci_hub_control()
1192 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1198 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_control()
1209 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_control()
1227 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_hub_status_data() local
1234 bus_state = &xhci->bus_state[hcd_index(hcd)]; in xhci_hub_status_data()
1248 spin_lock_irqsave(&xhci->lock, flags); in xhci_hub_status_data()
1267 xhci_dbg(xhci, "%s: stopping port polling.\n", __func__); in xhci_hub_status_data()
1270 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_hub_status_data()
1278 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_bus_suspend() local
1285 bus_state = &xhci->bus_state[hcd_index(hcd)]; in xhci_bus_suspend()
1287 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_suspend()
1292 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1293 xhci_dbg(xhci, "suspend failed because a port is resuming\n"); in xhci_bus_suspend()
1309 xhci_dbg(xhci, "port %d not suspended\n", port_index); in xhci_bus_suspend()
1310 slot_id = xhci_find_slot_id_by_port(hcd, xhci, in xhci_bus_suspend()
1313 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1314 xhci_stop_device(xhci, slot_id, 1); in xhci_bus_suspend()
1315 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_suspend()
1342 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_suspend()
1348 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_bus_resume() local
1360 bus_state = &xhci->bus_state[hcd_index(hcd)]; in xhci_bus_resume()
1365 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_resume()
1367 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_resume()
1372 temp = readl(&xhci->op_regs->command); in xhci_bus_resume()
1374 writel(temp, &xhci->op_regs->command); in xhci_bus_resume()
1391 xhci_set_link_state(xhci, port_array, in xhci_bus_resume()
1400 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_resume()
1402 spin_lock_irqsave(&xhci->lock, flags); in xhci_bus_resume()
1410 xhci_test_and_clear_bit(xhci, port_array, port_index, PORT_PLC); in xhci_bus_resume()
1411 xhci_set_link_state(xhci, port_array, port_index, XDEV_U0); in xhci_bus_resume()
1422 xhci_warn(xhci, "port %d resume PLC timeout\n", in xhci_bus_resume()
1424 xhci_test_and_clear_bit(xhci, port_array, port_index, PORT_PLC); in xhci_bus_resume()
1425 slot_id = xhci_find_slot_id_by_port(hcd, xhci, port_index + 1); in xhci_bus_resume()
1427 xhci_ring_device(xhci, slot_id); in xhci_bus_resume()
1430 (void) readl(&xhci->op_regs->command); in xhci_bus_resume()
1434 temp = readl(&xhci->op_regs->command); in xhci_bus_resume()
1436 writel(temp, &xhci->op_regs->command); in xhci_bus_resume()
1437 temp = readl(&xhci->op_regs->command); in xhci_bus_resume()
1439 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_bus_resume()