diff options
author | Thor Thayer <tthayer@opensource.altera.com> | 2016-10-10 16:25:24 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-10-11 12:29:04 +0200 |
commit | 6b1576aa875347c6454d911a2e001138c2cec7d5 (patch) | |
tree | ab2efceebe210623e9f54e967cec554dfa32bfb3 /drivers/spi/spi.c | |
parent | Merge remote-tracking branches 'spi/topic/ti-qspi', 'spi/topic/tools', 'spi/t... (diff) | |
download | linux-6b1576aa875347c6454d911a2e001138c2cec7d5.tar.xz linux-6b1576aa875347c6454d911a2e001138c2cec7d5.zip |
spi: Add Flag to Enable Slave Select with GPIO Chip Select.
Some SPI masters require slave selection before the transfer
can begin [1]. The SPI framework currently selects the chip using
either 1) the internal CS mechanism or 2) the GPIO CS, but not both.
This patch adds a new master->flags define to indicate both the GPIO
CS and the internal chip select mechanism should be used.
Tested On:
Altera CycloneV development kit
Compile tested for build errors on x86_64 (allyesconfigs)
[1] DesignWare dw_apb_ssi Databook, Version 3.20a (page 39)
Signed-off-by: Thor Thayer <tthayer@opensource.altera.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r-- | drivers/spi/spi.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 8146ccd35a1a..8708da7c8140 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -697,10 +697,15 @@ static void spi_set_cs(struct spi_device *spi, bool enable) if (spi->mode & SPI_CS_HIGH) enable = !enable; - if (gpio_is_valid(spi->cs_gpio)) + if (gpio_is_valid(spi->cs_gpio)) { gpio_set_value(spi->cs_gpio, !enable); - else if (spi->master->set_cs) + /* Some SPI masters need both GPIO CS & slave_select */ + if ((spi->master->flags & SPI_MASTER_GPIO_SS) && + spi->master->set_cs) + spi->master->set_cs(spi, !enable); + } else if (spi->master->set_cs) { spi->master->set_cs(spi, !enable); + } } #ifdef CONFIG_HAS_DMA |