spi-uclass: claim bus before setting speed
PATCH 1/1 spi-uclass: claim bus before setting speed
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.
--- drivers/spi/spi-uclass.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/spi/spi-uclass.c +10 -2
@@ -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)
Signature · 1 line
2.21.0
PATCH 1/1 spi-uclass: claim bus before setting speed
Quoted 4 lines · George Hilliard
The sunxi SPI peripheral driver attempts to interact with the peripheral in the
set_speedfunction. It also resets the device completely (disabling clocks and power) when the bus is released and
We do set_speed even before this, during spi_get_bus_and_cs call. I don't think claim would have any effect here. and the set_speed here is to update if speed is diff b/w slave and the actual.
If claim required here, this would also need during spi_get_bus_and_cs, but this isn't the case.
Quoted 3 lines
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.
Can you listed these cases, or some kind of non-working or no effect case would help here.