DECLARE_GLOBAL_DATA_PTR;
+#define SPI_DEFAULT_SPEED_HZ 100000
+
static int spi_set_speed_mode(struct udevice *bus, int speed, int mode)
{
struct dm_spi_ops *ops;
speed = spi->max_hz;
}
if (!speed)
- speed = 100000;
+ speed = SPI_DEFAULT_SPEED_HZ;
if (speed != slave->speed) {
int ret = spi_set_speed_mode(bus, speed, slave->mode);
}
plat = dev_get_parent_platdata(dev);
plat->cs = cs;
- plat->max_hz = speed;
+ if (speed) {
+ plat->max_hz = speed;
+ } else {
+ printf("Warning: SPI speed fallback to %u kHz\n",
+ SPI_DEFAULT_SPEED_HZ / 1000);
+ plat->max_hz = SPI_DEFAULT_SPEED_HZ;
+ }
plat->mode = mode;
created = true;
} else if (ret) {
int value;
plat->cs = dev_read_u32_default(dev, "reg", -1);
- plat->max_hz = dev_read_u32_default(dev, "spi-max-frequency", 0);
+ plat->max_hz = dev_read_u32_default(dev, "spi-max-frequency",
+ SPI_DEFAULT_SPEED_HZ);
if (dev_read_bool(dev, "spi-cpol"))
mode |= SPI_CPOL;
if (dev_read_bool(dev, "spi-cpha"))