From 67979f5665bb87384c309d5ec7da1e41ca7b53aa Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Thu, 21 Aug 2025 17:43:24 +0200 Subject: [PATCH 1/7] drivers: disk: sdmmc: stm32l4: Select DMA if enabled in dt On STM32L4, similarly to other STM32 series, enable DMA directly based on dt configuration and avoid need to configure it at application level. Signed-off-by: Erwan Gouriou --- drivers/disk/Kconfig.sdmmc | 2 +- .../disk/disk_access/boards/stm32l496g_disco_stm32l496xx.conf | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 tests/drivers/disk/disk_access/boards/stm32l496g_disco_stm32l496xx.conf diff --git a/drivers/disk/Kconfig.sdmmc b/drivers/disk/Kconfig.sdmmc index 50b689891a201..baf6b5592f4f6 100644 --- a/drivers/disk/Kconfig.sdmmc +++ b/drivers/disk/Kconfig.sdmmc @@ -38,7 +38,7 @@ config SDMMC_STM32 select USE_STM32_HAL_MMC_EX if SDMMC_STM32_EMMC && SOC_SERIES_STM32L4X select USE_STM32_LL_SDMMC select USE_STM32_HAL_DMA if (SOC_SERIES_STM32L4X || SOC_SERIES_STM32F7X || SOC_SERIES_STM32F4X) - select DMA if $(DT_STM32_SDMMC_HAS_DMA) && (SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X) + select DMA if $(DT_STM32_SDMMC_HAS_DMA) && (SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X || SOC_SERIES_STM32L4X) select PINCTRL select RESET help diff --git a/tests/drivers/disk/disk_access/boards/stm32l496g_disco_stm32l496xx.conf b/tests/drivers/disk/disk_access/boards/stm32l496g_disco_stm32l496xx.conf deleted file mode 100644 index 73aff8957e7a7..0000000000000 --- a/tests/drivers/disk/disk_access/boards/stm32l496g_disco_stm32l496xx.conf +++ /dev/null @@ -1 +0,0 @@ -CONFIG_DMA=y From 068846ce772a31e6a053ad89b556afcef15000dc Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Fri, 25 Jul 2025 10:54:44 +0200 Subject: [PATCH 2/7] drivers: dma: stm32u5: Clean up stream offset code STM32_DMA_STREAM_OFFSET is defined as 0 in case "dma u5" is in use. Clean up code relating to this define. Signed-off-by: Erwan Gouriou --- drivers/dma/dma_stm32u5.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/drivers/dma/dma_stm32u5.c b/drivers/dma/dma_stm32u5.c index c7d3225a49ecb..0fcae4bb1de10 100644 --- a/drivers/dma/dma_stm32u5.c +++ b/drivers/dma/dma_stm32u5.c @@ -265,9 +265,9 @@ static void dma_stm32_irq_handler(const struct device *dev, uint32_t id) dma_stm32_clear_stream_irq(dev, id); return; } - callback_arg = id + STM32_DMA_STREAM_OFFSET; + callback_arg = id; - /* The dma stream id is in range from STM32_DMA_STREAM_OFFSET.. */ + /* The dma stream id is in range from 0.. */ if (stm32_dma_is_ht_irq_active(dma, id)) { /* Let HAL DMA handle flags on its own */ if (!stream->hal_override) { @@ -349,16 +349,12 @@ static int dma_stm32_configure(const struct device *dev, struct dma_config *config) { const struct dma_stm32_config *dev_config = dev->config; - struct dma_stm32_stream *stream = - &dev_config->streams[id - STM32_DMA_STREAM_OFFSET]; + struct dma_stm32_stream *stream = &dev_config->streams[id]; DMA_TypeDef *dma = (DMA_TypeDef *)dev_config->base; uint32_t ll_priority; uint32_t ll_direction; int ret; - /* Give channel from index 0 */ - id = id - STM32_DMA_STREAM_OFFSET; - if (id >= dev_config->max_streams) { LOG_ERR("cannot configure the dma stream %d.", id); return -EINVAL; @@ -553,9 +549,6 @@ static int dma_stm32_reload(const struct device *dev, uint32_t id, DMA_TypeDef *dma = (DMA_TypeDef *)(config->base); struct dma_stm32_stream *stream; - /* Give channel from index 0 */ - id = id - STM32_DMA_STREAM_OFFSET; - if (id >= config->max_streams) { return -EINVAL; } @@ -590,9 +583,6 @@ static int dma_stm32_start(const struct device *dev, uint32_t id) DMA_TypeDef *dma = (DMA_TypeDef *)(config->base); struct dma_stm32_stream *stream; - /* Give channel from index 0 */ - id = id - STM32_DMA_STREAM_OFFSET; - /* Only M2P or M2M mode can be started manually. */ if (id >= config->max_streams) { return -EINVAL; @@ -619,9 +609,6 @@ static int dma_stm32_suspend(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; } @@ -642,9 +629,6 @@ 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; } @@ -658,12 +642,9 @@ static int dma_stm32_resume(const struct device *dev, uint32_t id) static int dma_stm32_stop(const struct device *dev, uint32_t id) { const struct dma_stm32_config *config = dev->config; - struct dma_stm32_stream *stream = &config->streams[id - STM32_DMA_STREAM_OFFSET]; + struct dma_stm32_stream *stream = &config->streams[id]; 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; } @@ -723,8 +704,6 @@ static int dma_stm32_get_status(const struct device *dev, DMA_TypeDef *dma = (DMA_TypeDef *)(config->base); struct dma_stm32_stream *stream; - /* Give channel from index 0 */ - id = id - STM32_DMA_STREAM_OFFSET; if (id >= config->max_streams) { return -EINVAL; } From bd9dceabdba07a6ec4a57275eb66b6d046f6f26b Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Fri, 22 Aug 2025 13:08:02 +0200 Subject: [PATCH 3/7] drivers: dma: stm32: Align channel offset handling in all API functions To ease code understanding of offset handling within the driver, harmonize its treatment within impacted functions. Signed-off-by: Erwan Gouriou --- drivers/dma/dma_stm32.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/dma/dma_stm32.c b/drivers/dma/dma_stm32.c index 968e5b9d8d935..1509d536d47d6 100644 --- a/drivers/dma/dma_stm32.c +++ b/drivers/dma/dma_stm32.c @@ -273,10 +273,9 @@ DMA_STM32_EXPORT_API int dma_stm32_configure(const struct device *dev, struct dma_config *config) { const struct dma_stm32_config *dev_config = dev->config; - struct dma_stm32_stream *stream = - &dev_config->streams[id - STM32_DMA_STREAM_OFFSET]; DMA_TypeDef *dma = (DMA_TypeDef *)dev_config->base; LL_DMA_InitTypeDef DMA_InitStruct; + struct dma_stm32_stream *stream; int ret; LL_DMA_StructInit(&DMA_InitStruct); @@ -289,6 +288,7 @@ DMA_STM32_EXPORT_API int dma_stm32_configure(const struct device *dev, return -EINVAL; } + stream = &dev_config->streams[id]; if (stream->busy) { LOG_ERR("dma stream %d is busy.", id); return -EBUSY; @@ -594,8 +594,8 @@ DMA_STM32_EXPORT_API int dma_stm32_start(const struct device *dev, uint32_t id) DMA_STM32_EXPORT_API int dma_stm32_stop(const struct device *dev, uint32_t id) { const struct dma_stm32_config *config = dev->config; - struct dma_stm32_stream *stream = &config->streams[id - STM32_DMA_STREAM_OFFSET]; DMA_TypeDef *dma = (DMA_TypeDef *)(config->base); + struct dma_stm32_stream *stream; /* Give channel from index 0 */ id = id - STM32_DMA_STREAM_OFFSET; @@ -604,6 +604,8 @@ DMA_STM32_EXPORT_API int dma_stm32_stop(const struct device *dev, uint32_t id) return -EINVAL; } + stream = &config->streams[id]; + if (stream->hal_override) { stream->busy = false; return 0; From b19109461d4d3d241b33023daa65a15819a15e2f Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Fri, 22 Aug 2025 13:15:14 +0200 Subject: [PATCH 4/7] drivers: dma: stm32: Minor indentation fix Makes it easier to grep. Signed-off-by: Erwan Gouriou --- drivers/dma/dma_stm32u5.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/dma/dma_stm32u5.c b/drivers/dma/dma_stm32u5.c index 0fcae4bb1de10..23693fbc5b8f7 100644 --- a/drivers/dma/dma_stm32u5.c +++ b/drivers/dma/dma_stm32u5.c @@ -563,9 +563,7 @@ static int dma_stm32_reload(const struct device *dev, uint32_t id, return -EINVAL; } - LL_DMA_ConfigAddresses(dma, - dma_stm32_id_to_stream(id), - src, dst); + LL_DMA_ConfigAddresses(dma, dma_stm32_id_to_stream(id), src, dst); LL_DMA_SetBlkDataLength(dma, dma_stm32_id_to_stream(id), size); From 6fb929cdbdfda7e15a4e24c245a7f035905ca6d2 Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Fri, 22 Aug 2025 14:12:28 +0200 Subject: [PATCH 5/7] drivers: stm32: Keep DMA stream offset handling internal to driver In HAL based stm32 drivers, dma handling is done internally to HAL. Though, in order to avoid a dma_config() call is done to ensure stream will be set as busy in zephyr dma driver to avoid potential resource sharing conflict. This dma_config() call was done while taking into account STM32_DMA_STREAM_OFFSET, which is wrong as it will prevent zephyr dma driver to set the right stream as busy. Fix this in impacted drivers. Signed-off-by: Erwan Gouriou --- drivers/flash/flash_stm32_ospi.c | 7 ++----- drivers/flash/flash_stm32_xspi.c | 7 ++----- drivers/i2s/i2s_stm32_sai.c | 6 ++---- drivers/video/video_stm32_dcmi.c | 7 ++----- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/flash/flash_stm32_ospi.c b/drivers/flash/flash_stm32_ospi.c index 7c0eee1234ad4..adeae3abbca4f 100644 --- a/drivers/flash/flash_stm32_ospi.c +++ b/drivers/flash/flash_stm32_ospi.c @@ -2219,12 +2219,9 @@ static int flash_stm32_ospi_init(const struct device *dev) dma_cfg.user_data = &hdma; /* HACK: This field is used to inform driver that it is overridden */ dma_cfg.linked_channel = STM32_DMA_HAL_OVERRIDE; - /* Because of the STREAM OFFSET, the DMA channel given here is from 1 - 8 */ - ret = dma_config(dev_data->dma.dev, - (dev_data->dma.channel + STM32_DMA_STREAM_OFFSET), &dma_cfg); + ret = dma_config(dev_data->dma.dev, dev_data->dma.channel, &dma_cfg); if (ret != 0) { - LOG_ERR("Failed to configure DMA channel %d", - dev_data->dma.channel + STM32_DMA_STREAM_OFFSET); + LOG_ERR("Failed to configure DMA channel %d", dev_data->dma.channel); return ret; } diff --git a/drivers/flash/flash_stm32_xspi.c b/drivers/flash/flash_stm32_xspi.c index 6ff3262598502..c2172fa31e37a 100644 --- a/drivers/flash/flash_stm32_xspi.c +++ b/drivers/flash/flash_stm32_xspi.c @@ -1977,12 +1977,9 @@ static int flash_stm32_xspi_dma_init(DMA_HandleTypeDef *hdma, struct stream *dma dma_stream->cfg.user_data = hdma; /* HACK: This field is used to inform driver that it is overridden */ dma_stream->cfg.linked_channel = STM32_DMA_HAL_OVERRIDE; - /* Because of the STREAM OFFSET, the DMA channel given here is from 1 - 8 */ - ret = dma_config(dma_stream->dev, - (dma_stream->channel + STM32_DMA_STREAM_OFFSET), &dma_stream->cfg); + ret = dma_config(dma_stream->dev, dma_stream->channel, &dma_stream->cfg); if (ret != 0) { - LOG_ERR("Failed to configure DMA channel %d", - dma_stream->channel + STM32_DMA_STREAM_OFFSET); + LOG_ERR("Failed to configure DMA channel %d", dma_stream->channel); return ret; } diff --git a/drivers/i2s/i2s_stm32_sai.c b/drivers/i2s/i2s_stm32_sai.c index 1ae504be43578..896b5590f2714 100644 --- a/drivers/i2s/i2s_stm32_sai.c +++ b/drivers/i2s/i2s_stm32_sai.c @@ -276,12 +276,10 @@ static int i2s_stm32_sai_dma_init(const struct device *dev) /* HACK: This field is used to inform driver that it is overridden */ dma_cfg.linked_channel = STM32_DMA_HAL_OVERRIDE; - /* Because of the STREAM OFFSET, the DMA channel given here is from 1 - 8 */ - ret = dma_config(stream->dma_dev, stream->dma_channel + STM32_DMA_STREAM_OFFSET, &dma_cfg); + ret = dma_config(stream->dma_dev, stream->dma_channel, &dma_cfg); if (ret != 0) { - LOG_ERR("Failed to configure DMA channel %d", - stream->dma_channel + STM32_DMA_STREAM_OFFSET); + LOG_ERR("Failed to configure DMA channel %d", stream->dma_channel); return ret; } diff --git a/drivers/video/video_stm32_dcmi.c b/drivers/video/video_stm32_dcmi.c index 363de09717b8f..211f9f102652b 100644 --- a/drivers/video/video_stm32_dcmi.c +++ b/drivers/video/video_stm32_dcmi.c @@ -136,12 +136,9 @@ static int stm32_dma_init(const struct device *dev) dma_cfg.user_data = &hdma; /* HACK: This field is used to inform driver that it is overridden */ dma_cfg.linked_channel = STM32_DMA_HAL_OVERRIDE; - /* Because of the STREAM OFFSET, the DMA channel given here is from 1 - 8 */ - ret = dma_config(config->dma.dma_dev, - config->dma.channel + STM32_DMA_STREAM_OFFSET, &dma_cfg); + ret = dma_config(config->dma.dma_dev, config->dma.channel, &dma_cfg); if (ret != 0) { - LOG_ERR("Failed to configure DMA channel %d", - config->dma.channel + STM32_DMA_STREAM_OFFSET); + LOG_ERR("Failed to configure DMA channel %d", config->dma.channel); return ret; } From 29633fdd4082ab64c265d546f69055d0dcf0caff Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Fri, 22 Aug 2025 14:31:42 +0200 Subject: [PATCH 6/7] include: drivers: stm32 dma: Provide a GET_INSTANCE macro To simplify the work on client drivers, provide a STM32_DMA_GET_INSTANCE() macro which abstracts: - STM32_DMA_STREAM_OFFSET - __LL_DMA_GET_STREAM_INSTANCE() vs __LL_DMA_GET_CHANNEL_INSTANCE() Signed-off-by: Erwan Gouriou --- include/zephyr/drivers/dma/dma_stm32.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/zephyr/drivers/dma/dma_stm32.h b/include/zephyr/drivers/dma/dma_stm32.h index 38f395b0108fc..dad8a6589e11a 100644 --- a/include/zephyr/drivers/dma/dma_stm32.h +++ b/include/zephyr/drivers/dma/dma_stm32.h @@ -85,4 +85,12 @@ #define STM32_DMA_FEATURES_FIFO_THRESHOLD(features) 0 #endif +#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_dma_v1) +#define STM32_DMA_GET_INSTANCE(reg, channel) \ + __LL_DMA_GET_STREAM_INSTANCE((reg), (channel) - STM32_DMA_STREAM_OFFSET); +#else +#define STM32_DMA_GET_INSTANCE(reg, channel) \ + __LL_DMA_GET_CHANNEL_INSTANCE((reg), (channel) - STM32_DMA_STREAM_OFFSET); +#endif + #endif /* ZEPHYR_INCLUDE_DRIVERS_DMA_STM32_H_ */ From d7e2581b55d2e5ca3a22f1a768141320cbb6bd3d Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Fri, 22 Aug 2025 14:33:32 +0200 Subject: [PATCH 7/7] drivers: stm32: Make use of new GET_INSTANCE DMA macro Use the new macro and factorize code when possible. Signed-off-by: Erwan Gouriou --- drivers/disk/sdmmc_stm32.c | 5 +---- drivers/flash/flash_stm32_ospi.c | 17 +---------------- drivers/flash/flash_stm32_qspi.c | 11 +---------- drivers/i2s/i2s_stm32_sai.c | 6 +----- drivers/video/video_stm32_dcmi.c | 9 ++------- 5 files changed, 6 insertions(+), 42 deletions(-) diff --git a/drivers/disk/sdmmc_stm32.c b/drivers/disk/sdmmc_stm32.c index ff55df60696df..44fc635feedd5 100644 --- a/drivers/disk/sdmmc_stm32.c +++ b/drivers/disk/sdmmc_stm32.c @@ -224,8 +224,8 @@ static int stm32_sdmmc_configure_dma(DMA_HandleTypeDef *handle, struct sdmmc_dma return ret; } + handle->Instance = STM32_DMA_GET_INSTANCE(dma->reg, dma->channel_nb); #if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_dma_v1) - handle->Instance = __LL_DMA_GET_STREAM_INSTANCE(dma->reg, dma->channel_nb); handle->Init.Channel = dma->cfg.dma_slot * DMA_CHANNEL_1; handle->Init.PeriphInc = DMA_PINC_DISABLE; handle->Init.MemInc = DMA_MINC_ENABLE; @@ -238,14 +238,11 @@ static int stm32_sdmmc_configure_dma(DMA_HandleTypeDef *handle, struct sdmmc_dma handle->Init.MemBurst = DMA_MBURST_INC4; handle->Init.PeriphBurst = DMA_PBURST_INC4; #else - uint32_t channel_id = dma->channel_nb - STM32_DMA_STREAM_OFFSET; - BUILD_ASSERT(STM32_SDMMC_USE_DMA_SHARED == 1, "Only txrx is supported on this family"); /* handle->Init.Direction is not initialised here on purpose. * Since the channel is reused for both directions, the direction is * configured before each read/write call. */ - handle->Instance = __LL_DMA_GET_CHANNEL_INSTANCE(dma->reg, channel_id); handle->Init.Request = dma->cfg.dma_slot; handle->Init.PeriphInc = DMA_PINC_DISABLE; handle->Init.MemInc = DMA_MINC_ENABLE; diff --git a/drivers/flash/flash_stm32_ospi.c b/drivers/flash/flash_stm32_ospi.c index adeae3abbca4f..3c08ba2077dc2 100644 --- a/drivers/flash/flash_stm32_ospi.c +++ b/drivers/flash/flash_stm32_ospi.c @@ -2253,27 +2253,12 @@ static int flash_stm32_ospi_init(const struct device *dev) hdma.Init.Mode = DMA_NORMAL; hdma.Init.Priority = table_priority[dma_cfg.channel_priority]; hdma.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma.Instance = STM32_DMA_GET_INSTANCE(dev_data->dma.reg, dev_data->dma.channel); #ifdef CONFIG_DMA_STM32_V1 /* TODO: Not tested in this configuration */ hdma.Init.Channel = dma_cfg.dma_slot; - hdma.Instance = __LL_DMA_GET_STREAM_INSTANCE(dev_data->dma.reg, - dev_data->dma.channel); #else hdma.Init.Request = dma_cfg.dma_slot; -#if CONFIG_DMA_STM32U5 - hdma.Instance = LL_DMA_GET_CHANNEL_INSTANCE(dev_data->dma.reg, - dev_data->dma.channel); -#elif defined(CONFIG_DMAMUX_STM32) - /* - * HAL expects a valid DMA channel (not DMAMUX). - * The channel is from 0 to 7 because of the STM32_DMA_STREAM_OFFSET in the dma_stm32 driver - */ - hdma.Instance = __LL_DMA_GET_CHANNEL_INSTANCE(dev_data->dma.reg, - dev_data->dma.channel); -#else - hdma.Instance = __LL_DMA_GET_CHANNEL_INSTANCE(dev_data->dma.reg, - dev_data->dma.channel-1); -#endif /* CONFIG_DMA_STM32U5 */ #endif /* CONFIG_DMA_STM32_V1 */ /* Initialize DMA HAL */ diff --git a/drivers/flash/flash_stm32_qspi.c b/drivers/flash/flash_stm32_qspi.c index fca6f0d8cb7f8..cf348d5cfb355 100644 --- a/drivers/flash/flash_stm32_qspi.c +++ b/drivers/flash/flash_stm32_qspi.c @@ -1592,21 +1592,12 @@ static int flash_stm32_qspi_init(const struct device *dev) hdma.Init.MemInc = DMA_MINC_ENABLE; hdma.Init.Mode = DMA_NORMAL; hdma.Init.Priority = table_priority[dma_cfg.channel_priority]; + hdma.Instance = STM32_DMA_GET_INSTANCE(dev_data->dma.reg, dev_data->dma.channel); #ifdef CONFIG_DMA_STM32_V1 /* TODO: Not tested in this configuration */ hdma.Init.Channel = dma_cfg.dma_slot; - hdma.Instance = __LL_DMA_GET_STREAM_INSTANCE(dev_data->dma.reg, - dev_data->dma.channel); #else hdma.Init.Request = dma_cfg.dma_slot; -#ifdef CONFIG_DMAMUX_STM32 - /* HAL expects a valid DMA channel (not a DMAMUX channel) */ - hdma.Instance = __LL_DMA_GET_CHANNEL_INSTANCE(dev_data->dma.reg, - dev_data->dma.channel); -#else - hdma.Instance = __LL_DMA_GET_CHANNEL_INSTANCE(dev_data->dma.reg, - dev_data->dma.channel-1); -#endif #endif /* CONFIG_DMA_STM32_V1 */ /* Initialize DMA HAL */ diff --git a/drivers/i2s/i2s_stm32_sai.c b/drivers/i2s/i2s_stm32_sai.c index 896b5590f2714..4f23db2ef0e12 100644 --- a/drivers/i2s/i2s_stm32_sai.c +++ b/drivers/i2s/i2s_stm32_sai.c @@ -17,8 +17,6 @@ #include #include -#include -#include #include #include @@ -284,13 +282,11 @@ static int i2s_stm32_sai_dma_init(const struct device *dev) } #if defined(CONFIG_SOC_SERIES_STM32H7X) - hdma->Instance = __LL_DMA_GET_STREAM_INSTANCE(stream->reg, stream->dma_channel); hdma->Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; hdma->Init.MemDataAlignment = DMA_PDATAALIGN_HALFWORD; hdma->Init.Priority = DMA_PRIORITY_HIGH; hdma->Init.FIFOMode = DMA_FIFOMODE_DISABLE; #else - hdma->Instance = LL_DMA_GET_CHANNEL_INSTANCE(stream->reg, stream->dma_channel); hdma->Init.BlkHWRequest = DMA_BREQ_SINGLE_BURST; hdma->Init.SrcDataWidth = DMA_SRC_DATAWIDTH_HALFWORD; hdma->Init.DestDataWidth = DMA_DEST_DATAWIDTH_HALFWORD; @@ -300,7 +296,7 @@ static int i2s_stm32_sai_dma_init(const struct device *dev) hdma->Init.TransferAllocatedPort = DMA_SRC_ALLOCATED_PORT0 | DMA_DEST_ALLOCATED_PORT0; hdma->Init.TransferEventMode = DMA_TCEM_BLOCK_TRANSFER; #endif - + hdma->Instance = STM32_DMA_GET_INSTANCE(stream->reg, stream->dma_channel); hdma->Init.Request = dma_cfg.dma_slot; hdma->Init.Mode = DMA_NORMAL; diff --git a/drivers/video/video_stm32_dcmi.c b/drivers/video/video_stm32_dcmi.c index 211f9f102652b..440b2c359ecd8 100644 --- a/drivers/video/video_stm32_dcmi.c +++ b/drivers/video/video_stm32_dcmi.c @@ -152,17 +152,12 @@ static int stm32_dma_init(const struct device *dev) hdma.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; hdma.Init.Mode = DMA_CIRCULAR; hdma.Init.Priority = DMA_PRIORITY_HIGH; + hdma.Instance = STM32_DMA_GET_INSTANCE(config->dma.reg, + config->dma.channel); #if defined(CONFIG_SOC_SERIES_STM32F7X) || defined(CONFIG_SOC_SERIES_STM32H7X) hdma.Init.FIFOMode = DMA_FIFOMODE_DISABLE; #endif -#if defined(CONFIG_SOC_SERIES_STM32F7X) || defined(CONFIG_SOC_SERIES_STM32H7X) - hdma.Instance = __LL_DMA_GET_STREAM_INSTANCE(config->dma.reg, - config->dma.channel); -#elif defined(CONFIG_SOC_SERIES_STM32L4X) - hdma.Instance = __LL_DMA_GET_CHANNEL_INSTANCE(config->dma.reg, config->dma.channel); -#endif - /* Initialize DMA HAL */ __HAL_LINKDMA(&data->hdcmi, DMA_Handle, hdma);