summaryrefslogtreecommitdiff
path: root/target/linux/generic-2.6
diff options
context:
space:
mode:
authorMichael Büsch <mb@bu3sch.de>2009-02-15 18:19:48 +0000
committerMichael Büsch <mb@bu3sch.de>2009-02-15 18:19:48 +0000
commitc2e122528467a2f2018a84c3e0333b7211717d9f (patch)
treed52ddc091f082737a81d93f6ad50e2f7b1324830 /target/linux/generic-2.6
parent1afc0de6d39439d3ecc17e8c003452da13ee60f1 (diff)
downloadmtk-20170518-c2e122528467a2f2018a84c3e0333b7211717d9f.zip
mtk-20170518-c2e122528467a2f2018a84c3e0333b7211717d9f.tar.gz
mtk-20170518-c2e122528467a2f2018a84c3e0333b7211717d9f.tar.bz2
spi-gpio: Implement spidelay for busses that need it.
SVN-Revision: 14525
Diffstat (limited to 'target/linux/generic-2.6')
-rw-r--r--target/linux/generic-2.6/patches-2.6.28/920-04-spi-gpio-implement-spi-delay.patch60
1 files changed, 60 insertions, 0 deletions
diff --git a/target/linux/generic-2.6/patches-2.6.28/920-04-spi-gpio-implement-spi-delay.patch b/target/linux/generic-2.6/patches-2.6.28/920-04-spi-gpio-implement-spi-delay.patch
new file mode 100644
index 0000000..b224081
--- /dev/null
+++ b/target/linux/generic-2.6/patches-2.6.28/920-04-spi-gpio-implement-spi-delay.patch
@@ -0,0 +1,60 @@
+Implement the SPI-GPIO delay function for busses that need speed limitation.
+
+--mb
+
+
+
+Index: linux-2.6.28.5/drivers/spi/spi_gpio.c
+===================================================================
+--- linux-2.6.28.5.orig/drivers/spi/spi_gpio.c 2009-02-15 18:53:47.000000000 +0100
++++ linux-2.6.28.5/drivers/spi/spi_gpio.c 2009-02-15 19:08:58.000000000 +0100
+@@ -21,6 +21,7 @@
+ #include <linux/init.h>
+ #include <linux/platform_device.h>
+ #include <linux/gpio.h>
++#include <linux/delay.h>
+
+ #include <linux/spi/spi.h>
+ #include <linux/spi/spi_bitbang.h>
+@@ -69,6 +70,7 @@ struct spi_gpio {
+ * #define SPI_MOSI_GPIO 120
+ * #define SPI_SCK_GPIO 121
+ * #define SPI_N_CHIPSEL 4
++ * #undef NEED_SPIDELAY
+ * #include "spi_gpio.c"
+ */
+
+@@ -76,6 +78,7 @@ struct spi_gpio {
+ #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)
+@@ -120,12 +123,20 @@ static inline int getmiso(const struct s
+ #undef pdata
+
+ /*
+- * NOTE: this clocks "as fast as we can". It "should" be 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.
++ * 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 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 */
++}
+
+ #define EXPAND_BITBANG_TXRX
+ #include <linux/spi/spi_bitbang.h>