drivers: i2s: change stm32 i2s driver to use two DMA controllers
The i2s driver assumes the tx channel and rx channel of dma are using the same dma controller. This commit changes it to be able to use different dma controllers. Signed-off-by: Song Qiang <songqiang1304521@gmail.com>
This commit is contained in:
parent
0b11de57cd
commit
ad5f81b2e7
2 changed files with 16 additions and 11 deletions
|
@ -500,7 +500,7 @@ static void dma_rx_callback(void *arg, u32_t channel, int status)
|
|||
goto rx_disable;
|
||||
}
|
||||
|
||||
ret = reload_dma(dev_data->dev_dma, stream->dma_channel,
|
||||
ret = reload_dma(dev_data->dev_dma_rx, stream->dma_channel,
|
||||
&stream->dma_cfg,
|
||||
(void *)LL_SPI_DMA_GetRegAddr(cfg->i2s),
|
||||
stream->mem_block,
|
||||
|
@ -583,7 +583,7 @@ static void dma_tx_callback(void *arg, u32_t channel, int status)
|
|||
/* Assure cache coherency before DMA read operation */
|
||||
DCACHE_CLEAN(stream->mem_block, mem_block_size);
|
||||
|
||||
ret = reload_dma(dev_data->dev_dma, stream->dma_channel,
|
||||
ret = reload_dma(dev_data->dev_dma_tx, stream->dma_channel,
|
||||
&stream->dma_cfg,
|
||||
stream->mem_block,
|
||||
(void *)LL_SPI_DMA_GetRegAddr(cfg->i2s),
|
||||
|
@ -646,9 +646,14 @@ static int i2s_stm32_initialize(struct device *dev)
|
|||
}
|
||||
|
||||
/* Get the binding to the DMA device */
|
||||
dev_data->dev_dma = device_get_binding(dev_data->dma_name);
|
||||
if (!dev_data->dev_dma) {
|
||||
LOG_ERR("%s device not found", dev_data->dma_name);
|
||||
dev_data->dev_dma_tx = device_get_binding(dev_data->tx.dma_name);
|
||||
if (!dev_data->dev_dma_tx) {
|
||||
LOG_ERR("%s device not found", dev_data->tx.dma_name);
|
||||
return -ENODEV;
|
||||
}
|
||||
dev_data->dev_dma_rx = device_get_binding(dev_data->rx.dma_name);
|
||||
if (!dev_data->dev_dma_rx) {
|
||||
LOG_ERR("%s device not found", dev_data->rx.dma_name);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -678,7 +683,7 @@ static int rx_stream_start(struct stream *stream, struct device *dev)
|
|||
/* remember active RX DMA channel (used in callback) */
|
||||
active_dma_rx_channel[stream->dma_channel] = dev;
|
||||
|
||||
ret = start_dma(dev_data->dev_dma, stream->dma_channel,
|
||||
ret = start_dma(dev_data->dev_dma_rx, stream->dma_channel,
|
||||
&stream->dma_cfg,
|
||||
(void *)LL_SPI_DMA_GetRegAddr(cfg->i2s),
|
||||
stream->mem_block,
|
||||
|
@ -722,7 +727,7 @@ static int tx_stream_start(struct stream *stream, struct device *dev)
|
|||
/* remember active TX DMA channel (used in callback) */
|
||||
active_dma_tx_channel[stream->dma_channel] = dev;
|
||||
|
||||
ret = start_dma(dev_data->dev_dma, stream->dma_channel,
|
||||
ret = start_dma(dev_data->dev_dma_tx, stream->dma_channel,
|
||||
&stream->dma_cfg,
|
||||
stream->mem_block,
|
||||
(void *)LL_SPI_DMA_GetRegAddr(cfg->i2s),
|
||||
|
@ -744,7 +749,7 @@ static void rx_stream_disable(struct stream *stream, struct device *dev)
|
|||
{
|
||||
const struct i2s_stm32_cfg *cfg = DEV_CFG(dev);
|
||||
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
|
||||
struct device *dev_dma = dev_data->dev_dma;
|
||||
struct device *dev_dma = dev_data->dev_dma_rx;
|
||||
|
||||
LL_I2S_DisableDMAReq_RX(cfg->i2s);
|
||||
LL_I2S_DisableIT_ERR(cfg->i2s);
|
||||
|
@ -764,7 +769,7 @@ static void tx_stream_disable(struct stream *stream, struct device *dev)
|
|||
{
|
||||
const struct i2s_stm32_cfg *cfg = DEV_CFG(dev);
|
||||
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
|
||||
struct device *dev_dma = dev_data->dev_dma;
|
||||
struct device *dev_dma = dev_data->dev_dma_tx;
|
||||
|
||||
LL_I2S_DisableDMAReq_TX(cfg->i2s);
|
||||
LL_I2S_DisableIT_ERR(cfg->i2s);
|
||||
|
|
|
@ -120,8 +120,8 @@ struct stream {
|
|||
|
||||
/* Device run time data */
|
||||
struct i2s_stm32_data {
|
||||
struct device *dev_dma;
|
||||
const char *dma_name;
|
||||
struct device *dev_dma_tx;
|
||||
struct device *dev_dma_rx;
|
||||
struct stream rx;
|
||||
struct stream tx;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue