Merge tag 'dmaengine-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul...
[platform/kernel/linux-rpi.git] / drivers / dma / mcf-edma-main.c
similarity index 88%
rename from drivers/dma/mcf-edma.c
rename to drivers/dma/mcf-edma-main.c
index 9413fad..b359421 100644 (file)
@@ -19,7 +19,6 @@ static irqreturn_t mcf_edma_tx_handler(int irq, void *dev_id)
        struct fsl_edma_engine *mcf_edma = dev_id;
        struct edma_regs *regs = &mcf_edma->regs;
        unsigned int ch;
-       struct fsl_edma_chan *mcf_chan;
        u64 intmap;
 
        intmap = ioread32(regs->inth);
@@ -31,31 +30,7 @@ static irqreturn_t mcf_edma_tx_handler(int irq, void *dev_id)
        for (ch = 0; ch < mcf_edma->n_chans; ch++) {
                if (intmap & BIT(ch)) {
                        iowrite8(EDMA_MASK_CH(ch), regs->cint);
-
-                       mcf_chan = &mcf_edma->chans[ch];
-
-                       spin_lock(&mcf_chan->vchan.lock);
-
-                       if (!mcf_chan->edesc) {
-                               /* terminate_all called before */
-                               spin_unlock(&mcf_chan->vchan.lock);
-                               continue;
-                       }
-
-                       if (!mcf_chan->edesc->iscyclic) {
-                               list_del(&mcf_chan->edesc->vdesc.node);
-                               vchan_cookie_complete(&mcf_chan->edesc->vdesc);
-                               mcf_chan->edesc = NULL;
-                               mcf_chan->status = DMA_COMPLETE;
-                               mcf_chan->idle = true;
-                       } else {
-                               vchan_cyclic_callback(&mcf_chan->edesc->vdesc);
-                       }
-
-                       if (!mcf_chan->edesc)
-                               fsl_edma_xfer_desc(mcf_chan);
-
-                       spin_unlock(&mcf_chan->vchan.lock);
+                       fsl_edma_tx_chan_handler(&mcf_edma->chans[ch]);
                }
        }
 
@@ -76,8 +51,7 @@ static irqreturn_t mcf_edma_err_handler(int irq, void *dev_id)
                if (err & BIT(ch)) {
                        fsl_edma_disable_request(&mcf_edma->chans[ch]);
                        iowrite8(EDMA_CERR_CERR(ch), regs->cerr);
-                       mcf_edma->chans[ch].status = DMA_ERROR;
-                       mcf_edma->chans[ch].idle = true;
+                       fsl_edma_err_chan_handler(&mcf_edma->chans[ch]);
                }
        }
 
@@ -172,7 +146,7 @@ static void mcf_edma_irq_free(struct platform_device *pdev,
 }
 
 static struct fsl_edma_drvdata mcf_data = {
-       .version = v2,
+       .flags = FSL_EDMA_DRV_EDMA64,
        .setup_irq = mcf_edma_irq_init,
 };
 
@@ -180,9 +154,8 @@ static int mcf_edma_probe(struct platform_device *pdev)
 {
        struct mcf_edma_platform_data *pdata;
        struct fsl_edma_engine *mcf_edma;
-       struct fsl_edma_chan *mcf_chan;
        struct edma_regs *regs;
-       int ret, i, len, chans;
+       int ret, i, chans;
 
        pdata = dev_get_platdata(&pdev->dev);
        if (!pdata) {
@@ -197,8 +170,8 @@ static int mcf_edma_probe(struct platform_device *pdev)
                chans = pdata->dma_channels;
        }
 
-       len = sizeof(*mcf_edma) + sizeof(*mcf_chan) * chans;
-       mcf_edma = devm_kzalloc(&pdev->dev, len, GFP_KERNEL);
+       mcf_edma = devm_kzalloc(&pdev->dev, struct_size(mcf_edma, chans, chans),
+                               GFP_KERNEL);
        if (!mcf_edma)
                return -ENOMEM;
 
@@ -227,7 +200,9 @@ static int mcf_edma_probe(struct platform_device *pdev)
                mcf_chan->dma_dir = DMA_NONE;
                mcf_chan->vchan.desc_free = fsl_edma_free_desc;
                vchan_init(&mcf_chan->vchan, &mcf_edma->dma_dev);
-               iowrite32(0x0, &regs->tcd[i].csr);
+               mcf_chan->tcd = mcf_edma->membase + EDMA_TCD
+                               + i * sizeof(struct fsl_edma_hw_tcd);
+               iowrite32(0x0, &mcf_chan->tcd->csr);
        }
 
        iowrite32(~0, regs->inth);