Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
---
drivers/usb/musb/musb_gadget.c | 76 ++++++++++++++++++++----------------------
1 file changed, 36 insertions(+), 40 deletions(-)
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index c685905..05a59d0 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -313,8 +313,8 @@ static void txstate(struct musb *musb, struct musb_request
*req)
/* MUSB_TXCSR_P_ISO is still set correctly */
-#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_UX500_DMA)
- {
+ if (is_dma_inventra(c) || is_dma_ux500(c)) {
+
if (request_size < musb_ep->packet_sz)
musb_ep->dma->desired_mode = 0;
else
@@ -365,7 +365,6 @@ static void txstate(struct musb *musb, struct musb_request
*req)
}
}
-#endif
if (is_dma_cppi(c) && use_dma) {
/* program endpoint CSR first, then setup DMA */
csr &= ~(MUSB_TXCSR_P_UNDERRUN | MUSB_TXCSR_TXPKTRDY);
@@ -510,11 +509,10 @@ void musb_g_tx(struct musb *musb, u8 epnum)
if ((request->zero && request->length
&& (request->length % musb_ep->packet_sz == 0)
&& (request->actual == request->length))
-#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_UX500_DMA)
- || (is_dma && (!dma->desired_mode ||
+ || ((is_dma_inventra(c) || is_dma_ux500(c)) &&
+ (is_dma && (!dma->desired_mode ||
(request->actual &
- (musb_ep->packet_sz - 1))))
-#endif
+ (musb_ep->packet_sz - 1)))))
) {
/*
* On DMA completion, FIFO may not be
@@ -637,8 +635,9 @@ static void rxstate(struct musb *musb, struct musb_request
*req)
use_mode_1 = 0;
if (request->actual < request->length) {
-#ifdef CONFIG_USB_INVENTRA_DMA
- if (is_buffer_mapped(req)) {
+ struct dma_controller *c = musb->dma_controller;
+
+ if (is_dma_inventra(c) && is_buffer_mapped(req)) {
struct dma_controller *c;
struct dma_channel *channel;
int use_dma = 0;
@@ -712,8 +711,8 @@ static void rxstate(struct musb *musb, struct musb_request
*req)
if (use_dma)
return;
}
-#elif defined(CONFIG_USB_UX500_DMA)
- if ((is_buffer_mapped(req)) &&
+
+ if (is_dma_ux500(c) && (is_buffer_mapped(req)) &&
(request->actual < request->length)) {
struct dma_controller *c;
@@ -761,7 +760,6 @@ static void rxstate(struct musb *musb, struct musb_request
*req)
return;
}
-#endif /* Mentor's DMA */
len = request->length - request->actual;
dev_dbg(musb->controller, "%s OUT/RX pio fifo %d/%d,
maxpacket %d\n",
@@ -771,7 +769,6 @@ static void rxstate(struct musb *musb, struct musb_request
*req)
fifo_count = min_t(unsigned, len, fifo_count);
-#ifdef CONFIG_USB_TUSB_OMAP_DMA
if (is_dma_tusb(musb->dma_controller) &&
is_buffer_mapped(req)) {
struct dma_controller *c = musb->dma_controller;
@@ -787,7 +784,6 @@ static void rxstate(struct musb *musb, struct musb_request
*req)
if (ret)
return;
}
-#endif
/*
* Unmap the dma buffer back to cpu if dma channel
* programming fails. This buffer is mapped if the
@@ -887,6 +883,8 @@ void musb_g_rx(struct musb *musb, u8 epnum)
}
if (dma && (csr & MUSB_RXCSR_DMAENAB)) {
+ struct dma_controller *c = musb->dma_controller;
+
csr &= ~(MUSB_RXCSR_AUTOCLEAR
| MUSB_RXCSR_DMAENAB
| MUSB_RXCSR_DMAMODE);
@@ -900,31 +898,32 @@ void musb_g_rx(struct musb *musb, u8 epnum)
musb_readw(epio, MUSB_RXCSR),
musb_ep->dma->actual_len, request);
-#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_TUSB_OMAP_DMA) || \
- defined(CONFIG_USB_UX500_DMA)
- /* Autoclear doesn't clear RxPktRdy for short packets */
- if ((dma->desired_mode == 0 && !hw_ep->rx_double_buffered)
- || (dma->actual_len
- & (musb_ep->packet_sz - 1))) {
- /* ack the read! */
- csr &= ~MUSB_RXCSR_RXPKTRDY;
- musb_writew(epio, MUSB_RXCSR, csr);
- }
+ if (is_dma_inventra(c) || is_dma_tusb(c) || is_dma_ux500(c)) {
+ /* Autoclear doesn't clear RxPktRdy for short packets */
+ if ((dma->desired_mode == 0 &&
+ !hw_ep->rx_double_buffered)
+ || (dma->actual_len
+ & (musb_ep->packet_sz - 1))) {
+ /* ack the read! */
+ csr &= ~MUSB_RXCSR_RXPKTRDY;
+ musb_writew(epio, MUSB_RXCSR, csr);
+ }
- /* incomplete, and not short? wait for next IN packet */
- if ((request->actual < request->length)
- && (musb_ep->dma->actual_len
- == musb_ep->packet_sz)) {
- /* In double buffer case, continue to unload fifo if
- * there is Rx packet in FIFO.
- **/
- csr = musb_readw(epio, MUSB_RXCSR);
- if ((csr & MUSB_RXCSR_RXPKTRDY) &&
- hw_ep->rx_double_buffered)
- goto exit;
- return;
+ /* incomplete, and not short? wait for next IN packet */
+ if ((request->actual < request->length)
+ && (musb_ep->dma->actual_len
+ == musb_ep->packet_sz)) {
+ /*
+ * In double buffer case, continue to unload
+ * fifo if there is Rx packet in FIFO.
+ */
+ csr = musb_readw(epio, MUSB_RXCSR);
+ if ((csr & MUSB_RXCSR_RXPKTRDY) &&
+ hw_ep->rx_double_buffered)
+ goto exit;
+ return;
+ }
}
-#endif
musb_g_giveback(musb_ep, request, 0);
/*
* In the giveback function the MUSB lock is
@@ -940,10 +939,7 @@ void musb_g_rx(struct musb *musb, u8 epnum)
if (!req)
return;
}
-#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_TUSB_OMAP_DMA) || \
- defined(CONFIG_USB_UX500_DMA)
exit:
-#endif
/* Analyze request */
rxstate(musb, req);
}
--
1.8.4.rc1
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html