Skip to content

Commit 00c3528

Browse files
talih0kartben
authored andcommitted
drivers: dma: dma_xmc4xxx: Add cyclic support
Adds cyclic support, where a multi-block transfer is automatically reloaded to the first block after the multi-block transfer completes. Signed-off-by: Andriy Gelman <[email protected]>
1 parent 51f3422 commit 00c3528

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drivers/dma/dma_xmc4xxx.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,11 @@ static int dma_xmc4xxx_config(const struct device *dev, uint32_t channel, struct
233233
return -EINVAL;
234234
}
235235

236-
if (block->source_gather_en || block->dest_scatter_en || config->block_count != 1) {
236+
if (block->source_gather_en || block->dest_scatter_en || config->block_count != 1 ||
237+
config->cyclic) {
237238
if ((uint32_t)dma != (uint32_t)XMC_DMA0 || channel >= 2) {
238-
LOG_ERR("Multi-block and gather/scatter only supported on DMA0 on ch0 and ch1");
239+
LOG_ERR("Multi-block, cyclic and gather/scatter only supported on DMA0 on "
240+
"ch0 and ch1");
239241
return -EINVAL;
240242
}
241243
}
@@ -277,7 +279,7 @@ static int dma_xmc4xxx_config(const struct device *dev, uint32_t channel, struct
277279
XMC_DMA_CH_ClearEventStatus(dma, channel, ALL_EVENTS);
278280

279281
/* check dma slot number */
280-
if (config->block_count == 1) {
282+
if (config->block_count == 1 && config->cyclic == 0) {
281283
uint32_t ctll;
282284

283285
dma->CH[channel].SAR = block->source_address;
@@ -313,12 +315,17 @@ static int dma_xmc4xxx_config(const struct device *dev, uint32_t channel, struct
313315

314316
if (i < config->block_count - 1) {
315317
desc->llp = (uint32_t)&descriptor_list[channel][i + 1];
316-
ctll |= BIT(GPDMA0_CH_CTLL_LLP_DST_EN_Pos) |
317-
BIT(GPDMA0_CH_CTLL_LLP_SRC_EN_Pos);
318+
} else if (config->cyclic) {
319+
desc->llp = (uint32_t)&descriptor_list[channel][0];
318320
} else {
319321
desc->llp = 0;
320322
}
321323

324+
if (i < config->block_count - 1 || config->cyclic) {
325+
ctll |= BIT(GPDMA0_CH_CTLL_LLP_DST_EN_Pos) |
326+
BIT(GPDMA0_CH_CTLL_LLP_SRC_EN_Pos);
327+
}
328+
322329
desc->ctll = ctll;
323330

324331
SET_CHECK_SCATTER_GATHER(source_gather);

0 commit comments

Comments
 (0)