Skip to content

Commit e1e53f4

Browse files
committed
spi: spi-imx: Fix spi_bus_clk if requested clock is higher than input clock
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071848 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2122415 commit db2d2dc Author: Frieder Schrempf <frieder.schrempf@kontron.de> Date: Tue, 15 Nov 2022 19:10:00 +0100 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: 6fd8b85 ("spi: spi-imx: Fix out-of-order CS/SCLK operation at low speeds") Fixes: 07e7593 ("spi: spi-imx: add PIO polling support") Cc: Marc Kleine-Budde <mkl@pengutronix.de> Cc: David Jander <david@protonic.nl> Cc: Fabio Estevam <festevam@gmail.com> Cc: Mark Brown <broonie@kernel.org> Cc: Marek Vasut <marex@denx.de> Cc: stable@vger.kernel.org Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de> Tested-by: Fabio Estevam <festevam@gmail.com> Acked-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20221115181002.2068270-1-frieder@fris.de Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Mark Salter <msalter@redhat.com>
1 parent aacab87 commit e1e53f4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/spi/spi-imx.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,7 @@ static unsigned int mx51_ecspi_clkdiv(struct spi_imx_data *spi_imx,
444444
unsigned int pre, post;
445445
unsigned int fin = spi_imx->spi_clk;
446446

447-
if (unlikely(fspi > fin))
448-
return 0;
447+
fspi = min(fspi, fin);
449448

450449
post = fls(fin) - fls(fspi);
451450
if (fin > fspi << post)

0 commit comments

Comments
 (0)