Skip to content

Commit 81ed02d

Browse files
hakehuangcarlescufi
authored andcommitted
dma: mcux edma driver support multi-channel
1. remove redundant protection on channel status 2. update link interface to support major and minor link Signed-off-by: Hake Huang <[email protected]>
1 parent e12e377 commit 81ed02d

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

drivers/dma/dma_mcux_edma.c

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -141,25 +141,15 @@ static void dma_mcux_edma_irq_handler(const struct device *dev)
141141

142142
LOG_DBG("IRQ CALLED");
143143
for (i = 0; i < DT_INST_PROP(0, dma_channels); i++) {
144-
if (DEV_CHANNEL_DATA(dev, i)->busy) {
145-
uint32_t flag =
146-
EDMA_GetChannelStatusFlags(DEV_BASE(dev), i);
147-
if ((flag & (uint32_t)kEDMA_InterruptFlag) != 0U) {
148-
LOG_DBG("IRQ OCCURRED");
149-
channel_irq(DEV_EDMA_HANDLE(dev, i));
150-
LOG_DBG("IRQ DONE");
144+
uint32_t flag = EDMA_GetChannelStatusFlags(DEV_BASE(dev), i);
145+
146+
if ((flag & (uint32_t)kEDMA_InterruptFlag) != 0U) {
147+
LOG_DBG("IRQ OCCURRED");
148+
channel_irq(DEV_EDMA_HANDLE(dev, i));
149+
LOG_DBG("IRQ DONE");
151150
#if defined __CORTEX_M && (__CORTEX_M == 4U)
152-
__DSB();
151+
__DSB();
153152
#endif
154-
} else {
155-
LOG_DBG("flag is 0x%x", flag);
156-
LOG_DBG("DMA ES 0x%x", DEV_BASE(dev)->ES);
157-
LOG_DBG("channel id %d", i);
158-
EDMA_ClearChannelStatusFlags(
159-
DEV_BASE(dev), i,
160-
kEDMA_ErrorFlag | kEDMA_DoneFlag);
161-
EDMA_AbortTransfer(DEV_EDMA_HANDLE(dev, i));
162-
}
163153
}
164154
}
165155
}
@@ -275,13 +265,6 @@ static int dma_mcux_edma_configure(const struct device *dev, uint32_t channel,
275265
EDMA_EnableChannelInterrupts(DEV_BASE(dev), channel,
276266
kEDMA_ErrorInterruptEnable);
277267

278-
if (config->source_chaining_en && config->dest_chaining_en) {
279-
/*chaining mode only support major link*/
280-
LOG_DBG("link major channel %d", config->linked_channel);
281-
EDMA_SetChannelLink(DEV_BASE(dev), channel, kEDMA_MajorLink,
282-
config->linked_channel);
283-
}
284-
285268
if (block_config->source_gather_en || block_config->dest_scatter_en) {
286269
if (config->block_count > CONFIG_DMA_TCD_QUEUE_SIZE) {
287270
LOG_ERR("please config DMA_TCD_QUEUE_SIZE as %d",
@@ -305,7 +288,7 @@ static int dma_mcux_edma_configure(const struct device *dev, uint32_t channel,
305288
} else {
306289
/* block_count shall be 1 */
307290
status_t ret;
308-
291+
LOG_DBG("block size is: %d", block_config->block_size);
309292
EDMA_PrepareTransfer(&(data->transferConfig),
310293
(void *)block_config->source_address,
311294
config->source_data_size,
@@ -323,6 +306,17 @@ static int dma_mcux_edma_configure(const struct device *dev, uint32_t channel,
323306
LOG_DBG("data csr is 0x%x", tcdRegs->CSR);
324307
}
325308

309+
if (config->dest_chaining_en) {
310+
LOG_DBG("link major channel %d", config->linked_channel);
311+
EDMA_SetChannelLink(DEV_BASE(dev), channel, kEDMA_MajorLink,
312+
config->linked_channel);
313+
}
314+
if (config->source_chaining_en) {
315+
LOG_DBG("link minor channel %d", config->linked_channel);
316+
EDMA_SetChannelLink(DEV_BASE(dev), channel, kEDMA_MinorLink,
317+
config->linked_channel);
318+
}
319+
326320
data->busy = false;
327321
if (config->dma_callback) {
328322
LOG_DBG("INSTALL call back on channel %d", channel);

0 commit comments

Comments
 (0)