linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] spi: omap2-mcspi: Add gpio_request and init CS
@ 2015-05-08 18:31 Michael Welling
  2015-05-08 18:55 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Welling @ 2015-05-08 18:31 UTC (permalink / raw)
  To: broonie, linux-spi, linux-kernel; +Cc: Michael Welling

If GPIO chip select is specified, request the GPIO in the setup function
and release it in the cleanup function.

Signed-off-by: Michael Welling <mwelling@ieee.org>
---

v2: Adds gpio_free to cleanup function.

Broken out of patch series because the other patch in the series was applied.
commit	b28cb9414db9f8e42ac18c9e360e4e99cda42489

This patch applies on top of that one.

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

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 3ac06ad..90cf7e7 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>
 
@@ -1011,6 +1012,12 @@ static int omap2_mcspi_setup(struct spi_device *spi)
 			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 = pm_runtime_get_sync(mcspi->dev);
 	if (ret < 0)
 		return ret;
@@ -1050,6 +1057,9 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
 			mcspi_dma->dma_tx = NULL;
 		}
 	}
+
+	if (gpio_is_valid(spi->cs_gpio))
+		gpio_free(spi->cs_gpio);
 }
 
 static int omap2_mcspi_work_one(struct omap2_mcspi *mcspi,
-- 
1.7.9.5


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

* Re: [PATCH v2] spi: omap2-mcspi: Add gpio_request and init CS
  2015-05-08 18:31 [PATCH v2] spi: omap2-mcspi: Add gpio_request and init CS Michael Welling
@ 2015-05-08 18:55 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2015-05-08 18:55 UTC (permalink / raw)
  To: Michael Welling; +Cc: linux-spi, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 200 bytes --]

On Fri, May 08, 2015 at 01:31:01PM -0500, Michael Welling wrote:
> If GPIO chip select is specified, request the GPIO in the setup function
> and release it in the cleanup function.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

end of thread, other threads:[~2015-05-08 18:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-08 18:31 [PATCH v2] spi: omap2-mcspi: Add gpio_request and init CS Michael Welling
2015-05-08 18:55 ` 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).