usb: musb: Set up function pointers for DMA
authorTony Lindgren <tony@atomide.com>
Fri, 1 May 2015 19:29:28 +0000 (12:29 -0700)
committerFelipe Balbi <balbi@ti.com>
Thu, 7 May 2015 18:35:51 +0000 (13:35 -0500)
Set up function pointers for DMA so get closer to
being able to build in all the DMA engines.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
17 files changed:
drivers/usb/musb/am35x.c
drivers/usb/musb/blackfin.c
drivers/usb/musb/cppi_dma.c
drivers/usb/musb/da8xx.c
drivers/usb/musb/davinci.c
drivers/usb/musb/jz4740.c
drivers/usb/musb/musb_core.c
drivers/usb/musb/musb_core.h
drivers/usb/musb/musb_cppi41.c
drivers/usb/musb/musb_dma.h
drivers/usb/musb/musb_dsps.c
drivers/usb/musb/musbhsdma.c
drivers/usb/musb/omap2430.c
drivers/usb/musb/tusb6010.c
drivers/usb/musb/tusb6010_omap.c
drivers/usb/musb/ux500.c
drivers/usb/musb/ux500_dma.c

index 72ce2e862b61216d2559c721ae8fbc8e5439b795..6cfd43a62d3ba4f9b4ce051f5be10415c40dea0e 100644 (file)
@@ -443,6 +443,10 @@ static const struct musb_platform_ops am35x_ops = {
        .exit           = am35x_musb_exit,
 
        .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,
        .disable        = am35x_musb_disable,
 
index 2a73a730bfa509b103f3f7990148b40b3dfa81bd..310238c6b5cd699bcd89ef101b926feba5d60a8c 100644 (file)
@@ -478,6 +478,10 @@ static const struct musb_platform_ops bfin_ops = {
        .fifo_mode      = 2,
        .read_fifo      = bfin_read_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,
        .disable        = bfin_musb_disable,
 
index 904fb85d85a6c36811ce33ddbf0761beff21454c..cc134109b056d1e210bb18a6f30e82abe7051529 100644 (file)
@@ -1297,7 +1297,8 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id)
 EXPORT_SYMBOL_GPL(cppi_interrupt);
 
 /* 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 device           *dev = musb->controller;
@@ -1334,7 +1335,7 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mr
        if (irq > 0) {
                if (request_irq(irq, cppi_interrupt, 0, "cppi-dma", musb)) {
                        dev_err(dev, "request_irq %d failed!\n", irq);
-                       dma_controller_destroy(&controller->controller);
+                       musb_dma_controller_destroy(&controller->controller);
                        return NULL;
                }
                controller->irq = irq;
@@ -1343,11 +1344,12 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mr
        cppi_controller_start(controller);
        return &controller->controller;
 }
+EXPORT_SYMBOL_GPL(cppi_dma_controller_create);
 
 /*
  *  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;
 
@@ -1363,6 +1365,7 @@ void dma_controller_destroy(struct dma_controller *c)
 
        kfree(cppi);
 }
+EXPORT_SYMBOL_GPL(cppi_dma_controller_destroy);
 
 /*
  * Context: controller irqlocked, endpoint selected
index 06c442c2fb20454c922953d69e3932e3c253cdc0..b03d3b867fca2f8b06f2340c3fffaf5c53a4da13 100644 (file)
@@ -463,6 +463,10 @@ static const struct musb_platform_ops da8xx_ops = {
        .exit           = da8xx_musb_exit,
 
        .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,
        .disable        = da8xx_musb_disable,
 
index 26bfdb33bcc7118132f87c3eabf2c97952503e29..cee61a51645ee3da566c1a5124a589ea7895025c 100644 (file)
@@ -495,6 +495,10 @@ static const struct musb_platform_ops davinci_ops = {
        .init           = davinci_musb_init,
        .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,
        .disable        = davinci_musb_disable,
 
index b7b5fdc0000e4a293e8192d68044c51e5280d663..5e5a8fa005f8befc1ca9eb4814b12afbf8e3ccea 100644 (file)
@@ -105,6 +105,10 @@ static int jz4740_musb_exit(struct musb *musb)
        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 = {
        .quirks         = MUSB_DMA_INVENTRA | MUSB_INDEXED_EP,
        .fifo_mode      = 2,
index 4ac060ab8a89ce0019ead8368c9d925ef531c2d7..5f35ecdcefd03a15037675789e81de4d42036611 100644 (file)
@@ -389,6 +389,15 @@ EXPORT_SYMBOL_GPL(musb_readl);
 void (*musb_writel)(void __iomem *addr, unsigned offset, u32 data);
 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
  */
@@ -2059,6 +2068,15 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
        if (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)
                musb->io.read_fifo = musb->ops->read_fifo;
        else
@@ -2078,7 +2096,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
        pm_runtime_get_sync(musb->controller);
 
        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)) {
                        status = PTR_ERR(musb->dma_controller);
                        goto fail2_5;
@@ -2189,7 +2208,7 @@ fail3:
        cancel_delayed_work_sync(&musb->finish_resume_work);
        cancel_delayed_work_sync(&musb->deassert_reset_work);
        if (musb->dma_controller)
-               dma_controller_destroy(musb->dma_controller);
+               musb_dma_controller_destroy(musb->dma_controller);
 fail2_5:
        pm_runtime_put_sync(musb->controller);
 
@@ -2248,7 +2267,7 @@ static int musb_remove(struct platform_device *pdev)
        musb_shutdown(pdev);
 
        if (musb->dma_controller)
-               dma_controller_destroy(musb->dma_controller);
+               musb_dma_controller_destroy(musb->dma_controller);
 
        cancel_work_sync(&musb->irq_work);
        cancel_delayed_work_sync(&musb->finish_resume_work);
index 3877249a8b2d39c009da0a93874b79c3155a26b4..c7a0d933eff904f0d64a15f16947abc58f6ac6d7 100644 (file)
@@ -157,6 +157,8 @@ struct musb_io;
  * @writel:    write 32 bits
  * @read_fifo: reads the 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
  * @exit:      undoes @init
  * @set_mode:  forcefully changes operating mode
@@ -195,6 +197,9 @@ struct musb_platform_ops {
        void    (*writel)(void __iomem *addr, unsigned offset, u32 data);
        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);
+       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);
        void    (*try_idle)(struct musb *musb, unsigned long timeout);
        int     (*recover)(struct musb *musb);
index 8bd8c5e26921caea09e9a7cd973b462df8622249..4d1b44c232ee4e19e79b8ebd10f0626ad4be635a 100644 (file)
@@ -678,7 +678,7 @@ err:
        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);
@@ -687,9 +687,10 @@ void dma_controller_destroy(struct dma_controller *c)
        cppi41_dma_controller_stop(controller);
        kfree(controller);
 }
+EXPORT_SYMBOL_GPL(cppi41_dma_controller_destroy);
 
-struct dma_controller *dma_controller_create(struct musb *musb,
-                                       void __iomem *base)
+struct dma_controller *
+cppi41_dma_controller_create(struct musb *musb, void __iomem *base)
 {
        struct cppi41_dma_controller *controller;
        int ret = 0;
@@ -726,3 +727,4 @@ kzalloc_fail:
                return ERR_PTR(ret);
        return NULL;
 }
+EXPORT_SYMBOL_GPL(cppi41_dma_controller_create);
index 555f2aed5a556bf72638dfa0869f9501e91ffa5a..46357e183b4c8b764045091dd2153a09df2d3789 100644 (file)
@@ -202,19 +202,41 @@ struct dma_controller {
 extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit);
 
 #ifdef CONFIG_MUSB_PIO_ONLY
-static inline struct dma_controller *dma_controller_create(struct musb *m,
-               void __iomem *io)
+static inline struct dma_controller *
+musb_dma_controller_create(struct musb *m, void __iomem *io)
 {
        return NULL;
 }
 
-static inline void dma_controller_destroy(struct dma_controller *d) { }
+static inline void musb_dma_controller_destroy(struct dma_controller *d) { }
 
 #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
 
