Skip to content

Commit e9b220a

Browse files
bgi-brtbroonie
authored andcommitted
spi: spi-imx: correctly configure burst length when using dma
If DMA is used, burst length should be set to the bus width of the DMA. Otherwise, the SPI hardware will transmit/receive one word per DMA request. Since this issue affects both transmission and reception, it cannot be detected with a loopback test. Replace magic numbers 512 and 0xfff with MX51_ECSPI_CTRL_MAX_BURST. Reported-by Stefan Bigler <[email protected]> Signed-off-by: Benjamin Bigler <[email protected]> Fixes: 15a6af9 ("spi: Increase imx51 ecspi burst length based on transfer length") Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 7a733e0 commit e9b220a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/spi/spi-imx.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,11 +659,18 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx,
659659
ctrl |= (spi_imx->target_burst * 8 - 1)
660660
<< MX51_ECSPI_CTRL_BL_OFFSET;
661661
else {
662-
if (spi_imx->count >= 512)
663-
ctrl |= 0xFFF << MX51_ECSPI_CTRL_BL_OFFSET;
664-
else
665-
ctrl |= (spi_imx->count * spi_imx->bits_per_word - 1)
662+
if (spi_imx->usedma) {
663+
ctrl |= (spi_imx->bits_per_word *
664+
spi_imx_bytes_per_word(spi_imx->bits_per_word) - 1)
666665
<< MX51_ECSPI_CTRL_BL_OFFSET;
666+
} else {
667+
if (spi_imx->count >= MX51_ECSPI_CTRL_MAX_BURST)
668+
ctrl |= (MX51_ECSPI_CTRL_MAX_BURST - 1)
669+
<< MX51_ECSPI_CTRL_BL_OFFSET;
670+
else
671+
ctrl |= (spi_imx->count * spi_imx->bits_per_word - 1)
672+
<< MX51_ECSPI_CTRL_BL_OFFSET;
673+
}
667674
}
668675

669676
/* set clock speed */

0 commit comments

Comments
 (0)