aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/dmaengine.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/dmaengine.h')
-rw-r--r--include/linux/dmaengine.h69
1 files changed, 62 insertions, 7 deletions
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index d08a5c5eb928..adb0b084eb5a 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -89,10 +89,23 @@ enum dma_transaction_type {
89 DMA_MEMSET, 89 DMA_MEMSET,
90 DMA_MEMCPY_CRC32C, 90 DMA_MEMCPY_CRC32C,
91 DMA_INTERRUPT, 91 DMA_INTERRUPT,
92 DMA_SLAVE,
92}; 93};
93 94
94/* last transaction type for creation of the capabilities mask */ 95/* last transaction type for creation of the capabilities mask */
95#define DMA_TX_TYPE_END (DMA_INTERRUPT + 1) 96#define DMA_TX_TYPE_END (DMA_SLAVE + 1)
97
98/**
99 * enum dma_slave_width - DMA slave register access width.
100 * @DMA_SLAVE_WIDTH_8BIT: Do 8-bit slave register accesses
101 * @DMA_SLAVE_WIDTH_16BIT: Do 16-bit slave register accesses
102 * @DMA_SLAVE_WIDTH_32BIT: Do 32-bit slave register accesses
103 */
104enum dma_slave_width {
105 DMA_SLAVE_WIDTH_8BIT,
106 DMA_SLAVE_WIDTH_16BIT,
107 DMA_SLAVE_WIDTH_32BIT,
108};
96 109
97/** 110/**
98 * enum dma_ctrl_flags - DMA flags to augment operation preparation, 111 * enum dma_ctrl_flags - DMA flags to augment operation preparation,
@@ -102,10 +115,14 @@ enum dma_transaction_type {
102 * @DMA_CTRL_ACK - the descriptor cannot be reused until the client 115 * @DMA_CTRL_ACK - the descriptor cannot be reused until the client
103 * acknowledges receipt, i.e. has has a chance to establish any 116 * acknowledges receipt, i.e. has has a chance to establish any
104 * dependency chains 117 * dependency chains
118 * @DMA_COMPL_SKIP_SRC_UNMAP - set to disable dma-unmapping the source buffer(s)
119 * @DMA_COMPL_SKIP_DEST_UNMAP - set to disable dma-unmapping the destination(s)
105 */ 120 */
106enum dma_ctrl_flags { 121enum dma_ctrl_flags {
107 DMA_PREP_INTERRUPT = (1 << 0), 122 DMA_PREP_INTERRUPT = (1 << 0),
108 DMA_CTRL_ACK = (1 << 1), 123 DMA_CTRL_ACK = (1 << 1),
124 DMA_COMPL_SKIP_SRC_UNMAP = (1 << 2),
125 DMA_COMPL_SKIP_DEST_UNMAP = (1 << 3),
109}; 126};
110 127
111/** 128/**
@@ -115,6 +132,32 @@ enum dma_ctrl_flags {
115typedef struct { DECLARE_BITMAP(bits, DMA_TX_TYPE_END); } dma_cap_mask_t; 132typedef struct { DECLARE_BITMAP(bits, DMA_TX_TYPE_END); } dma_cap_mask_t;
116 133
117/** 134/**
135 * struct dma_slave - Information about a DMA slave
136 * @dev: device acting as DMA slave
137 * @dma_dev: required DMA master device. If non-NULL, the client can not be
138 * bound to other masters than this.
139 * @tx_reg: physical address of data register used for
140 * memory-to-peripheral transfers
141 * @rx_reg: physical address of data register used for
142 * peripheral-to-memory transfers
143 * @reg_width: peripheral register width
144 *
145 * If dma_dev is non-NULL, the client can not be bound to other DMA
146 * masters than the one corresponding to this device. The DMA master
147 * driver may use this to determine if there is controller-specific
148 * data wrapped around this struct. Drivers of platform code that sets
149 * the dma_dev field must therefore make sure to use an appropriate
150 * controller-specific dma slave structure wrapping this struct.
151 */
152struct dma_slave {
153 struct device *dev;
154 struct device *dma_dev;
155 dma_addr_t tx_reg;
156 dma_addr_t rx_reg;
157 enum dma_slave_width reg_width;
158};
159
160/**
118 * struct dma_chan_percpu - the per-CPU part of struct dma_chan 161 * struct dma_chan_percpu - the per-CPU part of struct dma_chan
119 * @refcount: local_t used for open-coded "bigref" counting 162 * @refcount: local_t used for open-coded "bigref" counting
120 * @memcpy_count: transaction counter 163 * @memcpy_count: transaction counter
@@ -139,6 +182,7 @@ struct dma_chan_percpu {
139 * @rcu: the DMA channel's RCU head 182 * @rcu: the DMA channel's RCU head
140 * @device_node: used to add this to the device chan list 183 * @device_node: used to add this to the device chan list
141 * @local: per-cpu pointer to a struct dma_chan_percpu 184 * @local: per-cpu pointer to a struct dma_chan_percpu
185 * @client-count: how many clients are using this channel
142 */ 186 */
143struct dma_chan { 187struct dma_chan {
144 struct dma_device *device; 188 struct dma_device *device;
@@ -154,6 +198,7 @@ struct dma_chan {
154 198
155 struct list_head device_node; 199 struct list_head device_node;
156 struct dma_chan_percpu *local; 200 struct dma_chan_percpu *local;
201 int client_count;
157}; 202};
158 203
159#define to_dma_chan(p) container_of(p, struct dma_chan, dev) 204#define to_dma_chan(p) container_of(p, struct dma_chan, dev)
@@ -202,11 +247,14 @@ typedef enum dma_state_client (*dma_event_callback) (struct dma_client *client,
202 * @event_callback: func ptr to call when something happens 247 * @event_callback: func ptr to call when something happens
203 * @cap_mask: only return channels that satisfy the requested capabilities 248 * @cap_mask: only return channels that satisfy the requested capabilities
204 * a value of zero corresponds to any capability 249 * a value of zero corresponds to any capability
250 * @slave: data for preparing slave transfer. Must be non-NULL iff the
251 * DMA_SLAVE capability is requested.
205 * @global_node: list_head for global dma_client_list 252 * @global_node: list_head for global dma_client_list
206 */ 253 */
207struct dma_client { 254struct dma_client {
208 dma_event_callback event_callback; 255 dma_event_callback event_callback;
209 dma_cap_mask_t cap_mask; 256 dma_cap_mask_t cap_mask;
257 struct dma_slave *slave;
210 struct list_head global_node; 258 struct list_head global_node;
211}; 259};
212 260
@@ -263,6 +311,8 @@ struct dma_async_tx_descriptor {
263 * @device_prep_dma_zero_sum: prepares a zero_sum operation 311 * @device_prep_dma_zero_sum: prepares a zero_sum operation
264 * @device_prep_dma_memset: prepares a memset operation 312 * @device_prep_dma_memset: prepares a memset operation
265 * @device_prep_dma_interrupt: prepares an end of chain interrupt operation 313 * @device_prep_dma_interrupt: prepares an end of chain interrupt operation
314 * @device_prep_slave_sg: prepares a slave dma operation
315 * @device_terminate_all: terminate all pending operations
266 * @device_issue_pending: push pending transactions to hardware 316 * @device_issue_pending: push pending transactions to hardware
267 */ 317 */
268struct dma_device { 318struct dma_device {
@@ -279,7 +329,8 @@ struct dma_device {
279 int dev_id; 329 int dev_id;
280 struct device *dev; 330 struct device *dev;
281 331
282 int (*device_alloc_chan_resources)(struct dma_chan *chan); 332 int (*device_alloc_chan_resources)(struct dma_chan *chan,
333 struct dma_client *client);
283 void (*device_free_chan_resources)(struct dma_chan *chan); 334 void (*device_free_chan_resources)(struct dma_chan *chan);
284 335
285 struct dma_async_tx_descriptor *(*device_prep_dma_memcpy)( 336 struct dma_async_tx_descriptor *(*device_prep_dma_memcpy)(
@@ -297,6 +348,12 @@ struct dma_device {
297 struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)( 348 struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)(
298 struct dma_chan *chan, unsigned long flags); 349 struct dma_chan *chan, unsigned long flags);
299 350
351 struct dma_async_tx_descriptor *(*device_prep_slave_sg)(
352 struct dma_chan *chan, struct scatterlist *sgl,
353 unsigned int sg_len, enum dma_data_direction direction,
354 unsigned long flags);
355 void (*device_terminate_all)(struct dma_chan *chan);
356
300 enum dma_status (*device_is_tx_complete)(struct dma_chan *chan, 357 enum dma_status (*device_is_tx_complete)(struct dma_chan *chan,
301 dma_cookie_t cookie, dma_cookie_t *last, 358 dma_cookie_t cookie, dma_cookie_t *last,
302 dma_cookie_t *used); 359 dma_cookie_t *used);
@@ -318,16 +375,14 @@ dma_cookie_t dma_async_memcpy_pg_to_pg(struct dma_chan *chan,
318void dma_async_tx_descriptor_init(struct dma_async_tx_descriptor *tx, 375void dma_async_tx_descriptor_init(struct dma_async_tx_descriptor *tx,
319 struct dma_chan *chan); 376 struct dma_chan *chan);
320 377
321static inline void 378static inline void async_tx_ack(struct dma_async_tx_descriptor *tx)
322async_tx_ack(struct dma_async_tx_descriptor *tx)
323{ 379{
324 tx->flags |= DMA_CTRL_ACK; 380 tx->flags |= DMA_CTRL_ACK;
325} 381}
326 382
327static inline int 383static inline bool async_tx_test_ack(struct dma_async_tx_descriptor *tx)
328async_tx_test_ack(struct dma_async_tx_descriptor *tx)
329{ 384{
330 return tx->flags & DMA_CTRL_ACK; 385 return (tx->flags & DMA_CTRL_ACK) == DMA_CTRL_ACK;
331} 386}
332 387
333#define first_dma_cap(mask) __first_dma_cap(&(mask)) 388#define first_dma_cap(mask) __first_dma_cap(&(mask))