Commit 7f6283ed authored by Tony Lindgren's avatar Tony Lindgren Committed by Felipe Balbi

usb: musb: Set up function pointers for DMA

Set up function pointers for DMA so get closer to
being able to build in all the DMA engines.
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent f8e9f34f
...@@ -443,6 +443,10 @@ static const struct musb_platform_ops am35x_ops = { ...@@ -443,6 +443,10 @@ static const struct musb_platform_ops am35x_ops = {
.exit = am35x_musb_exit, .exit = am35x_musb_exit,
.read_fifo = am35x_read_fifo, .read_fifo = am35x_read_fifo,
#ifdef CONFIG_USB_INVENTRA_DMA
.dma_init = musbhs_dma_controller_create,
.dma_exit = musbhs_dma_controller_destroy,
#endif
.enable = am35x_musb_enable, .enable = am35x_musb_enable,
.disable = am35x_musb_disable, .disable = am35x_musb_disable,
......
...@@ -478,6 +478,10 @@ static const struct musb_platform_ops bfin_ops = { ...@@ -478,6 +478,10 @@ static const struct musb_platform_ops bfin_ops = {
.fifo_mode = 2, .fifo_mode = 2,
.read_fifo = bfin_read_fifo, .read_fifo = bfin_read_fifo,
.write_fifo = bfin_write_fifo, .write_fifo = bfin_write_fifo,
#ifdef CONFIG_USB_INVENTRA_DMA
.dma_init = musbhs_dma_controller_create,
.dma_exit = musbhs_dma_controller_destroy,
#endif
.enable = bfin_musb_enable, .enable = bfin_musb_enable,
.disable = bfin_musb_disable, .disable = bfin_musb_disable,
......
...@@ -1297,7 +1297,8 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id) ...@@ -1297,7 +1297,8 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id)
EXPORT_SYMBOL_GPL(cppi_interrupt); EXPORT_SYMBOL_GPL(cppi_interrupt);
/* Instantiate a software object representing a DMA controller. */ /* Instantiate a software object representing a DMA controller. */
struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mregs) struct dma_controller *
cppi_dma_controller_create(struct musb *musb, void __iomem *mregs)
{ {
struct cppi *controller; struct cppi *controller;
struct device *dev = musb->controller; struct device *dev = musb->controller;
...@@ -1334,7 +1335,7 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mr ...@@ -1334,7 +1335,7 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mr
if (irq > 0) { if (irq > 0) {
if (request_irq(irq, cppi_interrupt, 0, "cppi-dma", musb)) { if (request_irq(irq, cppi_interrupt, 0, "cppi-dma", musb)) {
dev_err(dev, "request_irq %d failed!\n", irq); dev_err(dev, "request_irq %d failed!\n", irq);
dma_controller_destroy(&controller->controller); musb_dma_controller_destroy(&controller->controller);
return NULL; return NULL;
} }
controller->irq = irq; controller->irq = irq;
...@@ -1343,11 +1344,12 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mr ...@@ -1343,11 +1344,12 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mr
cppi_controller_start(controller); cppi_controller_start(controller);
return &controller->controller; return &controller->controller;
} }
EXPORT_SYMBOL_GPL(cppi_dma_controller_create);
/* /*
* Destroy a previously-instantiated DMA controller. * Destroy a previously-instantiated DMA controller.
*/ */
void dma_controller_destroy(struct dma_controller *c) void cppi_dma_controller_destroy(struct dma_controller *c)
{ {
struct cppi *cppi; struct cppi *cppi;
...@@ -1363,6 +1365,7 @@ void dma_controller_destroy(struct dma_controller *c) ...@@ -1363,6 +1365,7 @@ void dma_controller_destroy(struct dma_controller *c)
kfree(cppi); kfree(cppi);
} }
EXPORT_SYMBOL_GPL(cppi_dma_controller_destroy);
/* /*
* Context: controller irqlocked, endpoint selected * Context: controller irqlocked, endpoint selected
......
...@@ -463,6 +463,10 @@ static const struct musb_platform_ops da8xx_ops = { ...@@ -463,6 +463,10 @@ static const struct musb_platform_ops da8xx_ops = {
.exit = da8xx_musb_exit, .exit = da8xx_musb_exit,
.fifo_mode = 2, .fifo_mode = 2,
#ifdef CONFIG_USB_TI_CPPI_DMA
.dma_init = cppi_dma_controller_create,
.dma_exit = cppi_dma_controller_destroy,
#endif
.enable = da8xx_musb_enable, .enable = da8xx_musb_enable,
.disable = da8xx_musb_disable, .disable = da8xx_musb_disable,
......
...@@ -495,6 +495,10 @@ static const struct musb_platform_ops davinci_ops = { ...@@ -495,6 +495,10 @@ static const struct musb_platform_ops davinci_ops = {
.init = davinci_musb_init, .init = davinci_musb_init,
.exit = davinci_musb_exit, .exit = davinci_musb_exit,
#ifdef CONFIG_USB_TI_CPPI_DMA
.dma_init = cppi_dma_controller_create,
.dma_exit = cppi_dma_controller_destroy,
#endif
.enable = davinci_musb_enable, .enable = davinci_musb_enable,
.disable = davinci_musb_disable, .disable = davinci_musb_disable,
......
...@@ -105,6 +105,10 @@ static int jz4740_musb_exit(struct musb *musb) ...@@ -105,6 +105,10 @@ static int jz4740_musb_exit(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,
......
...@@ -389,6 +389,15 @@ EXPORT_SYMBOL_GPL(musb_readl); ...@@ -389,6 +389,15 @@ EXPORT_SYMBOL_GPL(musb_readl);
void (*musb_writel)(void __iomem *addr, unsigned offset, u32 data); void (*musb_writel)(void __iomem *addr, unsigned offset, u32 data);
EXPORT_SYMBOL_GPL(musb_writel); EXPORT_SYMBOL_GPL(musb_writel);
#ifndef CONFIG_MUSB_PIO_ONLY
struct dma_controller *
(*musb_dma_controller_create)(struct musb *musb, void __iomem *base);
EXPORT_SYMBOL(musb_dma_controller_create);
void (*musb_dma_controller_destroy)(struct dma_controller *c);
EXPORT_SYMBOL(musb_dma_controller_destroy);
#endif
/* /*
* New style IO functions * New style IO functions
*/ */
...@@ -2059,6 +2068,15 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) ...@@ -2059,6 +2068,15 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
if (musb->ops->writel) if (musb->ops->writel)
musb_writel = musb->ops->writel; musb_writel = musb->ops->writel;
#ifndef CONFIG_MUSB_PIO_ONLY
if (!musb->ops->dma_init || !musb->ops->dma_exit) {
dev_err(dev, "DMA controller not set\n");
goto fail2;
}
musb_dma_controller_create = musb->ops->dma_init;
musb_dma_controller_destroy = musb->ops->dma_exit;
#endif
if (musb->ops->read_fifo) if (musb->ops->read_fifo)
musb->io.read_fifo = musb->ops->read_fifo; musb->io.read_fifo = musb->ops->read_fifo;
else else
...@@ -2078,7 +2096,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) ...@@ -2078,7 +2096,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
pm_runtime_get_sync(musb->controller); pm_runtime_get_sync(musb->controller);
if (use_dma && dev->dma_mask) { if (use_dma && dev->dma_mask) {
musb->dma_controller = dma_controller_create(musb, musb->mregs); musb->dma_controller =
musb_dma_controller_create(musb, musb->mregs);
if (IS_ERR(musb->dma_controller)) { if (IS_ERR(musb->dma_controller)) {
status = PTR_ERR(musb->dma_controller); status = PTR_ERR(musb->dma_controller);
goto fail2_5; goto fail2_5;
...@@ -2189,7 +2208,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) ...@@ -2189,7 +2208,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
cancel_delayed_work_sync(&musb->finish_resume_work); cancel_delayed_work_sync(&musb->finish_resume_work);
cancel_delayed_work_sync(&musb->deassert_reset_work); cancel_delayed_work_sync(&musb->deassert_reset_work);
if (musb->dma_controller) if (musb->dma_controller)
dma_controller_destroy(musb->dma_controller); musb_dma_controller_destroy(musb->dma_controller);
fail2_5: fail2_5:
pm_runtime_put_sync(musb->controller); pm_runtime_put_sync(musb->controller);
...@@ -2248,7 +2267,7 @@ static int musb_remove(struct platform_device *pdev) ...@@ -2248,7 +2267,7 @@ static int musb_remove(struct platform_device *pdev)
musb_shutdown(pdev); musb_shutdown(pdev);
if (musb->dma_controller) if (musb->dma_controller)
dma_controller_destroy(musb->dma_controller); musb_dma_controller_destroy(musb->dma_controller);
cancel_work_sync(&musb->irq_work); cancel_work_sync(&musb->irq_work);
cancel_delayed_work_sync(&musb->finish_resume_work); cancel_delayed_work_sync(&musb->finish_resume_work);
......
...@@ -157,6 +157,8 @@ struct musb_io; ...@@ -157,6 +157,8 @@ struct musb_io;
* @writel: write 32 bits * @writel: write 32 bits
* @read_fifo: reads the fifo * @read_fifo: reads the fifo
* @write_fifo: writes to fifo * @write_fifo: writes to fifo
* @dma_init: platform specific dma init function
* @dma_exit: platform specific dma exit function
* @init: turns on clocks, sets up platform-specific registers, etc * @init: turns on clocks, sets up platform-specific registers, etc
* @exit: undoes @init * @exit: undoes @init
* @set_mode: forcefully changes operating mode * @set_mode: forcefully changes operating mode
...@@ -195,6 +197,9 @@ struct musb_platform_ops { ...@@ -195,6 +197,9 @@ struct musb_platform_ops {
void (*writel)(void __iomem *addr, unsigned offset, u32 data); void (*writel)(void __iomem *addr, unsigned offset, u32 data);
void (*read_fifo)(struct musb_hw_ep *hw_ep, u16 len, u8 *buf); void (*read_fifo)(struct musb_hw_ep *hw_ep, u16 len, u8 *buf);
void (*write_fifo)(struct musb_hw_ep *hw_ep, u16 len, const u8 *buf); void (*write_fifo)(struct musb_hw_ep *hw_ep, u16 len, const u8 *buf);
struct dma_controller *
(*dma_init) (struct musb *musb, void __iomem *base);
void (*dma_exit)(struct dma_controller *c);
int (*set_mode)(struct musb *musb, u8 mode); int (*set_mode)(struct musb *musb, u8 mode);
void (*try_idle)(struct musb *musb, unsigned long timeout); void (*try_idle)(struct musb *musb, unsigned long timeout);
int (*recover)(struct musb *musb); int (*recover)(struct musb *musb);
......
...@@ -678,7 +678,7 @@ static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller) ...@@ -678,7 +678,7 @@ static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller)
return ret; return ret;
} }
void dma_controller_destroy(struct dma_controller *c) void cppi41_dma_controller_destroy(struct dma_controller *c)
{ {
struct cppi41_dma_controller *controller = container_of(c, struct cppi41_dma_controller *controller = container_of(c,
struct cppi41_dma_controller, controller); struct cppi41_dma_controller, controller);
...@@ -687,9 +687,10 @@ void dma_controller_destroy(struct dma_controller *c) ...@@ -687,9 +687,10 @@ void dma_controller_destroy(struct dma_controller *c)
cppi41_dma_controller_stop(controller); cppi41_dma_controller_stop(controller);
kfree(controller); kfree(controller);
} }
EXPORT_SYMBOL_GPL(cppi41_dma_controller_destroy);
struct dma_controller *dma_controller_create(struct musb *musb, struct dma_controller *
void __iomem *base) cppi41_dma_controller_create(struct musb *musb, void __iomem *base)
{ {
struct cppi41_dma_controller *controller; struct cppi41_dma_controller *controller;
int ret = 0; int ret = 0;
...@@ -726,3 +727,4 @@ struct dma_controller *dma_controller_create(struct musb *musb, ...@@ -726,3 +727,4 @@ struct dma_controller *dma_controller_create(struct musb *musb,
return ERR_PTR(ret); return ERR_PTR(ret);
return NULL; return NULL;
} }
EXPORT_SYMBOL_GPL(cppi41_dma_controller_create);
...@@ -202,19 +202,41 @@ struct dma_controller { ...@@ -202,19 +202,41 @@ struct dma_controller {
extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit); extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit);
#ifdef CONFIG_MUSB_PIO_ONLY #ifdef CONFIG_MUSB_PIO_ONLY
static inline struct dma_controller *dma_controller_create(struct musb *m, static inline struct dma_controller *
void __iomem *io) musb_dma_controller_create(struct musb *m, void __iomem *io)
{ {
return NULL; return NULL;
} }
static inline void dma_controller_destroy(struct dma_controller *d) { } static inline void musb_dma_controller_destroy(struct dma_controller *d) { }
#else #else
extern struct dma_controller *dma_controller_create(struct musb *, void __iomem *); extern struct dma_controller *
(*musb_dma_controller_create)(struct musb *, void __iomem *);
extern void dma_controller_destroy(struct dma_controller *); extern void (*musb_dma_controller_destroy)(struct dma_controller *);
#endif #endif
/* Platform specific DMA functions */
extern struct dma_controller *
musbhs_dma_controller_create(struct musb *musb, void __iomem *base);
extern void musbhs_dma_controller_destroy(struct dma_controller *c);
extern struct dma_controller *
tusb_dma_controller_create(struct musb *musb, void __iomem *base);
extern void tusb_dma_controller_destroy(struct dma_controller *c);
extern struct dma_controller *
cppi_dma_controller_create(struct musb *musb, void __iomem *base);
extern void cppi_dma_controller_destroy(struct dma_controller *c);
extern struct dma_controller *
cppi41_dma_controller_create(struct musb *musb, void __iomem *base);
extern void cppi41_dma_controller_destroy(struct dma_controller *c);
extern struct dma_controller *
ux500_dma_controller_create(struct musb *musb, void __iomem *base);
extern void ux500_dma_controller_destroy(struct dma_controller *c);
#endif /* __MUSB_DMA_H__ */ #endif /* __MUSB_DMA_H__ */
...@@ -638,6 +638,10 @@ static struct musb_platform_ops dsps_ops = { ...@@ -638,6 +638,10 @@ static struct musb_platform_ops dsps_ops = {
.init = dsps_musb_init, .init = dsps_musb_init,
.exit = dsps_musb_exit, .exit = dsps_musb_exit,
#ifdef CONFIG_USB_TI_CPPI41_DMA
.dma_init = cppi41_dma_controller_create,
.dma_exit = cppi41_dma_controller_destroy,
#endif
.enable = dsps_musb_enable, .enable = dsps_musb_enable,
.disable = dsps_musb_disable, .disable = dsps_musb_disable,
......
...@@ -357,7 +357,7 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data) ...@@ -357,7 +357,7 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data)
return retval; return retval;
} }
void dma_controller_destroy(struct dma_controller *c) void musbhs_dma_controller_destroy(struct dma_controller *c)
{ {
struct musb_dma_controller *controller = container_of(c, struct musb_dma_controller *controller = container_of(c,
struct musb_dma_controller, controller); struct musb_dma_controller, controller);
...@@ -369,8 +369,10 @@ void dma_controller_destroy(struct dma_controller *c) ...@@ -369,8 +369,10 @@ void dma_controller_destroy(struct dma_controller *c)
kfree(controller); kfree(controller);
} }
EXPORT_SYMBOL_GPL(musbhs_dma_controller_destroy);
struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *base) struct dma_controller *musbhs_dma_controller_create(struct musb *musb,
void __iomem *base)
{ {
struct musb_dma_controller *controller; struct musb_dma_controller *controller;
struct device *dev = musb->controller; struct device *dev = musb->controller;
...@@ -398,7 +400,7 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba ...@@ -398,7 +400,7 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba
if (request_irq(irq, dma_controller_irq, 0, if (request_irq(irq, dma_controller_irq, 0,
dev_name(musb->controller), &controller->controller)) { dev_name(musb->controller), &controller->controller)) {
dev_err(dev, "request_irq %d failed!\n", irq); dev_err(dev, "request_irq %d failed!\n", irq);
dma_controller_destroy(&controller->controller); musb_dma_controller_destroy(&controller->controller);
return NULL; return NULL;
} }
...@@ -407,3 +409,4 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba ...@@ -407,3 +409,4 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba
return &controller->controller; return &controller->controller;
} }
EXPORT_SYMBOL_GPL(musbhs_dma_controller_create);
...@@ -494,6 +494,10 @@ static int omap2430_musb_exit(struct musb *musb) ...@@ -494,6 +494,10 @@ static int omap2430_musb_exit(struct musb *musb)
static const struct musb_platform_ops omap2430_ops = { static const struct musb_platform_ops omap2430_ops = {
.quirks = MUSB_DMA_INVENTRA, .quirks = MUSB_DMA_INVENTRA,
#ifdef CONFIG_USB_INVENTRA_DMA
.dma_init = musbhs_dma_controller_create,
.dma_exit = musbhs_dma_controller_destroy,
#endif
.init = omap2430_musb_init, .init = omap2430_musb_init,
.exit = omap2430_musb_exit, .exit = omap2430_musb_exit,
......
...@@ -1192,6 +1192,10 @@ static const struct musb_platform_ops tusb_ops = { ...@@ -1192,6 +1192,10 @@ static const struct musb_platform_ops tusb_ops = {
.writeb = tusb_writeb, .writeb = tusb_writeb,
.read_fifo = tusb_read_fifo, .read_fifo = tusb_read_fifo,
.write_fifo = tusb_write_fifo, .write_fifo = tusb_write_fifo,
#ifdef CONFIG_USB_TUSB_OMAP_DMA
.dma_init = tusb_dma_controller_create,
.dma_exit = tusb_dma_controller_destroy,
#endif
.enable = tusb_musb_enable, .enable = tusb_musb_enable,
.disable = tusb_musb_disable, .disable = tusb_musb_disable,
......
...@@ -625,7 +625,7 @@ static void tusb_omap_dma_release(struct dma_channel *channel) ...@@ -625,7 +625,7 @@ static void tusb_omap_dma_release(struct dma_channel *channel)
channel = NULL; channel = NULL;
} }
void dma_controller_destroy(struct dma_controller *c) void tusb_dma_controller_destroy(struct dma_controller *c)
{ {
struct tusb_omap_dma *tusb_dma; struct tusb_omap_dma *tusb_dma;
int i; int i;
...@@ -644,8 +644,10 @@ void dma_controller_destroy(struct dma_controller *c) ...@@ -644,8 +644,10 @@ void dma_controller_destroy(struct dma_controller *c)
kfree(tusb_dma); kfree(tusb_dma);
} }
EXPORT_SYMBOL_GPL(tusb_dma_controller_destroy);
struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *base) struct dma_controller *
tusb_dma_controller_create(struct musb *musb, void __iomem *base)
{ {
void __iomem *tbase = musb->ctrl_base; void __iomem *tbase = musb->ctrl_base;
struct tusb_omap_dma *tusb_dma; struct tusb_omap_dma *tusb_dma;
...@@ -701,7 +703,8 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba ...@@ -701,7 +703,8 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba
return &tusb_dma->controller; return &tusb_dma->controller;
cleanup: cleanup:
dma_controller_destroy(&tusb_dma->controller); musb_dma_controller_destroy(&tusb_dma->controller);
out: out:
return NULL; return NULL;
} }
EXPORT_SYMBOL_GPL(tusb_dma_controller_create);
...@@ -189,6 +189,10 @@ static int ux500_musb_exit(struct musb *musb) ...@@ -189,6 +189,10 @@ static int ux500_musb_exit(struct musb *musb)
static const struct musb_platform_ops ux500_ops = { static const struct musb_platform_ops ux500_ops = {
.quirks = MUSB_DMA_UX500 | MUSB_INDEXED_EP, .quirks = MUSB_DMA_UX500 | MUSB_INDEXED_EP,
#ifdef CONFIG_USB_UX500_DMA
.dma_init = ux500_dma_controller_create,
.dma_exit = ux500_dma_controller_destroy,
#endif
.init = ux500_musb_init, .init = ux500_musb_init,
.exit = ux500_musb_exit, .exit = ux500_musb_exit,
.fifo_mode = 5, .fifo_mode = 5,
......
...@@ -359,7 +359,7 @@ static int ux500_dma_controller_start(struct ux500_dma_controller *controller) ...@@ -359,7 +359,7 @@ static int ux500_dma_controller_start(struct ux500_dma_controller *controller)
return 0; return 0;
} }
void dma_controller_destroy(struct dma_controller *c) void ux500_dma_controller_destroy(struct dma_controller *c)
{ {
struct ux500_dma_controller *controller = container_of(c, struct ux500_dma_controller *controller = container_of(c,
struct ux500_dma_controller, controller); struct ux500_dma_controller, controller);
...@@ -367,9 +367,10 @@ void dma_controller_destroy(struct dma_controller *c) ...@@ -367,9 +367,10 @@ void dma_controller_destroy(struct dma_controller *c)
ux500_dma_controller_stop(controller); ux500_dma_controller_stop(controller);
kfree(controller); kfree(controller);
} }
EXPORT_SYMBOL_GPL(ux500_dma_controller_destroy);
struct dma_controller *dma_controller_create(struct musb *musb, struct dma_controller *
void __iomem *base) ux500_dma_controller_create(struct musb *musb, void __iomem *base)
{ {
struct ux500_dma_controller *controller; struct ux500_dma_controller *controller;
struct platform_device *pdev = to_platform_device(musb->controller); struct platform_device *pdev = to_platform_device(musb->controller);
...@@ -407,3 +408,4 @@ struct dma_controller *dma_controller_create(struct musb *musb, ...@@ -407,3 +408,4 @@ struct dma_controller *dma_controller_create(struct musb *musb,
kzalloc_fail: kzalloc_fail:
return NULL; return NULL;
} }
EXPORT_SYMBOL_GPL(ux500_dma_controller_create);
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