dmaengine: Add an enum for the dmaengine alignment constraints
[deliverable/linux.git] / include / linux / dmaengine.h
index ad419757241ffc7c5d5346f4b82462f5a83f1897..03ed832adbc28ddb8b312b98d6225c40cfdb71b1 100644 (file)
@@ -65,6 +65,7 @@ enum dma_transaction_type {
        DMA_PQ,
        DMA_XOR_VAL,
        DMA_PQ_VAL,
+       DMA_MEMSET,
        DMA_INTERRUPT,
        DMA_SG,
        DMA_PRIVATE,
@@ -122,10 +123,18 @@ enum dma_transfer_direction {
  *      chunk and before first src/dst address for next chunk.
  *      Ignored for dst(assumed 0), if dst_inc is true and dst_sgl is false.
  *      Ignored for src(assumed 0), if src_inc is true and src_sgl is false.
+ * @dst_icg: Number of bytes to jump after last dst address of this
+ *      chunk and before the first dst address for next chunk.
+ *      Ignored if dst_inc is true and dst_sgl is false.
+ * @src_icg: Number of bytes to jump after last src address of this
+ *      chunk and before the first src address for next chunk.
+ *      Ignored if src_inc is true and src_sgl is false.
  */
 struct data_chunk {
        size_t size;
        size_t icg;
+       size_t dst_icg;
+       size_t src_icg;
 };
 
 /**
@@ -221,6 +230,16 @@ struct dma_chan_percpu {
        unsigned long bytes_transferred;
 };
 
+/**
+ * struct dma_router - DMA router structure
+ * @dev: pointer to the DMA router device
+ * @route_free: function to be called when the route can be disconnected
+ */
+struct dma_router {
+       struct device *dev;
+       void (*route_free)(struct device *dev, void *route_data);
+};
+
 /**
  * struct dma_chan - devices supply DMA channels, clients use them
  * @device: ptr to the dma device who supplies this channel, always !%NULL
@@ -232,6 +251,8 @@ struct dma_chan_percpu {
  * @local: per-cpu pointer to a struct dma_chan_percpu
  * @client_count: how many clients are using this channel
  * @table_count: number of appearances in the mem-to-mem allocation table
+ * @router: pointer to the DMA router structure
+ * @route_data: channel specific data for the router
  * @private: private data for certain client-channel associations
  */
 struct dma_chan {
@@ -247,6 +268,11 @@ struct dma_chan {
        struct dma_chan_percpu __percpu *local;
        int client_count;
        int table_count;
+
+       /* DMA router */
+       struct dma_router *router;
+       void *route_data;
+
        void *private;
 };
 
@@ -558,6 +584,20 @@ struct dma_tx_state {
        u32 residue;
 };
 
+/**
+ * enum dmaengine_alignment - defines alignment of the DMA async tx
+ * buffers
+ */
+enum dmaengine_alignment {
+       DMAENGINE_ALIGN_1_BYTE = 0,
+       DMAENGINE_ALIGN_2_BYTES = 1,
+       DMAENGINE_ALIGN_4_BYTES = 2,
+       DMAENGINE_ALIGN_8_BYTES = 3,
+       DMAENGINE_ALIGN_16_BYTES = 4,
+       DMAENGINE_ALIGN_32_BYTES = 5,
+       DMAENGINE_ALIGN_64_BYTES = 6,
+};
+
 /**
  * struct dma_device - info on the entity supplying DMA services
  * @chancnt: how many DMA channels are supported
@@ -570,6 +610,7 @@ struct dma_tx_state {
  * @copy_align: alignment shift for memcpy operations
  * @xor_align: alignment shift for xor operations
  * @pq_align: alignment shift for pq operations
+ * @fill_align: alignment shift for memset operations
  * @dev_id: unique device ID
  * @dev: struct device reference for dma mapping api
  * @src_addr_widths: bit mask of src addr widths the device supports
@@ -588,6 +629,7 @@ struct dma_tx_state {
  * @device_prep_dma_xor_val: prepares a xor validation operation
  * @device_prep_dma_pq: prepares a pq operation
  * @device_prep_dma_pq_val: prepares a pqzero_sum operation
+ * @device_prep_dma_memset: prepares a memset operation
  * @device_prep_dma_interrupt: prepares an end of chain interrupt operation
  * @device_prep_slave_sg: prepares a slave dma operation
  * @device_prep_dma_cyclic: prepare a cyclic dma operation suitable for audio.
@@ -617,9 +659,10 @@ struct dma_device {
        dma_cap_mask_t  cap_mask;
        unsigned short max_xor;
        unsigned short max_pq;
-       u8 copy_align;
-       u8 xor_align;
-       u8 pq_align;
+       enum dmaengine_alignment copy_align;
+       enum dmaengine_alignment xor_align;
+       enum dmaengine_alignment pq_align;
+       enum dmaengine_alignment fill_align;
        #define DMA_HAS_PQ_CONTINUE (1 << 15)
 
        int dev_id;
@@ -650,6 +693,9 @@ struct dma_device {
                struct dma_chan *chan, dma_addr_t *pq, dma_addr_t *src,
                unsigned int src_cnt, const unsigned char *scf, size_t len,
                enum sum_check_flags *pqres, unsigned long flags);
+       struct dma_async_tx_descriptor *(*device_prep_dma_memset)(
+               struct dma_chan *chan, dma_addr_t dest, int value, size_t len,
+               unsigned long flags);
        struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)(
                struct dma_chan *chan, unsigned long flags);
        struct dma_async_tx_descriptor *(*device_prep_dma_sg)(
@@ -745,6 +791,17 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_interleaved_dma(
        return chan->device->device_prep_interleaved_dma(chan, xt, flags);
 }
 
+static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_memset(
+               struct dma_chan *chan, dma_addr_t dest, int value, size_t len,
+               unsigned long flags)
+{
+       if (!chan || !chan->device)
+               return NULL;
+
+       return chan->device->device_prep_dma_memset(chan, dest, value,
+                                                   len, flags);
+}
+
 static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_sg(
                struct dma_chan *chan,
                struct scatterlist *dst_sg, unsigned int dst_nents,
@@ -790,7 +847,8 @@ static inline dma_cookie_t dmaengine_submit(struct dma_async_tx_descriptor *desc
        return desc->tx_submit(desc);
 }
 
-static inline bool dmaengine_check_align(u8 align, size_t off1, size_t off2, size_t len)
+static inline bool dmaengine_check_align(enum dmaengine_alignment align,
+                                        size_t off1, size_t off2, size_t len)
 {
        size_t mask;
 
@@ -820,6 +878,12 @@ static inline bool is_dma_pq_aligned(struct dma_device *dev, size_t off1,
        return dmaengine_check_align(dev->pq_align, off1, off2, len);
 }
 
+static inline bool is_dma_fill_aligned(struct dma_device *dev, size_t off1,
+                                      size_t off2, size_t len)
+{
+       return dmaengine_check_align(dev->fill_align, off1, off2, len);
+}
+
 static inline void
 dma_set_maxpq(struct dma_device *dma, int maxpq, int has_pq_continue)
 {
@@ -874,6 +938,33 @@ static inline int dma_maxpq(struct dma_device *dma, enum dma_ctrl_flags flags)
        BUG();
 }
 
+static inline size_t dmaengine_get_icg(bool inc, bool sgl, size_t icg,
+                                     size_t dir_icg)
+{
+       if (inc) {
+               if (dir_icg)
+                       return dir_icg;
+               else if (sgl)
+                       return icg;
+       }
+
+       return 0;
+}
+
+static inline size_t dmaengine_get_dst_icg(struct dma_interleaved_template *xt,
+                                          struct data_chunk *chunk)
+{
+       return dmaengine_get_icg(xt->dst_inc, xt->dst_sgl,
+                                chunk->icg, chunk->dst_icg);
+}
+
+static inline size_t dmaengine_get_src_icg(struct dma_interleaved_template *xt,
+                                          struct data_chunk *chunk)
+{
+       return dmaengine_get_icg(xt->src_inc, xt->src_sgl,
+                                chunk->icg, chunk->src_icg);
+}
+
 /* --- public DMA engine API --- */
 
 #ifdef CONFIG_DMA_ENGINE
This page took 0.039402 seconds and 5 git commands to generate.