diff options
author | Paul Barker <paul.barker@sancloud.com> | 2022-10-05 13:18:34 +0100 |
---|---|---|
committer | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2022-10-16 12:23:22 +0200 |
commit | c98f6fed93ca49a956d628200b2dfa1454ce6fbb (patch) | |
tree | da69733fed050f319e35332aa052cfee314b1efc /drivers/spi/spi-uclass.c | |
parent | 0e49f5c26caf9972137a474065afd4bdfe5ec062 (diff) |
spi: Implement spi_set_speed
This function is already defined in spi.h but no implementation of it
currently exists in the tree. The implementation is based on the static
function spi_set_speed_mode(). The function prototype is modified so
that an success or error condition can be returned to the caller.
Signed-off-by: Paul Barker <paul.barker@sancloud.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'drivers/spi/spi-uclass.c')
-rw-r--r-- | drivers/spi/spi-uclass.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index f2791c4b88e..c929e7c1d0e 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -130,6 +130,21 @@ void spi_release_bus(struct spi_slave *slave) dm_spi_release_bus(slave->dev); } +int spi_set_speed(struct spi_slave *slave, uint hz) +{ + struct dm_spi_ops *ops; + int ret; + + ops = spi_get_ops(slave->dev->parent); + if (ops->set_speed) + ret = ops->set_speed(slave->dev->parent, hz); + else + ret = -EINVAL; + if (ret) + dev_err(slave->dev, "Cannot set speed (err=%d)\n", ret); + return ret; +} + int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { |