usb: dwc2: Simplify wait_for_chhltd(), remove ignore_ack
[oweals/u-boot.git] / drivers / usb / host / ehci-hcd.c
index 88b670b7f8a76511fdc7c127e685b4c99b004270..c664b1629e090cc68975cb9d392aa2846fa3cd2e 100644 (file)
@@ -15,6 +15,7 @@
 #include <usb.h>
 #include <asm/io.h>
 #include <malloc.h>
+#include <memalign.h>
 #include <watchdog.h>
 #include <linux/compiler.h>
 
@@ -278,56 +279,16 @@ static inline u8 ehci_encode_speed(enum usb_device_speed speed)
 static void ehci_update_endpt2_dev_n_port(struct usb_device *udev,
                                          struct QH *qh)
 {
-       struct usb_device *ttdev;
-       int parent_devnum;
+       uint8_t portnr = 0;
+       uint8_t hubaddr = 0;
 
        if (udev->speed != USB_SPEED_LOW && udev->speed != USB_SPEED_FULL)
                return;
 
-       /*
-        * For full / low speed devices we need to get the devnum and portnr of
-        * the tt, so of the first upstream usb-2 hub, there may be usb-1 hubs
-        * in the tree before that one!
-        */
-#ifdef CONFIG_DM_USB
-       /*
-        * When called from usb-uclass.c: usb_scan_device() udev->dev points
-        * to the parent udevice, not the actual udevice belonging to the
-        * udev as the device is not instantiated yet. So when searching
-        * for the first usb-2 parent start with udev->dev not
-        * udev->dev->parent .
-        */
-       struct udevice *parent;
-       struct usb_device *uparent;
-
-       ttdev = udev;
-       parent = udev->dev;
-       uparent = dev_get_parentdata(parent);
-
-       while (uparent->speed != USB_SPEED_HIGH) {
-               struct udevice *dev = parent;
-
-               if (device_get_uclass_id(dev->parent) != UCLASS_USB_HUB) {
-                       printf("ehci: Error cannot find high-speed parent of usb-1 device\n");
-                       return;
-               }
-
-               ttdev = dev_get_parentdata(dev);
-               parent = dev->parent;
-               uparent = dev_get_parentdata(parent);
-       }
-       parent_devnum = uparent->devnum;
-#else
-       ttdev = udev;
-       while (ttdev->parent && ttdev->parent->speed != USB_SPEED_HIGH)
-               ttdev = ttdev->parent;
-       if (!ttdev->parent)
-               return;
-       parent_devnum = ttdev->parent->devnum;
-#endif
+       usb_find_usb2_hub_address_port(udev, &hubaddr, &portnr);
 
-       qh->qh_endpt2 |= cpu_to_hc32(QH_ENDPT2_PORTNUM(ttdev->portnr) |
-                                    QH_ENDPT2_HUBADDR(parent_devnum));
+       qh->qh_endpt2 |= cpu_to_hc32(QH_ENDPT2_PORTNUM(portnr) |
+                                    QH_ENDPT2_HUBADDR(hubaddr));
 }
 
 static int