]> git.baikalelectronics.ru Git - kernel.git/commit
spi: imx: mx51-ecspi: Fix low-speed CONFIGREG delay calculation
authorMarek Vasut <marex@denx.de>
Mon, 26 Jul 2021 10:01:02 +0000 (12:01 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 26 Jul 2021 17:57:14 +0000 (18:57 +0100)
commit346d51636007d0174148b06c157177d9428366af
treeb2488f96935811b5820d654fda66d9bfbc8e5881
parent750eb66dad90a26066b51eb6d3c41e00129efabb
spi: imx: mx51-ecspi: Fix low-speed CONFIGREG delay calculation

The spi_imx->spi_bus_clk may be uninitialized and thus also zero in
mx51_ecspi_prepare_message(), which would lead to division by zero
in kernel. Since bitbang .setup_transfer callback which initializes
the spi_imx->spi_bus_clk is called after bitbang prepare_message
callback, iterate over all the transfers in spi_message, find the
one with lowest bus frequency, and use that bus frequency for the
delay calculation.

Note that it is not possible to move this CONFIGREG delay back into
the .setup_transfer callback, because that is invoked too late, after
the GPIO chipselects were already configured.

Fixes: 170e814ea29c ("spi: imx: mx51-ecspi: Reinstate low-speed CONFIGREG delay")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210726100102.5188-1-marex@denx.de
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-imx.c