From: Martin Sperl <redacted>
Setup gpio-cs to the correct levels during setup and also make the
gpio definitely an output GPIO.
This is transparently fixing some badly configured DTs in the process
where cs-gpio is set but the gpios are still configured with native cs.
It also makes 100% sure that the initial CS levels are as expected -
especially on systems with devices on a bus with mixed CS_HIGH/CS_LOW
settings.
Fixes: 1ea29b39f4c812ece2f936065a0a3d6fe44a263e
Signed-off-by: Martin Sperl <redacted>
---
drivers/spi/spi-bcm2835aux.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-bcm2835aux.c b/drivers/spi/spi-bcm2835aux.c
index 4b6fdcb2cf4b..922fd798508e 100644
--- a/drivers/spi/spi-bcm2835aux.c
+++ b/drivers/spi/spi-bcm2835aux.c
@@ -449,7 +449,17 @@ static int bcm2835aux_spi_setup(struct spi_device *spi)
return -EINVAL;
}
- return 0;
+ /* with gpio-cs set the GPIO to the correct level
+ * and as output (in case the dt has the gpio not configured
+ * as output but native cs)
+ */
+ ret = gpio_direction_output(spi->cs_gpio,
+ (spi->mode & SPI_CS_HIGH) ? 0 : 1);
+ if (ret)
+ dev_err(&spi->dev, "could not set gpio %i as output: %i\n",
+ spi->cs_gpio, ret);
+
+ return ret;
}
static int bcm2835aux_spi_probe(struct platform_device *pdev)
--
2.11.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel