Skip to contentSkip to conversation

spi: bcm2835: clarify native chip-select fallback

PATCH New Artem Novak 1 participant 1 message Nov 22

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: bcm2835: clarify native chip-select fallback

Document why the driver uses GPIO-controlled chip-select instead of the hardware-controlled native chip-select.

Also explain how the temporary GPIO lookup table is used when the device tree does not provide a CS GPIO descriptor, and document the fallback's limitation regarding the alternate GPIOs 36/35.

---
 drivers/spi/spi-bcm2835.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/spi/spi-bcm2835.c +9 -6
index cc5748973281..d4c938fa3a23 100644
@@ -1310,13 +1310,16 @@ static int bcm2835_spi_setup(struct spi_device *spi)
 		return 0;
 
 	/*
-	 * TODO: The code below is a slightly better alternative to the utter
-	 * abuse of the GPIO API that I found here before. It creates a
-	 * temporary lookup table, assigns it to the SPI device, gets the GPIO
-	 * descriptor and then releases the lookup table.
+	 * The hardware-controlled native chip-select can produce short
+	 * glitches during transfers, so use GPIO-controlled chip-select
+	 * instead.
 	 *
-	 * More on the problem that it addresses:
-	 *   https://www.spinics.net/lists/linux-gpio/msg36218.html
+	 * If the device tree doesn't provide a CS GPIO descriptor, create a
+	 * temporary lookup table to obtain the GPIO through the consumer API.
+	 * This fallback assumes GPIOs 8/7 and doesn't detect whether the
+	 * alternate GPIOs 36/35 are configured.
+	 *
+	 * See https://www.spinics.net/lists/linux-gpio/msg36218.html
 	 */
 	lookup = kzalloc_flex(*lookup, table, 2);
 	if (!lookup) {
Signature · 1 line
2.56.1