mxs: spi: clear XFER_LEN in CTRL0 register during DMA
Subsystems (2)
PATCH 1/1 mxs: spi: clear XFER_LEN in CTRL0 register during DMA
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.
--- drivers/spi/spi-mxs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/spi/spi-mxs.c +4 -1
@@ -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;
Signature · 1 line
1.7.10.4
PATCH 1/1 mxs: spi: clear XFER_LEN in CTRL0 register during DMA
Dear Juha Lumme,
Quoted 1 line
On MX23 the
XFER_LEN
XFER_COUNT ;-)
Quoted 1 line
part in CTRL0 register was improperly OR'd
... during construction of DMA descriptor chain. Instead of being freshly set.
Quoted 2 lines
, and
because of that too many characters
Bytes
Quoted 1 line
were being expected from SPI.
expected from SPI during the last DMA cycle.
Quoted 1 line
This caused a timeout (
SSP_TIMEOUT) to happen in the last package
... during the processing of the last DMA descriptor ...
Quoted 2 lines
in the
DMA chain, and resulted into a corrupted read.
Write too, really ;-)
Quoted 1 line
This is a workaround for the problem
This is actually a correct fix for the issue.
Quoted 2 lines
, by clearing the
XFER_LENbytes always before reading the new size forXFER_LEN.
before setting new XFER_COUNT into the ctrl0 field of DMA control transfer.
Quoted 4 lines
Cc Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Shawn Guo <[email protected]Signed-off-by Juha Lumme <[email protected]>
All but the commit message,
Quoted 18 lines
--- drivers/spi/spi-mxs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/spi/spi-mxs.c +1
-0@@ -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)
drivers/spi/spi-mxs.c static int mxs_spi_txrx_dma(struct mxs_spi *spi, int · line 266
Quoted 10 lines
drivers/spi/spi-mxs.c +3
-1ctrl0 |=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