diff options
Diffstat (limited to 'drivers/dma/mxs-dma.c')
-rw-r--r-- | drivers/dma/mxs-dma.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c index b06cd4ca626f..65334c49b71e 100644 --- a/drivers/dma/mxs-dma.c +++ b/drivers/dma/mxs-dma.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include <mach/dma.h> | 28 | #include <mach/dma.h> |
29 | #include <mach/common.h> | 29 | #include <mach/common.h> |
30 | 30 | ||
31 | #include "dmaengine.h" | ||
32 | |||
31 | /* | 33 | /* |
32 | * NOTE: The term "PIO" throughout the mxs-dma implementation means | 34 | * NOTE: The term "PIO" throughout the mxs-dma implementation means |
33 | * PIO mode of mxs apbh-dma and apbx-dma. With this working mode, | 35 | * PIO mode of mxs apbh-dma and apbx-dma. With this working mode, |
@@ -111,7 +113,6 @@ struct mxs_dma_chan { | |||
111 | struct mxs_dma_ccw *ccw; | 113 | struct mxs_dma_ccw *ccw; |
112 | dma_addr_t ccw_phys; | 114 | dma_addr_t ccw_phys; |
113 | int desc_count; | 115 | int desc_count; |
114 | dma_cookie_t last_completed; | ||
115 | enum dma_status status; | 116 | enum dma_status status; |
116 | unsigned int flags; | 117 | unsigned int flags; |
117 | #define MXS_DMA_SG_LOOP (1 << 0) | 118 | #define MXS_DMA_SG_LOOP (1 << 0) |
@@ -193,19 +194,6 @@ static void mxs_dma_resume_chan(struct mxs_dma_chan *mxs_chan) | |||
193 | mxs_chan->status = DMA_IN_PROGRESS; | 194 | mxs_chan->status = DMA_IN_PROGRESS; |
194 | } | 195 | } |
195 | 196 | ||
196 | static dma_cookie_t mxs_dma_assign_cookie(struct mxs_dma_chan *mxs_chan) | ||
197 | { | ||
198 | dma_cookie_t cookie = mxs_chan->chan.cookie; | ||
199 | |||
200 | if (++cookie < 0) | ||
201 | cookie = 1; | ||
202 | |||
203 | mxs_chan->chan.cookie = cookie; | ||
204 | mxs_chan->desc.cookie = cookie; | ||
205 | |||
206 | return cookie; | ||
207 | } | ||
208 | |||
209 | static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan) | 197 | static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan) |
210 | { | 198 | { |
211 | return container_of(chan, struct mxs_dma_chan, chan); | 199 | return container_of(chan, struct mxs_dma_chan, chan); |
@@ -217,7 +205,7 @@ static dma_cookie_t mxs_dma_tx_submit(struct dma_async_tx_descriptor *tx) | |||
217 | 205 | ||
218 | mxs_dma_enable_chan(mxs_chan); | 206 | mxs_dma_enable_chan(mxs_chan); |
219 | 207 | ||
220 | return mxs_dma_assign_cookie(mxs_chan); | 208 | return dma_cookie_assign(tx); |
221 | } | 209 | } |
222 | 210 | ||
223 | static void mxs_dma_tasklet(unsigned long data) | 211 | static void mxs_dma_tasklet(unsigned long data) |
@@ -274,7 +262,7 @@ static irqreturn_t mxs_dma_int_handler(int irq, void *dev_id) | |||
274 | stat1 &= ~(1 << channel); | 262 | stat1 &= ~(1 << channel); |
275 | 263 | ||
276 | if (mxs_chan->status == DMA_SUCCESS) | 264 | if (mxs_chan->status == DMA_SUCCESS) |
277 | mxs_chan->last_completed = mxs_chan->desc.cookie; | 265 | dma_cookie_complete(&mxs_chan->desc); |
278 | 266 | ||
279 | /* schedule tasklet on this channel */ | 267 | /* schedule tasklet on this channel */ |
280 | tasklet_schedule(&mxs_chan->tasklet); | 268 | tasklet_schedule(&mxs_chan->tasklet); |
@@ -352,7 +340,7 @@ static void mxs_dma_free_chan_resources(struct dma_chan *chan) | |||
352 | static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg( | 340 | static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg( |
353 | struct dma_chan *chan, struct scatterlist *sgl, | 341 | struct dma_chan *chan, struct scatterlist *sgl, |
354 | unsigned int sg_len, enum dma_transfer_direction direction, | 342 | unsigned int sg_len, enum dma_transfer_direction direction, |
355 | unsigned long append) | 343 | unsigned long append, void *context) |
356 | { | 344 | { |
357 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); | 345 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); |
358 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; | 346 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
@@ -447,7 +435,8 @@ err_out: | |||
447 | 435 | ||
448 | static struct dma_async_tx_descriptor *mxs_dma_prep_dma_cyclic( | 436 | static struct dma_async_tx_descriptor *mxs_dma_prep_dma_cyclic( |
449 | struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len, | 437 | struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len, |
450 | size_t period_len, enum dma_transfer_direction direction) | 438 | size_t period_len, enum dma_transfer_direction direction, |
439 | void *context) | ||
451 | { | 440 | { |
452 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); | 441 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); |
453 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; | 442 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
@@ -538,7 +527,7 @@ static enum dma_status mxs_dma_tx_status(struct dma_chan *chan, | |||
538 | dma_cookie_t last_used; | 527 | dma_cookie_t last_used; |
539 | 528 | ||
540 | last_used = chan->cookie; | 529 | last_used = chan->cookie; |
541 | dma_set_tx_state(txstate, mxs_chan->last_completed, last_used, 0); | 530 | dma_set_tx_state(txstate, chan->completed_cookie, last_used, 0); |
542 | 531 | ||
543 | return mxs_chan->status; | 532 | return mxs_chan->status; |
544 | } | 533 | } |
@@ -630,6 +619,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev) | |||
630 | 619 | ||
631 | mxs_chan->mxs_dma = mxs_dma; | 620 | mxs_chan->mxs_dma = mxs_dma; |
632 | mxs_chan->chan.device = &mxs_dma->dma_device; | 621 | mxs_chan->chan.device = &mxs_dma->dma_device; |
622 | dma_cookie_init(&mxs_chan->chan); | ||
633 | 623 | ||
634 | tasklet_init(&mxs_chan->tasklet, mxs_dma_tasklet, | 624 | tasklet_init(&mxs_chan->tasklet, mxs_dma_tasklet, |
635 | (unsigned long) mxs_chan); | 625 | (unsigned long) mxs_chan); |