summaryrefslogtreecommitdiff
path: root/drivers
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-10-02 00:39:22 +0200
commitf08a344a50ba88f25bf9302153830dbfab135310 (patch)
tree14d04e61dcf458cd8d4cb65de9b108b0e0a3d4b6 /drivers
parentfcf547a7c92cccd99283738071ef1a3ece1a25b2 (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>
Diffstat (limited to 'drivers')
-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 5c5223bc73ef..8c3b019f6bfd 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>
@@ -678,6 +679,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;
@@ -759,6 +771,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;