linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: juha.lumme@gmail.com (Juha Lumme)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mxs: spi: clear XFER_LEN in CTRL0 register during DMA
Date: Wed, 26 Dec 2012 14:01:28 +0900	[thread overview]
Message-ID: <1356498088-31176-1-git-send-email-juha.lumme@gmail.com> (raw)

On MX23 the XFER_LEN part in CTRL0 register was improperly OR'd, and because
of that too many characters were being expected from SPI.
This caused a timeout (SSP_TIMEOUT) to happen in the last package in the DMA
chain, and resulted into a corrupted read.
This is a workaround for the problem, by clearing the XFER_LEN bytes always
before reading the new size for XFER_LEN.

Cc: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo at linaro.org
Signed-off-by: Juha Lumme <juha.lumme@gmail.com>
---
 drivers/spi/spi-mxs.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
index 86dd04d..265c33f 100644
--- a/drivers/spi/spi-mxs.c
+++ b/drivers/spi/spi-mxs.c
@@ -241,6 +241,7 @@ static int mxs_spi_txrx_dma(struct mxs_spi *spi, int cs,
 	INIT_COMPLETION(spi->c);
 
 	ctrl0 = readl(ssp->base + HW_SSP_CTRL0);
+	ctrl0 &= ~BM_SSP_CTRL0_XFER_COUNT;
 	ctrl0 |= BM_SSP_CTRL0_DATA_XFER | mxs_spi_cs_to_reg(cs);
 
 	if (*first)
@@ -256,8 +257,10 @@ static int mxs_spi_txrx_dma(struct mxs_spi *spi, int cs,
 		if ((sg_count + 1 == sgs) && *last)
 			ctrl0 |= BM_SSP_CTRL0_IGNORE_CRC;
 
-		if (ssp->devid == IMX23_SSP)
+		if (ssp->devid == IMX23_SSP) {
+			ctrl0 &= ~BM_SSP_CTRL0_XFER_COUNT;
 			ctrl0 |= min;
+		}
 
 		dma_xfer[sg_count].pio[0] = ctrl0;
 		dma_xfer[sg_count].pio[3] = min;
-- 
1.7.10.4

             reply	other threads:[~2012-12-26  5:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-26  5:01 Juha Lumme [this message]
2012-12-26  5:06 ` [PATCH] mxs: spi: clear XFER_LEN in CTRL0 register during DMA Marek Vasut

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=1356498088-31176-1-git-send-email-juha.lumme@gmail.com \
    --to=juha.lumme@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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).