drivers: spi_nrfx_spi: 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:
Bartosz Bilas 2021-10-07 17:06:19 +02:00 committed by Carles Cufí
commit ae03c0a6bf

View file

@ -146,7 +146,6 @@ static int configure(const struct device *dev,
dev_data->initialized = true; dev_data->initialized = true;
ctx->config = spi_cfg; ctx->config = spi_cfg;
spi_context_cs_configure(ctx);
return 0; return 0;
} }
@ -327,14 +326,20 @@ static int spi_nrfx_pm_action(const struct device *dev,
": cannot enable both pull-up and pull-down on MISO line"); \ ": cannot enable both pull-up and pull-down on MISO line"); \
static int spi_##idx##_init(const struct device *dev) \ static int spi_##idx##_init(const struct device *dev) \
{ \ { \
int err; \
IRQ_CONNECT(DT_IRQN(SPI(idx)), DT_IRQ(SPI(idx), priority), \ IRQ_CONNECT(DT_IRQN(SPI(idx)), DT_IRQ(SPI(idx), priority), \
nrfx_isr, nrfx_spi_##idx##_irq_handler, 0); \ nrfx_isr, nrfx_spi_##idx##_irq_handler, 0); \
err = spi_context_cs_configure_all(&get_dev_data(dev)->ctx); \
if (err < 0) { \
return err; \
} \
spi_context_unlock_unconditionally(&get_dev_data(dev)->ctx); \ spi_context_unlock_unconditionally(&get_dev_data(dev)->ctx); \
return 0; \ return 0; \
} \ } \
static struct spi_nrfx_data spi_##idx##_data = { \ static struct spi_nrfx_data spi_##idx##_data = { \
SPI_CONTEXT_INIT_LOCK(spi_##idx##_data, ctx), \ SPI_CONTEXT_INIT_LOCK(spi_##idx##_data, ctx), \
SPI_CONTEXT_INIT_SYNC(spi_##idx##_data, ctx), \ SPI_CONTEXT_INIT_SYNC(spi_##idx##_data, ctx), \
SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(idx), ctx) \
.dev = DEVICE_DT_GET(SPI(idx)), \ .dev = DEVICE_DT_GET(SPI(idx)), \
.busy = false, \ .busy = false, \
}; \ }; \