From 9c49ee3e481bf20ab3d42248fc6a88ec79da1bf7 Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Thu, 1 Dec 2022 11:25:46 +0100 Subject: [PATCH] drivers: dma: stm32u5 dma with resume API function Add the resume API function for the dma driver of the stm32U5 serie. That completes the suspend API function. Controlling the SUSPF bit of the GPDMA CR register is enough to suspend/resume the channel. Signed-off-by: Francois Ramu --- drivers/dma/dma_stm32u5.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/dma/dma_stm32u5.c b/drivers/dma/dma_stm32u5.c index 7b12c2cad02..3b1814d4f25 100644 --- a/drivers/dma/dma_stm32u5.c +++ b/drivers/dma/dma_stm32u5.c @@ -586,6 +586,24 @@ static int dma_stm32_suspend(const struct device *dev, uint32_t id) return 0; } +static int dma_stm32_resume(const struct device *dev, uint32_t id) +{ + const struct dma_stm32_config *config = dev->config; + DMA_TypeDef *dma = (DMA_TypeDef *)(config->base); + + /* Give channel from index 0 */ + id = id - STM32_DMA_STREAM_OFFSET; + + if (id >= config->max_streams) { + return -EINVAL; + } + + /* Resume the channel : it's enough after suspend */ + LL_DMA_ResumeChannel(dma, dma_stm32_id_to_stream(id)); + + return 0; +} + static int dma_stm32_stop(const struct device *dev, uint32_t id) { const struct dma_stm32_config *config = dev->config; @@ -662,6 +680,7 @@ static const struct dma_driver_api dma_funcs = { .stop = dma_stm32_stop, .get_status = dma_stm32_get_status, .suspend = dma_stm32_suspend, + .resume = dma_stm32_resume, }; #define DMA_STM32_OFFSET_INIT(index)