Skip to content
Snippets Groups Projects
Commit 60e2809a authored by Simon Glass's avatar Simon Glass
Browse files

dm: spi: Avoid setting the speed with every transfer


Only set the speed if it has changed from last time. Since the speed will
be 0 when the device is probed it will always be changed on the first
transfer after the device is probed.

Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
parent 172a31bf
No related branches found
No related tags found
No related merge requests found
......@@ -63,9 +63,12 @@ int spi_claim_bus(struct spi_slave *slave)
}
if (!speed)
speed = 100000;
ret = spi_set_speed_mode(bus, speed, slave->mode);
if (ret)
return ret;
if (speed != slave->speed) {
ret = spi_set_speed_mode(bus, speed, slave->mode);
if (ret)
return ret;
slave->speed = speed;
}
return ops->claim_bus ? ops->claim_bus(dev) : 0;
}
......
......@@ -100,6 +100,8 @@ struct dm_spi_slave_platdata {
* @dev: SPI slave device
* @max_hz: Maximum speed for this slave
* @mode: SPI mode to use for this slave (see SPI mode flags)
* @speed: Current bus speed. This is 0 until the bus is first
* claimed.
* @bus: ID of the bus that the slave is attached to. For
* driver model this is the sequence number of the SPI
* bus (bus->seq) so does not need to be stored
......@@ -117,6 +119,7 @@ struct spi_slave {
#ifdef CONFIG_DM_SPI
struct udevice *dev; /* struct spi_slave is dev->parentdata */
uint max_hz;
uint speed;
uint mode;
#else
unsigned int bus;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment