Skip to content

Commit c712c05

Browse files
NXP-CarlosSongbroonie
authored andcommitted
spi: imx: fix the burst length at DMA mode and CPU mode
For DMA mode, the bus width of the DMA is equal to the size of data word, so burst length should be configured as bits per word. For CPU mode, because of the spi transfer len is in byte, so calculate the total number of words according to spi transfer len and bits per word, burst length should be configured as total data bits. Signed-off-by: Carlos Song <[email protected]> Reviewed-by: Clark Wang <[email protected]> Fixes: e9b220a ("spi: spi-imx: correctly configure burst length when using dma") Fixes: 5f66db0 ("spi: imx: Take in account bits per word instead of assuming 8-bits") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 6500ad2 commit c712c05

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/spi/spi-imx.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
33
// Copyright (C) 2008 Juergen Beisert
44

5+
#include <linux/bits.h>
56
#include <linux/clk.h>
67
#include <linux/completion.h>
78
#include <linux/delay.h>
@@ -660,15 +661,15 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx,
660661
<< MX51_ECSPI_CTRL_BL_OFFSET;
661662
else {
662663
if (spi_imx->usedma) {
663-
ctrl |= (spi_imx->bits_per_word *
664-
spi_imx_bytes_per_word(spi_imx->bits_per_word) - 1)
664+
ctrl |= (spi_imx->bits_per_word - 1)
665665
<< MX51_ECSPI_CTRL_BL_OFFSET;
666666
} else {
667667
if (spi_imx->count >= MX51_ECSPI_CTRL_MAX_BURST)
668-
ctrl |= (MX51_ECSPI_CTRL_MAX_BURST - 1)
668+
ctrl |= (MX51_ECSPI_CTRL_MAX_BURST * BITS_PER_BYTE - 1)
669669
<< MX51_ECSPI_CTRL_BL_OFFSET;
670670
else
671-
ctrl |= (spi_imx->count * spi_imx->bits_per_word - 1)
671+
ctrl |= spi_imx->count / DIV_ROUND_UP(spi_imx->bits_per_word,
672+
BITS_PER_BYTE) * spi_imx->bits_per_word
672673
<< MX51_ECSPI_CTRL_BL_OFFSET;
673674
}
674675
}

0 commit comments

Comments
 (0)