Lines Matching refs:hub
105 static inline char *portspeed(struct usb_hub *hub, int portstatus) in portspeed() argument
107 if (hub_is_superspeed(hub->hdev)) in portspeed()
173 struct usb_hub *hub, in usb_set_lpm_mel() argument
191 (hub->descriptor->u.ss.bHubHdrDecLat * 100); in usb_set_lpm_mel()
218 struct usb_hub *hub, in usb_set_lpm_pel() argument
294 struct usb_hub *hub; in usb_set_lpm_parameters() local
304 hub = usb_hub_to_struct_hub(udev->parent); in usb_set_lpm_parameters()
308 if (!hub) in usb_set_lpm_parameters()
317 hub, &udev->parent->u1_params, hub_u1_del); in usb_set_lpm_parameters()
320 hub, &udev->parent->u2_params, hub_u2_del); in usb_set_lpm_parameters()
342 hub, &udev->parent->u1_params, hub_u1_del, in usb_set_lpm_parameters()
351 hub, &udev->parent->u2_params, hub_u2_del, in usb_set_lpm_parameters()
433 static void set_port_led(struct usb_hub *hub, int port1, int selector) in set_port_led() argument
435 struct usb_port *port_dev = hub->ports[port1 - 1]; in set_port_led()
438 status = set_port_feature(hub->hdev, (selector << 8) | port1, in set_port_led()
448 struct usb_hub *hub = in led_work() local
450 struct usb_device *hdev = hub->hdev; in led_work()
455 if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing) in led_work()
463 switch (hub->indicator[i]) { in led_work()
502 set_port_led(hub, i + 1, selector); in led_work()
503 hub->indicator[i] = mode; in led_work()
508 set_port_led(hub, cursor + 1, HUB_LED_GREEN); in led_work()
509 hub->indicator[cursor] = INDICATOR_CYCLE; in led_work()
514 &hub->leds, LED_CYCLE_PERIOD); in led_work()
555 static int hub_port_status(struct usb_hub *hub, int port1, in hub_port_status() argument
560 mutex_lock(&hub->status_mutex); in hub_port_status()
561 ret = get_port_status(hub->hdev, port1, &hub->status->port); in hub_port_status()
564 dev_err(hub->intfdev, in hub_port_status()
569 *status = le16_to_cpu(hub->status->port.wPortStatus); in hub_port_status()
570 *change = le16_to_cpu(hub->status->port.wPortChange); in hub_port_status()
574 mutex_unlock(&hub->status_mutex); in hub_port_status()
578 static void kick_hub_wq(struct usb_hub *hub) in kick_hub_wq() argument
582 if (hub->disconnected || work_pending(&hub->events)) in kick_hub_wq()
593 intf = to_usb_interface(hub->intfdev); in kick_hub_wq()
595 kref_get(&hub->kref); in kick_hub_wq()
597 if (queue_work(hub_wq, &hub->events)) in kick_hub_wq()
602 kref_put(&hub->kref, hub_release); in kick_hub_wq()
607 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_kick_hub_wq() local
609 if (hub) in usb_kick_hub_wq()
610 kick_hub_wq(hub); in usb_kick_hub_wq()
624 struct usb_hub *hub; in usb_wakeup_notification() local
629 hub = usb_hub_to_struct_hub(hdev); in usb_wakeup_notification()
630 if (hub) { in usb_wakeup_notification()
631 set_bit(portnum, hub->wakeup_bits); in usb_wakeup_notification()
632 kick_hub_wq(hub); in usb_wakeup_notification()
640 struct usb_hub *hub = urb->context; in hub_irq() local
653 dev_dbg (hub->intfdev, "transfer --> %d\n", status); in hub_irq()
654 if ((++hub->nerrors < 10) || hub->error) in hub_irq()
656 hub->error = status; in hub_irq()
663 bits |= ((unsigned long) ((*hub->buffer)[i])) in hub_irq()
665 hub->event_bits[0] = bits; in hub_irq()
669 hub->nerrors = 0; in hub_irq()
672 kick_hub_wq(hub); in hub_irq()
675 if (hub->quiescing) in hub_irq()
678 if ((status = usb_submit_urb (hub->urb, GFP_ATOMIC)) != 0 in hub_irq()
680 dev_err (hub->intfdev, "resubmit --> %d\n", status); in hub_irq()
709 struct usb_hub *hub = in hub_tt_work() local
713 spin_lock_irqsave (&hub->tt.lock, flags); in hub_tt_work()
714 while (!list_empty(&hub->tt.clear_list)) { in hub_tt_work()
717 struct usb_device *hdev = hub->hdev; in hub_tt_work()
721 next = hub->tt.clear_list.next; in hub_tt_work()
726 spin_unlock_irqrestore (&hub->tt.lock, flags); in hub_tt_work()
739 spin_lock_irqsave(&hub->tt.lock, flags); in hub_tt_work()
741 spin_unlock_irqrestore (&hub->tt.lock, flags); in hub_tt_work()
756 int usb_hub_set_port_power(struct usb_device *hdev, struct usb_hub *hub, in usb_hub_set_port_power() argument
770 set_bit(port1, hub->power_bits); in usb_hub_set_port_power()
772 clear_bit(port1, hub->power_bits); in usb_hub_set_port_power()
831 static void hub_power_on(struct usb_hub *hub, bool do_delay) in hub_power_on() argument
841 if (hub_is_port_power_switchable(hub)) in hub_power_on()
842 dev_dbg(hub->intfdev, "enabling power on all ports\n"); in hub_power_on()
844 dev_dbg(hub->intfdev, "trying to enable port power on " in hub_power_on()
846 for (port1 = 1; port1 <= hub->hdev->maxchild; port1++) in hub_power_on()
847 if (test_bit(port1, hub->power_bits)) in hub_power_on()
848 set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); in hub_power_on()
850 usb_clear_port_feature(hub->hdev, port1, in hub_power_on()
853 msleep(hub_power_on_good_delay(hub)); in hub_power_on()
856 static int hub_hub_status(struct usb_hub *hub, in hub_hub_status() argument
861 mutex_lock(&hub->status_mutex); in hub_hub_status()
862 ret = get_hub_status(hub->hdev, &hub->status->hub); in hub_hub_status()
865 dev_err(hub->intfdev, in hub_hub_status()
868 *status = le16_to_cpu(hub->status->hub.wHubStatus); in hub_hub_status()
869 *change = le16_to_cpu(hub->status->hub.wHubChange); in hub_hub_status()
872 mutex_unlock(&hub->status_mutex); in hub_hub_status()
876 static int hub_set_port_link_state(struct usb_hub *hub, int port1, in hub_set_port_link_state() argument
879 return set_port_feature(hub->hdev, in hub_set_port_link_state()
894 static int hub_usb3_port_disable(struct usb_hub *hub, int port1) in hub_usb3_port_disable() argument
900 if (!hub_is_superspeed(hub->hdev)) in hub_usb3_port_disable()
903 ret = hub_port_status(hub, port1, &portstatus, &portchange); in hub_usb3_port_disable()
917 dev_dbg(&hub->ports[port1 - 1]->dev, in hub_usb3_port_disable()
922 ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED); in hub_usb3_port_disable()
928 ret = hub_port_status(hub, port1, &portstatus, &portchange); in hub_usb3_port_disable()
940 dev_warn(&hub->ports[port1 - 1]->dev, in hub_usb3_port_disable()
943 return hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_RX_DETECT); in hub_usb3_port_disable()
946 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) in hub_port_disable() argument
948 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_disable()
949 struct usb_device *hdev = hub->hdev; in hub_port_disable()
954 if (!hub->error) { in hub_port_disable()
955 if (hub_is_superspeed(hub->hdev)) in hub_port_disable()
956 ret = hub_usb3_port_disable(hub, port1); in hub_port_disable()
971 static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) in hub_port_logical_disconnect() argument
973 dev_dbg(&hub->ports[port1 - 1]->dev, "logical disconnect\n"); in hub_port_logical_disconnect()
974 hub_port_disable(hub, port1, 1); in hub_port_logical_disconnect()
985 set_bit(port1, hub->change_bits); in hub_port_logical_disconnect()
986 kick_hub_wq(hub); in hub_port_logical_disconnect()
1003 struct usb_hub *hub; in usb_remove_device() local
1008 hub = usb_hub_to_struct_hub(udev->parent); in usb_remove_device()
1009 intf = to_usb_interface(hub->intfdev); in usb_remove_device()
1012 set_bit(udev->portnum, hub->removed_bits); in usb_remove_device()
1013 hub_port_logical_disconnect(hub, udev->portnum); in usb_remove_device()
1026 static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) in hub_activate() argument
1028 struct usb_device *hdev = hub->hdev; in hub_activate()
1038 device_lock(hub->intfdev); in hub_activate()
1041 if (hub->disconnected) { in hub_activate()
1042 device_unlock(hub->intfdev); in hub_activate()
1043 kref_put(&hub->kref, hub_release); in hub_activate()
1050 kref_get(&hub->kref); in hub_activate()
1069 dev_err(hub->intfdev, in hub_activate()
1086 unsigned delay = hub_power_on_good_delay(hub); in hub_activate()
1088 hub_power_on(hub, false); in hub_activate()
1089 INIT_DELAYED_WORK(&hub->init_work, hub_init_func2); in hub_activate()
1091 &hub->init_work, in hub_activate()
1096 to_usb_interface(hub->intfdev)); in hub_activate()
1106 &hub->tt, GFP_NOIO); in hub_activate()
1108 dev_err(hub->intfdev, "Host not " in hub_activate()
1111 dev_err(hub->intfdev, "LS/FS devices " in hub_activate()
1116 hub_power_on(hub, true); in hub_activate()
1118 hub_power_on(hub, true); in hub_activate()
1128 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_activate()
1133 status = hub_port_status(hub, port1, &portstatus, &portchange); in hub_activate()
1164 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1169 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1174 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1178 hub_is_superspeed(hub->hdev)) { in hub_activate()
1180 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1188 clear_bit(port1, hub->removed_bits); in hub_activate()
1196 set_bit(port1, hub->change_bits); in hub_activate()
1210 if (portchange || (hub_is_superspeed(hub->hdev) && in hub_activate()
1212 set_bit(port1, hub->change_bits); in hub_activate()
1221 if (test_bit(port1, hub->power_bits)) in hub_activate()
1222 set_bit(port1, hub->change_bits); in hub_activate()
1227 set_bit(port1, hub->change_bits); in hub_activate()
1244 INIT_DELAYED_WORK(&hub->init_work, hub_init_func3); in hub_activate()
1246 &hub->init_work, in hub_activate()
1248 device_unlock(hub->intfdev); in hub_activate()
1255 hub->quiescing = 0; in hub_activate()
1257 status = usb_submit_urb(hub->urb, GFP_NOIO); in hub_activate()
1259 dev_err(hub->intfdev, "activate --> %d\n", status); in hub_activate()
1260 if (hub->has_indicators && blinkenlights) in hub_activate()
1262 &hub->leds, LED_CYCLE_PERIOD); in hub_activate()
1265 kick_hub_wq(hub); in hub_activate()
1269 usb_autopm_put_interface_async(to_usb_interface(hub->intfdev)); in hub_activate()
1272 device_unlock(hub->intfdev); in hub_activate()
1274 kref_put(&hub->kref, hub_release); in hub_activate()
1280 struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); in hub_init_func2() local
1282 hub_activate(hub, HUB_INIT2); in hub_init_func2()
1287 struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); in hub_init_func3() local
1289 hub_activate(hub, HUB_INIT3); in hub_init_func3()
1296 static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) in hub_quiesce() argument
1298 struct usb_device *hdev = hub->hdev; in hub_quiesce()
1301 cancel_delayed_work_sync(&hub->init_work); in hub_quiesce()
1304 hub->quiescing = 1; in hub_quiesce()
1309 if (hub->ports[i]->child) in hub_quiesce()
1310 usb_disconnect(&hub->ports[i]->child); in hub_quiesce()
1315 usb_kill_urb(hub->urb); in hub_quiesce()
1316 if (hub->has_indicators) in hub_quiesce()
1317 cancel_delayed_work_sync(&hub->leds); in hub_quiesce()
1318 if (hub->tt.hub) in hub_quiesce()
1319 flush_work(&hub->tt.clear_work); in hub_quiesce()
1322 static void hub_pm_barrier_for_all_ports(struct usb_hub *hub) in hub_pm_barrier_for_all_ports() argument
1326 for (i = 0; i < hub->hdev->maxchild; ++i) in hub_pm_barrier_for_all_ports()
1327 pm_runtime_barrier(&hub->ports[i]->dev); in hub_pm_barrier_for_all_ports()
1333 struct usb_hub *hub = usb_get_intfdata(intf); in hub_pre_reset() local
1335 hub_quiesce(hub, HUB_PRE_RESET); in hub_pre_reset()
1336 hub->in_reset = 1; in hub_pre_reset()
1337 hub_pm_barrier_for_all_ports(hub); in hub_pre_reset()
1344 struct usb_hub *hub = usb_get_intfdata(intf); in hub_post_reset() local
1346 hub->in_reset = 0; in hub_post_reset()
1347 hub_pm_barrier_for_all_ports(hub); in hub_post_reset()
1348 hub_activate(hub, HUB_POST_RESET); in hub_post_reset()
1352 static int hub_configure(struct usb_hub *hub, in hub_configure() argument
1356 struct usb_device *hdev = hub->hdev; in hub_configure()
1357 struct device *hub_dev = hub->intfdev; in hub_configure()
1367 hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL); in hub_configure()
1368 if (!hub->buffer) { in hub_configure()
1373 hub->status = kmalloc(sizeof(*hub->status), GFP_KERNEL); in hub_configure()
1374 if (!hub->status) { in hub_configure()
1378 mutex_init(&hub->status_mutex); in hub_configure()
1380 hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL); in hub_configure()
1381 if (!hub->descriptor) { in hub_configure()
1390 ret = get_hub_descriptor(hdev, hub->descriptor); in hub_configure()
1394 } else if (hub->descriptor->bNbrPorts > USB_MAXCHILDREN) { in hub_configure()
1398 } else if (hub->descriptor->bNbrPorts == 0) { in hub_configure()
1404 maxchild = hub->descriptor->bNbrPorts; in hub_configure()
1408 hub->ports = kzalloc(maxchild * sizeof(struct usb_port *), GFP_KERNEL); in hub_configure()
1409 if (!hub->ports) { in hub_configure()
1414 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); in hub_configure()
1430 portstr[i] = hub->descriptor->u.hs.DeviceRemovable in hub_configure()
1464 spin_lock_init (&hub->tt.lock); in hub_configure()
1465 INIT_LIST_HEAD (&hub->tt.clear_list); in hub_configure()
1466 INIT_WORK(&hub->tt.clear_work, hub_tt_work); in hub_configure()
1472 hub->tt.hub = hdev; in hub_configure()
1478 hub->tt.multi = 1; in hub_configure()
1482 hub->tt.hub = hdev; in hub_configure()
1497 hub->tt.think_time = 666; in hub_configure()
1500 8, hub->tt.think_time); in hub_configure()
1504 hub->tt.think_time = 666 * 2; in hub_configure()
1507 16, hub->tt.think_time); in hub_configure()
1510 hub->tt.think_time = 666 * 3; in hub_configure()
1513 24, hub->tt.think_time); in hub_configure()
1516 hub->tt.think_time = 666 * 4; in hub_configure()
1519 32, hub->tt.think_time); in hub_configure()
1525 hub->has_indicators = 1; in hub_configure()
1530 hub->descriptor->bPwrOn2PwrGood * 2); in hub_configure()
1547 hub->mA_per_port = full_load; in hub_configure()
1549 hub->mA_per_port = hdev->bus_mA; in hub_configure()
1550 hub->limited_power = 1; in hub_configure()
1554 hub->descriptor->bHubContrCurrent; in hub_configure()
1557 hub->descriptor->bHubContrCurrent); in hub_configure()
1558 hub->limited_power = 1; in hub_configure()
1564 hub->mA_per_port = unit_load; /* 7.2.1 */ in hub_configure()
1569 hub->mA_per_port = full_load; in hub_configure()
1571 if (hub->mA_per_port < full_load) in hub_configure()
1573 hub->mA_per_port); in hub_configure()
1575 ret = hub_hub_status(hub, &hubstatus, &hubchange); in hub_configure()
1600 if (maxp > sizeof(*hub->buffer)) in hub_configure()
1601 maxp = sizeof(*hub->buffer); in hub_configure()
1603 hub->urb = usb_alloc_urb(0, GFP_KERNEL); in hub_configure()
1604 if (!hub->urb) { in hub_configure()
1609 usb_fill_int_urb(hub->urb, hdev, pipe, *hub->buffer, maxp, hub_irq, in hub_configure()
1610 hub, endpoint->bInterval); in hub_configure()
1613 if (hub->has_indicators && blinkenlights) in hub_configure()
1614 hub->indicator[0] = INDICATOR_CYCLE; in hub_configure()
1618 ret = usb_hub_create_port_device(hub, i + 1); in hub_configure()
1620 dev_err(hub->intfdev, in hub_configure()
1627 struct usb_port *port_dev = hub->ports[i]; in hub_configure()
1641 &hub->tt, GFP_KERNEL); in hub_configure()
1648 usb_hub_adjust_deviceremovable(hdev, hub->descriptor); in hub_configure()
1650 hub_activate(hub, HUB_INIT); in hub_configure()
1662 struct usb_hub *hub = container_of(kref, struct usb_hub, kref); in hub_release() local
1664 usb_put_dev(hub->hdev); in hub_release()
1665 usb_put_intf(to_usb_interface(hub->intfdev)); in hub_release()
1666 kfree(hub); in hub_release()
1673 struct usb_hub *hub = usb_get_intfdata(intf); in hub_disconnect() local
1681 hub->disconnected = 1; in hub_disconnect()
1684 hub->error = 0; in hub_disconnect()
1685 hub_quiesce(hub, HUB_DISCONNECT); in hub_disconnect()
1697 usb_hub_remove_port_device(hub, port1); in hub_disconnect()
1701 if (hub->hdev->speed == USB_SPEED_HIGH) in hub_disconnect()
1704 usb_free_urb(hub->urb); in hub_disconnect()
1705 kfree(hub->ports); in hub_disconnect()
1706 kfree(hub->descriptor); in hub_disconnect()
1707 kfree(hub->status); in hub_disconnect()
1708 kfree(hub->buffer); in hub_disconnect()
1711 kref_put(&hub->kref, hub_release); in hub_disconnect()
1719 struct usb_hub *hub; in hub_probe() local
1814 hub = kzalloc(sizeof(*hub), GFP_KERNEL); in hub_probe()
1815 if (!hub) { in hub_probe()
1820 kref_init(&hub->kref); in hub_probe()
1821 hub->intfdev = &intf->dev; in hub_probe()
1822 hub->hdev = hdev; in hub_probe()
1823 INIT_DELAYED_WORK(&hub->leds, led_work); in hub_probe()
1824 INIT_DELAYED_WORK(&hub->init_work, NULL); in hub_probe()
1825 INIT_WORK(&hub->events, hub_event); in hub_probe()
1829 usb_set_intfdata (intf, hub); in hub_probe()
1837 hub->quirk_check_port_auto_suspend = 1; in hub_probe()
1839 if (hub_configure(hub, endpoint) >= 0) in hub_probe()
1850 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in hub_ioctl() local
1864 if (hub->ports[i]->child == NULL) in hub_ioctl()
1868 hub->ports[i]->child->devnum; in hub_ioctl()
1888 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in find_port_owner() local
1898 *ppowner = &(hub->ports[port1 - 1]->port_owner); in find_port_owner()
1937 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_release_all_ports() local
1941 if (hub->ports[n]->port_owner == owner) in usb_hub_release_all_ports()
1942 hub->ports[n]->port_owner = NULL; in usb_hub_release_all_ports()
1950 struct usb_hub *hub; in usb_device_is_owned() local
1954 hub = usb_hub_to_struct_hub(udev->parent); in usb_device_is_owned()
1955 return !!hub->ports[udev->portnum - 1]->port_owner; in usb_device_is_owned()
1960 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in recursively_mark_NOTATTACHED() local
1964 if (hub->ports[i]->child) in recursively_mark_NOTATTACHED()
1965 recursively_mark_NOTATTACHED(hub->ports[i]->child); in recursively_mark_NOTATTACHED()
2116 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in hub_disconnect_children() local
2121 if (hub->ports[i]->child) in hub_disconnect_children()
2122 usb_disconnect(&hub->ports[i]->child); in hub_disconnect_children()
2146 struct usb_hub *hub = NULL; in usb_disconnect() local
2171 hub = usb_hub_to_struct_hub(udev->parent); in usb_disconnect()
2172 port_dev = hub->ports[port1 - 1]; in usb_disconnect()
2181 if (!test_and_set_bit(port1, hub->child_usage_bits)) in usb_disconnect()
2204 if (port_dev && test_and_clear_bit(port1, hub->child_usage_bits)) in usb_disconnect()
2363 struct usb_hub *hub; in set_usb_port_removable() local
2371 hub = usb_hub_to_struct_hub(udev->parent); in set_usb_port_removable()
2373 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); in set_usb_port_removable()
2379 if (le16_to_cpu(hub->descriptor->u.ss.DeviceRemovable) in set_usb_port_removable()
2383 if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8))) in set_usb_port_removable()
2397 switch (hub->ports[udev->portnum - 1]->connect_type) { in set_usb_port_removable()
2492 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_new_device() local
2494 struct usb_port *port_dev = hub->ports[port1 - 1]; in usb_new_device()
2508 if (!test_and_set_bit(port1, hub->child_usage_bits)) in usb_new_device()
2602 static unsigned hub_is_wusb(struct usb_hub *hub) in hub_is_wusb() argument
2605 if (hub->hdev->parent != NULL) /* not a root hub? */ in hub_is_wusb()
2607 hcd = container_of(hub->hdev->bus, struct usb_hcd, self); in hub_is_wusb()
2642 static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1, in hub_port_warm_reset_required() argument
2647 if (!hub_is_superspeed(hub->hdev)) in hub_port_warm_reset_required()
2650 if (test_bit(port1, hub->warm_reset_bits)) in hub_port_warm_reset_required()
2658 static int hub_port_wait_reset(struct usb_hub *hub, int port1, in hub_port_wait_reset() argument
2672 ret = hub_port_status(hub, port1, &portstatus, &portchange); in hub_port_wait_reset()
2684 dev_dbg(&hub->ports[port1 - 1]->dev, in hub_port_wait_reset()
2692 if (hub_port_warm_reset_required(hub, port1, portstatus)) in hub_port_wait_reset()
2703 if (!hub_is_superspeed(hub->hdev) && in hub_port_wait_reset()
2713 if (hub_is_wusb(hub)) in hub_port_wait_reset()
2715 else if (hub_is_superspeed(hub->hdev)) in hub_port_wait_reset()
2727 static int hub_port_reset(struct usb_hub *hub, int port1, in hub_port_reset() argument
2732 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_reset()
2734 if (!hub_is_superspeed(hub->hdev)) { in hub_port_reset()
2736 dev_err(hub->intfdev, "only USB3 hub support " in hub_port_reset()
2749 if (hub_port_status(hub, port1, &portstatus, &portchange) == 0) in hub_port_reset()
2750 if (hub_port_warm_reset_required(hub, port1, in hub_port_reset()
2754 clear_bit(port1, hub->warm_reset_bits); in hub_port_reset()
2758 status = set_port_feature(hub->hdev, port1, (warm ? in hub_port_reset()
2768 status = hub_port_wait_reset(hub, port1, udev, delay, in hub_port_reset()
2771 dev_dbg(hub->intfdev, in hub_port_reset()
2778 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2781 if (!hub_is_superspeed(hub->hdev)) in hub_port_reset()
2784 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2786 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2788 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2795 if (hub_port_status(hub, port1, in hub_port_reset()
2799 if (!hub_port_warm_reset_required(hub, port1, in hub_port_reset()
2843 if (!hub_is_superspeed(hub->hdev)) in hub_port_reset()
2850 static int port_is_power_on(struct usb_hub *hub, unsigned portstatus) in port_is_power_on() argument
2854 if (hub_is_superspeed(hub->hdev)) { in port_is_power_on()
2882 static int port_is_suspended(struct usb_hub *hub, unsigned portstatus) in port_is_suspended() argument
2886 if (hub_is_superspeed(hub->hdev)) { in port_is_suspended()
2902 struct usb_hub *hub, int port1, in check_port_resume_type() argument
2905 struct usb_port *port_dev = hub->ports[port1 - 1]; in check_port_resume_type()
2911 && hub_port_warm_reset_required(hub, port1, portstatus)) { in check_port_resume_type()
2915 else if (status || port_is_suspended(hub, portstatus) || in check_port_resume_type()
2916 !port_is_power_on(hub, portstatus)) { in check_port_resume_type()
2922 status = hub_port_status(hub, port1, &portstatus, in check_port_resume_type()
2946 usb_clear_port_feature(hub->hdev, port1, in check_port_resume_type()
2949 usb_clear_port_feature(hub->hdev, port1, in check_port_resume_type()
3053 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in wakeup_enabled_descendants() local
3056 (hub ? hub->wakeup_enabled_descendants : 0); in wakeup_enabled_descendants()
3109 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_port_suspend() local
3110 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; in usb_port_suspend()
3152 if (hub_is_superspeed(hub->hdev)) in usb_port_suspend()
3153 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U3); in usb_port_suspend()
3167 status = set_port_feature(hub->hdev, port1, in usb_port_suspend()
3206 && test_and_clear_bit(port1, hub->child_usage_bits)) in usb_port_suspend()
3209 usb_mark_last_busy(hub->hdev); in usb_port_suspend()
3331 struct usb_hub *hub, int *port1, in wait_for_ss_port_enable() argument
3341 status = hub_port_status(hub, *port1, portstatus, portchange); in wait_for_ss_port_enable()
3382 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_port_resume() local
3383 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; in usb_port_resume()
3388 if (!test_and_set_bit(port1, hub->child_usage_bits)) { in usb_port_resume()
3400 status = hub_port_status(hub, port1, &portstatus, &portchange); in usb_port_resume()
3401 if (status == 0 && !port_is_suspended(hub, portstatus)) in usb_port_resume()
3405 if (hub_is_superspeed(hub->hdev)) in usb_port_resume()
3406 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U0); in usb_port_resume()
3408 status = usb_clear_port_feature(hub->hdev, in usb_port_resume()
3422 status = hub_port_status(hub, port1, &portstatus, &portchange); in usb_port_resume()
3431 if (hub_is_superspeed(hub->hdev)) { in usb_port_resume()
3433 usb_clear_port_feature(hub->hdev, port1, in usb_port_resume()
3437 usb_clear_port_feature(hub->hdev, port1, in usb_port_resume()
3442 if (udev->persist_enabled && hub_is_superspeed(hub->hdev)) in usb_port_resume()
3443 status = wait_for_ss_port_enable(udev, hub, &port1, &portchange, in usb_port_resume()
3447 hub, port1, status, portchange, portstatus); in usb_port_resume()
3452 hub_port_logical_disconnect(hub, port1); in usb_port_resume()
3486 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, in hub_handle_remote_wakeup() argument
3490 struct usb_port *port_dev = hub->ports[port - 1]; in hub_handle_remote_wakeup()
3496 hdev = hub->hdev; in hub_handle_remote_wakeup()
3520 hub_port_disable(hub, port, 1); in hub_handle_remote_wakeup()
3526 static int check_ports_changed(struct usb_hub *hub) in check_ports_changed() argument
3530 for (port1 = 1; port1 <= hub->hdev->maxchild; ++port1) { in check_ports_changed()
3534 status = hub_port_status(hub, port1, &portstatus, &portchange); in check_ports_changed()
3543 struct usb_hub *hub = usb_get_intfdata (intf); in hub_suspend() local
3544 struct usb_device *hdev = hub->hdev; in hub_suspend()
3552 hub->wakeup_enabled_descendants = 0; in hub_suspend()
3554 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_suspend()
3564 hub->wakeup_enabled_descendants += in hub_suspend()
3568 if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) { in hub_suspend()
3570 if (check_ports_changed(hub)) { in hub_suspend()
3592 hub_quiesce(hub, HUB_SUSPEND); in hub_suspend()
3598 struct usb_hub *hub = usb_get_intfdata(intf); in hub_resume() local
3601 hub_activate(hub, HUB_RESUME); in hub_resume()
3607 struct usb_hub *hub = usb_get_intfdata(intf); in hub_reset_resume() local
3610 hub_activate(hub, HUB_RESET_RESUME); in hub_reset_resume()
4075 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, in hub_handle_remote_wakeup() argument
4099 int hub_port_debounce(struct usb_hub *hub, int port1, bool must_be_connected) in hub_port_debounce() argument
4105 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_debounce()
4108 ret = hub_port_status(hub, port1, &portstatus, &portchange); in hub_port_debounce()
4125 usb_clear_port_feature(hub->hdev, port1, in hub_port_debounce()
4194 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in hub_set_initial_usb2_lpm_policy() local
4200 if (hub) in hub_set_initial_usb2_lpm_policy()
4201 connect_type = hub->ports[udev->portnum - 1]->connect_type; in hub_set_initial_usb2_lpm_policy()
4235 hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, in hub_port_init() argument
4238 struct usb_device *hdev = hub->hdev; in hub_port_init()
4264 retval = hub_port_reset(hub, port1, udev, delay, false); in hub_port_init()
4321 if (!hub->tt.hub) { in hub_port_init()
4326 udev->tt = &hub->tt; in hub_port_init()
4402 retval = hub_port_reset(hub, port1, udev, delay, false); in hub_port_init()
4486 hub_port_reset(hub, port1, udev, in hub_port_init()
4539 hub_port_disable(hub, port1, 0); in hub_port_init()
4547 check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1) in check_highspeed() argument
4565 if (hub->has_indicators) { in check_highspeed()
4566 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK; in check_highspeed()
4568 &hub->leds, 0); in check_highspeed()
4575 hub_power_remaining (struct usb_hub *hub) in hub_power_remaining() argument
4577 struct usb_device *hdev = hub->hdev; in hub_power_remaining()
4581 if (!hub->limited_power) in hub_power_remaining()
4584 remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent; in hub_power_remaining()
4586 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_power_remaining()
4608 if (delta > hub->mA_per_port) in hub_power_remaining()
4610 delta, hub->mA_per_port); in hub_power_remaining()
4614 dev_warn(hub->intfdev, "%dmA over power budget!\n", in hub_power_remaining()
4621 static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, in hub_port_connect() argument
4626 struct usb_device *hdev = hub->hdev; in hub_port_connect()
4628 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_connect()
4644 clear_bit(port1, hub->removed_bits); in hub_port_connect()
4648 status = hub_port_debounce_be_stable(hub, port1); in hub_port_connect()
4665 test_bit(port1, hub->removed_bits)) { in hub_port_connect()
4671 if (hub_is_port_power_switchable(hub) in hub_port_connect()
4672 && !port_is_power_on(hub, portstatus) in hub_port_connect()
4680 if (hub_is_superspeed(hub->hdev)) in hub_port_connect()
4699 udev->bus_mA = hub->mA_per_port; in hub_port_connect()
4701 udev->wusb = hub_is_wusb(hub); in hub_port_connect()
4704 if (hub_is_superspeed(hub->hdev)) in hub_port_connect()
4717 status = hub_port_init(hub, udev, port1, i); in hub_port_connect()
4745 if (hub->has_indicators) { in hub_port_connect()
4746 hub->indicator[port1-1] = in hub_port_connect()
4750 &hub->leds, 0); in hub_port_connect()
4761 check_highspeed (hub, udev, port1); in hub_port_connect()
4802 status = hub_power_remaining(hub); in hub_port_connect()
4804 dev_dbg(hub->intfdev, "%dmA power budget left\n", status); in hub_port_connect()
4809 hub_port_disable(hub, port1, 1); in hub_port_connect()
4818 if (hub->hdev->parent || in hub_port_connect()
4827 hub_port_disable(hub, port1, 1); in hub_port_connect()
4828 if (hcd->driver->relinquish_port && !hub->hdev->parent) in hub_port_connect()
4841 static void hub_port_connect_change(struct usb_hub *hub, int port1, in hub_port_connect_change() argument
4845 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_connect_change()
4850 portchange, portspeed(hub, portstatus)); in hub_port_connect_change()
4852 if (hub->has_indicators) { in hub_port_connect_change()
4853 set_port_led(hub, port1, HUB_LED_AUTO); in hub_port_connect_change()
4854 hub->indicator[port1-1] = INDICATOR_AUTO; in hub_port_connect_change()
4859 if (hub->hdev->bus->is_b_host) in hub_port_connect_change()
4883 clear_bit(port1, hub->change_bits); in hub_port_connect_change()
4890 hub_port_connect(hub, port1, portstatus, portchange); in hub_port_connect_change()
4894 static void port_event(struct usb_hub *hub, int port1) in port_event() argument
4898 struct usb_port *port_dev = hub->ports[port1 - 1]; in port_event()
4900 struct usb_device *hdev = hub->hdev; in port_event()
4903 connect_change = test_bit(port1, hub->change_bits); in port_event()
4904 clear_bit(port1, hub->event_bits); in port_event()
4905 clear_bit(port1, hub->wakeup_bits); in port_event()
4907 if (hub_port_status(hub, port1, &portstatus, &portchange) < 0) in port_event()
4940 hub_power_on(hub, true); in port_event()
4941 hub_port_status(hub, port1, &status, &unused); in port_event()
4971 if (hub_handle_remote_wakeup(hub, port1, portstatus, portchange)) in port_event()
4978 if (hub_port_warm_reset_required(hub, port1, portstatus)) { in port_event()
4982 if (hub_port_reset(hub, port1, NULL, in port_event()
4984 hub_port_disable(hub, port1, 1); in port_event()
4996 hub_port_connect_change(hub, port1, portstatus, portchange); in port_event()
5003 struct usb_hub *hub; in hub_event() local
5009 hub = container_of(work, struct usb_hub, events); in hub_event()
5010 hdev = hub->hdev; in hub_event()
5011 hub_dev = hub->intfdev; in hub_event()
5017 (u16) hub->change_bits[0], in hub_event()
5018 (u16) hub->event_bits[0]); in hub_event()
5023 if (unlikely(hub->disconnected)) in hub_event()
5028 hub->error = -ENODEV; in hub_event()
5029 hub_quiesce(hub, HUB_DISCONNECT); in hub_event()
5041 if (hub->quiescing) in hub_event()
5044 if (hub->error) { in hub_event()
5045 dev_dbg(hub_dev, "resetting for error %d\n", hub->error); in hub_event()
5053 hub->nerrors = 0; in hub_event()
5054 hub->error = 0; in hub_event()
5059 struct usb_port *port_dev = hub->ports[i - 1]; in hub_event()
5061 if (test_bit(i, hub->event_bits) in hub_event()
5062 || test_bit(i, hub->change_bits) in hub_event()
5063 || test_bit(i, hub->wakeup_bits)) { in hub_event()
5076 port_event(hub, i); in hub_event()
5083 if (test_and_clear_bit(0, hub->event_bits) == 0) in hub_event()
5085 else if (hub_hub_status(hub, &hubstatus, &hubchange) < 0) in hub_event()
5093 hub->limited_power = 1; in hub_event()
5095 hub->limited_power = 0; in hub_event()
5104 hub_power_on(hub, true); in hub_event()
5105 hub_hub_status(hub, &status, &unused); in hub_event()
5119 kref_put(&hub->kref, hub_release); in hub_event()
5489 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_reset_device() local
5504 port_dev = hub->ports[udev->portnum - 1]; in usb_reset_device()
5621 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_find_child() local
5625 return hub->ports[port1 - 1]->child; in usb_hub_find_child()
5632 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_adjust_deviceremovable() local
5636 if (!hub) in usb_hub_adjust_deviceremovable()
5641 struct usb_port *port_dev = hub->ports[i - 1]; in usb_hub_adjust_deviceremovable()
5657 struct usb_port *port_dev = hub->ports[i - 1]; in usb_hub_adjust_deviceremovable()
5686 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_get_hub_port_acpi_handle() local
5688 if (!hub) in usb_get_hub_port_acpi_handle()
5691 return ACPI_HANDLE(&hub->ports[port1 - 1]->dev); in usb_get_hub_port_acpi_handle()