All of lore.kernel.org
 help / color / mirror / Atom feed
From: sxauwsk <sxauwsk@163.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	sxauwsk <sxauwsk@163.com>
Subject: [PATCH] spi: cadence: Add usleep_range() for cdns_spi_fill_tx_fifo()
Date: Mon, 16 Apr 2018 20:07:31 +0800	[thread overview]
Message-ID: <1523880451-37748-1-git-send-email-sxauwsk@163.com> (raw)

In case of xspi work in busy condition, may send bytes failed then caused
communication failure. once something wrong, spi controller did't work any more.

My test found this situation appear in both of read/write operation.
so when TX FIFO is full, add one byte delay before send data.

Signed-off-by: sxauwsk <sxauwsk@163.com>
---
 drivers/spi/spi-cadence.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index 5c9516a..9694042 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -313,6 +313,14 @@ static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi)

	while ((trans_cnt < CDNS_SPI_FIFO_DEPTH) &&
 	       (xspi->tx_bytes > 0)) {
+
+		/* When xspi in busy condition, bytes may send failed,
+		 * then spi control did't work thoroughly, add one byte delay
+		 */
+		if (cdns_spi_read(xspi, CDNS_SPI_ISR_OFFSET) &
+		    CDNS_SPI_IXR_TXFULL_MASK)
+			usleep_range(10, 20);
+
 		if (xspi->txbuf)
 			cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++);
 		else
--
1.7.9.5

             reply	other threads:[~2018-04-17  2:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-16 12:07 sxauwsk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-04-16 20:01 [PATCH] spi: cadence: Add usleep_range() for cdns_spi_fill_tx_fifo() sxauwsk
     [not found] <201804102112307962582@163.com>
2018-04-10 13:49 ` Mark Brown
2018-04-09 11:16 sxauwsk
2018-04-13 18:03 ` 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=1523880451-37748-1-git-send-email-sxauwsk@163.com \
    --to=sxauwsk@163.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.