]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - include/linux/spi/spi.h
spi: Provide core support for DMA mapping transfers
[karo-tx-linux.git] / include / linux / spi / spi.h
index a1d4ca290862d766d5460f198503ae4530df3f45..b354dcbed55b0cf4100fabfac0e82f0fc584fdcd 100644 (file)
@@ -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...)
@@ -386,6 +388,17 @@ struct spi_master {
        /* called on release() to free memory provided by 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
@@ -404,6 +417,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);
@@ -425,6 +439,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)