From: Michael Welling Date: Fri, 8 May 2015 18:31:01 +0000 (-0500) Subject: spi: omap2-mcspi: Add gpio_request and init CS X-Git-Tag: firefly_0821_release~176^2~1599^2~4^2~5 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bc7f9bbc80bcc77745b3f54ec4e7103e3e142bb9;p=firefly-linux-kernel-4.4.55.git spi: omap2-mcspi: Add gpio_request and init CS 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 Signed-off-by: Mark Brown --- diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 3ac06ade23d0..90cf7e775f15 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -35,6 +35,7 @@ #include #include +#include #include @@ -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,