--- zzzz-none-000/linux-3.10.107/drivers/spi/spi-gpio.c 2017-06-27 09:49:32.000000000 +0000 +++ vr9-7490-729/linux-3.10.107/drivers/spi/spi-gpio.c 2021-11-10 11:53:55.000000000 +0000 @@ -73,6 +73,7 @@ * #define SPI_MOSI_GPIO 120 * #define SPI_SCK_GPIO 121 * #define SPI_N_CHIPSEL 4 + * #undef NEED_SPIDELAY * #include "spi-gpio.c" */ @@ -80,6 +81,7 @@ #define DRIVER_NAME "spi_gpio" #define GENERIC_BITBANG /* vs tight inlines */ +#define NEED_SPIDELAY 1 /* all functions referencing these symbols must define pdata */ #define SPI_MISO_GPIO ((pdata)->miso) @@ -130,12 +132,19 @@ #undef pdata /* - * NOTE: this clocks "as fast as we can". It "should" be a function of the + * NOTE: to clock "as fast as we can", set spi_device.max_speed_hz + * and spi_transfer.speed_hz to 0. Otherwise this is a function of the * requested device clock. Software overhead means we usually have trouble - * reaching even one Mbit/sec (except when we can inline bitops), so for now - * we'll just assume we never need additional per-bit slowdowns. + * reaching even one Mbit/sec (except when we can inline bitops). So on small + * embedded devices with fast SPI slaves you usually don't need a delay. */ -#define spidelay(nsecs) do {} while (0) +static inline void spidelay(unsigned nsecs) +{ +#ifdef NEED_SPIDELAY + if (unlikely(nsecs)) + ndelay(nsecs); +#endif /* NEED_SPIDELAY */ +} #include "spi-bitbang-txrx.h"