linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] spi: omap2-mcspi: Add support for GPIO chipselects
@ 2015-04-27  3:44 Michael Welling
       [not found] ` <1430106270-17142-1-git-send-email-mwelling-EkmVulN54Sk@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Welling @ 2015-04-27  3:44 UTC (permalink / raw)
  To: broonie-DgEjT+Ai2ygdnm+yROfE0A, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: Michael Welling

This patch allows for GPIOs specified in the devicetree to be used as SPI
chipselects on TI OMAP2 SoCs.

Tested on the AM3354.

Signed-off-by: Michael Welling <mwelling-EkmVulN54Sk@public.gmane.org>
---

v2: Considers the possible use of SPI_CS_HIGH during chip select activation.

 drivers/spi/spi-omap2-mcspi.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index d1a5b9f..5e388a8 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -35,6 +35,7 @@
 #include <linux/gcd.h>
 
 #include <linux/spi/spi.h>
+#include <linux/gpio.h>
 
 #include <linux/platform_data/spi-omap2-mcspi.h>
 
@@ -246,6 +247,12 @@ static void omap2_mcspi_force_cs(struct spi_device *spi, int cs_active)
 {
 	u32 l;
 
+	if (gpio_is_valid(spi->cs_gpio)) {
+		gpio_set_value(spi->cs_gpio, (cs_active) ?
+			!!(spi->mode & SPI_CS_HIGH) :
+			!(spi->mode & SPI_CS_HIGH));
+	}
+
 	l = mcspi_cached_chconf0(spi);
 	if (cs_active)
 		l |= OMAP2_MCSPI_CHCONF_FORCE;
@@ -1015,6 +1022,12 @@ static int omap2_mcspi_setup(struct spi_device *spi)
 	if (ret < 0)
 		return ret;
 
+	if (gpio_is_valid(spi->cs_gpio)) {
+		if (gpio_request(spi->cs_gpio, dev_name(&spi->dev)) == 0)
+			gpio_direction_output(spi->cs_gpio,
+				!(spi->mode & SPI_CS_HIGH));
+	}
+
 	ret = omap2_mcspi_setup_transfer(spi, NULL);
 	pm_runtime_mark_last_busy(mcspi->dev);
 	pm_runtime_put_autosuspend(mcspi->dev);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-04-29 10:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-27  3:44 [PATCH v2] spi: omap2-mcspi: Add support for GPIO chipselects Michael Welling
     [not found] ` <1430106270-17142-1-git-send-email-mwelling-EkmVulN54Sk@public.gmane.org>
2015-04-27 19:55   ` Mark Brown
     [not found]     ` <20150427195550.GE22845-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-04-28  1:21       ` Michael Welling
2015-04-28  5:32         ` Martin Sperl
     [not found]           ` <55B19D93-B930-4363-9D44-0E97B4B836BF-d5rIkyn9cnPYtjvyW6yDsg@public.gmane.org>
2015-04-28 22:49             ` Michael Welling
2015-04-28 14:04         ` Ezequiel Garcia
2015-04-28 22:50           ` Michael Welling
2015-04-28 14:34         ` Mark Brown
     [not found]           ` <20150428143425.GS22845-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-04-28 23:06             ` Michael Welling
2015-04-29 10:47               ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).