ARM: renesas: Drop unused mmc.h
[pandora-u-boot.git] / common / usb_hub.c
index d736389..2e054eb 100644 (file)
@@ -47,7 +47,7 @@
 #define HUB_SHORT_RESET_TIME   20
 #define HUB_LONG_RESET_TIME    200
 
-#define HUB_DEBOUNCE_TIMEOUT   1000
+#define HUB_DEBOUNCE_TIMEOUT   CONFIG_USB_HUB_DEBOUNCE_TIMEOUT
 
 #define PORT_OVERCURRENT_MAX_SCAN_COUNT                3
 
@@ -168,14 +168,18 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
        int i;
        struct usb_device *dev;
        unsigned pgood_delay = hub->desc.bPwrOn2PwrGood * 2;
-       const char *env;
+       const char __maybe_unused *env;
 
        dev = hub->pusb_dev;
 
        debug("enabling power on all ports\n");
        for (i = 0; i < dev->maxchild; i++) {
+               if (usb_hub_is_superspeed(dev)) {
+                       usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_RESET);
+                       debug("Reset : port %d returns %lX\n", i + 1, dev->status);
+               }
                usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER);
-               debug("port %d returns %lX\n", i + 1, dev->status);
+               debug("PowerOn : port %d returns %lX\n", i + 1, dev->status);
        }
 
 #ifdef CONFIG_SANDBOX
@@ -193,10 +197,12 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
         * but allow this time to be increased via env variable as some
         * devices break the spec and require longer warm-up times
         */
+#if CONFIG_IS_ENABLED(ENV_SUPPORT)
        env = env_get("usb_pgood_delay");
        if (env)
                pgood_delay = max(pgood_delay,
                                  (unsigned)simple_strtol(env, NULL, 0));
+#endif
        debug("pgood_delay=%dms\n", pgood_delay);
 
        /*
@@ -393,6 +399,13 @@ int usb_hub_port_connect_change(struct usb_device *dev, int port)
                break;
        }
 
+       /*
+        * USB 2.0 7.1.7.5: devices must be able to accept a SetAddress()
+        * request (refer to Section 11.24.2 and Section 9.4 respectively)
+        * after the reset recovery time 10 ms
+        */
+       mdelay(10);
+
 #if CONFIG_IS_ENABLED(DM_USB)
        struct udevice *child;
 
@@ -504,11 +517,6 @@ static int usb_scan_port(struct usb_device_scan *usb_scan)
        if (portchange & USB_PORT_STAT_C_ENABLE) {
                debug("port %d enable change, status %x\n", i + 1, portstatus);
                usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_ENABLE);
-               /*
-                * The following hack causes a ghost device problem
-                * to Faraday EHCI
-                */
-#ifndef CONFIG_USB_EHCI_FARADAY
                /*
                 * EM interference sometimes causes bad shielded USB
                 * devices to be shutdown by the hub, this hack enables
@@ -521,7 +529,6 @@ static int usb_scan_port(struct usb_device_scan *usb_scan)
                              i + 1);
                        usb_hub_port_connect_change(dev, i);
                }
-#endif
        }
 
        if (portstatus & USB_PORT_STAT_SUSPEND) {