]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/usb/musb/musb_host.c
Merge branch 'master' into tk71
[mv-sheeva.git] / drivers / usb / musb / musb_host.c
index 9e65c47cc98b95761daba7186dd180550b954def..0f523d7db57b8985689ab9145a69ad10d1876740 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/list.h>
+#include <linux/dma-mapping.h>
 
 #include "musb_core.h"
 #include "musb_host.h"
@@ -608,7 +609,7 @@ musb_rx_reinit(struct musb *musb, struct musb_qh *qh, struct musb_hw_ep *ep)
        /* Set RXMAXP with the FIFO size of the endpoint
         * to disable double buffer mode.
         */
-       if (musb->hwvers < MUSB_HWVERS_2000)
+       if (musb->double_buffer_not_ok)
                musb_writew(ep->regs, MUSB_RXMAXP, ep->max_packet_sz_rx);
        else
                musb_writew(ep->regs, MUSB_RXMAXP,
@@ -783,14 +784,13 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
                /* protocol/endpoint/interval/NAKlimit */
                if (epnum) {
                        musb_writeb(epio, MUSB_TXTYPE, qh->type_reg);
-                       if (can_bulk_split(musb, qh->type))
+                       if (musb->double_buffer_not_ok)
                                musb_writew(epio, MUSB_TXMAXP,
-                                       packet_sz
-                                       | ((hw_ep->max_packet_sz_tx /
-                                               packet_sz) - 1) << 11);
+                                               hw_ep->max_packet_sz_tx);
                        else
                                musb_writew(epio, MUSB_TXMAXP,
-                                       packet_sz);
+                                               qh->maxpacket |
+                                               ((qh->hb_mult - 1) << 11));
                        musb_writeb(epio, MUSB_TXINTERVAL, qh->intv_reg);
                } else {
                        musb_writeb(epio, MUSB_NAKLIMIT0, qh->intv_reg);
@@ -1119,6 +1119,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)
        u32                     status = 0;
        void __iomem            *mbase = musb->mregs;
        struct dma_channel      *dma;
+       bool                    transfer_pending = false;
 
        musb_ep_select(mbase, epnum);
        tx_csr = musb_readw(epio, MUSB_TXCSR);
@@ -1279,7 +1280,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)
                                offset = d->offset;
                                length = d->length;
                        }
-               } else if (dma) {
+               } else if (dma && urb->transfer_buffer_length == qh->offset) {
                        done = true;
                } else {
                        /* see if we need to send more data, or ZLP */
@@ -1292,6 +1293,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)
                        if (!done) {
                                offset = qh->offset;
                                length = urb->transfer_buffer_length - offset;
+                               transfer_pending = true;
                        }
                }
        }
@@ -1311,7 +1313,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)
                urb->actual_length = qh->offset;
                musb_advance_schedule(musb, urb, hw_ep, USB_DIR_OUT);
                return;
-       } else  if (usb_pipeisoc(pipe) && dma) {
+       } else if ((usb_pipeisoc(pipe) || transfer_pending) && dma) {
                if (musb_tx_dma_program(musb->dma_controller, hw_ep, qh, urb,
                                offset, length)) {
                        if (is_cppi_enabled() || tusb_dma_omap())
@@ -1332,6 +1334,8 @@ void musb_host_tx(struct musb *musb, u8 epnum)
         */
        if (length > qh->maxpacket)
                length = qh->maxpacket;
+       /* Unmap the buffer so that CPU can use it */
+       unmap_urb_for_dma(musb_to_hcd(musb), urb);
        musb_write_fifo(hw_ep, length, urb->transfer_buffer + offset);
        qh->segsize = length;
 
@@ -1752,6 +1756,8 @@ void musb_host_rx(struct musb *musb, u8 epnum)
 #endif /* Mentor DMA */
 
                if (!dma) {
+                       /* Unmap the buffer so that CPU can use it */
+                       unmap_urb_for_dma(musb_to_hcd(musb), urb);
                        done = musb_host_packet_rx(musb, urb,
                                        epnum, iso_err);
                        DBG(6, "read %spacket\n", done ? "last " : "");