Skip to content

Commit 3e5ec1d

Browse files
gclementbroonie
authored andcommitted
spi: Fix SPI_CS_HIGH setting when using native and GPIO CS
When improving the CS GPIO support at core level, the SPI_CS_HIGH has been enabled for all the CS lines used for a given SPI controller. However, the SPI framework allows to have on the same controller native CS and GPIO CS. The native CS may not support the SPI_CS_HIGH, so they should not be setup automatically. With this patch the setting is done only for the CS that will use a GPIO as CS Fixes: f3186dd ("spi: Optionally use GPIO descriptors for CS GPIOs") Cc: <stable@vger.kernel.org> Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com> Link: https://lore.kernel.org/r/20191018152929.3287-1-gregory.clement@bootlin.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent b2662a1 commit 3e5ec1d

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎drivers/spi/spi.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,15 +1711,7 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
17111711
spi->mode |= SPI_3WIRE;
17121712
if (of_property_read_bool(nc, "spi-lsb-first"))
17131713
spi->mode |= SPI_LSB_FIRST;
1714-
1715-
/*
1716-
* For descriptors associated with the device, polarity inversion is
1717-
* handled in the gpiolib, so all chip selects are "active high" in
1718-
* the logical sense, the gpiolib will invert the line if need be.
1719-
*/
1720-
if (ctlr->use_gpio_descriptors)
1721-
spi->mode |= SPI_CS_HIGH;
1722-
else if (of_property_read_bool(nc, "spi-cs-high"))
1714+
if (of_property_read_bool(nc, "spi-cs-high"))
17231715
spi->mode |= SPI_CS_HIGH;
17241716

17251717
/* Device DUAL/QUAD mode */
@@ -1783,6 +1775,14 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
17831775
}
17841776
spi->chip_select = value;
17851777

1778+
/*
1779+
* For descriptors associated with the device, polarity inversion is
1780+
* handled in the gpiolib, so all gpio chip selects are "active high"
1781+
* in the logical sense, the gpiolib will invert the line if need be.
1782+
*/
1783+
if ((ctlr->use_gpio_descriptors) && ctlr->cs_gpiods[spi->chip_select])
1784+
spi->mode |= SPI_CS_HIGH;
1785+
17861786
/* Device speed */
17871787
rc = of_property_read_u32(nc, "spi-max-frequency", &value);
17881788
if (rc) {

0 commit comments

Comments
 (0)