+/* 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__ */
index 63a8d5bbd3659f411142d08295c79e9bebea9ccd..1334a3de31b8e937756d9546073d41f71ee513bd 100644 (file)
@@ -638,6 +638,10 @@ static struct musb_platform_ops dsps_ops = {
        .init           = dsps_musb_init,
        .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,
        .disable        = dsps_musb_disable,
 
index ab7ec09a8afe5200b65ba773ee4cab675aa4d855..7539c3188ffc749bed2fe4da98c0a491ba583ac6 100644 (file)
@@ -357,7 +357,7 @@ done:
        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);
@@ -369,8 +369,10 @@ void dma_controller_destroy(struct dma_controller *c)
 
        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 device *dev = musb->controller;
@@ -398,7 +400,7 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba
        if (request_irq(irq, dma_controller_irq, 0,
                        dev_name(musb->controller), &controller->controller)) {
                dev_err(dev, "request_irq %d failed!\n", irq);
-               dma_controller_destroy(&controller->controller);
+               musb_dma_controller_destroy(&controller->controller);
 
                return NULL;
        }
@@ -407,3 +409,4 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba
 
        return &controller->controller;
 }
+EXPORT_SYMBOL_GPL(musbhs_dma_controller_create);
index 5546a22db2ed4b07631aad70932c77e4dfc8dbd9..70f2b8a2e6cfe5d62d6509c507670aee8c981dd7 100644 (file)
@@ -494,6 +494,10 @@ static int omap2430_musb_exit(struct musb *musb)
 
 static const struct musb_platform_ops omap2430_ops = {
        .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,
        .exit           = omap2430_musb_exit,
 
index af923ded829ee0acf0b49a2554ee9f7fca983938..df7c9f46be548f61800b7beaa7f182b5dc447ad5 100644 (file)
@@ -1192,6 +1192,10 @@ static const struct musb_platform_ops tusb_ops = {
        .writeb         = tusb_writeb,
        .read_fifo      = tusb_read_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,
        .disable        = tusb_musb_disable,
 
index 3ce152c0408e6464c93a5e8c46f429753aef38a0..4c82077da475404ded343c5dfba80a0c8da5d8d0 100644 (file)
@@ -625,7 +625,7 @@ static void tusb_omap_dma_release(struct dma_channel *channel)
        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;
        int                     i;
@@ -644,8 +644,10 @@ void dma_controller_destroy(struct dma_controller *c)
 
        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;
        struct tusb_omap_dma    *tusb_dma;
@@ -701,7 +703,8 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba
        return &tusb_dma->controller;
 
 cleanup:
-       dma_controller_destroy(&tusb_dma->controller);
+       musb_dma_controller_destroy(&tusb_dma->controller);
 out:
        return NULL;
 }
+EXPORT_SYMBOL_GPL(tusb_dma_controller_create);
index c6582f13ed487040870131edb6d062b0ffcd5f25..2967b51383d81abaa198d048f10b2691fee489e9 100644 (file)
@@ -189,6 +189,10 @@ static int ux500_musb_exit(struct musb *musb)
 
 static const struct musb_platform_ops ux500_ops = {
        .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,
        .exit           = ux500_musb_exit,
        .fifo_mode      = 5,
index e93845c26bdb2ee0884d9706919180356f904ac6..d0b6a1cd7f622a8cb3848a5a76126fedc6daa938 100644 (file)
@@ -359,7 +359,7 @@ static int ux500_dma_controller_start(struct ux500_dma_controller *controller)
        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);
@@ -367,9 +367,10 @@ void dma_controller_destroy(struct dma_controller *c)
        ux500_dma_controller_stop(controller);
        kfree(controller);
 }
+EXPORT_SYMBOL_GPL(ux500_dma_controller_destroy);
 
-struct dma_controller *dma_controller_create(struct musb *musb,
-                                       void __iomem *base)
+struct dma_controller *
+ux500_dma_controller_create(struct musb *musb, void __iomem *base)
 {
        struct ux500_dma_controller *controller;
        struct platform_device *pdev = to_platform_device(musb->controller);
@@ -407,3 +408,4 @@ plat_get_fail:
 kzalloc_fail:
        return NULL;
 }
+EXPORT_SYMBOL_GPL(ux500_dma_controller_create);