Skip to content

Commit f5bf7df

Browse files
talih0kartben
authored andcommitted
drivers: dma_xmc4xxx: Support calling dma_stop() after dma_config()
In the dma loop_transfer test (test_loop_repeated_start_stop()), the order of calls is dma_config() -> dma_stop() -> dma_start(). This currently does not work on xmc4xxx because after calling dma_stop(), the dma would be in a suspended state. Fix this by leaving the suspended state before exiting dma_stop(). Also don't clear the context (dma_channel->dlr_line and dma_channel->cb) that was setup by dma_config(). Signed-off-by: Andriy Gelman <[email protected]>
1 parent 9c4cd30 commit f5bf7df

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/dma/dma_xmc4xxx.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ static int dma_xmc4xxx_config(const struct device *dev, uint32_t channel, struct
221221
config->source_burst_length / 4 << GPDMA0_CH_CTLL_SRC_MSIZE_Pos |
222222
BIT(GPDMA0_CH_CTLL_INT_EN_Pos);
223223

224+
dma->CH[channel].CFGH = 0;
224225
if (config->channel_direction == MEMORY_TO_PERIPHERAL ||
225226
config->channel_direction == PERIPHERAL_TO_MEMORY) {
226227
uint8_t request_source = XMC4XXX_DMA_GET_REQUEST_SOURCE(config->dma_slot);
@@ -315,8 +316,14 @@ static int dma_xmc4xxx_config(const struct device *dev, uint32_t channel, struct
315316
static int dma_xmc4xxx_start(const struct device *dev, uint32_t channel)
316317
{
317318
const struct dma_xmc4xxx_config *dev_cfg = dev->config;
319+
struct dma_xmc4xxx_data *dev_data = dev->data;
320+
uint8_t dlr_line = dev_data->channels[channel].dlr_line;
318321

319322
LOG_DBG("Starting channel %d", channel);
323+
if (dlr_line != DLR_LINE_UNSET && (DLR->LNEN & BIT(dlr_line)) == 0) {
324+
DLR->LNEN |= BIT(dlr_line);
325+
}
326+
320327
XMC_DMA_CH_Enable(dev_cfg->dma, channel);
321328
return 0;
322329
}
@@ -341,10 +348,8 @@ static int dma_xmc4xxx_stop(const struct device *dev, uint32_t channel)
341348
DLR->LNEN &= ~BIT(dma_channel->dlr_line);
342349
}
343350

344-
dma_channel->dlr_line = DLR_LINE_UNSET;
345-
dma_channel->cb = NULL;
346-
347351
XMC_DMA_CH_Disable(dma, channel);
352+
XMC_DMA_CH_Resume(dma, channel);
348353
return 0;
349354
}
350355

0 commit comments

Comments
 (0)