summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Goger <klaus.goger@theobroma-systems.com>2018-05-08 10:35:43 +0200
committerChristoph Muellner <christoph.muellner@theobroma-systems.com>2019-04-30 20:01:56 +0200
commitbf76e08f1cc34ae4a453e53e400c5d4e472d3dd0 (patch)
treee54a05a1888ee556063fea1cf933716d75ef15b9
parent51fdc026c6fecf81c8a85edef4e954a05e67b5c8 (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.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index ae196078edf6..3a2d43300301 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>
@@ -664,6 +665,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;
@@ -745,6 +757,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;