drivers: spi_mcux_flexcomm: initialize all cs gpios during init
In case when we have multiple devices connected to the one SPI interface the initial state of CS gpios after MCU reset is floating and it might be low that prevents us from communicating between particular devices. Fix that by initializing all provided cs gpios and setting them as inactive. Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
This commit is contained in:
parent
0ccdd5f263
commit
ab2d23c5f4
|
@ -213,7 +213,6 @@ static int spi_mcux_configure(const struct device *dev,
|
|||
SPI_SetDummyData(base, 0);
|
||||
|
||||
data->ctx.config = spi_cfg;
|
||||
spi_context_cs_configure(&data->ctx);
|
||||
} else {
|
||||
spi_slave_config_t slave_config;
|
||||
|
||||
|
@ -674,6 +673,7 @@ static int spi_mcux_release(const struct device *dev,
|
|||
|
||||
static int spi_mcux_init(const struct device *dev)
|
||||
{
|
||||
int err;
|
||||
const struct spi_mcux_config *config = dev->config;
|
||||
struct spi_mcux_data *data = dev->data;
|
||||
|
||||
|
@ -693,6 +693,12 @@ static int spi_mcux_init(const struct device *dev)
|
|||
}
|
||||
#endif /* CONFIG_SPI_MCUX_FLEXCOMM_DMA */
|
||||
|
||||
|
||||
err = spi_context_cs_configure_all(&data->ctx);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
spi_context_unlock_unconditionally(&data->ctx);
|
||||
|
||||
return 0;
|
||||
|
@ -762,6 +768,7 @@ static void spi_mcux_config_func_##id(const struct device *dev) \
|
|||
static struct spi_mcux_data spi_mcux_data_##id = { \
|
||||
SPI_CONTEXT_INIT_LOCK(spi_mcux_data_##id, ctx), \
|
||||
SPI_CONTEXT_INIT_SYNC(spi_mcux_data_##id, ctx), \
|
||||
SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(id), ctx) \
|
||||
SPI_DMA_CHANNELS(id) \
|
||||
}; \
|
||||
DEVICE_DT_INST_DEFINE(id, \
|
||||
|
|
Loading…
Reference in a new issue