Skip to content

Commit aa0162d

Browse files
jannaubroonie
authored andcommitted
spi: Restore delays for non-GPIO chip select
SPI controller with integrated chip select handling still need to adhere to SPI device's CS setup, hold and inactive delays. For controller without set_cs_timing spi core shall handle the delays to avoid duplicated delay handling in each controller driver. Fixes a regression for the out of tree SPI controller and SPI HID transport on Apple M1/M1 Pro/Max notebooks. Fixes: 4d8ff6b ("spi: Add multi-cs memories support in SPI core") Signed-off-by: Janne Grunau <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 2ae0ab0 commit aa0162d

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

drivers/spi/spi.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,10 +1063,14 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)
10631063
if (spi->mode & SPI_CS_HIGH)
10641064
enable = !enable;
10651065

1066-
if (spi_is_csgpiod(spi)) {
1067-
if (!spi->controller->set_cs_timing && !activate)
1068-
spi_delay_exec(&spi->cs_hold, NULL);
1066+
/*
1067+
* Handle chip select delays for GPIO based CS or controllers without
1068+
* programmable chip select timing.
1069+
*/
1070+
if ((spi_is_csgpiod(spi) || !spi->controller->set_cs_timing) && !activate)
1071+
spi_delay_exec(&spi->cs_hold, NULL);
10691072

1073+
if (spi_is_csgpiod(spi)) {
10701074
if (!(spi->mode & SPI_NO_CS)) {
10711075
/*
10721076
* Historically ACPI has no means of the GPIO polarity and
@@ -1099,16 +1103,16 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)
10991103
if ((spi->controller->flags & SPI_CONTROLLER_GPIO_SS) &&
11001104
spi->controller->set_cs)
11011105
spi->controller->set_cs(spi, !enable);
1102-
1103-
if (!spi->controller->set_cs_timing) {
1104-
if (activate)
1105-
spi_delay_exec(&spi->cs_setup, NULL);
1106-
else
1107-
spi_delay_exec(&spi->cs_inactive, NULL);
1108-
}
11091106
} else if (spi->controller->set_cs) {
11101107
spi->controller->set_cs(spi, !enable);
11111108
}
1109+
1110+
if (spi_is_csgpiod(spi) || !spi->controller->set_cs_timing) {
1111+
if (activate)
1112+
spi_delay_exec(&spi->cs_setup, NULL);
1113+
else
1114+
spi_delay_exec(&spi->cs_inactive, NULL);
1115+
}
11121116
}
11131117

11141118
#ifdef CONFIG_HAS_DMA

0 commit comments

Comments
 (0)