@@ -976,6 +976,11 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)
enable = !enable;
if (spi->cs_gpiod) {
+ /* Some SPI masters need both GPIO CS & slave_select */
+ if ((spi->controller->flags & SPI_MASTER_GPIO_SS) &&
+ spi->controller->set_cs)
+ spi->controller->set_cs(spi, !enable);
+
if (!(spi->mode & SPI_NO_CS)) {
/*
* Historically ACPI has no means of the GPIO polarity and
@@ -993,10 +998,6 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)
/* Polarity handled by GPIO library */
gpiod_set_value_cansleep(spi->cs_gpiod, activate);
}
- /* Some SPI masters need both GPIO CS & slave_select */
- if ((spi->controller->flags & SPI_MASTER_GPIO_SS) &&
- spi->controller->set_cs)
- spi->controller->set_cs(spi, !enable);
} else if (spi->controller->set_cs) {
spi->controller->set_cs(spi, !enable);
}
In some cases it is necessary to adjust the spi controller configuration before gpio cs is set. For example if spi devices requiring different cpol are used from the same controller the adjustment to cpol has to be made before gpio is activated. To achieve this set_cs should be executed before gpio cs and necessary adjustments can be made inside of controller driver. Suggested-by: Lukasz Zemla <Lukasz.Zemla@woodward.com> Signed-off-by: Edmund Berenson <edmund.berenson@emlix.com> --- drivers/spi/spi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)