]> git.sur5r.net Git - u-boot/blobdiff - drivers/usb/gadget/designware_udc.c
Merge branch 'master' of git://git.denx.de/u-boot-mpc5xxx
[u-boot] / drivers / usb / gadget / designware_udc.c
index 67cdb29e6d12a2af7c547554c3c357cb575b344c..7e9ccdeeb830b4f5b4ad46b28676e187c99e0c77 100644 (file)
@@ -202,6 +202,7 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32 len)
        u32 i, nw, nb;
        u32 *wrdp;
        u8 *bytp;
+       u32 tmp[128];
 
        if (readl(&udc_regs_p->dev_stat) & DEV_STAT_RXFIFO_EMPTY)
                return -1;
@@ -209,7 +210,12 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32 len)
        nw = len / sizeof(u32);
        nb = len % sizeof(u32);
 
-       wrdp = (u32 *)bufp;
+       /* use tmp buf if bufp is not word aligned */
+       if ((int)bufp & 0x3)
+               wrdp = (u32 *)&tmp[0];
+       else
+               wrdp = (u32 *)bufp;
+
        for (i = 0; i < nw; i++) {
                writel(readl(fifo_ptr), wrdp);
                wrdp++;
@@ -223,6 +229,10 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32 len)
        }
        readl(&outep_regs_p[epNum].write_done);
 
+       /* copy back tmp buffer to bufp if bufp is not word aligned */
+       if ((int)bufp & 0x3)
+               memcpy(bufp, tmp, len);
+
        return 0;
 }