diff options
author | Klaus Goger <klaus.goger@theobroma-systems.com> | 2018-05-08 10:35:43 +0200 |
---|---|---|
committer | Jakob Unterwurzacher <jakob.unterwurzacher@theobroma-systems.com> | 2018-05-09 15:26:54 +0200 |
commit | 71b9c32a38b7901cb638b2fd814a914b194d1677 (patch) | |
tree | 6a0dce66931d201b6622a068ea9625ebf4a0394f | |
parent | d8829a7ff1e8dc1ec33219e49ed9b451b386eec8 (diff) |
spi: rockchip: configure gpios from cs-gpios
SPI core provides the functionality to have GPIO based chip selects but
assumes that the pins are already configured by the platform.
Configure GPIO style pins in rockchip_spi_setup so they can be used
later on.
Signed-off-by: Klaus Goger <klaus.goger@theobroma-systems.com>
-rw-r--r-- | drivers/spi/spi-rockchip.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 98ecf4c6ef61..e7b54325ae1b 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -15,6 +15,7 @@ #include <linux/clk.h> #include <linux/dmaengine.h> +#include <linux/gpio.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> @@ -643,6 +644,17 @@ static bool rockchip_spi_can_dma(struct spi_master *master, return (xfer->len > rs->fifo_len); } +static int rockchip_spi_setup(struct spi_device *spi_dev) +{ + int ret = 0; + + if (gpio_is_valid(spi_dev->cs_gpio)) { + ret = gpio_direction_output(spi_dev->cs_gpio, + !(spi_dev->mode & SPI_CS_HIGH)); + } + return ret; +} + static int rockchip_spi_probe(struct platform_device *pdev) { int ret = 0; @@ -724,6 +736,7 @@ static int rockchip_spi_probe(struct platform_device *pdev) master->bits_per_word_mask = SPI_BPW_MASK(16) | SPI_BPW_MASK(8); master->set_cs = rockchip_spi_set_cs; + master->setup = rockchip_spi_setup; master->prepare_message = rockchip_spi_prepare_message; master->unprepare_message = rockchip_spi_unprepare_message; master->transfer_one = rockchip_spi_transfer_one; |