]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/usb.c
powerpc: remove 4xx support
[people/ms/u-boot.git] / common / usb.c
index c7b8b0ee5a8d7b1f0e00455e04bf6a797a9f7f8c..0904259757371a25b2cb25f2d1189b6a53a43d17 100644 (file)
@@ -37,9 +37,6 @@
 #include <asm/unaligned.h>
 #include <errno.h>
 #include <usb.h>
-#ifdef CONFIG_4xx
-#include <asm/4xx_pci.h>
-#endif
 
 #define USB_BUFSIZ     512
 
@@ -210,7 +207,7 @@ int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe,
  * clear keyboards LEDs). For data transfers, (storage transfers) we don't
  * allow control messages with 0 timeout, by previousely resetting the flag
  * asynch_allowed (usb_disable_asynch(1)).
- * returns the transfered length if OK or -1 if error. The transfered length
+ * returns the transferred length if OK or -1 if error. The transferred length
  * and the current status are stored in the dev->act_len and dev->status.
  */
 int usb_control_msg(struct usb_device *dev, unsigned int pipe,
@@ -557,12 +554,10 @@ int usb_clear_halt(struct usb_device *dev, int pipe)
 static int usb_get_descriptor(struct usb_device *dev, unsigned char type,
                        unsigned char index, void *buf, int size)
 {
-       int res;
-       res = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
-                       USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
-                       (type << 8) + index, 0,
-                       buf, size, USB_CNTL_TIMEOUT);
-       return res;
+       return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+                              USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
+                              (type << 8) + index, 0, buf, size,
+                              USB_CNTL_TIMEOUT);
 }
 
 /**********************************************************************
@@ -612,14 +607,10 @@ int usb_get_configuration_no(struct usb_device *dev, int cfgno,
  */
 static int usb_set_address(struct usb_device *dev)
 {
-       int res;
-
        debug("set address %d\n", dev->devnum);
-       res = usb_control_msg(dev, usb_snddefctrl(dev),
-                               USB_REQ_SET_ADDRESS, 0,
-                               (dev->devnum), 0,
-                               NULL, 0, USB_CNTL_TIMEOUT);
-       return res;
+
+       return usb_control_msg(dev, usb_snddefctrl(dev), USB_REQ_SET_ADDRESS,
+                              0, (dev->devnum), 0, NULL, 0, USB_CNTL_TIMEOUT);
 }
 
 /********************************************************************
@@ -919,19 +910,8 @@ __weak int usb_alloc_device(struct usb_device *udev)
 
 static int usb_hub_port_reset(struct usb_device *dev, struct usb_device *hub)
 {
-       if (hub) {
-               unsigned short portstatus;
-               int err;
-
-               /* reset the port for the second time */
-               err = legacy_hub_port_reset(hub, dev->portnr - 1, &portstatus);
-               if (err < 0) {
-                       printf("\n     Couldn't reset port %i\n", dev->portnr);
-                       return err;
-               }
-       } else {
+       if (!hub)
                usb_reset_root_port(dev);
-       }
 
        return 0;
 }
@@ -1075,7 +1055,7 @@ static int usb_prepare_device(struct usb_device *dev, int addr, bool do_read,
 
 int usb_select_config(struct usb_device *dev)
 {
-       unsigned char *tmpbuf = 0;
+       unsigned char *tmpbuf = NULL;
        int err;
 
        err = get_descriptor_len(dev, USB_DT_DEVICE_SIZE, USB_DT_DEVICE_SIZE);
@@ -1088,6 +1068,14 @@ int usb_select_config(struct usb_device *dev)
        le16_to_cpus(&dev->descriptor.idProduct);
        le16_to_cpus(&dev->descriptor.bcdDevice);
 
+       /*
+        * Kingston DT Ultimate 32GB USB 3.0 seems to be extremely sensitive
+        * about this first Get Descriptor request. If there are any other
+        * requests in the first microframe, the stick crashes. Wait about
+        * one microframe duration here (1mS for USB 1.x , 125uS for USB 2.0).
+        */
+       mdelay(1);
+
        /* only support for one config for now */
        err = usb_get_configuration_len(dev, 0);
        if (err >= 0) {
@@ -1118,6 +1106,14 @@ int usb_select_config(struct usb_device *dev)
                        "len %d, status %lX\n", dev->act_len, dev->status);
                return err;
        }
+
+       /*
+        * Wait until the Set Configuration request gets processed by the
+        * device. This is required by at least SanDisk Cruzer Pop USB 2.0
+        * and Kingston DT Ultimate 32GB USB 3.0 on DWC2 OTG controller.
+        */
+       mdelay(10);
+
        debug("new device strings: Mfr=%d, Product=%d, SerialNumber=%d\n",
              dev->descriptor.iManufacturer, dev->descriptor.iProduct,
              dev->descriptor.iSerialNumber);
@@ -1177,7 +1173,7 @@ int usb_new_device(struct usb_device *dev)
         * with the device. So a get_descriptor will fail before any
         * of that is done for XHCI unlike EHCI.
         */
-#ifdef CONFIG_USB_XHCI
+#ifdef CONFIG_USB_XHCI_HCD
        do_read = false;
 #endif
        err = usb_setup_device(dev, do_read, dev->parent);