drivers: spi_cc13xx_cc26xx: 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:03:29 +02:00 committed by Carles Cufí
commit 37925430b1

View file

@ -114,8 +114,6 @@ static int spi_cc13xx_cc26xx_configure(const struct device *dev,
cfg->cs_pin, cfg->sck_pin);
ctx->config = config;
/* This will reconfigure the CS pin as GPIO if same as cfg->cs_pin. */
spi_context_cs_configure(ctx);
/* Disable SSI before making configuration changes */
SSIDisable(cfg->base);
@ -297,14 +295,20 @@ static const struct spi_driver_api spi_cc13xx_cc26xx_driver_api = {
POST_KERNEL, CONFIG_SPI_INIT_PRIORITY, \
&spi_cc13xx_cc26xx_driver_api)
#define SPI_CC13XX_CC26XX_INIT_FUNC(n) \
static int spi_cc13xx_cc26xx_init_##n(const struct device *dev) \
{ \
SPI_CC13XX_CC26XX_POWER_SPI(n); \
\
spi_context_unlock_unconditionally(&get_dev_data(dev)->ctx);\
\
return 0; \
#define SPI_CC13XX_CC26XX_INIT_FUNC(n) \
static int spi_cc13xx_cc26xx_init_##n(const struct device *dev) \
{ \
int err; \
SPI_CC13XX_CC26XX_POWER_SPI(n); \
\
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); \
\
return 0; \
}
#define SPI_CC13XX_CC26XX_INIT(n) \
@ -322,10 +326,11 @@ static const struct spi_driver_api spi_cc13xx_cc26xx_driver_api = {
\
static struct spi_cc13xx_cc26xx_data \
spi_cc13xx_cc26xx_data_##n = { \
SPI_CONTEXT_INIT_LOCK(spi_cc13xx_cc26xx_data_##n, ctx), \
SPI_CONTEXT_INIT_SYNC(spi_cc13xx_cc26xx_data_##n, ctx), \
}; \
\
SPI_CONTEXT_INIT_LOCK(spi_cc13xx_cc26xx_data_##n, ctx), \
SPI_CONTEXT_INIT_SYNC(spi_cc13xx_cc26xx_data_##n, ctx), \
SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(n), ctx) \
}; \
\
SPI_CC13XX_CC26XX_DEVICE_INIT(n);
DT_INST_FOREACH_STATUS_OKAY(SPI_CC13XX_CC26XX_INIT)