Now pass the dma_controller to the macro that checks if a given dma engine is available. For consistency the all the macros start if is_dma_. The mentor and TUSB is added and will be used later. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> --- drivers/usb/musb/davinci.c | 2 +- drivers/usb/musb/musb_core.c | 2 +- drivers/usb/musb/musb_dma.h | 20 ++++++++++++++++---- drivers/usb/musb/musb_gadget.c | 9 +++++---- drivers/usb/musb/musb_host.c | 21 +++++++++++++-------- drivers/usb/musb/tusb6010.c | 2 +- drivers/usb/musb/tusb6010.h | 6 ------ 7 files changed, 37 insertions(+), 25 deletions(-) diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index ed0834e..4dda846 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -285,7 +285,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) * mask, state, "vector", and EOI registers. */ cppi = container_of(musb->dma_controller, struct cppi, controller); - if (is_cppi_enabled() && musb->dma_controller && !cppi->irq) + if (is_dma_cppi(musb->dma_controller) && !cppi->irq) retval = cppi_interrupt(irq, __hci); /* ack and handle non-CPPI interrupts */ diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index b9d7416..ae96227 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1541,7 +1541,7 @@ void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit) if (!epnum) { #ifndef CONFIG_USB_TUSB_OMAP_DMA - if (!is_cppi_enabled()) { + if (!is_dma_cppi(musb->dma_controller)) { /* endpoint 0 */ if (devctl & MUSB_DEVCTL_HM) musb_h_ep0_irq(musb); diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h index 7a8bfb5..19f66ca 100644 --- a/drivers/usb/musb/musb_dma.h +++ b/drivers/usb/musb/musb_dma.h @@ -69,15 +69,27 @@ struct musb_hw_ep; #endif #if defined(CONFIG_USB_TI_CPPI_DMA) || defined(CONFIG_USB_TI_CPPI41_DMA) -#define is_cppi_enabled() 1 +#define is_dma_cppi(x) (x && x->type == MSUB_DMA_CPPI) #else -#define is_cppi_enabled() 0 +#define is_dma_cppi(x) (x && 0) #endif #ifdef CONFIG_USB_TUSB_OMAP_DMA -#define tusb_dma_omap() 1 +#define is_dma_tusb(x) (x && x->type == MSUB_DMA_TUSB6010) #else -#define tusb_dma_omap() 0 +#define is_dma_tusb(x) (x && 0) +#endif + +#ifdef CONFIG_USB_INVENTRA_DMA +#define is_dma_inventra(x) (x && x->type == MSUB_DMA_MENTOR) +#else +#define is_dma_inventra(x) (x && 0) +#endif + +#ifdef CONFIG_USB_UX500_DMA +#define is_dma_ux500(x) (x && x->type == MSUB_DMA_UX500) +#else +#define is_dma_ux500(x) (x && 0) #endif /* Anomaly 05000456 - USB Receive Interrupt Is Not Generated in DMA Mode 1 diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 06ceaf1..c685905 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -366,7 +366,7 @@ static void txstate(struct musb *musb, struct musb_request *req) } #endif - if (is_cppi_enabled() && use_dma) { + if (is_dma_cppi(c) && use_dma) { /* program endpoint CSR first, then setup DMA */ csr &= ~(MUSB_TXCSR_P_UNDERRUN | MUSB_TXCSR_TXPKTRDY); csr |= MUSB_TXCSR_DMAENAB | MUSB_TXCSR_DMAMODE | @@ -402,7 +402,7 @@ static void txstate(struct musb *musb, struct musb_request *req) musb_writew(epio, MUSB_TXCSR, csr); /* invariant: prequest->buf is non-null */ } - } else if (tusb_dma_omap() && use_dma) + } else if (is_dma_tusb(c) && use_dma) use_dma = c->channel_program( musb_ep->dma, musb_ep->packet_sz, request->zero, @@ -595,7 +595,7 @@ static void rxstate(struct musb *musb, struct musb_request *req) return; } - if (is_cppi_enabled() && is_buffer_mapped(req)) { + if (is_dma_cppi(musb->dma_controller) && is_buffer_mapped(req)) { struct dma_controller *c = musb->dma_controller; struct dma_channel *channel = musb_ep->dma; @@ -772,7 +772,8 @@ 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 (tusb_dma_omap() && is_buffer_mapped(req)) { + if (is_dma_tusb(musb->dma_controller) && + is_buffer_mapped(req)) { struct dma_controller *c = musb->dma_controller; struct dma_channel *channel = musb_ep->dma; u32 dma_addr = request->dma + request->actual; diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index a9695f5..2ceaa2a 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -175,14 +175,15 @@ static inline void musb_h_tx_start(struct musb_hw_ep *ep) } -static inline void musb_h_tx_dma_start(struct musb_hw_ep *ep) +static inline void musb_h_tx_dma_start(struct musb_hw_ep *ep, + struct dma_controller *c) { u16 txcsr; /* NOTE: no locks here; caller should lock and select EP */ txcsr = musb_readw(ep->regs, MUSB_TXCSR); txcsr |= MUSB_TXCSR_DMAENAB | MUSB_TXCSR_H_WZC_BITS; - if (is_cppi_enabled()) + if (is_dma_cppi(c)) txcsr |= MUSB_TXCSR_DMAMODE; musb_writew(ep->regs, MUSB_TXCSR, txcsr); } @@ -211,6 +212,7 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh) { u16 frame; u32 len; + struct dma_controller *c = musb->dma_controller; void __iomem *mbase = musb->mregs; struct urb *urb = next_urb(qh); void *buf = urb->transfer_buffer; @@ -295,8 +297,8 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh) if (!hw_ep->tx_channel) musb_h_tx_start(hw_ep); - else if (is_cppi_enabled() || tusb_dma_omap()) - musb_h_tx_dma_start(hw_ep); + else if (is_dma_cppi(c) || is_dma_tusb(c)) + musb_h_tx_dma_start(hw_ep, c); } } @@ -657,7 +659,7 @@ static bool musb_tx_dma_program(struct dma_controller *dma, channel->desired_mode = mode; musb_writew(epio, MUSB_TXCSR, csr); #else - if (!is_cppi_enabled() && !tusb_dma_omap()) + if (!is_dma_cppi(dma) && !is_dma_tusb(dma)) return false; channel->actual_len = 0; @@ -902,7 +904,8 @@ static void musb_ep_program(struct musb *musb, u8 epnum, /* kick things off */ - if ((is_cppi_enabled() || tusb_dma_omap()) && dma_channel) { + if (dma_channel && (is_dma_cppi(dma_controller) || + is_dma_tusb(dma_controller))) { /* Candidate for DMA */ dma_channel->actual_len = 0L; qh->segsize = len; @@ -1439,8 +1442,10 @@ void musb_host_tx(struct musb *musb, u8 epnum) } 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()) - musb_h_tx_dma_start(hw_ep); + struct dma_controller *c = musb->dma_controller; + + if (is_dma_cppi(c) || is_dma_tusb(c)) + musb_h_tx_dma_start(hw_ep, c); return; } } else if (tx_csr & MUSB_TXCSR_DMAENAB) { diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 0d68fc1..c1e2421 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -846,7 +846,7 @@ static irqreturn_t tusb_musb_interrupt(int irq, void *__hci) dev_dbg(musb->controller, "DMA IRQ %08x\n", dma_src); real_dma_src = ~real_dma_src & dma_src; - if (tusb_dma_omap() && real_dma_src) { + if (is_dma_tusb(musb->dma_controller) && real_dma_src) { int tx_source = (real_dma_src & 0xffff); int i; diff --git a/drivers/usb/musb/tusb6010.h b/drivers/usb/musb/tusb6010.h index 35c933a..d6f0d74 100644 --- a/drivers/usb/musb/tusb6010.h +++ b/drivers/usb/musb/tusb6010.h @@ -20,12 +20,6 @@ extern u8 tusb_get_revision(struct musb *musb); #define musb_in_tusb() 0 #endif -#ifdef CONFIG_USB_TUSB_OMAP_DMA -#define tusb_dma_omap() 1 -#else -#define tusb_dma_omap() 0 -#endif - /* VLYNQ control register. 32-bit at offset 0x000 */ #define TUSB_VLYNQ_CTRL 0x004 -- 1.8.4.rc1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html