Skip to content

Commit 95143fc

Browse files
shlomowcarlescufi
authored andcommitted
drivers: dma: stm32: add support for stm32h7
Add the missing parts for adding support to stm32h7 dma driver. The fix is to make dmamux driver work with dma v1 driver. Signed-off-by: Shlomi Vaknin <[email protected]>
1 parent 084a3de commit 95143fc

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

drivers/dma/Kconfig.stm32

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ config DMA_STM32_V2
3131

3232
config DMAMUX_STM32
3333
bool
34-
depends on DMA_STM32_V2
3534
default $(dt_compat_enabled,$(DT_COMPAT_ST_STM32_DMAMUX))
3635
help
3736
Enable DMAMUX support.

drivers/dma/dma_stm32.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ DMA_STM32_EXPORT_API int dma_stm32_configure(const struct device *dev,
423423
DMA_InitStruct.PeriphBurst = stm32_dma_get_pburst(config,
424424
stream->source_periph);
425425

426+
#if !defined(CONFIG_SOC_SERIES_STM32H7X)
426427
if (config->channel_direction != MEMORY_TO_MEMORY) {
427428
if (config->dma_slot >= 8) {
428429
LOG_ERR("dma slot error.");
@@ -434,7 +435,9 @@ DMA_STM32_EXPORT_API int dma_stm32_configure(const struct device *dev,
434435
config->dma_slot = 0;
435436
}
436437
}
438+
437439
DMA_InitStruct.Channel = dma_stm32_slot_to_channel(config->dma_slot);
440+
#endif
438441

439442
DMA_InitStruct.FIFOThreshold = stm32_dma_get_fifo_threshold(
440443
config->head_block->fifo_mode_control);
@@ -562,7 +565,7 @@ DMA_STM32_EXPORT_API int dma_stm32_stop(const struct device *dev, uint32_t id)
562565
return -EINVAL;
563566
}
564567

565-
#ifndef CONFIG_DMAMUX_STM32
568+
#if !defined(CONFIG_DMAMUX_STM32) || defined(CONFIG_SOC_SERIES_STM32H7X)
566569
LL_DMA_DisableIT_TC(dma, dma_stm32_id_to_stream(id));
567570
#endif /* CONFIG_DMAMUX_STM32 */
568571

drivers/dma/dma_stm32.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ struct dma_stm32_config {
4444
struct dma_stm32_stream *streams;
4545
};
4646

47-
#ifdef CONFIG_DMA_STM32_V1
48-
/* from DTS the dma stream id is in range 0..<dma-requests>-1 */
49-
#define STREAM_OFFSET 0
50-
#else
47+
#if defined(CONFIG_DMAMUX_STM32) || defined(CONFIG_DMA_STM32_V2)
5148
/* from DTS the dma stream id is in range 1..<dma-requests> */
5249
/* so decrease to set range from 0 from now on */
5350
#define STREAM_OFFSET 1
54-
#endif /* CONFIG_DMA_STM32_V1 */
51+
#else
52+
/* from DTS the dma stream id is in range 0..<dma-requests>-1 */
53+
#define STREAM_OFFSET 0
54+
#endif /* CONFIG_DMAMUX_STM32 || CONFIG_DMA_STM32_V2 */
5555

5656
uint32_t dma_stm32_id_to_stream(uint32_t id);
57-
#ifdef CONFIG_DMA_STM32_V1
57+
#if !defined(CONFIG_DMAMUX_STM32)
5858
uint32_t dma_stm32_slot_to_channel(uint32_t id);
5959
#endif
6060

@@ -90,7 +90,11 @@ bool stm32_dma_is_irq_happened(DMA_TypeDef *dma, uint32_t id);
9090
bool stm32_dma_is_unexpected_irq_happened(DMA_TypeDef *dma, uint32_t id);
9191
void stm32_dma_enable_stream(DMA_TypeDef *dma, uint32_t id);
9292
int stm32_dma_disable_stream(DMA_TypeDef *dma, uint32_t id);
93-
void stm32_dma_config_channel_function(DMA_TypeDef *dma, uint32_t id, uint32_t slot);
93+
94+
#if !defined(CONFIG_DMAMUX_STM32)
95+
void stm32_dma_config_channel_function(DMA_TypeDef *dma, uint32_t id,
96+
uint32_t slot);
97+
#endif
9498

9599
#ifdef CONFIG_DMA_STM32_V1
96100
void stm32_dma_disable_fifo_irq(DMA_TypeDef *dma, uint32_t id);

drivers/dma/dma_stm32_v1.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ uint32_t dma_stm32_id_to_stream(uint32_t id)
3535
return stream_nr[id];
3636
}
3737

38+
#if !defined(CONFIG_DMAMUX_STM32)
3839
uint32_t dma_stm32_slot_to_channel(uint32_t slot)
3940
{
4041
static const uint32_t channel_nr[] = {
@@ -52,6 +53,7 @@ uint32_t dma_stm32_slot_to_channel(uint32_t slot)
5253

5354
return channel_nr[slot];
5455
}
56+
#endif
5557

5658
void dma_stm32_clear_ht(DMA_TypeDef *DMAx, uint32_t id)
5759
{
@@ -334,11 +336,14 @@ void stm32_dma_disable_fifo_irq(DMA_TypeDef *dma, uint32_t id)
334336
LL_DMA_DisableIT_FE(dma, dma_stm32_id_to_stream(id));
335337
}
336338

337-
void stm32_dma_config_channel_function(DMA_TypeDef *dma, uint32_t id, uint32_t slot)
339+
#if !defined(CONFIG_DMAMUX_STM32)
340+
void stm32_dma_config_channel_function(DMA_TypeDef *dma, uint32_t id,
341+
uint32_t slot)
338342
{
339343
LL_DMA_SetChannelSelection(dma, dma_stm32_id_to_stream(id),
340344
dma_stm32_slot_to_channel(slot));
341345
}
346+
#endif
342347

343348
uint32_t stm32_dma_get_mburst(struct dma_config *config, bool source_periph)
344349
{

0 commit comments

Comments
 (0)