summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-pl022.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2021-03-30 18:49:07 +0200
committerMark Brown <broonie@kernel.org>2021-03-31 13:54:29 +0100
commit8bb2dbf1e14d05e92a23e03bcbd1c27f7ee937f7 (patch)
treeb997a71c2c144fa0af0505a974455abb2d4bc416 /drivers/spi/spi-pl022.c
parent77f983a9df421fa00ca6a2f494dc79f8afca75a2 (diff)
spi: pl022: Convert to use GPIO descriptors
This converts the PL022 driver to use GPIO descriptors instead of the old global GPIO numberspace. Since the driver handles messages on its own it needs to manage the GPIO descriptor directly. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20210330164907.2346010-3-linus.walleij@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-pl022.c')
-rw-r--r--drivers/spi/spi-pl022.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 680f9cdfe295..0c9e3f270f05 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -31,7 +31,6 @@
#include <linux/dma-mapping.h>
#include <linux/scatterlist.h>
#include <linux/pm_runtime.h>
-#include <linux/gpio.h>
#include <linux/of.h>
#include <linux/pinctrl/consumer.h>
@@ -363,7 +362,7 @@ struct vendor_data {
* @dummypage: a dummy page used for driving data on the bus with DMA
* @dma_running: indicates whether DMA is in operation
* @cur_cs: current chip select index
- * @cur_gpio: current chip select GPIO line
+ * @cur_gpiod: current chip select GPIO descriptor
*/
struct pl022 {
struct amba_device *adev;
@@ -398,7 +397,7 @@ struct pl022 {
bool dma_running;
#endif
int cur_cs;
- int cur_gpio;
+ struct gpio_desc *cur_gpiod;
};
/**
@@ -454,8 +453,16 @@ static void pl022_cs_control(struct pl022 *pl022, u32 command)
{
if (pl022->vendor->internal_cs_ctrl)
internal_cs_control(pl022, command);
- else if (gpio_is_valid(pl022->cur_gpio))
- gpio_set_value(pl022->cur_gpio, command);
+ else if (pl022->cur_gpiod)
+ /*
+ * This needs to be inverted since with GPIOLIB in
+ * control, the inversion will be handled by
+ * GPIOLIB's active low handling. The "command"
+ * passed into this function will be SSP_CHIP_SELECT
+ * which is enum:ed to 0, so we need the inverse
+ * (1) to activate chip select.
+ */
+ gpiod_set_value(pl022->cur_gpiod, !command);
}
/**
@@ -1582,7 +1589,7 @@ static int pl022_transfer_one_message(struct spi_master *master,
pl022->cur_chip = spi_get_ctldata(msg->spi);
pl022->cur_cs = msg->spi->chip_select;
/* This is always available but may be set to -ENOENT */
- pl022->cur_gpio = msg->spi->cs_gpio;
+ pl022->cur_gpiod = msg->spi->cs_gpiod;
restore_state(pl022);
flush(pl022);
@@ -2135,6 +2142,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
master->unprepare_transfer_hardware = pl022_unprepare_transfer_hardware;
master->rt = platform_info->rt;
master->dev.of_node = dev->of_node;
+ master->use_gpio_descriptors = true;
/*
* Supports mode 0-3, loopback, and active low CS. Transfers are