aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/spi
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2014-01-16 07:22:43 -0500
committerMark Brown <broonie@linaro.org>2014-02-03 08:05:21 -0500
commit99adef310f682d6343cb40c1f6c9c25a4b3a450d (patch)
tree40310c296f820941de639b761927ee6375a623ce /include/linux/spi
parent38dbfb59d1175ef458d006556061adeaa8751b72 (diff)
spi: Provide core support for DMA mapping transfers
The process of DMA mapping buffers for SPI transfers does not vary between devices so in order to save duplication of code in drivers this can be factored out into the core, allowing it to be integrated with the work that is being done on factoring out the common elements from the data path including more sharing of dmaengine code. In order to use this masters need to provide a can_dma() operation and while the hardware is prepared they should ensure that DMA channels are provided in tx_dma and rx_dma. The core will then ensure that the buffers are mapped for DMA prior to calling transfer_one_message(). Currently the cleanup on error is not complete, this needs to be improved. Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'include/linux/spi')
-rw-r--r--include/linux/spi/spi.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index a1d4ca290862..b354dcbed55b 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -25,6 +25,8 @@
25#include <linux/kthread.h> 25#include <linux/kthread.h>
26#include <linux/completion.h> 26#include <linux/completion.h>
27 27
28struct dma_chan;
29
28/* 30/*
29 * INTERFACES between SPI master-side drivers and SPI infrastructure. 31 * INTERFACES between SPI master-side drivers and SPI infrastructure.
30 * (There's no SPI slave support for Linux yet...) 32 * (There's no SPI slave support for Linux yet...)
@@ -387,6 +389,17 @@ struct spi_master {
387 void (*cleanup)(struct spi_device *spi); 389 void (*cleanup)(struct spi_device *spi);
388 390
389 /* 391 /*
392 * Used to enable core support for DMA handling, if can_dma()
393 * exists and returns true then the transfer will be mapped
394 * prior to transfer_one() being called. The driver should
395 * not modify or store xfer and dma_tx and dma_rx must be set
396 * while the device is prepared.
397 */
398 bool (*can_dma)(struct spi_master *master,
399 struct spi_device *spi,
400 struct spi_transfer *xfer);
401
402 /*
390 * These hooks are for drivers that want to use the generic 403 * These hooks are for drivers that want to use the generic
391 * master transfer queueing mechanism. If these are used, the 404 * master transfer queueing mechanism. If these are used, the
392 * transfer() function above must NOT be specified by the driver. 405 * transfer() function above must NOT be specified by the driver.
@@ -404,6 +417,7 @@ struct spi_master {
404 bool rt; 417 bool rt;
405 bool auto_runtime_pm; 418 bool auto_runtime_pm;
406 bool cur_msg_prepared; 419 bool cur_msg_prepared;
420 bool cur_msg_mapped;
407 struct completion xfer_completion; 421 struct completion xfer_completion;
408 422
409 int (*prepare_transfer_hardware)(struct spi_master *master); 423 int (*prepare_transfer_hardware)(struct spi_master *master);
@@ -425,6 +439,10 @@ struct spi_master {
425 439
426 /* gpio chip select */ 440 /* gpio chip select */
427 int *cs_gpios; 441 int *cs_gpios;
442
443 /* DMA channels for use with core dmaengine helpers */
444 struct dma_chan *dma_tx;
445 struct dma_chan *dma_rx;
428}; 446};
429 447
430static inline void *spi_master_get_devdata(struct spi_master *master) 448static inline void *spi_master_get_devdata(struct spi_master *master)