The sunxi SPI peripheral driver attempts to interact with the peripheral in the set_speed function. It also resets the device completely (disabling clocks and power) when the bus is released and turns it back on when claiming. So, if the clock was set up before the bus was claimed, the speed change would have no effect, and the peripheral wouldn't work in many cases.
This change allows the peripheral driver to initialize the device before attempting to do anything else. Signed-off-by: George Hilliard <thirtythreefo...@gmail.com> Cc: Jagan Teki <jt...@openedev.com> --- drivers/spi/spi-uclass.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index 88cb2a12622..88aa883b206 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -51,6 +51,7 @@ int dm_spi_claim_bus(struct udevice *dev) struct dm_spi_bus *spi = dev_get_uclass_priv(bus); struct spi_slave *slave = dev_get_parent_priv(dev); int speed; + int ret; speed = slave->max_hz; if (spi->max_hz) { @@ -61,15 +62,22 @@ int dm_spi_claim_bus(struct udevice *dev) } if (!speed) speed = SPI_DEFAULT_SPEED_HZ; + + if (ops->claim_bus) { + ret = ops->claim_bus(dev); + if (ret) + return log_ret(ret); + } + if (speed != slave->speed) { - int ret = spi_set_speed_mode(bus, speed, slave->mode); + ret = spi_set_speed_mode(bus, speed, slave->mode); if (ret) return log_ret(ret); slave->speed = speed; } - return log_ret(ops->claim_bus ? ops->claim_bus(dev) : 0); + return 0; } void dm_spi_release_bus(struct udevice *dev) -- 2.21.0 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot