From: Linus Walleij <linus.walleij@linaro.org>
To: Mark Brown <broonie@kernel.org>, linux-spi@vger.kernel.org
Cc: Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH 3/3] spi: pl022: Convert to use GPIO descriptors
Date: Tue, 30 Mar 2021 18:49:07 +0200 [thread overview]
Message-ID: <20210330164907.2346010-3-linus.walleij@linaro.org> (raw)
In-Reply-To: <20210330164907.2346010-1-linus.walleij@linaro.org>
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>
---
drivers/spi/spi-pl022.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 84ffed2a3554..fda025a5ec06 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
--
2.29.2
next prev parent reply other threads:[~2021-03-30 16:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-30 16:49 [PATCH 1/3] spi: pl022: Drop custom per-chip cs_control Linus Walleij
2021-03-30 16:49 ` [PATCH 2/3] spi: pl022: Use GPIOs looked up by the core Linus Walleij
2021-03-30 16:49 ` Linus Walleij [this message]
2021-04-01 10:16 ` [PATCH 1/3] spi: pl022: Drop custom per-chip cs_control Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210330164907.2346010-3-linus.walleij@linaro.org \
--to=linus.walleij@linaro.org \
--cc=broonie@kernel.org \
--cc=linux-spi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).