]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/usb_hub.c
Merge branch 'master' of git://git.denx.de/u-boot-arm
[karo-tx-uboot.git] / common / usb_hub.c
index ab419433f879f7cfe8304037986843e57f203cc1..0d79ec3ea84abfc8d61988cbfc30c8ba17cec60e 100644 (file)
@@ -105,19 +105,22 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
        int ret;
 
        dev = hub->pusb_dev;
-       /* Enable power to the ports */
+
+       /*
+        * Enable power to the ports:
+        * Here we Power-cycle the ports: aka,
+        * turning them off and turning on again.
+        */
        debug("enabling power on all ports\n");
        for (i = 0; i < dev->maxchild; i++) {
-               /*
-                * Power-cycle the ports here: aka,
-                * turning them off and turning on again.
-                */
                usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_POWER);
                debug("port %d returns %lX\n", i + 1, dev->status);
+       }
 
-               /* Wait at least 2*bPwrOn2PwrGood for PP to change */
-               mdelay(pgood_delay);
+       /* Wait at least 2*bPwrOn2PwrGood for PP to change */
+       mdelay(pgood_delay);
 
+       for (i = 0; i < dev->maxchild; i++) {
                ret = usb_get_port_status(dev, i + 1, portsts);
                if (ret < 0) {
                        debug("port %d: get_port_status failed\n", i + 1);
@@ -138,7 +141,9 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
                        debug("port %d: Port power change failed\n", i + 1);
                        return;
                }
+       }
 
+       for (i = 0; i < dev->maxchild; i++) {
                usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER);
                debug("port %d returns %lX\n", i + 1, dev->status);
        }
@@ -165,12 +170,24 @@ static struct usb_hub_device *usb_hub_allocate(void)
 
 static inline char *portspeed(int portstatus)
 {
-       if (portstatus & (1 << USB_PORT_FEAT_HIGHSPEED))
-               return "480 Mb/s";
-       else if (portstatus & (1 << USB_PORT_FEAT_LOWSPEED))
-               return "1.5 Mb/s";
-       else
-               return "12 Mb/s";
+       char *speed_str;
+
+       switch (portstatus & USB_PORT_STAT_SPEED_MASK) {
+       case USB_PORT_STAT_SUPER_SPEED:
+               speed_str = "5 Gb/s";
+               break;
+       case USB_PORT_STAT_HIGH_SPEED:
+               speed_str = "480 Mb/s";
+               break;
+       case USB_PORT_STAT_LOW_SPEED:
+               speed_str = "1.5 Mb/s";
+               break;
+       default:
+               speed_str = "12 Mb/s";
+               break;
+       }
+
+       return speed_str;
 }
 
 int hub_port_reset(struct usb_device *dev, int port,
@@ -268,12 +285,20 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port)
        /* Allocate a new device struct for it */
        usb = usb_alloc_new_device(dev->controller);
 
-       if (portstatus & USB_PORT_STAT_HIGH_SPEED)
+       switch (portstatus & USB_PORT_STAT_SPEED_MASK) {
+       case USB_PORT_STAT_SUPER_SPEED:
+               usb->speed = USB_SPEED_SUPER;
+               break;
+       case USB_PORT_STAT_HIGH_SPEED:
                usb->speed = USB_SPEED_HIGH;
-       else if (portstatus & USB_PORT_STAT_LOW_SPEED)
+               break;
+       case USB_PORT_STAT_LOW_SPEED:
                usb->speed = USB_SPEED_LOW;
-       else
+               break;
+       default:
                usb->speed = USB_SPEED_FULL;
+               break;
+       }
 
        dev->children[port] = usb;
        usb->parent = dev;