blob: c867933b0bd69ae60945b9d42f0f5a1f5e6a91a8 [file] [log] [blame]
From 9a6c12a7d63d01aa91aa75725bcf30dc73e3e07c Mon Sep 17 00:00:00 2001
From: Linus Walleij <>
Date: Tue, 16 Jul 2019 22:46:51 +0200
Subject: [PATCH] spi: gpio: Add SPI_MASTER_GPIO_SS flag
commit 2922d1cc1696200a3e1fd6d82a7798fcd2cadf12 upstream.
The GPIO SPI master has some code in its local CS
callback to set the initial sck GPIO value. This was
lost in the commit converting it to use SPI core
GPIO handling as this callback isn't called if the
internal GPIO handling is active.
Add the special SPI_MASTER_GPIO_SS to ascertain it
gets called anyway so we get the initial SCK setting
right. There is some platform provided GPIO handling
there as well but this will be skipped as the cs_gpios
will be NULL.
My test targets seem not to care about the initial
SCK value so I am uncertain if this is a regression,
but to preserve the previous semantic we better do
Cc: Andrey Smirnov <>
Fixes: 249e2632dcd0 ("spi: gpio: Don't request CS GPIO in DT use-case")
Signed-off-by: Linus Walleij <>
Signed-off-by: Mark Brown <>
Signed-off-by: Paul Gortmaker <>
diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index cb111e6c4df3..49c99fcbbaf3 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -412,6 +412,12 @@ static int spi_gpio_probe(struct platform_device *pdev)
bb = &spi_gpio->bitbang;
bb->master = master;
+ /*
+ * There is some additional business, apart from driving the CS GPIO
+ * line, that we need to do on selection. This makes the local
+ * callback for chipselect always get called.
+ */
+ master->flags |= SPI_MASTER_GPIO_SS;
bb->chipselect = spi_gpio_chipselect;
bb->set_line_direction = spi_gpio_set_direction;