]> Git Repo - u-boot.git/blobdiff - common/usb_hub.c
spl: Move bloblist writing until the image is known
[u-boot.git] / common / usb_hub.c
index 9069f4b33aa191284f023fc67baf8af020067a47..85c0822d8b7ba55989ece166473b12400c3ba545 100644 (file)
 #include <common.h>
 #include <command.h>
 #include <dm.h>
+#include <env.h>
 #include <errno.h>
+#include <log.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <asm/processor.h>
 #include <asm/unaligned.h>
 #include <linux/ctype.h>
+#include <linux/delay.h>
 #include <linux/list.h>
 #include <asm/byteorder.h>
 #ifdef CONFIG_SANDBOX
@@ -43,6 +47,8 @@
 #define HUB_SHORT_RESET_TIME   20
 #define HUB_LONG_RESET_TIME    200
 
+#define HUB_DEBOUNCE_TIMEOUT   CONFIG_USB_HUB_DEBOUNCE_TIMEOUT
+
 #define PORT_OVERCURRENT_MAX_SCAN_COUNT                3
 
 struct usb_device_scan {
@@ -140,7 +146,8 @@ int usb_get_port_status(struct usb_device *dev, int port, void *data)
 
        if (!usb_hub_is_root_hub(dev->dev) && usb_hub_is_superspeed(dev)) {
                struct usb_port_status *status = (struct usb_port_status *)data;
-               u16 tmp = (status->wPortStatus) & USB_SS_PORT_STAT_MASK;
+               u16 tmp = le16_to_cpu(status->wPortStatus) &
+                       USB_SS_PORT_STAT_MASK;
 
                if (status->wPortStatus & USB_SS_PORT_STAT_POWER)
                        tmp |= USB_PORT_STAT_POWER;
@@ -148,7 +155,7 @@ int usb_get_port_status(struct usb_device *dev, int port, void *data)
                    USB_SS_PORT_STAT_SPEED_5GBPS)
                        tmp |= USB_PORT_STAT_SUPER_SPEED;
 
-               status->wPortStatus = tmp;
+               status->wPortStatus = cpu_to_le16(tmp);
        }
 #endif
 
@@ -161,7 +168,7 @@ 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;
 
@@ -186,10 +193,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);
 
        /*
@@ -203,10 +212,10 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
         * will be done based on this value in the USB port loop in
         * usb_hub_configure() later.
         */
-       hub->connect_timeout = hub->query_delay + 1000;
+       hub->connect_timeout = hub->query_delay + HUB_DEBOUNCE_TIMEOUT;
        debug("devnum=%d poweron: query_delay=%d connect_timeout=%d\n",
              dev->devnum, max(100, (int)pgood_delay),
-             max(100, (int)pgood_delay) + 1000);
+             max(100, (int)pgood_delay) + HUB_DEBOUNCE_TIMEOUT);
 }
 
 #if !CONFIG_IS_ENABLED(DM_USB)
@@ -497,11 +506,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
@@ -514,7 +518,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) {
@@ -954,9 +957,9 @@ UCLASS_DRIVER(usb_hub) = {
        .post_bind      = dm_scan_fdt_dev,
        .post_probe     = usb_hub_post_probe,
        .child_pre_probe        = usb_child_pre_probe,
-       .per_child_auto_alloc_size = sizeof(struct usb_device),
-       .per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata),
-       .per_device_auto_alloc_size = sizeof(struct usb_hub_device),
+       .per_child_auto = sizeof(struct usb_device),
+       .per_child_plat_auto    = sizeof(struct usb_dev_plat),
+       .per_device_auto        = sizeof(struct usb_hub_device),
 };
 
 static const struct usb_device_id hub_id_table[] = {
This page took 0.030138 seconds and 4 git commands to generate.