mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
spi: spi-imx: Fix spi_bus_clk if requested clock is higher than input clock
[ Upstream commit db2d2dc9a0b58c6faefb6b002fdbed4f0362d1a4 ]
In case the requested bus clock is higher than the input clock, the correct
dividers (pre = 0, post = 0) are returned from mx51_ecspi_clkdiv(), but
*fres is left uninitialized and therefore contains an arbitrary value.
This causes trouble for the recently introduced PIO polling feature as the
value in spi_imx->spi_bus_clk is used there to calculate for which
transfers to enable PIO polling.
Fix this by setting *fres even if no clock dividers are in use.
This issue was observed on Kontron BL i.MX8MM with an SPI peripheral clock set
to 50 MHz by default and a requested SPI bus clock of 80 MHz for the SPI NOR
flash.
With the fix applied the debug message from mx51_ecspi_clkdiv() now prints the
following:
spi_imx 30820000.spi: mx51_ecspi_clkdiv: fin: 50000000, fspi: 50000000,
post: 0, pre: 0
Fixes: 6fd8b8503a ("spi: spi-imx: Fix out-of-order CS/SCLK operation at low speeds")
Fixes: 07e759387788 ("spi: spi-imx: add PIO polling support")
Cc: Marc Kleine-Budde <[email protected]>
Cc: David Jander <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: [email protected]
Signed-off-by: Frieder Schrempf <[email protected]>
Tested-by: Fabio Estevam <[email protected]>
Acked-by: Marek Vasut <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
This commit is contained in:
parent
83aae3204e
commit
255289adce
1 changed files with 1 additions and 2 deletions
|
|
@ -431,8 +431,7 @@ static unsigned int mx51_ecspi_clkdiv(struct spi_imx_data *spi_imx,
|
|||
unsigned int pre, post;
|
||||
unsigned int fin = spi_imx->spi_clk;
|
||||
|
||||
if (unlikely(fspi > fin))
|
||||
return 0;
|
||||
fspi = min(fspi, fin);
|
||||
|
||||
post = fls(fin) - fls(fspi);
|
||||
if (fin > fspi << post)
|
||||
|
|
|
|||
Loading…
Reference in a new issue