[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALHCpMgQPDqV1tB6v0sA0imwfZGkoG_j84NZCehOT1pf8MTuCA@mail.gmail.com>
Date: Thu, 3 Dec 2020 20:12:19 +0300
From: Максим Киселёв
<bigunclemax@...il.com>
To: Vladimir Oltean <olteanv@...il.com>,
Mark Brown <broonie@...nel.org>, linux-spi@...r.kernel.org,
linux-kernel@...r.kernel.org,
Максим Киселёв
<bigunclemax@...il.com>, Maxim Kochetkov <fido_max@...ox.ru>
Subject: [PATCH] spi: spi-fsl-dspi: Add GPIO chip select support
From: Maxim Kiselev <bigunclemax@...il.com>
Date: Thu, 3 Dec 2020 18:56:12 +0300
Subject: [PATCH] spi: spi-fsl-dspi: Add GPIO chip select support
This patch allows use of GPIO for the chip select.
Because dSPI controller can't send transactions without hardware chip
selects, so first unused native CS will be set in SPI_PUSHR_CMD_PCS
Signed-off-by: Maxim Kiselev <bigunclemax@...il.com>
---
drivers/spi/spi-fsl-dspi.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 028736687488..d5fba34de740 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -913,9 +913,14 @@ static int dspi_transfer_one_message(struct
spi_controller *ctlr,
dspi->cur_transfer = transfer;
dspi->cur_msg = message;
dspi->cur_chip = spi_get_ctldata(spi);
+
+ if (spi->cs_gpiod)
+ gpiod_set_value(spi->cs_gpiod, 1);
+
/* Prepare command word for CMD FIFO */
dspi->tx_cmd = SPI_PUSHR_CMD_CTAS(0) |
- SPI_PUSHR_CMD_PCS(spi->chip_select);
+ SPI_PUSHR_CMD_PCS(spi->cs_gpiod ?
+ ctlr->unused_native_cs : spi->chip_select);
if (list_is_last(&dspi->cur_transfer->transfer_list,
&dspi->cur_msg->transfers)) {
/* Leave PCS activated after last transfer when
@@ -1240,6 +1245,7 @@ static int dspi_probe(struct platform_device *pdev)
dspi->pdev = pdev;
dspi->ctlr = ctlr;
+ ctlr->use_gpio_descriptors = true;
ctlr->setup = dspi_setup;
ctlr->transfer_one_message = dspi_transfer_one_message;
ctlr->dev.of_node = pdev->dev.of_node;
--
2.27.0
Powered by blists - more mailing lists