drivers: spi_gecko: 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:04:56 +02:00 committed by Carles Cufí
commit bcd0364ab8

View file

@ -107,8 +107,6 @@ static int spi_config(const struct device *dev,
/* At this point, it's mandatory to set this on the context! */
data->ctx.config = config;
spi_context_cs_configure(&data->ctx);
return 0;
}
@ -209,7 +207,9 @@ static void spi_gecko_init_pins(const struct device *dev)
static int spi_gecko_init(const struct device *dev)
{
int err;
const struct spi_gecko_config *config = dev->config;
struct spi_gecko_data *data = dev->data;
USART_InitSync_TypeDef usartInit = USART_INITSYNC_DEFAULT;
/* The peripheral and gpio clock are already enabled from soc and gpio
@ -237,6 +237,11 @@ static int spi_gecko_init(const struct device *dev)
/* Initialize USART pins */
spi_gecko_init_pins(dev);
err = spi_context_cs_configure_all(&data->ctx);
if (err < 0) {
return err;
}
/* Enable the peripheral */
config->base->CMD = (uint32_t) usartEnable;
@ -291,6 +296,7 @@ static struct spi_driver_api spi_gecko_api = {
static struct spi_gecko_data spi_gecko_data_##n = { \
SPI_CONTEXT_INIT_LOCK(spi_gecko_data_##n, ctx), \
SPI_CONTEXT_INIT_SYNC(spi_gecko_data_##n, ctx), \
SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(n), ctx) \
}; \
static struct spi_gecko_config spi_gecko_cfg_##n = { \
.base = (USART_TypeDef *) \