aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-bcm2835aux.c
diff options
context:
space:
mode:
authorMartin Sperl <kernel@martin.sperl.org>2019-03-30 09:31:04 +0000
committerMark Brown <broonie@kernel.org>2019-04-03 11:32:13 +0700
commitccd978b708b03b18196205b3baee83b5047ee453 (patch)
treec7727fffed9b5a58baa4329bf417d433ec663828 /drivers/spi/spi-bcm2835aux.c
parentspi: bcm2835aux: warn in dmesg that native cs is not really supported (diff)
downloadlinux-dev-ccd978b708b03b18196205b3baee83b5047ee453.tar.xz
linux-dev-ccd978b708b03b18196205b3baee83b5047ee453.zip
spi: bcm2835aux: setup gpio-cs to output and correct level during setup
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: 1ea29b39f4c812ec ("spi: bcm2835aux: add bcm2835 auxiliary spi device...") Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-bcm2835aux.c')
-rw-r--r--drivers/spi/spi-bcm2835aux.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/spi/spi-bcm2835aux.c b/drivers/spi/spi-bcm2835aux.c
index a105db371417..99414319001a 100644
--- a/drivers/spi/spi-bcm2835aux.c
+++ b/drivers/spi/spi-bcm2835aux.c
@@ -403,8 +403,20 @@ static int bcm2835aux_spi_setup(struct spi_device *spi)
/* sanity check for native cs */
if (spi->mode & SPI_NO_CS)
return 0;
- if (gpio_is_valid(spi->cs_gpio))
- return 0;
+ if (gpio_is_valid(spi->cs_gpio)) {
+ /* 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;
+ }
/* for dt-backwards compatibility: only support native on CS0
* known things not supported with broken native CS: