]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Merge branch 'master' of git://git.denx.de/u-boot-usb
authorTom Rini <trini@ti.com>
Wed, 3 Jul 2013 12:40:58 +0000 (08:40 -0400)
committerTom Rini <trini@ti.com>
Wed, 3 Jul 2013 12:40:58 +0000 (08:40 -0400)
README
drivers/dfu/dfu.c
drivers/usb/eth/asix.c
drivers/usb/gadget/composite.c
drivers/usb/gadget/f_dfu.c
drivers/usb/gadget/f_mass_storage.c
drivers/usb/gadget/g_dnl.c
drivers/usb/musb-new/musb_uboot.c
include/dfu.h
include/g_dnl.h
include/linux/usb/composite.h

diff --git a/README b/README
index 5c343da32bdf581420c0d18e5cea3cac49c8f9e3..85e5a8d6d444c22b03ed1c76b05f2a02a61c0fe6 100644 (file)
--- a/README
+++ b/README
@@ -1392,6 +1392,12 @@ The following options need to be configured:
                CONFIG_DFU_NAND
                This enables support for exposing NAND devices via DFU.
 
+               CONFIG_SYS_DFU_DATA_BUF_SIZE
+               Dfu transfer uses a buffer before writing data to the
+               raw storage device. Make the size (in bytes) of this buffer
+               configurable. The size of this buffer is also configurable
+               through the "dfu_bufsiz" environment variable.
+
                CONFIG_SYS_DFU_MAX_FILE_SIZE
                When updating files rather than the raw storage device,
                we use a static buffer to copy the file into and then write
index 6af6890d09158049a9fc5f9d250565c9ed34cc25..e429d7479fbffe6423c9a77207a02774fa054c10 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <common.h>
+#include <errno.h>
 #include <malloc.h>
 #include <mmc.h>
 #include <fat.h>
@@ -41,8 +42,34 @@ static int dfu_find_alt_num(const char *s)
        return ++i;
 }
 
-static unsigned char __aligned(CONFIG_SYS_CACHELINE_SIZE)
-                                    dfu_buf[DFU_DATA_BUF_SIZE];
+static unsigned char *dfu_buf;
+static unsigned long dfu_buf_size = CONFIG_SYS_DFU_DATA_BUF_SIZE;
+
+static unsigned char *dfu_free_buf(void)
+{
+       free(dfu_buf);
+       dfu_buf = NULL;
+       return dfu_buf;
+}
+
+static unsigned char *dfu_get_buf(void)
+{
+       char *s;
+
+       if (dfu_buf != NULL)
+               return dfu_buf;
+
+       s = getenv("dfu_bufsiz");
+       dfu_buf_size = s ? (unsigned long)simple_strtol(s, NULL, 16) :
+                       CONFIG_SYS_DFU_DATA_BUF_SIZE;
+
+       dfu_buf = memalign(CONFIG_SYS_CACHELINE_SIZE, dfu_buf_size);
+       if (dfu_buf == NULL)
+               printf("%s: Could not memalign 0x%lx bytes\n",
+                      __func__, dfu_buf_size);
+
+       return dfu_buf;
+}
 
 static int dfu_write_buffer_drain(struct dfu_entity *dfu)
 {
@@ -87,8 +114,10 @@ int dfu_write(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
                dfu->offset = 0;
                dfu->bad_skip = 0;
                dfu->i_blk_seq_num = 0;
-               dfu->i_buf_start = dfu_buf;
-               dfu->i_buf_end = dfu_buf + sizeof(dfu_buf);
+               dfu->i_buf_start = dfu_get_buf();
+               if (dfu->i_buf_start == NULL)
+                       return -ENOMEM;
+               dfu->i_buf_end = dfu_get_buf() + dfu_buf_size;
                dfu->i_buf = dfu->i_buf_start;
 
                dfu->inited = 1;
@@ -148,11 +177,12 @@ int dfu_write(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
                printf("\nDFU complete CRC32: 0x%08x\n", dfu->crc);
 
                /* clear everything */
+               dfu_free_buf();
                dfu->crc = 0;
                dfu->offset = 0;
                dfu->i_blk_seq_num = 0;
                dfu->i_buf_start = dfu_buf;
-               dfu->i_buf_end = dfu_buf + sizeof(dfu_buf);
+               dfu->i_buf_end = dfu_buf;
                dfu->i_buf = dfu->i_buf_start;
 
                dfu->inited = 0;
@@ -229,8 +259,10 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
                dfu->i_blk_seq_num = 0;
                dfu->crc = 0;
                dfu->offset = 0;
-               dfu->i_buf_start = dfu_buf;
-               dfu->i_buf_end = dfu_buf + sizeof(dfu_buf);
+               dfu->i_buf_start = dfu_get_buf();
+               if (dfu->i_buf_start == NULL)
+                       return -ENOMEM;
+               dfu->i_buf_end = dfu_get_buf() + dfu_buf_size;
                dfu->i_buf = dfu->i_buf_start;
                dfu->b_left = 0;
 
@@ -257,11 +289,12 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
                debug("%s: %s CRC32: 0x%x\n", __func__, dfu->name, dfu->crc);
                puts("\nUPLOAD ... done\nCtrl+C to exit ...\n");
 
+               dfu_free_buf();
                dfu->i_blk_seq_num = 0;
                dfu->crc = 0;
                dfu->offset = 0;
                dfu->i_buf_start = dfu_buf;
-               dfu->i_buf_end = dfu_buf + sizeof(dfu_buf);
+               dfu->i_buf_end = dfu_buf;
                dfu->i_buf = dfu->i_buf_start;
                dfu->b_left = 0;
 
index 76624b92564b7dca9b6de50b9f90977bee70c84f..db39bd86f54578c422a498ad1a156fb9dcf0734a 100644 (file)
@@ -585,6 +585,7 @@ struct asix_dongle {
 static const struct asix_dongle const asix_dongles[] = {
        { 0x05ac, 0x1402, FLAG_TYPE_AX88772 },  /* Apple USB Ethernet Adapter */
        { 0x07d1, 0x3c05, FLAG_TYPE_AX88772 },  /* D-Link DUB-E100 H/W Ver B1 */
+       { 0x2001, 0x1a02, FLAG_TYPE_AX88772 },  /* D-Link DUB-E100 H/W Ver C1 */
        /* Cables-to-Go USB Ethernet Adapter */
        { 0x0b95, 0x772a, FLAG_TYPE_AX88772 },
        { 0x0b95, 0x7720, FLAG_TYPE_AX88772 },  /* Trendnet TU2-ET100 V3.0R */
index f30778a163b2950b2681a5ea9b610a7d74d10fb3..f8677931b46cbbda93ff47c516ebae8acbf508cc 100644 (file)
@@ -997,7 +997,8 @@ static int composite_bind(struct usb_gadget *gadget)
        if (status < 0)
                goto fail;
 
-       cdev->desc = *composite->dev;
+       memcpy(&cdev->desc, composite->dev,
+              sizeof(struct usb_device_descriptor));
        cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
 
        debug("%s: ready\n", composite->name);
index a322ae5eb8720751a7178984e1422fa67b80cd5d..e3fa0e373d10328e2e70506bcfd65ed927f1f2ad 100644 (file)
@@ -183,6 +183,7 @@ static inline void to_dfu_mode(struct f_dfu *f_dfu)
 {
        f_dfu->usb_function.strings = dfu_strings;
        f_dfu->usb_function.hs_descriptors = f_dfu->function;
+       f_dfu->dfu_state = DFU_STATE_dfuIDLE;
 }
 
 static inline void to_runtime_mode(struct f_dfu *f_dfu)
@@ -233,7 +234,6 @@ static int state_app_idle(struct f_dfu *f_dfu,
        case USB_REQ_DFU_DETACH:
                f_dfu->dfu_state = DFU_STATE_appDETACH;
                to_dfu_mode(f_dfu);
-               f_dfu->dfu_state = DFU_STATE_dfuIDLE;
                value = RET_ZLP;
                break;
        default:
@@ -589,7 +589,7 @@ static int dfu_prepare_function(struct f_dfu *f_dfu, int n)
        struct usb_interface_descriptor *d;
        int i = 0;
 
-       f_dfu->function = calloc(sizeof(struct usb_descriptor_header *), n);
+       f_dfu->function = calloc(sizeof(struct usb_descriptor_header *), n + 1);
        if (!f_dfu->function)
                goto enomem;
 
@@ -653,6 +653,8 @@ static int dfu_bind(struct usb_configuration *c, struct usb_function *f)
                        ->iInterface = id;
        }
 
+       to_dfu_mode(f_dfu);
+
        stringtab_dfu.strings = f_dfu->strings;
 
        cdev->req->context = f_dfu;
index 45bc132aef6729827594dcf1a373c7e49510114f..5b348d7a6ef2a6b50bd59b55e165279d9f53c778 100644 (file)
@@ -577,9 +577,9 @@ static int fsg_setup(struct usb_function *f,
 {
        struct fsg_dev          *fsg = fsg_from_func(f);
        struct usb_request      *req = fsg->common->ep0req;
-       u16                     w_index = le16_to_cpu(ctrl->wIndex);
-       u16                     w_value = le16_to_cpu(ctrl->wValue);
-       u16                     w_length = le16_to_cpu(ctrl->wLength);
+       u16                     w_index = get_unaligned_le16(&ctrl->wIndex);
+       u16                     w_value = get_unaligned_le16(&ctrl->wValue);
+       u16                     w_length = get_unaligned_le16(&ctrl->wLength);
 
        if (!fsg_is_set(fsg->common))
                return -EOPNOTSUPP;
@@ -617,7 +617,7 @@ static int fsg_setup(struct usb_function *f,
             "unknown class-specific control req "
             "%02x.%02x v%04x i%04x l%u\n",
             ctrl->bRequestType, ctrl->bRequest,
-            le16_to_cpu(ctrl->wValue), w_index, w_length);
+            get_unaligned_le16(&ctrl->wValue), w_index, w_length);
        return -EOPNOTSUPP;
 }
 
index cc3f3449c97c85b2e4fad5ed46f3f55210d845fc..8a3777b6e0b2d8e09525b600084465f612c6bb28 100644 (file)
@@ -125,6 +125,12 @@ static int g_dnl_config_register(struct usb_composite_dev *cdev)
        return usb_add_config(cdev, &config);
 }
 
+__weak
+int g_dnl_bind_fixup(struct usb_device_descriptor *dev)
+{
+       return 0;
+}
+
 static int g_dnl_bind(struct usb_composite_dev *cdev)
 {
        struct usb_gadget *gadget = cdev->gadget;
@@ -147,6 +153,7 @@ static int g_dnl_bind(struct usb_composite_dev *cdev)
        g_dnl_string_defs[1].id = id;
        device_desc.iProduct = id;
 
+       g_dnl_bind_fixup(&device_desc);
        ret = g_dnl_config_register(cdev);
        if (ret)
                goto error;
index 15d2ec007816faa609ebf4ee806db45627ad4033..c2400328a365ebe8c2d269743368db1ac64f4c71 100644 (file)
@@ -1,4 +1,5 @@
 #include <common.h>
+#include <watchdog.h>
 #include <asm/errno.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
@@ -164,6 +165,7 @@ static struct musb *gadget;
 
 int usb_gadget_handle_interrupts(void)
 {
+       WATCHDOG_RESET();
        if (!gadget || !gadget->isr)
                return -EINVAL;
 
index a107f4b13e308aa17f2eb64ef7b5e402d02c6d95..124653c8164fa96daaa0c20222b4f067d467ade9 100644 (file)
@@ -68,7 +68,9 @@ static inline unsigned int get_mmc_blk_size(int dev)
 
 #define DFU_NAME_SIZE                  32
 #define DFU_CMD_BUF_SIZE               128
-#define DFU_DATA_BUF_SIZE              (1024*1024*8)   /* 8 MiB */
+#ifndef CONFIG_SYS_DFU_DATA_BUF_SIZE
+#define CONFIG_SYS_DFU_DATA_BUF_SIZE           (1024*1024*8)   /* 8 MiB */
+#endif
 #ifndef CONFIG_SYS_DFU_MAX_FILE_SIZE
 #define CONFIG_SYS_DFU_MAX_FILE_SIZE   (4 << 20)       /* 4 MiB */
 #endif
index f47395f35d3133510093080033237ebf54db1aa6..f8affd8d91bd3bc031eff4728996abdbf333dd25 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
-
+int g_dnl_bind_fixup(struct usb_device_descriptor *);
 int g_dnl_register(const char *s);
 void g_dnl_unregister(void);
 
index 53cb0955071904ed4e498d10387b1e6afe64736b..4f76f88d67ca3a7c12a743c61468dbb30a845796 100644 (file)
@@ -331,7 +331,7 @@ struct usb_composite_dev {
        /* private: */
        /* internals */
        unsigned int                    suspended:1;
-       struct usb_device_descriptor    desc;
+       struct usb_device_descriptor __aligned(CONFIG_SYS_CACHELINE_SIZE) desc;
        struct list_head                configs;
        struct usb_composite_driver     *driver;
        u8                              next_string_id;