Lines Matching +full:short +full:- +full:descriptor

5  * (C) Copyright Johannes Erdfelt 1999-2001
14 * Adapted for U-Boot:
17 * SPDX-License-Identifier: GPL-2.0+
67 return hdev->descriptor.bDeviceProtocol == 3; in usb_hub_is_superspeed()
73 if (device_get_uclass_id(hub->parent) != UCLASS_USB_HUB) in usb_hub_is_root_hub()
82 return -EINVAL; in usb_set_hub_depth()
92 unsigned short dtype = USB_DT_HUB; in usb_get_hub_descriptor()
137 * that U-Boot understands. Do this only when the hub is not root hub. in usb_get_port_status()
144 if (!usb_hub_is_root_hub(dev->dev) && usb_hub_is_superspeed(dev)) { in usb_get_port_status()
146 u16 tmp = (status->wPortStatus) & USB_SS_PORT_STAT_MASK; in usb_get_port_status()
148 if (status->wPortStatus & USB_SS_PORT_STAT_POWER) in usb_get_port_status()
150 if ((status->wPortStatus & USB_SS_PORT_STAT_SPEED) == in usb_get_port_status()
154 status->wPortStatus = tmp; in usb_get_port_status()
166 unsigned pgood_delay = hub->desc.bPwrOn2PwrGood * 2; in usb_hub_power_on()
169 dev = hub->pusb_dev; in usb_hub_power_on()
172 for (i = 0; i < dev->maxchild; i++) { in usb_hub_power_on()
174 debug("port %d returns %lX\n", i + 1, dev->status); in usb_hub_power_on()
188 * plus spec-defined max time for device to connect in usb_hub_power_on()
190 * devices break the spec and require longer warm-up times in usb_hub_power_on()
202 hub->query_delay = get_timer(0) + max(100, (int)pgood_delay); in usb_hub_power_on()
205 * Record the power-on timeout here. The max. delay (timeout) in usb_hub_power_on()
209 hub->connect_timeout = hub->query_delay + 1000; in usb_hub_power_on()
211 dev->devnum, max(100, (int)pgood_delay), in usb_hub_power_on()
223 /* Zero out global hub_dev in case its re-used again */ in usb_hub_reset()
262 * usb_hub_port_reset() - reset a port given its usb_device pointer
272 unsigned short *portstat) in usb_hub_port_reset()
276 unsigned short portstatus, portchange; in usb_hub_port_reset()
277 int delay = HUB_SHORT_RESET_TIME; /* start with short reset delay */ in usb_hub_port_reset()
280 debug("%s: resetting '%s' port %d...\n", __func__, dev->dev->name, in usb_hub_port_reset()
294 dev->status); in usb_hub_port_reset()
295 return -1; in usb_hub_port_reset()
297 portstatus = le16_to_cpu(portsts->wPortStatus); in usb_hub_port_reset()
298 portchange = le16_to_cpu(portsts->wPortChange); in usb_hub_port_reset()
311 * - C_CONNECTION hasn't been set. in usb_hub_port_reset()
312 * - CONNECTION is still set. in usb_hub_port_reset()
337 return -1; in usb_hub_port_reset()
348 unsigned short portstatus; in usb_hub_port_connect_change()
358 portstatus = le16_to_cpu(portsts->wPortStatus); in usb_hub_port_connect_change()
361 le16_to_cpu(portsts->wPortChange), in usb_hub_port_connect_change()
371 debug("usb_disconnect(&hub->children[port]);\n"); in usb_hub_port_connect_change()
374 return -ENOTCONN; in usb_hub_port_connect_change()
380 if (ret != -ENXIO) in usb_hub_port_connect_change()
403 ret = usb_scan_device(dev->dev, port + 1, speed, &child); in usb_hub_port_connect_change()
407 ret = usb_alloc_new_device(dev->controller, &usb); in usb_hub_port_connect_change()
413 dev->children[port] = usb; in usb_hub_port_connect_change()
414 usb->speed = speed; in usb_hub_port_connect_change()
415 usb->parent = dev; in usb_hub_port_connect_change()
416 usb->portnr = port + 1; in usb_hub_port_connect_change()
421 usb_free_device(dev->controller); in usb_hub_port_connect_change()
422 dev->children[port] = NULL; in usb_hub_port_connect_change()
436 unsigned short portstatus; in usb_scan_port()
437 unsigned short portchange; in usb_scan_port()
443 dev = usb_scan->dev; in usb_scan_port()
444 hub = usb_scan->hub; in usb_scan_port()
445 i = usb_scan->port; in usb_scan_port()
451 if (get_timer(0) < hub->query_delay) in usb_scan_port()
457 if (get_timer(0) >= hub->connect_timeout) { in usb_scan_port()
459 dev->devnum, i + 1); in usb_scan_port()
461 list_del(&usb_scan->list); in usb_scan_port()
468 portstatus = le16_to_cpu(portsts->wPortStatus); in usb_scan_port()
469 portchange = le16_to_cpu(portsts->wPortChange); in usb_scan_port()
481 if (get_timer(0) >= hub->connect_timeout) { in usb_scan_port()
483 dev->devnum, i + 1); in usb_scan_port()
485 list_del(&usb_scan->list); in usb_scan_port()
504 debug("devnum=%d port=%d: USB dev found\n", dev->devnum, i + 1); in usb_scan_port()
524 debug("already running port %i disabled by hub (EMI?), re-enabling...\n", in usb_scan_port()
537 debug("port %d over-current change\n", i + 1); in usb_scan_port()
540 /* Only power-on this one port */ in usb_scan_port()
542 hub->overcurrent_count[i]++; in usb_scan_port()
545 * If the max-scan-count is not reached, return without removing in usb_scan_port()
546 * the device from scan-list. This will re-issue a new scan. in usb_scan_port()
548 if (hub->overcurrent_count[i] <= in usb_scan_port()
553 printf("Port %d over-current occurred %d times\n", i + 1, in usb_scan_port()
554 hub->overcurrent_count[i]); in usb_scan_port()
561 list_del(&usb_scan->list); in usb_scan_port()
614 hub = dev_get_uclass_priv(dev->dev); in usb_get_hub_device()
625 short hubCharacteristics; in usb_hub_configure()
626 struct usb_hub_descriptor *descriptor; in usb_hub_configure() local
633 return -ENOMEM; in usb_hub_configure()
634 hub->pusb_dev = dev; in usb_hub_configure()
636 /* Get the the hub descriptor */ in usb_hub_configure()
640 "descriptor, giving up %lX\n", dev->status); in usb_hub_configure()
643 descriptor = (struct usb_hub_descriptor *)buffer; in usb_hub_configure()
645 length = min_t(int, descriptor->bLength, in usb_hub_configure()
651 "descriptor 2nd giving up %lX\n", dev->status); in usb_hub_configure()
654 memcpy((unsigned char *)&hub->desc, buffer, length); in usb_hub_configure()
657 &descriptor->wHubCharacteristics)), in usb_hub_configure()
658 &hub->desc.wHubCharacteristics); in usb_hub_configure()
660 bitmap = (unsigned char *)&hub->desc.u.hs.DeviceRemovable[0]; in usb_hub_configure()
663 bitmap = (unsigned char *)&hub->desc.u.hs.PortPowerCtrlMask[0]; in usb_hub_configure()
666 for (i = 0; i < ((hub->desc.bNbrPorts + 1 + 7)/8); i++) in usb_hub_configure()
667 hub->desc.u.hs.DeviceRemovable[i] = in usb_hub_configure()
668 descriptor->u.hs.DeviceRemovable[i]; in usb_hub_configure()
670 for (i = 0; i < ((hub->desc.bNbrPorts + 1 + 7)/8); i++) in usb_hub_configure()
671 hub->desc.u.hs.PortPowerCtrlMask[i] = in usb_hub_configure()
672 descriptor->u.hs.PortPowerCtrlMask[i]; in usb_hub_configure()
674 dev->maxchild = descriptor->bNbrPorts; in usb_hub_configure()
675 debug("%d ports detected\n", dev->maxchild); in usb_hub_configure()
677 hubCharacteristics = get_unaligned(&hub->desc.wHubCharacteristics); in usb_hub_configure()
698 debug("global over-current protection\n"); in usb_hub_configure()
701 debug("individual port over-current protection\n"); in usb_hub_configure()
705 debug("no over-current protection\n"); in usb_hub_configure()
709 switch (dev->descriptor.bDeviceProtocol) { in usb_hub_configure()
719 hub->tt.multi = true; in usb_hub_configure()
729 dev->descriptor.bDeviceProtocol); in usb_hub_configure()
736 if (dev->descriptor.bDeviceProtocol != 0) { in usb_hub_configure()
737 hub->tt.think_time = 666; in usb_hub_configure()
739 8, hub->tt.think_time); in usb_hub_configure()
743 hub->tt.think_time = 666 * 2; in usb_hub_configure()
745 16, hub->tt.think_time); in usb_hub_configure()
748 hub->tt.think_time = 666 * 3; in usb_hub_configure()
750 24, hub->tt.think_time); in usb_hub_configure()
753 hub->tt.think_time = 666 * 4; in usb_hub_configure()
755 32, hub->tt.think_time); in usb_hub_configure()
760 descriptor->bPwrOn2PwrGood * 2); in usb_hub_configure()
762 descriptor->bHubContrCurrent); in usb_hub_configure()
764 for (i = 0; i < dev->maxchild; i++) in usb_hub_configure()
766 hub->desc.u.hs.DeviceRemovable[(i + 1) / 8] & \ in usb_hub_configure()
770 debug("usb_hub_configure: failed to get Status - " \ in usb_hub_configure()
771 "too long: %d\n", descriptor->bLength); in usb_hub_configure()
772 return -EFBIG; in usb_hub_configure()
778 dev->status); in usb_hub_configure()
785 le16_to_cpu(hubsts->wHubStatus), in usb_hub_configure()
786 le16_to_cpu(hubsts->wHubChange)); in usb_hub_configure()
788 (le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_LOCAL_POWER) ? \ in usb_hub_configure()
790 debug("%sover-current condition exists\n", in usb_hub_configure()
791 (le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_OVERCURRENT) ? \ in usb_hub_configure()
797 * after the hub descriptor is fetched. in usb_hub_configure()
800 if (ret < 0 && ret != -ENOSYS) { in usb_hub_configure()
809 * USB device. USB 3.0 hubs use a 20-bit field called 'route string' in usb_hub_configure()
815 if (usb_hub_is_root_hub(dev->dev)) { in usb_hub_configure()
816 hub->hub_depth = -1; in usb_hub_configure()
821 hdev = dev->dev->parent; in usb_hub_configure()
824 hdev = hdev->parent; in usb_hub_configure()
827 hub->hub_depth = depth; in usb_hub_configure()
839 __func__, dev->status); in usb_hub_configure()
853 for (i = 0; i < dev->maxchild; i++) in usb_hub_configure()
863 for (i = 0; i < dev->maxchild; i++) { in usb_hub_configure()
869 return -ENOMEM; in usb_hub_configure()
871 usb_scan->dev = dev; in usb_hub_configure()
872 usb_scan->hub = hub; in usb_hub_configure()
873 usb_scan->port = i; in usb_hub_configure()
874 list_add_tail(&usb_scan->list, &usb_scan_list); in usb_hub_configure()
890 iface = &dev->config.if_desc[ifnum]; in usb_hub_check()
892 if (iface->desc.bInterfaceClass != USB_CLASS_HUB) in usb_hub_check()
896 if ((iface->desc.bInterfaceSubClass != 0) && in usb_hub_check()
897 (iface->desc.bInterfaceSubClass != 1)) in usb_hub_check()
899 /* Multiple endpoints? What kind of mutant ninja-hub is this? */ in usb_hub_check()
900 if (iface->desc.bNumEndpoints != 1) in usb_hub_check()
902 ep = &iface->ep_desc[0]; in usb_hub_check()
904 if (!(ep->bEndpointAddress & USB_DIR_IN)) in usb_hub_check()
907 if ((ep->bmAttributes & 3) != 3) in usb_hub_check()
915 iface->desc.bInterfaceClass, iface->desc.bInterfaceSubClass, in usb_hub_check()
916 iface->desc.bNumEndpoints); in usb_hub_check()
919 ep->bEndpointAddress, ep->bmAttributes); in usb_hub_check()
922 return -ENOENT; in usb_hub_check()
951 { .compatible = "usb-hub" },