drivers: dma : stm32 with dmamux has a special offset

This new offset value in the dma config is made to
build the table of dma mux_channels with a dmamux.
Range depends on the nb of channels for selected dma instance

Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
Francois Ramu 2020-10-15 08:50:23 +02:00 committed by Anas Nashif
commit 720863217d
2 changed files with 12 additions and 6 deletions

View file

@ -593,16 +593,11 @@ static int dma_stm32_init(const struct device *dev)
config->config_irq(dev); config->config_irq(dev);
#ifdef CONFIG_DMAMUX_STM32
int offset = (strncmp(dev->name, "DMA_1", 5)
? config->max_streams : 0);
#endif /* CONFIG_DMAMUX_STM32 */
for (uint32_t i = 0; i < config->max_streams; i++) { for (uint32_t i = 0; i < config->max_streams; i++) {
config->streams[i].busy = false; config->streams[i].busy = false;
#ifdef CONFIG_DMAMUX_STM32 #ifdef CONFIG_DMAMUX_STM32
/* each further stream->mux_channel is fixed here */ /* each further stream->mux_channel is fixed here */
config->streams[i].mux_channel = i + offset; config->streams[i].mux_channel = i + config->offset;
#endif /* CONFIG_DMAMUX_STM32 */ #endif /* CONFIG_DMAMUX_STM32 */
} }
@ -638,6 +633,13 @@ static const struct dma_driver_api dma_funcs = {
.get_status = dma_stm32_get_status, .get_status = dma_stm32_get_status,
}; };
#ifdef CONFIG_DMAMUX_STM32
#define DMA_STM32_OFFSET_INIT(index) \
.offset = DT_INST_PROP(index, dma_offset),
#else
#define DMA_STM32_OFFSET_INIT(index)
#endif /* CONFIG_DMAMUX_STM32 */
#define DMA_STM32_INIT_DEV(index) \ #define DMA_STM32_INIT_DEV(index) \
static struct dma_stm32_stream \ static struct dma_stm32_stream \
dma_stm32_streams_##index[DMA_STM32_##index##_STREAM_COUNT]; \ dma_stm32_streams_##index[DMA_STM32_##index##_STREAM_COUNT]; \
@ -650,6 +652,7 @@ const struct dma_stm32_config dma_stm32_config_##index = { \
.support_m2m = DT_INST_PROP(index, st_mem2mem), \ .support_m2m = DT_INST_PROP(index, st_mem2mem), \
.max_streams = DMA_STM32_##index##_STREAM_COUNT, \ .max_streams = DMA_STM32_##index##_STREAM_COUNT, \
.streams = dma_stm32_streams_##index, \ .streams = dma_stm32_streams_##index, \
DMA_STM32_OFFSET_INIT(index) \
}; \ }; \
\ \
static struct dma_stm32_data dma_stm32_data_##index = { \ static struct dma_stm32_data dma_stm32_data_##index = { \

View file

@ -36,6 +36,9 @@ struct dma_stm32_config {
bool support_m2m; bool support_m2m;
uint32_t base; uint32_t base;
uint32_t max_streams; uint32_t max_streams;
#ifdef CONFIG_DMAMUX_STM32
uint8_t offset; /* position in the list of dmamux channel list */
#endif
struct dma_stm32_stream *streams; struct dma_stm32_stream *streams;
}; };