From: Robin Gong <[email protected]>

There are some differences between vf610 and next i.mx7ulp. Put such
differences into static driver data for distiguish easily in driver.

Signed-off-by: Robin Gong <[email protected]>
---
 drivers/dma/fsl-edma-common.h | 10 ++++++++++
 drivers/dma/fsl-edma.c        | 36 +++++++++++++++++++++++++++---------
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h
index 21a9cfd..014ab74 100644
--- a/drivers/dma/fsl-edma-common.h
+++ b/drivers/dma/fsl-edma-common.h
@@ -7,6 +7,7 @@
 #define _FSL_EDMA_COMMON_H_
 
 #include <linux/dma-direction.h>
+#include <linux/platform_device.h>
 #include "virt-dma.h"
 
 #define EDMA_CR_EDBG           BIT(1)
@@ -140,6 +141,14 @@ enum edma_version {
        v2, /* 64ch Coldfire */
 };
 
+struct fsl_edma_drvdata {
+       enum edma_version       version;
+       u32     dmamuxs;
+       bool    has_dmaclk;
+       int     (*setup_irq)(struct platform_device *pdev,
+                            struct fsl_edma_engine *fsl_edma);
+};
+
 struct fsl_edma_engine {
        struct dma_device       dma_dev;
        void __iomem            *membase;
@@ -147,6 +156,7 @@ struct fsl_edma_engine {
        struct clk              *muxclk[DMAMUX_NR];
        u32                     dmamux_nr;
        struct mutex            fsl_edma_mutex;
+       const struct fsl_edma_drvdata *drvdata;
        u32                     n_chans;
        int                     txirq;
        int                     errirq;
diff --git a/drivers/dma/fsl-edma.c b/drivers/dma/fsl-edma.c
index 7b65ef4..cf18301 100644
--- a/drivers/dma/fsl-edma.c
+++ b/drivers/dma/fsl-edma.c
@@ -184,16 +184,39 @@ static void fsl_disable_clocks(struct fsl_edma_engine 
*fsl_edma, int nr_clocks)
                clk_disable_unprepare(fsl_edma->muxclk[i]);
 }
 
+static struct fsl_edma_drvdata vf610_data = {
+       .version = v1,
+       .dmamuxs = DMAMUX_NR,
+       .has_dmaclk = false,
+       .setup_irq = fsl_edma_irq_init,
+};
+
+static const struct of_device_id fsl_edma_dt_ids[] = {
+       { .compatible = "fsl,vf610-edma", .data = &vf610_data},
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, fsl_edma_dt_ids);
+
 static int fsl_edma_probe(struct platform_device *pdev)
 {
+       const struct of_device_id *of_id =
+                       of_match_device(fsl_edma_dt_ids, &pdev->dev);
        struct device_node *np = pdev->dev.of_node;
        struct fsl_edma_engine *fsl_edma;
+       const struct fsl_edma_drvdata *drvdata = NULL;
        struct fsl_edma_chan *fsl_chan;
        struct edma_regs *regs;
        struct resource *res;
        int len, chans;
        int ret, i;
 
+       if (of_id)
+               drvdata = of_id->data;
+       if (!drvdata) {
+               dev_err(&pdev->dev, "unable to find driver data\n");
+               return -EINVAL;
+       }
+
        ret = of_property_read_u32(np, "dma-channels", &chans);
        if (ret) {
                dev_err(&pdev->dev, "Can't get dma-channels.\n");
@@ -205,8 +228,9 @@ static int fsl_edma_probe(struct platform_device *pdev)
        if (!fsl_edma)
                return -ENOMEM;
 
-       fsl_edma->version = v1;
-       fsl_edma->dmamux_nr = DMAMUX_NR;
+       fsl_edma->drvdata = drvdata;
+       fsl_edma->version = drvdata->version;
+       fsl_edma->dmamux_nr = drvdata->dmamuxs;
        fsl_edma->n_chans = chans;
        mutex_init(&fsl_edma->fsl_edma_mutex);
 
@@ -264,7 +288,7 @@ static int fsl_edma_probe(struct platform_device *pdev)
        }
 
        edma_writel(fsl_edma, ~0, regs->intl);
-       ret = fsl_edma_irq_init(pdev, fsl_edma);
+       ret = fsl_edma->drvdata->setup_irq(pdev, fsl_edma);
        if (ret)
                return ret;
 
@@ -383,12 +407,6 @@ static const struct dev_pm_ops fsl_edma_pm_ops = {
        .resume_early   = fsl_edma_resume_early,
 };
 
-static const struct of_device_id fsl_edma_dt_ids[] = {
-       { .compatible = "fsl,vf610-edma", },
-       { /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, fsl_edma_dt_ids);
-
 static struct platform_driver fsl_edma_driver = {
        .driver         = {
                .name   = "fsl-edma",
-- 
2.7.4

Reply via email to