aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorImre Deak <imre.deak@nokia.com>2006-02-17 13:02:18 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-05-16 17:33:56 -0400
commit4cff33f94fefcce1b3c01a9d1da6bb85fe3cbdfa (patch)
tree0ef6066c4f2c0225517a6402bb04f4b4d56afd4d /include
parent716f8954fb3029ca2df52a986b60af8d06f093ee (diff)
[PATCH] SPI: per-transfer overrides for wordsize and clocking
Some protocols (like one for some bitmap displays) require different clock speed or word size settings for each transfer in an SPI message. This adds those parameters to struct spi_transfer. They are to be used when they are nonzero; otherwise the defaults from spi_device are to be used. The patch also adds a setup_transfer callback to spi_bitbang, uses it for messages that use those overrides, and implements it so that the pure bitbanging code can help resolve any questions about how it should work. Signed-off-by: Imre Deak <imre.deak@nokia.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include')
-rw-r--r--include/linux/spi/spi.h8
-rw-r--r--include/linux/spi/spi_bitbang.h6
2 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index b05f1463a267..caa4665e3fa2 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -31,6 +31,7 @@ extern struct bus_type spi_bus_type;
31 * @master: SPI controller used with the device. 31 * @master: SPI controller used with the device.
32 * @max_speed_hz: Maximum clock rate to be used with this chip 32 * @max_speed_hz: Maximum clock rate to be used with this chip
33 * (on this board); may be changed by the device's driver. 33 * (on this board); may be changed by the device's driver.
34 * The spi_transfer.speed_hz can override this for each transfer.
34 * @chip-select: Chipselect, distinguishing chips handled by "master". 35 * @chip-select: Chipselect, distinguishing chips handled by "master".
35 * @mode: The spi mode defines how data is clocked out and in. 36 * @mode: The spi mode defines how data is clocked out and in.
36 * This may be changed by the device's driver. 37 * This may be changed by the device's driver.
@@ -38,6 +39,7 @@ extern struct bus_type spi_bus_type;
38 * like eight or 12 bits are common. In-memory wordsizes are 39 * like eight or 12 bits are common. In-memory wordsizes are
39 * powers of two bytes (e.g. 20 bit samples use 32 bits). 40 * powers of two bytes (e.g. 20 bit samples use 32 bits).
40 * This may be changed by the device's driver. 41 * This may be changed by the device's driver.
42 * The spi_transfer.bits_per_word can override this for each transfer.
41 * @irq: Negative, or the number passed to request_irq() to receive 43 * @irq: Negative, or the number passed to request_irq() to receive
42 * interrupts from this device. 44 * interrupts from this device.
43 * @controller_state: Controller's runtime state 45 * @controller_state: Controller's runtime state
@@ -268,6 +270,10 @@ extern struct spi_master *spi_busnum_to_master(u16 busnum);
268 * @tx_dma: DMA address of tx_buf, if spi_message.is_dma_mapped 270 * @tx_dma: DMA address of tx_buf, if spi_message.is_dma_mapped
269 * @rx_dma: DMA address of rx_buf, if spi_message.is_dma_mapped 271 * @rx_dma: DMA address of rx_buf, if spi_message.is_dma_mapped
270 * @len: size of rx and tx buffers (in bytes) 272 * @len: size of rx and tx buffers (in bytes)
273 * @speed_hz: Select a speed other then the device default for this
274 * transfer. If 0 the default (from spi_device) is used.
275 * @bits_per_word: select a bits_per_word other then the device default
276 * for this transfer. If 0 the default (from spi_device) is used.
271 * @cs_change: affects chipselect after this transfer completes 277 * @cs_change: affects chipselect after this transfer completes
272 * @delay_usecs: microseconds to delay after this transfer before 278 * @delay_usecs: microseconds to delay after this transfer before
273 * (optionally) changing the chipselect status, then starting 279 * (optionally) changing the chipselect status, then starting
@@ -322,7 +328,9 @@ struct spi_transfer {
322 dma_addr_t rx_dma; 328 dma_addr_t rx_dma;
323 329
324 unsigned cs_change:1; 330 unsigned cs_change:1;
331 u8 bits_per_word;
325 u16 delay_usecs; 332 u16 delay_usecs;
333 u32 speed_hz;
326 334
327 struct list_head transfer_list; 335 struct list_head transfer_list;
328}; 336};
diff --git a/include/linux/spi/spi_bitbang.h b/include/linux/spi/spi_bitbang.h
index c961fe9bf3eb..c954557b757c 100644
--- a/include/linux/spi/spi_bitbang.h
+++ b/include/linux/spi/spi_bitbang.h
@@ -30,6 +30,12 @@ struct spi_bitbang {
30 30
31 struct spi_master *master; 31 struct spi_master *master;
32 32
33 /* setup_transfer() changes clock and/or wordsize to match settings
34 * for this transfer; zeroes restore defaults from spi_device.
35 */
36 int (*setup_transfer)(struct spi_device *spi,
37 struct spi_transfer *t);
38
33 void (*chipselect)(struct spi_device *spi, int is_on); 39 void (*chipselect)(struct spi_device *spi, int is_on);
34#define BITBANG_CS_ACTIVE 1 /* normally nCS, active low */ 40#define BITBANG_CS_ACTIVE 1 /* normally nCS, active low */
35#define BITBANG_CS_INACTIVE 0 41#define BITBANG_CS_INACTIVE 0