[PATCH] mxs: spi: clear XFER_LEN in CTRL0 register during DMA
From: marex@denx.de (Marek Vasut)
Date: 2012-12-26 05:06:26
Also in:
linux-spi
Dear Juha Lumme,
On MX23 the XFER_LEN
XFER_COUNT ;-)
part in CTRL0 register was improperly OR'd
... during construction of DMA descriptor chain. Instead of being freshly set.
, and because of that too many characters
Bytes
were being expected from SPI.
expected from SPI during the last DMA cycle.
This caused a timeout (SSP_TIMEOUT) to happen in the last package
... during the processing of the last DMA descriptor ...
in the DMA chain, and resulted into a corrupted read.
Write too, really ;-)
This is a workaround for the problem
This is actually a correct fix for the issue.
, by clearing the XFER_LEN bytes always before reading the new size for XFER_LEN.
before setting new XFER_COUNT into the ctrl0 field of DMA control transfer.
Cc: Marek Vasut <marex@denx.de> Cc: Fabio Estevam <redacted> Cc: Shawn Guo <shawn.guo@linaro.org Signed-off-by: Juha Lumme <redacted>
All but the commit message, Acked-by: Marek Vasut <marex@denx.de>
quoted hunk ↗ jump to hunk
--- 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, intcs, 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, intcs, 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;
Best regards, Marek Vasut