aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/dmaengine.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-29 18:34:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-29 18:34:57 -0400
commitef08e78268423fc4d7fbc3e54bd9a67fc8da7cc5 (patch)
treed0561d3ef89c9cd277a38168e33850666cbd33c4 /drivers/dma/dmaengine.h
parent71db34fc4330f7c784397acb9f1e6ee7f7b32eb2 (diff)
parent5b2e02e401deb44e7f5befe19404d8b2688efea4 (diff)
Merge branch 'next' of git://git.infradead.org/users/vkoul/slave-dma
Pull slave-dmaengine update from Vinod Koul: "This includes the cookie cleanup by Russell, the addition of context parameter for dmaengine APIs, more arm dmaengine driver cleanup by moving code to dmaengine, this time for imx by Javier and pl330 by Boojin along with the usual driver fixes." Fix up some fairly trivial conflicts with various other cleanups. * 'next' of git://git.infradead.org/users/vkoul/slave-dma: (67 commits) dmaengine: imx: fix the build failure on x86_64 dmaengine: i.MX: Fix merge of cookie branch. dmaengine: i.MX: Add support for interleaved transfers. dmaengine: imx-dma: use 'dev_dbg' and 'dev_warn' for messages. dmaengine: imx-dma: remove 'imx_dmav1_baseaddr' and 'dma_clk'. dmaengine: imx-dma: remove unused arg of imxdma_sg_next. dmaengine: imx-dma: remove internal structure. dmaengine: imx-dma: remove 'resbytes' field of 'internal' structure. dmaengine: imx-dma: remove 'in_use' field of 'internal' structure. dmaengine: imx-dma: remove sg member from internal structure. dmaengine: imx-dma: remove 'imxdma_setup_sg_hw' function. dmaengine: imx-dma: remove 'imxdma_config_channel_hw' function. dmaengine: imx-dma: remove 'imxdma_setup_mem2mem_hw' function. dmaengine: imx-dma: remove dma_mode member of internal structure. dmaengine: imx-dma: remove data member from internal structure. dmaengine: imx-dma: merge old dma-v1.c with imx-dma.c dmaengine: at_hdmac: add slave config operation dmaengine: add context parameter to prep_slave_sg and prep_dma_cyclic dmaengine/dma_slave: introduce inline wrappers dma: imx-sdma: Treat firmware messages as warnings instead of erros ...
Diffstat (limited to 'drivers/dma/dmaengine.h')
-rw-r--r--drivers/dma/dmaengine.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h
new file mode 100644
index 000000000000..17f983a4e9ba
--- /dev/null
+++ b/drivers/dma/dmaengine.h
@@ -0,0 +1,89 @@
1/*
2 * The contents of this file are private to DMA engine drivers, and is not
3 * part of the API to be used by DMA engine users.
4 */
5#ifndef DMAENGINE_H
6#define DMAENGINE_H
7
8#include <linux/bug.h>
9#include <linux/dmaengine.h>
10
11/**
12 * dma_cookie_init - initialize the cookies for a DMA channel
13 * @chan: dma channel to initialize
14 */
15static inline void dma_cookie_init(struct dma_chan *chan)
16{
17 chan->cookie = DMA_MIN_COOKIE;
18 chan->completed_cookie = DMA_MIN_COOKIE;
19}
20
21/**
22 * dma_cookie_assign - assign a DMA engine cookie to the descriptor
23 * @tx: descriptor needing cookie
24 *
25 * Assign a unique non-zero per-channel cookie to the descriptor.
26 * Note: caller is expected to hold a lock to prevent concurrency.
27 */
28static inline dma_cookie_t dma_cookie_assign(struct dma_async_tx_descriptor *tx)
29{
30 struct dma_chan *chan = tx->chan;
31 dma_cookie_t cookie;
32
33 cookie = chan->cookie + 1;
34 if (cookie < DMA_MIN_COOKIE)
35 cookie = DMA_MIN_COOKIE;
36 tx->cookie = chan->cookie = cookie;
37
38 return cookie;
39}
40
41/**
42 * dma_cookie_complete - complete a descriptor
43 * @tx: descriptor to complete
44 *
45 * Mark this descriptor complete by updating the channels completed
46 * cookie marker. Zero the descriptors cookie to prevent accidental
47 * repeated completions.
48 *
49 * Note: caller is expected to hold a lock to prevent concurrency.
50 */
51static inline void dma_cookie_complete(struct dma_async_tx_descriptor *tx)
52{
53 BUG_ON(tx->cookie < DMA_MIN_COOKIE);
54 tx->chan->completed_cookie = tx->cookie;
55 tx->cookie = 0;
56}
57
58/**
59 * dma_cookie_status - report cookie status
60 * @chan: dma channel
61 * @cookie: cookie we are interested in
62 * @state: dma_tx_state structure to return last/used cookies
63 *
64 * Report the status of the cookie, filling in the state structure if
65 * non-NULL. No locking is required.
66 */
67static inline enum dma_status dma_cookie_status(struct dma_chan *chan,
68 dma_cookie_t cookie, struct dma_tx_state *state)
69{
70 dma_cookie_t used, complete;
71
72 used = chan->cookie;
73 complete = chan->completed_cookie;
74 barrier();
75 if (state) {
76 state->last = complete;
77 state->used = used;
78 state->residue = 0;
79 }
80 return dma_async_is_complete(cookie, complete, used);
81}
82
83static inline void dma_set_residue(struct dma_tx_state *state, u32 residue)
84{
85 if (state)
86 state->residue = residue;
87}
88
89#endif