linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Максим Киселёв" <bigunclemax@gmail.com>
To: "Vladimir Oltean" <olteanv@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Максим Киселёв" <bigunclemax@gmail.com>,
	"Maxim Kochetkov" <fido_max@inbox.ru>
Subject: 
Date: Thu, 3 Dec 2020 19:57:36 +0300	[thread overview]
Message-ID: <CALHCpMiWdSYxzKK5dXb7AGQ1ncsXmD853g9Aq0zd5YjE5cno8w@mail.gmail.com> (raw)

From 772007b92eda50186c2e420b5bd895d4e4006ae8 Mon Sep 17 00:00:00 2001
From: Maxim Kiselev <bigunclemax@gmail.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@gmail.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

                 reply	other threads:[~2020-12-03 16:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CALHCpMiWdSYxzKK5dXb7AGQ1ncsXmD853g9Aq0zd5YjE5cno8w@mail.gmail.com \
    --to=bigunclemax@gmail.com \
    --cc=broonie@kernel.org \
    --cc=fido_max@inbox.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=olteanv@gmail.com \
    /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).