drivers: i2s: change the stm32 DMA in the driver to use dts

This commit moves DMA parameters previously hard coded in the driver
to the dts.

Signed-off-by: Song Qiang <songqiang1304521@gmail.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Song Qiang 2019-10-24 15:57:17 +08:00 committed by Kumar Gala
commit f0d3ee52fb
8 changed files with 149 additions and 45 deletions

View file

@ -7,6 +7,7 @@
#include <string.h>
#include <drivers/dma.h>
#include <drivers/i2s.h>
#include <dt-bindings/dma/stm32_dma.h>
#include <soc.h>
#include <clock_control/stm32_clock_control.h>
#include <drivers/clock_control.h>
@ -838,23 +839,29 @@ static struct device *get_dev_from_tx_dma_channel(u32_t dma_channel)
return active_dma_tx_channel[dma_channel];
}
#define I2S_DMA_CHANNEL_INIT(index, dir, dir_cap) \
/* src_dev and dest_dev should be 'MEM' or 'PERIPH'. */
#define I2S_DMA_CHANNEL_INIT(index, dir, dir_cap, src_dev, dest_dev) \
.dir = { \
.dma_channel = I2S##index##_DMA_CHAN_##dir_cap, \
.dma_name = DT_I2S_##index##_DMA_CONTROLLER_##dir_cap, \
.dma_channel = DT_I2S_##index##_DMA_CHANNEL_##dir_cap, \
.dma_cfg = { \
.block_count = 1, \
.dma_slot = I2S##index##_DMA_SLOT_##dir_cap, \
.dma_slot = DT_I2S_##index##_DMA_SLOT_##dir_cap, \
.channel_direction = PERIPHERAL_TO_MEMORY, \
.source_data_size = 1, /* 16bit default */ \
.dest_data_size = 1, /* 16bit default */ \
.source_burst_length = 0, /* SINGLE transfer */ \
.dest_burst_length = 1, \
.channel_priority = I2S_DMA_CHAN_PRIORITY, \
.channel_priority = STM32_DMA_CONFIG_PRIORITY( \
DT_I2S_##index##_DMA_CHANNEL_CONFIG_##dir_cap), \
.dma_callback = dma_##dir##_callback, \
}, \
.src_addr_increment = I2S_DMA_SRC_ADDR_INC_##dir_cap, \
.dst_addr_increment = I2S_DMA_DST_ADDR_INC_##dir_cap, \
.fifo_threshold = I2S_DMA_FIFO_THRESHOLD, \
.src_addr_increment = STM32_DMA_CONFIG_##src_dev##_ADDR_INC( \
DT_I2S_##index##_DMA_CHANNEL_CONFIG_##dir_cap), \
.dst_addr_increment = STM32_DMA_CONFIG_##dest_dev##_ADDR_INC( \
DT_I2S_##index##_DMA_CHANNEL_CONFIG_##dir_cap), \
.fifo_threshold = STM32_DMA_FEATURES_FIFO_THRESHOLD( \
DT_I2S_##index##_DMA_FEATURES_##dir_cap), \
.stream_start = dir##_stream_start, \
.stream_disable = dir##_stream_disable, \
.queue_drop = dir##_queue_drop, \
@ -881,9 +888,8 @@ struct queue_item rx_##index##_ring_buf[CONFIG_I2S_STM32_RX_BLOCK_COUNT + 1];\
struct queue_item tx_##index##_ring_buf[CONFIG_I2S_STM32_TX_BLOCK_COUNT + 1];\
\
static struct i2s_stm32_data i2s_stm32_data_##index = { \
.dma_name = I2S##index##_DMA_CHAN_RX, \
I2S_DMA_CHANNEL_INIT(index, rx, RX), \
I2S_DMA_CHANNEL_INIT(index, tx, TX), \
I2S_DMA_CHANNEL_INIT(index, rx, RX, PERIPH, MEM), \
I2S_DMA_CHANNEL_INIT(index, tx, TX, MEM, PERIPH), \
}; \
DEVICE_AND_API_INIT(i2s_stm32_##index, DT_I2S_##index##_NAME, \
&i2s_stm32_initialize, &i2s_stm32_data_##index, \