summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2014-01-16 12:22:43 +0000
committerRobin Gong <b38343@freescale.com>2014-10-20 08:29:55 +0800
commit0f07ad70af97c144222c3d7b7cc73fa7d2f8f549 (patch)
treef2a7623cd367d55c0b0c041f863bfde99a56ccce /include
parent21113987c8a44c4ece385c368cd7e9058311da10 (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> (cherry picked from commit 99adef310f682d6343cb40c1f6c9c25a4b3a450d)
Diffstat (limited to 'include')
-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 1619ed48e75d..ec0c6328bfd4 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -25,6 +25,8 @@
#include <linux/kthread.h>
#include <linux/completion.h>
+struct dma_chan;
+
/*
* INTERFACES between SPI master-side drivers and SPI infrastructure.
* (There's no SPI slave support for Linux yet...)
@@ -385,6 +387,17 @@ struct spi_master {
void (*cleanup)(struct spi_device *spi);
/*
+ * Used to enable core support for DMA handling, if can_dma()
+ * exists and returns true then the transfer will be mapped
+ * prior to transfer_one() being called. The driver should
+ * not modify or store xfer and dma_tx and dma_rx must be set
+ * while the device is prepared.
+ */
+ bool (*can_dma)(struct spi_master *master,
+ struct spi_device *spi,
+ struct spi_transfer *xfer);
+
+ /*
* These hooks are for drivers that want to use the generic
* master transfer queueing mechanism. If these are used, the
* transfer() function above must NOT be specified by the driver.
@@ -402,6 +415,7 @@ struct spi_master {
bool rt;
bool auto_runtime_pm;
bool cur_msg_prepared;
+ bool cur_msg_mapped;
struct completion xfer_completion;
int (*prepare_transfer_hardware)(struct spi_master *master);
@@ -423,6 +437,10 @@ struct spi_master {
/* gpio chip select */
int *cs_gpios;
+
+ /* DMA channels for use with core dmaengine helpers */
+ struct dma_chan *dma_tx;
+ struct dma_chan *dma_rx;
};
static inline void *spi_master_get_devdata(struct spi_master *master)