driver/fm: fdt.c: fix fdt_fixup_fman_firmware() to support ARM platforms
[oweals/u-boot.git] / common / usb_storage.c
index cc9b3e37a1cbec27ce9acbab1bbb7f9e973f5374..8737cf7ceaabbb673b094ff8237e4c9c3fb9d78b 100644 (file)
@@ -39,6 +39,7 @@
 #include <errno.h>
 #include <inttypes.h>
 #include <mapmem.h>
+#include <memalign.h>
 #include <asm/byteorder.h>
 #include <asm/processor.h>
 #include <dm/device-internal.h>
@@ -64,7 +65,6 @@ static const unsigned char us_direction[256/8] = {
 static ccb usb_ccb __attribute__((aligned(ARCH_DMA_MINALIGN)));
 static __u32 CBWTag;
 
-#define USB_MAX_STOR_DEV 5
 static int usb_max_devs; /* number of highest available usb device */
 
 static block_dev_desc_t usb_dev_desc[USB_MAX_STOR_DEV];
@@ -118,10 +118,10 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *us,
                      block_dev_desc_t *dev_desc);
 int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
                      struct us_data *ss);
-unsigned long usb_stor_read(int device, lbaint_t blknr,
-                           lbaint_t blkcnt, void *buffer);
-unsigned long usb_stor_write(int device, lbaint_t blknr,
-                            lbaint_t blkcnt, const void *buffer);
+static unsigned long usb_stor_read(block_dev_desc_t *block_dev, lbaint_t blknr,
+                                  lbaint_t blkcnt, void *buffer);
+static unsigned long usb_stor_write(block_dev_desc_t *block_dev, lbaint_t blknr,
+                                   lbaint_t blkcnt, const void *buffer);
 void uhci_show_temp_int_td(void);
 
 #ifdef CONFIG_PARTITIONS
@@ -1026,9 +1026,10 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor,
 }
 #endif /* CONFIG_USB_BIN_FIXUP */
 
-unsigned long usb_stor_read(int device, lbaint_t blknr,
-                           lbaint_t blkcnt, void *buffer)
+static unsigned long usb_stor_read(block_dev_desc_t *block_dev, lbaint_t blknr,
+                                  lbaint_t blkcnt, void *buffer)
 {
+       int device = block_dev->dev;
        lbaint_t start, blks;
        uintptr_t buf_addr;
        unsigned short smallblks;
@@ -1096,9 +1097,10 @@ retry_it:
        return blkcnt;
 }
 
-unsigned long usb_stor_write(int device, lbaint_t blknr,
-                               lbaint_t blkcnt, const void *buffer)
+static unsigned long usb_stor_write(block_dev_desc_t *block_dev, lbaint_t blknr,
+                                   lbaint_t blkcnt, const void *buffer)
 {
+       int device = block_dev->dev;
        lbaint_t start, blks;
        uintptr_t buf_addr;
        unsigned short smallblks;
@@ -1176,25 +1178,9 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
        struct usb_endpoint_descriptor *ep_desc;
        unsigned int flags = 0;
 
-       int protocol = 0;
-       int subclass = 0;
-
        /* let's examine the device now */
        iface = &dev->config.if_desc[ifnum];
 
-#if 0
-       /* this is the place to patch some storage devices */
-       debug("iVendor %X iProduct %X\n", dev->descriptor.idVendor,
-                       dev->descriptor.idProduct);
-
-       if ((dev->descriptor.idVendor) == 0x066b &&
-           (dev->descriptor.idProduct) == 0x0103) {
-               debug("patched for E-USB\n");
-               protocol = US_PR_CB;
-               subclass = US_SC_UFI;       /* an assumption */
-       }
-#endif
-
        if (dev->descriptor.bDeviceClass != 0 ||
                        iface->desc.bInterfaceClass != USB_CLASS_MASS_STORAGE ||
                        iface->desc.bInterfaceSubClass < US_SC_MIN ||
@@ -1214,17 +1200,8 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
        ss->ifnum = ifnum;
        ss->pusb_dev = dev;
        ss->attention_done = 0;
-
-       /* If the device has subclass and protocol, then use that.  Otherwise,
-        * take data from the specific interface.
-        */
-       if (subclass) {
-               ss->subclass = subclass;
-               ss->protocol = protocol;
-       } else {
-               ss->subclass = iface->desc.bInterfaceSubClass;
-               ss->protocol = iface->desc.bInterfaceProtocol;
-       }
+       ss->subclass = iface->desc.bInterfaceSubClass;
+       ss->protocol = iface->desc.bInterfaceProtocol;
 
        /* set the handler pointers based on the protocol */
        debug("Transport: ");
@@ -1407,7 +1384,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss,
 
 static int usb_mass_storage_probe(struct udevice *dev)
 {
-       struct usb_device *udev = dev_get_parentdata(dev);
+       struct usb_device *udev = dev_get_parent_priv(dev);
        int ret;
 
        usb_disable_asynch(1); /* asynch transfer not allowed */
@@ -1442,6 +1419,6 @@ static const struct usb_device_id mass_storage_id_table[] = {
        { }             /* Terminating entry */
 };
 
-USB_DEVICE(usb_mass_storage, mass_storage_id_table);
+U_BOOT_USB_DEVICE(usb_mass_storage, mass_storage_id_table);
 
 #endif