drivers: spi_mcux_dspi: 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
bcd0364ab8
commit
0ccdd5f263
1 changed files with 8 additions and 1 deletions
|
@ -654,7 +654,6 @@ static int spi_mcux_configure(const struct device *dev,
|
|||
#endif
|
||||
|
||||
data->ctx.config = spi_cfg;
|
||||
spi_context_cs_configure(&data->ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -746,6 +745,7 @@ static int spi_mcux_release(const struct device *dev,
|
|||
|
||||
static int spi_mcux_init(const struct device *dev)
|
||||
{
|
||||
int err;
|
||||
struct spi_mcux_data *data = dev->data;
|
||||
#ifdef CONFIG_DSPI_MCUX_EDMA
|
||||
enum dma_channel_filter spi_filter = DMA_CHANNEL_NORMAL;
|
||||
|
@ -763,6 +763,12 @@ static int spi_mcux_init(const struct device *dev)
|
|||
config->irq_config_func(dev);
|
||||
#endif
|
||||
data->dev = dev;
|
||||
|
||||
err = spi_context_cs_configure_all(&data->ctx);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
spi_context_unlock_unconditionally(&data->ctx);
|
||||
|
||||
return 0;
|
||||
|
@ -856,6 +862,7 @@ static const struct spi_driver_api spi_mcux_driver_api = {
|
|||
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) \
|
||||
TX_DMA_CONFIG(id) RX_DMA_CONFIG(id) \
|
||||
}; \
|
||||
static const struct spi_mcux_config spi_mcux_config_##id = { \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue