drivers: spi_psoc6: 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
225f0b3825
commit
97d3de2349
1 changed files with 8 additions and 1 deletions
|
@ -253,7 +253,6 @@ static int spi_psoc6_configure(const struct device *dev,
|
||||||
data->cfg.oversample = spi_psoc6_get_freqdiv(spi_cfg->frequency);
|
data->cfg.oversample = spi_psoc6_get_freqdiv(spi_cfg->frequency);
|
||||||
|
|
||||||
data->ctx.config = spi_cfg;
|
data->ctx.config = spi_cfg;
|
||||||
spi_context_cs_configure(&data->ctx);
|
|
||||||
} else {
|
} else {
|
||||||
/* Slave mode is not implemented yet. */
|
/* Slave mode is not implemented yet. */
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
@ -367,7 +366,9 @@ static int spi_psoc6_release(const struct device *dev,
|
||||||
|
|
||||||
static int spi_psoc6_init(const struct device *dev)
|
static int spi_psoc6_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
|
int err;
|
||||||
const struct spi_psoc6_config *config = dev->config;
|
const struct spi_psoc6_config *config = dev->config;
|
||||||
|
struct spi_psoc6_data *data = dev->data;
|
||||||
|
|
||||||
soc_gpio_list_configure(config->pins, config->num_pins);
|
soc_gpio_list_configure(config->pins, config->num_pins);
|
||||||
|
|
||||||
|
@ -383,6 +384,11 @@ static int spi_psoc6_init(const struct device *dev)
|
||||||
config->irq_config_func(dev);
|
config->irq_config_func(dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
err = spi_context_cs_configure_all(&data->ctx);
|
||||||
|
if (err < 0) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
return spi_psoc6_release(dev, NULL);
|
return spi_psoc6_release(dev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,6 +412,7 @@ static const struct spi_driver_api spi_psoc6_driver_api = {
|
||||||
static struct spi_psoc6_data spi_psoc6_dev_data_##n = { \
|
static struct spi_psoc6_data spi_psoc6_dev_data_##n = { \
|
||||||
SPI_CONTEXT_INIT_LOCK(spi_psoc6_dev_data_##n, ctx), \
|
SPI_CONTEXT_INIT_LOCK(spi_psoc6_dev_data_##n, ctx), \
|
||||||
SPI_CONTEXT_INIT_SYNC(spi_psoc6_dev_data_##n, ctx), \
|
SPI_CONTEXT_INIT_SYNC(spi_psoc6_dev_data_##n, ctx), \
|
||||||
|
SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(n), ctx) \
|
||||||
}; \
|
}; \
|
||||||
DEVICE_DT_INST_DEFINE(n, &spi_psoc6_init, NULL, \
|
DEVICE_DT_INST_DEFINE(n, &spi_psoc6_init, NULL, \
|
||||||
&spi_psoc6_dev_data_##n, \
|
&spi_psoc6_dev_data_##n, \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue