1 Implement the SPI-GPIO delay function for busses that need speed limitation.
7 --- a/drivers/spi/spi_gpio.c
8 +++ b/drivers/spi/spi_gpio.c
10 #include <linux/init.h>
11 #include <linux/platform_device.h>
12 #include <linux/gpio.h>
13 +#include <linux/delay.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/spi_bitbang.h>
17 @@ -69,6 +70,7 @@ struct spi_gpio {
18 * #define SPI_MOSI_GPIO 120
19 * #define SPI_SCK_GPIO 121
20 * #define SPI_N_CHIPSEL 4
21 + * #undef NEED_SPIDELAY
22 * #include "spi_gpio.c"
25 @@ -76,6 +78,7 @@ struct spi_gpio {
26 #define DRIVER_NAME "spi_gpio"
28 #define GENERIC_BITBANG /* vs tight inlines */
29 +#define NEED_SPIDELAY 1
31 /* all functions referencing these symbols must define pdata */
32 #define SPI_MISO_GPIO ((pdata)->miso)
33 @@ -120,12 +123,20 @@ static inline int getmiso(const struct s
37 - * NOTE: this clocks "as fast as we can". It "should" be a function of the
38 - * requested device clock. Software overhead means we usually have trouble
39 - * reaching even one Mbit/sec (except when we can inline bitops), so for now
40 - * we'll just assume we never need additional per-bit slowdowns.
41 + * NOTE: to clock "as fast as we can", set spi_device.max_speed_hz
42 + * and spi_transfer.speed_hz to 0.
43 + * Otherwise this is a function of the requested device clock.
44 + * Software overhead means we usually have trouble
45 + * reaching even one Mbit/sec (except when we can inline bitops). So on small
46 + * embedded devices with fast SPI slaves you usually don't need a delay.
48 -#define spidelay(nsecs) do {} while (0)
49 +static inline void spidelay(unsigned nsecs)
52 + if (unlikely(nsecs))
54 +#endif /* NEED_SPIDELAY */
57 #include "spi_bitbang_txrx.h"