diff options
author | Mark Brown <broonie@kernel.org> | 2023-10-30 13:20:58 +0000 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2023-10-30 13:20:58 +0000 |
commit | 1b2e883e1af895b62808b044ac96b77e7c9017b1 (patch) | |
tree | 5be3c6044108f29e2f027b5e0a70862de35840eb /drivers/spi/spi-stm32.c | |
parent | 75223bbea840e125359fc63942b5f93462b474c6 (diff) | |
parent | c3aa5cb264a38ae9bbcce32abca4c155af0456df (diff) |
spi: Merge up fix
One small fix that didn't seem worth sending before the merge window.
Diffstat (limited to 'drivers/spi/spi-stm32.c')
-rw-r--r-- | drivers/spi/spi-stm32.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index 10cdccf46c48..e6e3e4ea29f9 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -278,6 +278,7 @@ struct stm32_spi_cfg { * @fifo_size: size of the embedded fifo in bytes * @cur_midi: master inter-data idleness in ns * @cur_speed: speed configured in Hz + * @cur_half_period: time of a half bit in us * @cur_bpw: number of bits in a single SPI data frame * @cur_fthlv: fifo threshold level (data frames in a single data packet) * @cur_comm: SPI communication mode @@ -305,6 +306,7 @@ struct stm32_spi { unsigned int cur_midi; unsigned int cur_speed; + unsigned int cur_half_period; unsigned int cur_bpw; unsigned int cur_fthlv; unsigned int cur_comm; @@ -469,6 +471,8 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz, spi->cur_speed = spi->clk_rate / (1 << mbrdiv); + spi->cur_half_period = DIV_ROUND_CLOSEST(USEC_PER_SEC, 2 * spi->cur_speed); + return mbrdiv - 1; } @@ -710,6 +714,10 @@ static void stm32h7_spi_disable(struct stm32_spi *spi) return; } + /* Add a delay to make sure that transmission is ended. */ + if (spi->cur_half_period) + udelay(spi->cur_half_period); + if (spi->cur_usedma && spi->dma_tx) dmaengine_terminate_async(spi->dma_tx); if (spi->cur_usedma && spi->dma_rx) |