diff options
author | Michael Walle <mwalle@kernel.org> | 2024-07-12 19:14:56 +0200 |
---|---|---|
committer | Andre Przywara <andre.przywara@arm.com> | 2024-07-16 01:40:40 +0100 |
commit | 674e4f994f5da537cab62ad86bc8bdf5acaae88c (patch) | |
tree | 578ca44419d5c70e16b6ed8abb4f86e0abedb062 | |
parent | a7766911bc2fc40df351564d71e6b93999c97b03 (diff) | |
download | u-boot-674e4f994f5da537cab62ad86bc8bdf5acaae88c.tar.gz u-boot-674e4f994f5da537cab62ad86bc8bdf5acaae88c.tar.bz2 u-boot-674e4f994f5da537cab62ad86bc8bdf5acaae88c.zip |
spi: sunxi: drop max_hz handling
The driver is trying to read the "spi-max-frequency" property of the
*controller* driver node. There is no such property. The
"spi-max-frequency" property belongs to the SPI devices on the bus.
Right now, the driver will always fall back to the default value of 1MHz
and thus flash reads are very slow with just about 215kb/s.
In fact, the SPI uclass will already take care of everything and we just
have to clamp the frequency to the values the driver/hardware supports.
Thus, drop the whole max_hz handling.
Signed-off-by: Michael Walle <mwalle@kernel.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Andre Przywara <andre.przywara@arm.com>
-rw-r--r-- | drivers/spi/spi-sunxi.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/spi/spi-sunxi.c b/drivers/spi/spi-sunxi.c index 13725ee7a2..a7333d8d9c 100644 --- a/drivers/spi/spi-sunxi.c +++ b/drivers/spi/spi-sunxi.c @@ -135,7 +135,6 @@ struct sun4i_spi_variant { struct sun4i_spi_plat { struct sun4i_spi_variant *variant; u32 base; - u32 max_hz; }; struct sun4i_spi_priv { @@ -238,6 +237,13 @@ static void sun4i_spi_set_speed_mode(struct udevice *dev) u32 reg; /* + * The uclass should take care that this won't happen. But anyway, + * avoid a div-by-zero exception. + */ + if (!priv->freq) + return; + + /* * Setup clock divider. * * We have two choices there. Either we can use the clock @@ -401,11 +407,10 @@ static int sun4i_spi_xfer(struct udevice *dev, unsigned int bitlen, static int sun4i_spi_set_speed(struct udevice *dev, uint speed) { - struct sun4i_spi_plat *plat = dev_get_plat(dev); struct sun4i_spi_priv *priv = dev_get_priv(dev); - if (speed > plat->max_hz) - speed = plat->max_hz; + if (speed > SUN4I_SPI_MAX_RATE) + speed = SUN4I_SPI_MAX_RATE; if (speed < SUN4I_SPI_MIN_RATE) speed = SUN4I_SPI_MIN_RATE; @@ -458,7 +463,6 @@ static int sun4i_spi_probe(struct udevice *bus) priv->variant = plat->variant; priv->base = plat->base; - priv->freq = plat->max_hz; return 0; } @@ -466,16 +470,9 @@ static int sun4i_spi_probe(struct udevice *bus) static int sun4i_spi_of_to_plat(struct udevice *bus) { struct sun4i_spi_plat *plat = dev_get_plat(bus); - int node = dev_of_offset(bus); plat->base = dev_read_addr(bus); plat->variant = (struct sun4i_spi_variant *)dev_get_driver_data(bus); - plat->max_hz = fdtdec_get_int(gd->fdt_blob, node, - "spi-max-frequency", - SUN4I_SPI_DEFAULT_RATE); - - if (plat->max_hz > SUN4I_SPI_MAX_RATE) - plat->max_hz = SUN4I_SPI_MAX_RATE; return 0; } |