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