Skip to content

Commit d8d4355

Browse files
1991Joyzouvinodkoul
authored andcommitted
dmaengine: fsl-edma: add i.MX8ULP edma support
Add support for the i.MX8ULP platform to the eDMA driver. Introduce the use of the correct FSL_EDMA_DRV_HAS_CHCLK flag to handle per-channel clock configurations. Signed-off-by: Joy Zou <joy.zou@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://lore.kernel.org/r/20240323-8ulp_edma-v3-5-c0e981027c05@nxp.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent b14f56b commit d8d4355

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

drivers/dma/fsl-edma-common.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Copyright (c) 2013-2014 Freescale Semiconductor, Inc
44
// Copyright (c) 2017 Sysam, Angelo Dureghello <angelo@sysam.it>
55

6+
#include <linux/clk.h>
67
#include <linux/dmapool.h>
78
#include <linux/module.h>
89
#include <linux/slab.h>
@@ -810,6 +811,9 @@ int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
810811
{
811812
struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
812813

814+
if (fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_HAS_CHCLK)
815+
clk_prepare_enable(fsl_chan->clk);
816+
813817
fsl_chan->tcd_pool = dma_pool_create("tcd_pool", chan->device->dev,
814818
fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_TCD64 ?
815819
sizeof(struct fsl_edma_hw_tcd64) : sizeof(struct fsl_edma_hw_tcd),
@@ -838,6 +842,8 @@ void fsl_edma_free_chan_resources(struct dma_chan *chan)
838842
fsl_chan->tcd_pool = NULL;
839843
fsl_chan->is_sw = false;
840844
fsl_chan->srcid = 0;
845+
if (fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_HAS_CHCLK)
846+
clk_disable_unprepare(fsl_chan->clk);
841847
}
842848

843849
void fsl_edma_cleanup_vchan(struct dma_device *dmadev)

drivers/dma/fsl-edma-common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ struct fsl_edma_desc {
192192
#define FSL_EDMA_DRV_WRAP_IO BIT(3)
193193
#define FSL_EDMA_DRV_EDMA64 BIT(4)
194194
#define FSL_EDMA_DRV_HAS_PD BIT(5)
195+
#define FSL_EDMA_DRV_HAS_CHCLK BIT(6)
195196
#define FSL_EDMA_DRV_HAS_CHMUX BIT(7)
196197
/* imx8 QM audio edma remote local swapped */
197198
#define FSL_EDMA_DRV_QUIRK_SWAPPED BIT(8)

drivers/dma/fsl-edma-main.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,16 @@ static struct fsl_edma_drvdata imx8qm_audio_data = {
356356
.setup_irq = fsl_edma3_irq_init,
357357
};
358358

359+
static struct fsl_edma_drvdata imx8ulp_data = {
360+
.flags = FSL_EDMA_DRV_HAS_CHMUX | FSL_EDMA_DRV_HAS_CHCLK | FSL_EDMA_DRV_HAS_DMACLK |
361+
FSL_EDMA_DRV_EDMA3,
362+
.chreg_space_sz = 0x10000,
363+
.chreg_off = 0x10000,
364+
.mux_off = 0x10000 + offsetof(struct fsl_edma3_ch_reg, ch_mux),
365+
.mux_skip = 0x10000,
366+
.setup_irq = fsl_edma3_irq_init,
367+
};
368+
359369
static struct fsl_edma_drvdata imx93_data3 = {
360370
.flags = FSL_EDMA_DRV_HAS_DMACLK | FSL_EDMA_DRV_EDMA3,
361371
.chreg_space_sz = 0x10000,
@@ -388,6 +398,7 @@ static const struct of_device_id fsl_edma_dt_ids[] = {
388398
{ .compatible = "fsl,imx7ulp-edma", .data = &imx7ulp_data},
389399
{ .compatible = "fsl,imx8qm-edma", .data = &imx8qm_data},
390400
{ .compatible = "fsl,imx8qm-adma", .data = &imx8qm_audio_data},
401+
{ .compatible = "fsl,imx8ulp-edma", .data = &imx8ulp_data},
391402
{ .compatible = "fsl,imx93-edma3", .data = &imx93_data3},
392403
{ .compatible = "fsl,imx93-edma4", .data = &imx93_data4},
393404
{ .compatible = "fsl,imx95-edma5", .data = &imx95_data5},
@@ -441,6 +452,7 @@ static int fsl_edma_probe(struct platform_device *pdev)
441452
struct fsl_edma_engine *fsl_edma;
442453
const struct fsl_edma_drvdata *drvdata = NULL;
443454
u32 chan_mask[2] = {0, 0};
455+
char clk_name[36];
444456
struct edma_regs *regs;
445457
int chans;
446458
int ret, i;
@@ -550,11 +562,21 @@ static int fsl_edma_probe(struct platform_device *pdev)
550562
+ i * drvdata->chreg_space_sz + drvdata->chreg_off + len;
551563
fsl_chan->mux_addr = fsl_edma->membase + drvdata->mux_off + i * drvdata->mux_skip;
552564

565+
if (drvdata->flags & FSL_EDMA_DRV_HAS_CHCLK) {
566+
snprintf(clk_name, sizeof(clk_name), "ch%02d", i);
567+
fsl_chan->clk = devm_clk_get_enabled(&pdev->dev,
568+
(const char *)clk_name);
569+
570+
if (IS_ERR(fsl_chan->clk))
571+
return PTR_ERR(fsl_chan->clk);
572+
}
553573
fsl_chan->pdev = pdev;
554574
vchan_init(&fsl_chan->vchan, &fsl_edma->dma_dev);
555575

556576
edma_write_tcdreg(fsl_chan, cpu_to_le32(0), csr);
557577
fsl_edma_chan_mux(fsl_chan, 0, false);
578+
if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_HAS_CHCLK)
579+
clk_disable_unprepare(fsl_chan->clk);
558580
}
559581

560582
ret = fsl_edma->drvdata->setup_irq(pdev, fsl_edma);

0 commit comments

Comments
 (0)