From: <tthayer@opensource.altera.com>
To: <broonie@kernel.org>
Cc: <andriy.shevchenko@linux.intel.com>,
<jarkko.nikula@linux.intel.com>, <jszhang@marvell.com>,
<michael@smart-africa.com>, <kernel@mseidel.net>,
<linux-spi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<tthayer@opensource.altera.com>
Subject: [PATCH] spi: dw: Enable Slave Select with GPIO Chip Select.
Date: Wed, 5 Oct 2016 16:38:58 -0500 [thread overview]
Message-ID: <1475703538-5018-1-git-send-email-tthayer@opensource.altera.com> (raw)
From: Thor Thayer <tthayer@opensource.altera.com>
Currently in the GPIO CS case, the transfer is stalled. The DesignWare
IP datasheet points out that the slave must be selected (SER) before the
transfer can start [1]. The SPI framework selects the chip using either
1) the internal CS mechanism or 2) the GPIO CS, but not both.
This patch adds the Slave Select locally so that the transfer will
start and complete. The GPIO CS is taken care of earlier in the SPI
framework (spi_set_cs).
Tested On:
Altera CycloneV development kit
Compile tested for build errors on x86_64 (allyesconfigs)
[1] DesignWare dw_apb_ssi Databook, Version 3.20a (page 39)
Signed-off-by: Thor Thayer <tthayer@opensource.altera.com>
---
drivers/spi/spi-dw.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 27960e4..86e321d 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -296,6 +296,10 @@ static int dw_spi_transfer_one(struct spi_master *master,
spi_enable_chip(dws, 0);
+ /* Slave select required before transfer can begin. Force in gpio CS */
+ if (gpio_is_valid(spi->cs_gpio))
+ dw_spi_set_cs(spi, 0);
+
/* Handle per transfer options for bpw and speed */
if (transfer->speed_hz != dws->current_freq) {
if (transfer->speed_hz != chip->speed_hz) {
@@ -390,6 +394,10 @@ static void dw_spi_handle_err(struct spi_master *master,
if (dws->dma_mapped)
dws->dma_ops->dma_stop(dws);
+ /* Cleanup Slave Select in gpio CS case */
+ if (gpio_is_valid(msg->spi->cs_gpio))
+ dw_spi_set_cs(msg->spi, 1);
+
spi_reset_chip(dws);
}
@@ -440,6 +448,10 @@ static void dw_spi_cleanup(struct spi_device *spi)
{
struct chip_data *chip = spi_get_ctldata(spi);
+ /* Cleanup Slave Select in gpio CS case */
+ if (gpio_is_valid(spi->cs_gpio))
+ dw_spi_set_cs(spi, 1);
+
kfree(chip);
spi_set_ctldata(spi, NULL);
}
--
1.7.9.5
next reply other threads:[~2016-10-05 21:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-05 21:38 tthayer [this message]
[not found] ` <1475703538-5018-1-git-send-email-tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>
2016-10-06 9:37 ` [PATCH] spi: dw: Enable Slave Select with GPIO Chip Select Mark Brown
2016-10-06 14:15 ` Thor Thayer
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=1475703538-5018-1-git-send-email-tthayer@opensource.altera.com \
--to=tthayer@opensource.altera.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=broonie@kernel.org \
--cc=jarkko.nikula@linux.intel.com \
--cc=jszhang@marvell.com \
--cc=kernel@mseidel.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=michael@smart-africa.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).