b22408193558f486c76b4058dc5b3be533d07c87
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.28 / 920-04-spi-gpio-implement-spi-delay.patch
1 Implement the SPI-GPIO delay function for busses that need speed limitation.
2
3 --mb
4
5
6
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
11 @@ -21,6 +21,7 @@
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/gpio.h>
15 +#include <linux/delay.h>
16
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"
25 */
26
27 @@ -76,6 +78,7 @@ struct spi_gpio {
28 #define DRIVER_NAME "spi_gpio"
29
30 #define GENERIC_BITBANG /* vs tight inlines */
31 +#define NEED_SPIDELAY 1
32
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
36 #undef pdata
37
38 /*
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.
49 */
50 -#define spidelay(nsecs) do {} while (0)
51 +static inline void spidelay(unsigned nsecs)
52 +{
53 +#ifdef NEED_SPIDELAY
54 + if (unlikely(nsecs))
55 + ndelay(nsecs);
56 +#endif /* NEED_SPIDELAY */
57 +}
58
59 #define EXPAND_BITBANG_TXRX
60 #include <linux/spi/spi_bitbang.h>
This page took 0.046064 seconds and 3 git commands to generate.