diff mbox

[RFC,v2,1/3] spi-gpio: implement spidelay() for platforms that configure SLOWER_SPI_GPIO

Message ID 0e2c28d0e0d60b9655e7d80e79cc811206b725b9.1291925752.git.bengardiner@nanometrics.ca (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Ben Gardiner Dec. 9, 2010, 8:34 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 78f9fd0..0570dcd 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -143,6 +143,23 @@  config SPI_GPIO
 	  GPIO operations, you should be able to leverage that for better
 	  speed with a custom version of this driver; see the source code.
 
+config SLOWER_SPI_GPIO
+	bool "Enable delays in the GPIO-based bitbanging SPI Master"
+	default n
+	depends on SPI_GPIO
+	help
+	  The GPIO bitbanging SPI master driver will run without any delays if this
+	  option is not set. This option will enable the use of delays in the
+	  operation of the GPIO bitbanging SPI master implementation to honour the
+	  maximum speed of very slow devices.
+
+	  To configure slow speed devices your board-specific setup logic must also
+	  provide platform data assigning the speed for a device on a given chip
+	  select of the GPIO bitbanging SPI master.
+
+	  If your platform requires SPI buses driven at slow speeds select yes. If
+	  in doubt, select no.
+
 config SPI_IMX_VER_IMX1
 	def_bool y if SOC_IMX1
 
diff --git a/drivers/spi/spi_gpio.c b/drivers/spi/spi_gpio.c
index 63e51b0..b31fddd 100644
--- a/drivers/spi/spi_gpio.c
+++ b/drivers/spi/spi_gpio.c
@@ -19,6 +19,7 @@ 
  */
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
 
@@ -119,6 +120,9 @@  static inline int getmiso(const struct spi_device *spi)
 
 #undef pdata
 
+#if defined(CONFIG_SLOWER_SPI_GPIO)
+#define spidelay(nsecs) ndelay(nsecs)
+#else
 /*
  * 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
@@ -126,6 +130,7 @@  static inline int getmiso(const struct spi_device *spi)
  * we'll just assume we never need additional per-bit slowdowns.
  */
 #define spidelay(nsecs)	do {} while (0)
+#endif
 
 #include "spi_bitbang_txrx.h"