]> git.proxmox.com Git - mirror_ubuntu-focal-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)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 20 Sep 2021 16:50:00 +0000 (18:50 +0200)
commit88a2a328ed6dd6b0c4a9b4215377a8c50bde9a31
treedb7776113ce0100565923f93c30b06de85c7502b
parenta652f9aaa6c5346c8db0c2a18efa20f8aa7f1bf4
spi: imx: mx51-ecspi: Fix low-speed CONFIGREG delay calculation

BugLink: https://bugs.launchpad.net/bugs/1941798
[ Upstream commit 53ca18acbe645656132fb5a329833db711067e54 ]

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: 135cbd378eab ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
drivers/spi/spi-imx.c