diff options
author | Marcin Wojtas <mw@semihalf.com> | 2021-04-30 15:26:30 +0200 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2021-05-16 06:48:45 +0200 |
commit | 562f8d5b36e4d35365aa9a545e4d11b5c2557ec1 (patch) | |
tree | bc07999e224f8a663a7ed0159dd4ec095a822172 /drivers/spi | |
parent | 037818c544c44b31dd532409e3abc3747e24a60d (diff) | |
download | u-boot-562f8d5b36e4d35365aa9a545e4d11b5c2557ec1.tar.gz u-boot-562f8d5b36e4d35365aa9a545e4d11b5c2557ec1.tar.bz2 u-boot-562f8d5b36e4d35365aa9a545e4d11b5c2557ec1.zip |
spi: kirkwood: prevent configuring speed exceeding max controller freq
This patch adds a limitation in the kirkwood_spi driver
set_speed hook, which prevents setting too high transfer
speed.
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Reviewed-by: Kostya Porotchkin <kostap@marvell.com>
Tested-by: Kostya Porotchkin <kostap@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/kirkwood_spi.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c index 3dc62f351a..063ed5f35a 100644 --- a/drivers/spi/kirkwood_spi.c +++ b/drivers/spi/kirkwood_spi.c @@ -110,10 +110,17 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen, static int mvebu_spi_set_speed(struct udevice *bus, uint hz) { struct mvebu_spi_plat *plat = dev_get_plat(bus); + struct dm_spi_bus *spi = dev_get_uclass_priv(bus); struct kwspi_registers *reg = plat->spireg; u32 data, divider; unsigned int spr, sppr; + if (hz > spi->max_hz) { + debug("%s: limit speed to the max_hz of the bus %d\n", + __func__, spi->max_hz); + hz = spi->max_hz; + } + /* * Calculate spi clock prescaller using max_hz. * SPPR is SPI Baud Rate Pre-selection, it holds bits 5 and 7:6 in |