drivers/i2s: stm32: Convert to dt based pinctrl configuration

Convert STM32 I2S driver to dt based pinctrl configuration

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
Erwan Gouriou 2020-10-23 15:09:05 +02:00 committed by Kumar Gala
commit 344ff12c37
2 changed files with 19 additions and 2 deletions

View file

@ -13,6 +13,7 @@
#include <soc.h>
#include <drivers/clock_control/stm32_clock_control.h>
#include <drivers/clock_control.h>
#include <pinmux/stm32/pinmux_stm32.h>
#include "i2s_ll_stm32.h"
#include <logging/log.h>
@ -662,6 +663,15 @@ static int i2s_stm32_initialize(const struct device *dev)
return -EIO;
}
/* Configure dt provided device signals when available */
ret = stm32_dt_pinctrl_configure(cfg->pinctrl_list,
cfg->pinctrl_list_size,
(uint32_t)cfg->i2s);
if (ret < 0) {
LOG_ERR("I2S pinctrl setup failed (%d)", ret);
return ret;
}
cfg->irq_config(dev);
k_sem_init(&dev_data->rx.sem, 0, CONFIG_I2S_STM32_RX_BLOCK_COUNT);
@ -888,6 +898,9 @@ static const struct device *get_dev_from_tx_dma_channel(uint32_t dma_channel)
#define I2S_INIT(index, clk_sel) \
DEVICE_DECLARE(i2s_stm32_##index); \
\
static const struct soc_gpio_pinctrl i2s_pins_##index[] = \
ST_STM32_DT_INST_PINCTRL(index, 0);\
\
static void i2s_stm32_irq_config_func_##index(const struct device *dev);\
\
static const struct i2s_stm32_cfg i2s_stm32_config_##index = { \
@ -897,6 +910,8 @@ static const struct i2s_stm32_cfg i2s_stm32_config_##index = { \
.bus = DT_CLOCKS_CELL(DT_NODELABEL(i2s##index), bus), \
}, \
.i2s_clk_sel = CLK_SEL_##clk_sel, \
.pinctrl_list = i2s_pins_##index, \
.pinctrl_list_size = ARRAY_SIZE(i2s_pins_##index), \
.irq_config = i2s_stm32_irq_config_func_##index, \
}; \
\

View file

@ -72,6 +72,8 @@ struct i2s_stm32_cfg {
SPI_TypeDef *i2s;
struct stm32_pclken pclken;
uint32_t i2s_clk_sel;
const struct soc_gpio_pinctrl *pinctrl_list;
size_t pinctrl_list_size;
void (*irq_config)(const struct device *dev);
};