diff options
author | Hector Martin <marcan@marcan.st> | 2021-12-11 02:05:34 +0900 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2021-12-13 19:35:45 +0000 |
commit | 95c07247399536f83b89dc60cfe7b279d17e69f6 (patch) | |
tree | 0b42f0705f54ecf3491c700cf5f25c6032382506 /drivers/spi | |
parent | e9d7c323cfbbd07c365a419b4ce3dc2f161442c7 (diff) | |
download | linux-95c07247399536f83b89dc60cfe7b279d17e69f6.tar.gz linux-95c07247399536f83b89dc60cfe7b279d17e69f6.tar.bz2 linux-95c07247399536f83b89dc60cfe7b279d17e69f6.zip |
spi: Fix incorrect cs_setup delay handling
Move the cs_setup delay to the end of spi_set_cs.
From include/linux/spi/spi.h:
* @cs_setup: delay to be introduced by the controller after CS is
asserted
The cs_setup delay needs to happen *after* CS is asserted, that is, at
the end of spi_set_cs, not at the beginning. Otherwise we're just
delaying before the SPI transaction starts at all, which isn't very
useful.
No drivers use this right now, but that is likely to change soon with an
upcoming Apple SPI HID transport driver.
Fixes: 25093bdeb6bc ("spi: implement SW control for CS times")
Signed-off-by: Hector Martin <marcan@marcan.st>
Link: https://lore.kernel.org/r/20211210170534.177139-1-marcan@marcan.st
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 8726309b3eaf..7c790858547c 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -944,12 +944,9 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force) spi->controller->last_cs_enable = enable; spi->controller->last_cs_mode_high = spi->mode & SPI_CS_HIGH; - if (spi->cs_gpiod || gpio_is_valid(spi->cs_gpio) || - !spi->controller->set_cs_timing) { - if (activate) - spi_delay_exec(&spi->cs_setup, NULL); - else - spi_delay_exec(&spi->cs_hold, NULL); + if ((spi->cs_gpiod || gpio_is_valid(spi->cs_gpio) || + !spi->controller->set_cs_timing) && !activate) { + spi_delay_exec(&spi->cs_hold, NULL); } if (spi->mode & SPI_CS_HIGH) @@ -991,7 +988,9 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force) if (spi->cs_gpiod || gpio_is_valid(spi->cs_gpio) || !spi->controller->set_cs_timing) { - if (!activate) + if (activate) + spi_delay_exec(&spi->cs_setup, NULL); + else spi_delay_exec(&spi->cs_inactive, NULL); } } |