Skip to content

Commit a590370

Browse files
Roman Guskovbroonie
authored andcommitted
spi: stm32: FIFO threshold level - fix align packet size
if cur_bpw <= 8 and xfer_len < 4 then the value of fthlv will be 1 and SPI registers content may have been lost. * If SPI data register is accessed as a 16-bit register and DSIZE <= 8bit, better to select FTHLV = 2, 4, 6 etc * If SPI data register is accessed as a 32-bit register and DSIZE > 8bit, better to select FTHLV = 2, 4, 6 etc, while if DSIZE <= 8bit, better to select FTHLV = 4, 8, 12 etc Signed-off-by: Roman Guskov <rguskov@dh-electronics.com> Fixes: dcbe0d8 ("spi: add driver for STM32 SPI controller") Reviewed-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20201221123532.27272-1-rguskov@dh-electronics.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 17fa81a commit a590370

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/spi/spi-stm32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,9 @@ static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi, u32 xfer_len)
493493

494494
/* align packet size with data registers access */
495495
if (spi->cur_bpw > 8)
496-
fthlv -= (fthlv % 2); /* multiple of 2 */
496+
fthlv += (fthlv % 2) ? 1 : 0;
497497
else
498-
fthlv -= (fthlv % 4); /* multiple of 4 */
498+
fthlv += (fthlv % 4) ? (4 - (fthlv % 4)) : 0;
499499

500500
if (!fthlv)
501501
fthlv = 1;

0 commit comments

Comments
 (0)