aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThor Thayer <tthayer@opensource.altera.com>2016-10-10 10:25:24 -0400
committerMark Brown <broonie@kernel.org>2016-10-11 06:29:04 -0400
commit6b1576aa875347c6454d911a2e001138c2cec7d5 (patch)
treeab2efceebe210623e9f54e967cec554dfa32bfb3
parent2ce04684335f886fb5adb9ecbd2a85affca549d1 (diff)
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>
-rw-r--r--drivers/spi/spi.c9
-rw-r--r--include/linux/spi/spi.h1
2 files changed, 8 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)
697 if (spi->mode & SPI_CS_HIGH) 697 if (spi->mode & SPI_CS_HIGH)
698 enable = !enable; 698 enable = !enable;
699 699
700 if (gpio_is_valid(spi->cs_gpio)) 700 if (gpio_is_valid(spi->cs_gpio)) {
701 gpio_set_value(spi->cs_gpio, !enable); 701 gpio_set_value(spi->cs_gpio, !enable);
702 else if (spi->master->set_cs) 702 /* Some SPI masters need both GPIO CS & slave_select */
703 if ((spi->master->flags & SPI_MASTER_GPIO_SS) &&
704 spi->master->set_cs)
705 spi->master->set_cs(spi, !enable);
706 } else if (spi->master->set_cs) {
703 spi->master->set_cs(spi, !enable); 707 spi->master->set_cs(spi, !enable);
708 }
704} 709}
705 710
706#ifdef CONFIG_HAS_DMA 711#ifdef CONFIG_HAS_DMA
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 4b743ac35396..75c6bd0ac605 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -442,6 +442,7 @@ struct spi_master {
442#define SPI_MASTER_NO_TX BIT(2) /* can't do buffer write */ 442#define SPI_MASTER_NO_TX BIT(2) /* can't do buffer write */
443#define SPI_MASTER_MUST_RX BIT(3) /* requires rx */ 443#define SPI_MASTER_MUST_RX BIT(3) /* requires rx */
444#define SPI_MASTER_MUST_TX BIT(4) /* requires tx */ 444#define SPI_MASTER_MUST_TX BIT(4) /* requires tx */
445#define SPI_MASTER_GPIO_SS BIT(5) /* GPIO CS must select slave */
445 446
446 /* 447 /*
447 * on some hardware transfer / message size may be constrained 448 * on some hardware transfer / message size may be constrained