]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/usb.c
mmc: extend mmcinfo to show enhanced partition attribute
[people/ms/u-boot.git] / common / usb.c
index e23d78885521d0e5bf35d19cb3bc140ba0571c2c..736cd9f00950929c3a269987d8c9c2e32cc80f7e 100644 (file)
@@ -33,7 +33,7 @@
 #include <linux/ctype.h>
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
-
+#include <errno.h>
 #include <usb.h>
 #ifdef CONFIG_4xx
 #include <asm/4xx_pci.h>
@@ -59,6 +59,7 @@ int usb_init(void)
        void *ctrl;
        struct usb_device *dev;
        int i, start_index = 0;
+       int ret;
 
        dev_index = 0;
        asynch_allowed = 1;
@@ -74,7 +75,13 @@ int usb_init(void)
        for (i = 0; i < CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
                /* init low_level USB */
                printf("USB%d:   ", i);
-               if (usb_lowlevel_init(i, &ctrl)) {
+               ret = usb_lowlevel_init(i, USB_INIT_HOST, &ctrl);
+               if (ret == -ENODEV) {   /* No such device. */
+                       puts("Port not available.\n");
+                       continue;
+               }
+
+               if (ret) {              /* Other error. */
                        puts("lowlevel init failed\n");
                        continue;
                }
@@ -919,7 +926,6 @@ int usb_new_device(struct usb_device *dev)
         * thread_id=5729457&forum_id=5398
         */
        __maybe_unused struct usb_device_descriptor *desc;
-       int port = -1;
        struct usb_device *parent = dev->parent;
        unsigned short portstatus;
 
@@ -957,24 +963,10 @@ int usb_new_device(struct usb_device *dev)
 #endif
 
        if (parent) {
-               int j;
-
-               /* find the port number we're at */
-               for (j = 0; j < parent->maxchild; j++) {
-                       if (parent->children[j] == dev) {
-                               port = j;
-                               break;
-                       }
-               }
-               if (port < 0) {
-                       printf("usb_new_device:cannot locate device's port.\n");
-                       return 1;
-               }
-
                /* reset the port for the second time */
-               err = hub_port_reset(dev->parent, port, &portstatus);
+               err = hub_port_reset(dev->parent, dev->portnr - 1, &portstatus);
                if (err < 0) {
-                       printf("\n     Couldn't reset port %i\n", port);
+                       printf("\n     Couldn't reset port %i\n", dev->portnr);
                        return 1;
                }
        }
@@ -1066,4 +1058,9 @@ int usb_new_device(struct usb_device *dev)
        return 0;
 }
 
+__weak
+int board_usb_init(int index, enum usb_init_type init)
+{
+       return 0;
+}
 /* EOF */