Commit 57aadb46 authored by Paul Cercueil's avatar Paul Cercueil Committed by Greg Kroah-Hartman

usb: musb: jz4740: Add support for DMA

Add support for using the DMA channels built into the Inventra IP.
Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
Tested-by: default avatarArtur Rojek <contact@artur-rojek.eu>
Signed-off-by: default avatarBin Liu <b-liu@ti.com>
Link: https://lore.kernel.org/r/20200316211136.2274-4-b-liu@ti.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2f6a0e65
...@@ -144,7 +144,7 @@ config USB_UX500_DMA ...@@ -144,7 +144,7 @@ config USB_UX500_DMA
config USB_INVENTRA_DMA config USB_INVENTRA_DMA
bool 'Inventra' bool 'Inventra'
depends on USB_MUSB_OMAP2PLUS || USB_MUSB_MEDIATEK depends on USB_MUSB_OMAP2PLUS || USB_MUSB_MEDIATEK || USB_MUSB_JZ4740
help help
Enable DMA transfers using Mentor's engine. Enable DMA transfers using Mentor's engine.
......
...@@ -24,11 +24,14 @@ struct jz4740_glue { ...@@ -24,11 +24,14 @@ struct jz4740_glue {
static irqreturn_t jz4740_musb_interrupt(int irq, void *__hci) static irqreturn_t jz4740_musb_interrupt(int irq, void *__hci)
{ {
unsigned long flags; unsigned long flags;
irqreturn_t retval = IRQ_NONE; irqreturn_t retval = IRQ_NONE, retval_dma = IRQ_NONE;
struct musb *musb = __hci; struct musb *musb = __hci;
spin_lock_irqsave(&musb->lock, flags); spin_lock_irqsave(&musb->lock, flags);
if (IS_ENABLED(CONFIG_USB_INVENTRA_DMA) && musb->dma_controller)
retval_dma = dma_controller_irq(irq, musb->dma_controller);
musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB); musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX); musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX); musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
...@@ -46,7 +49,10 @@ static irqreturn_t jz4740_musb_interrupt(int irq, void *__hci) ...@@ -46,7 +49,10 @@ static irqreturn_t jz4740_musb_interrupt(int irq, void *__hci)
spin_unlock_irqrestore(&musb->lock, flags); spin_unlock_irqrestore(&musb->lock, flags);
return retval; if (retval == IRQ_HANDLED || retval_dma == IRQ_HANDLED)
return IRQ_HANDLED;
return IRQ_NONE;
} }
static struct musb_fifo_cfg jz4740_musb_fifo_cfg[] = { static struct musb_fifo_cfg jz4740_musb_fifo_cfg[] = {
...@@ -93,14 +99,14 @@ static int jz4740_musb_init(struct musb *musb) ...@@ -93,14 +99,14 @@ static int jz4740_musb_init(struct musb *musb)
return 0; return 0;
} }
/*
* DMA has not been confirmed to work with CONFIG_USB_INVENTRA_DMA,
* so let's not set up the dma function pointers yet.
*/
static const struct musb_platform_ops jz4740_musb_ops = { static const struct musb_platform_ops jz4740_musb_ops = {
.quirks = MUSB_DMA_INVENTRA | MUSB_INDEXED_EP, .quirks = MUSB_DMA_INVENTRA | MUSB_INDEXED_EP,
.fifo_mode = 2, .fifo_mode = 2,
.init = jz4740_musb_init, .init = jz4740_musb_init,
#ifdef CONFIG_USB_INVENTRA_DMA
.dma_init = musbhs_dma_controller_create_noirq,
.dma_exit = musbhs_dma_controller_destroy,
#endif
}; };
static const struct musb_hdrc_platform_data jz4740_musb_pdata = { static const struct musb_hdrc_platform_data jz4740_musb_pdata = {
...@@ -142,6 +148,8 @@ static int jz4740_probe(struct platform_device *pdev) ...@@ -142,6 +148,8 @@ static int jz4740_probe(struct platform_device *pdev)
} }
musb->dev.parent = dev; musb->dev.parent = dev;
musb->dev.dma_mask = &musb->dev.coherent_dma_mask;
musb->dev.coherent_dma_mask = DMA_BIT_MASK(32);
glue->pdev = musb; glue->pdev = musb;
glue->clk = clk; glue->clk = clk;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment