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 <shlomi.39sd@gmail.com>
This commit is contained in:
Shlomi Vaknin 2021-03-30 18:22:30 +03:00 committed by Carles Cufí
commit 95143fc98e
4 changed files with 21 additions and 10 deletions

View file

@ -31,7 +31,6 @@ config DMA_STM32_V2
config DMAMUX_STM32
bool
depends on DMA_STM32_V2
default $(dt_compat_enabled,$(DT_COMPAT_ST_STM32_DMAMUX))
help
Enable DMAMUX support.

View file

@ -423,6 +423,7 @@ DMA_STM32_EXPORT_API int dma_stm32_configure(const struct device *dev,
DMA_InitStruct.PeriphBurst = stm32_dma_get_pburst(config,
stream->source_periph);
#if !defined(CONFIG_SOC_SERIES_STM32H7X)
if (config->channel_direction != MEMORY_TO_MEMORY) {
if (config->dma_slot >= 8) {
LOG_ERR("dma slot error.");
@ -434,7 +435,9 @@ DMA_STM32_EXPORT_API int dma_stm32_configure(const struct device *dev,
config->dma_slot = 0;
}
}
DMA_InitStruct.Channel = dma_stm32_slot_to_channel(config->dma_slot);
#endif
DMA_InitStruct.FIFOThreshold = stm32_dma_get_fifo_threshold(
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)
return -EINVAL;
}
#ifndef CONFIG_DMAMUX_STM32
#if !defined(CONFIG_DMAMUX_STM32) || defined(CONFIG_SOC_SERIES_STM32H7X)
LL_DMA_DisableIT_TC(dma, dma_stm32_id_to_stream(id));
#endif /* CONFIG_DMAMUX_STM32 */

View file

@ -44,17 +44,17 @@ struct dma_stm32_config {
struct dma_stm32_stream *streams;
};
#ifdef CONFIG_DMA_STM32_V1
/* from DTS the dma stream id is in range 0..<dma-requests>-1 */
#define STREAM_OFFSET 0
#else
#if defined(CONFIG_DMAMUX_STM32) || defined(CONFIG_DMA_STM32_V2)
/* from DTS the dma stream id is in range 1..<dma-requests> */
/* so decrease to set range from 0 from now on */
#define STREAM_OFFSET 1
#endif /* CONFIG_DMA_STM32_V1 */
#else
/* from DTS the dma stream id is in range 0..<dma-requests>-1 */
#define STREAM_OFFSET 0
#endif /* CONFIG_DMAMUX_STM32 || CONFIG_DMA_STM32_V2 */
uint32_t dma_stm32_id_to_stream(uint32_t id);
#ifdef CONFIG_DMA_STM32_V1
#if !defined(CONFIG_DMAMUX_STM32)
uint32_t dma_stm32_slot_to_channel(uint32_t id);
#endif
@ -90,7 +90,11 @@ bool stm32_dma_is_irq_happened(DMA_TypeDef *dma, uint32_t id);
bool stm32_dma_is_unexpected_irq_happened(DMA_TypeDef *dma, uint32_t id);
void stm32_dma_enable_stream(DMA_TypeDef *dma, uint32_t id);
int stm32_dma_disable_stream(DMA_TypeDef *dma, uint32_t id);
void stm32_dma_config_channel_function(DMA_TypeDef *dma, uint32_t id, uint32_t slot);
#if !defined(CONFIG_DMAMUX_STM32)
void stm32_dma_config_channel_function(DMA_TypeDef *dma, uint32_t id,
uint32_t slot);
#endif
#ifdef CONFIG_DMA_STM32_V1
void stm32_dma_disable_fifo_irq(DMA_TypeDef *dma, uint32_t id);

View file

@ -35,6 +35,7 @@ uint32_t dma_stm32_id_to_stream(uint32_t id)
return stream_nr[id];
}
#if !defined(CONFIG_DMAMUX_STM32)
uint32_t dma_stm32_slot_to_channel(uint32_t slot)
{
static const uint32_t channel_nr[] = {
@ -52,6 +53,7 @@ uint32_t dma_stm32_slot_to_channel(uint32_t slot)
return channel_nr[slot];
}
#endif
void dma_stm32_clear_ht(DMA_TypeDef *DMAx, uint32_t id)
{
@ -334,11 +336,14 @@ void stm32_dma_disable_fifo_irq(DMA_TypeDef *dma, uint32_t id)
LL_DMA_DisableIT_FE(dma, dma_stm32_id_to_stream(id));
}
void stm32_dma_config_channel_function(DMA_TypeDef *dma, uint32_t id, uint32_t slot)
#if !defined(CONFIG_DMAMUX_STM32)
void stm32_dma_config_channel_function(DMA_TypeDef *dma, uint32_t id,
uint32_t slot)
{
LL_DMA_SetChannelSelection(dma, dma_stm32_id_to_stream(id),
dma_stm32_slot_to_channel(slot));
}
#endif
uint32_t stm32_dma_get_mburst(struct dma_config *config, bool source_periph)
{