2 * Driver for the Synopsys DesignWare DMA Controller (aka DMACA on
5 * Copyright (C) 2007-2008 Atmel Corporation
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 #include <linux/clk.h>
12 #include <linux/delay.h>
13 #include <linux/dmaengine.h>
14 #include <linux/dma-mapping.h>
15 #include <linux/init.h>
16 #include <linux/interrupt.h>
19 #include <linux/module.h>
20 #include <linux/platform_device.h>
21 #include <linux/slab.h>
23 #include "dw_dmac_regs.h"
26 * This supports the Synopsys "DesignWare AHB Central DMA Controller",
27 * (DW_ahb_dmac) which is used with various AMBA 2.0 systems (not all
28 * of which use ARM any more). See the "Databook" from Synopsys for
29 * information beyond what licensees probably provide.
31 * The driver has currently been tested only with the Atmel AT32AP7000,
32 * which does not support descriptor writeback.
35 /* NOTE: DMS+SMS is system-specific. We should get this information
36 * from the platform code somehow.
38 #define DWC_DEFAULT_CTLLO (DWC_CTLL_DST_MSIZE(0) \
39 | DWC_CTLL_SRC_MSIZE(0) \
46 * This is configuration-dependent and usually a funny size like 4095.
47 * Let's round it down to the nearest power of two.
49 * Note that this is a transfer count, i.e. if we transfer 32-bit
50 * words, we can do 8192 bytes per descriptor.
52 * This parameter is also system-specific.
54 #define DWC_MAX_COUNT 2048U
57 * Number of descriptors to allocate for each channel. This should be
58 * made configurable somehow; preferably, the clients (at least the
59 * ones using slave transfers) should be able to give us a hint.
61 #define NR_DESCS_PER_CHANNEL 64
63 /*----------------------------------------------------------------------*/
66 * Because we're not relying on writeback from the controller (it may not
67 * even be configured into the core!) we don't need to use dma_pool. These
68 * descriptors -- and associated data -- are cacheable. We do need to make
69 * sure their dcache entries are written back before handing them off to
70 * the controller, though.
73 static struct device
*chan2dev(struct dma_chan
*chan
)
75 return &chan
->dev
->device
;
77 static struct device
*chan2parent(struct dma_chan
*chan
)
79 return chan
->dev
->device
.parent
;
82 static struct dw_desc
*dwc_first_active(struct dw_dma_chan
*dwc
)
84 return list_entry(dwc
->active_list
.next
, struct dw_desc
, desc_node
);
87 static struct dw_desc
*dwc_first_queued(struct dw_dma_chan
*dwc
)
89 return list_entry(dwc
->queue
.next
, struct dw_desc
, desc_node
);
92 static struct dw_desc
*dwc_desc_get(struct dw_dma_chan
*dwc
)
94 struct dw_desc
*desc
, *_desc
;
95 struct dw_desc
*ret
= NULL
;
98 spin_lock_bh(&dwc
->lock
);
99 list_for_each_entry_safe(desc
, _desc
, &dwc
->free_list
, desc_node
) {
100 if (async_tx_test_ack(&desc
->txd
)) {
101 list_del(&desc
->desc_node
);
105 dev_dbg(chan2dev(&dwc
->chan
), "desc %p not ACKed\n", desc
);
108 spin_unlock_bh(&dwc
->lock
);
110 dev_vdbg(chan2dev(&dwc
->chan
), "scanned %u descriptors on freelist\n", i
);
115 static void dwc_sync_desc_for_cpu(struct dw_dma_chan
*dwc
, struct dw_desc
*desc
)
117 struct dw_desc
*child
;
119 list_for_each_entry(child
, &desc
->tx_list
, desc_node
)
120 dma_sync_single_for_cpu(chan2parent(&dwc
->chan
),
121 child
->txd
.phys
, sizeof(child
->lli
),
123 dma_sync_single_for_cpu(chan2parent(&dwc
->chan
),
124 desc
->txd
.phys
, sizeof(desc
->lli
),
129 * Move a descriptor, including any children, to the free list.
130 * `desc' must not be on any lists.
132 static void dwc_desc_put(struct dw_dma_chan
*dwc
, struct dw_desc
*desc
)
135 struct dw_desc
*child
;
137 dwc_sync_desc_for_cpu(dwc
, desc
);
139 spin_lock_bh(&dwc
->lock
);
140 list_for_each_entry(child
, &desc
->tx_list
, desc_node
)
141 dev_vdbg(chan2dev(&dwc
->chan
),
142 "moving child desc %p to freelist\n",
144 list_splice_init(&desc
->tx_list
, &dwc
->free_list
);
145 dev_vdbg(chan2dev(&dwc
->chan
), "moving desc %p to freelist\n", desc
);
146 list_add(&desc
->desc_node
, &dwc
->free_list
);
147 spin_unlock_bh(&dwc
->lock
);
151 /* Called with dwc->lock held and bh disabled */
153 dwc_assign_cookie(struct dw_dma_chan
*dwc
, struct dw_desc
*desc
)
155 dma_cookie_t cookie
= dwc
->chan
.cookie
;
160 dwc
->chan
.cookie
= cookie
;
161 desc
->txd
.cookie
= cookie
;
166 /*----------------------------------------------------------------------*/
168 /* Called with dwc->lock held and bh disabled */
169 static void dwc_dostart(struct dw_dma_chan
*dwc
, struct dw_desc
*first
)
171 struct dw_dma
*dw
= to_dw_dma(dwc
->chan
.device
);
173 /* ASSERT: channel is idle */
174 if (dma_readl(dw
, CH_EN
) & dwc
->mask
) {
175 dev_err(chan2dev(&dwc
->chan
),
176 "BUG: Attempted to start non-idle channel\n");
177 dev_err(chan2dev(&dwc
->chan
),
178 " SAR: 0x%x DAR: 0x%x LLP: 0x%x CTL: 0x%x:%08x\n",
179 channel_readl(dwc
, SAR
),
180 channel_readl(dwc
, DAR
),
181 channel_readl(dwc
, LLP
),
182 channel_readl(dwc
, CTL_HI
),
183 channel_readl(dwc
, CTL_LO
));
185 /* The tasklet will hopefully advance the queue... */
189 channel_writel(dwc
, LLP
, first
->txd
.phys
);
190 channel_writel(dwc
, CTL_LO
,
191 DWC_CTLL_LLP_D_EN
| DWC_CTLL_LLP_S_EN
);
192 channel_writel(dwc
, CTL_HI
, 0);
193 channel_set_bit(dw
, CH_EN
, dwc
->mask
);
196 /*----------------------------------------------------------------------*/
199 dwc_descriptor_complete(struct dw_dma_chan
*dwc
, struct dw_desc
*desc
)
201 dma_async_tx_callback callback
;
203 struct dma_async_tx_descriptor
*txd
= &desc
->txd
;
205 dev_vdbg(chan2dev(&dwc
->chan
), "descriptor %u complete\n", txd
->cookie
);
207 dwc
->completed
= txd
->cookie
;
208 callback
= txd
->callback
;
209 param
= txd
->callback_param
;
211 dwc_sync_desc_for_cpu(dwc
, desc
);
212 list_splice_init(&desc
->tx_list
, &dwc
->free_list
);
213 list_move(&desc
->desc_node
, &dwc
->free_list
);
215 if (!dwc
->chan
.private) {
216 struct device
*parent
= chan2parent(&dwc
->chan
);
217 if (!(txd
->flags
& DMA_COMPL_SKIP_DEST_UNMAP
)) {
218 if (txd
->flags
& DMA_COMPL_DEST_UNMAP_SINGLE
)
219 dma_unmap_single(parent
, desc
->lli
.dar
,
220 desc
->len
, DMA_FROM_DEVICE
);
222 dma_unmap_page(parent
, desc
->lli
.dar
,
223 desc
->len
, DMA_FROM_DEVICE
);
225 if (!(txd
->flags
& DMA_COMPL_SKIP_SRC_UNMAP
)) {
226 if (txd
->flags
& DMA_COMPL_SRC_UNMAP_SINGLE
)
227 dma_unmap_single(parent
, desc
->lli
.sar
,
228 desc
->len
, DMA_TO_DEVICE
);
230 dma_unmap_page(parent
, desc
->lli
.sar
,
231 desc
->len
, DMA_TO_DEVICE
);
236 * The API requires that no submissions are done from a
237 * callback, so we don't need to drop the lock here
243 static void dwc_complete_all(struct dw_dma
*dw
, struct dw_dma_chan
*dwc
)
245 struct dw_desc
*desc
, *_desc
;
248 if (dma_readl(dw
, CH_EN
) & dwc
->mask
) {
249 dev_err(chan2dev(&dwc
->chan
),
250 "BUG: XFER bit set, but channel not idle!\n");
252 /* Try to continue after resetting the channel... */
253 channel_clear_bit(dw
, CH_EN
, dwc
->mask
);
254 while (dma_readl(dw
, CH_EN
) & dwc
->mask
)
259 * Submit queued descriptors ASAP, i.e. before we go through
260 * the completed ones.
262 if (!list_empty(&dwc
->queue
))
263 dwc_dostart(dwc
, dwc_first_queued(dwc
));
264 list_splice_init(&dwc
->active_list
, &list
);
265 list_splice_init(&dwc
->queue
, &dwc
->active_list
);
267 list_for_each_entry_safe(desc
, _desc
, &list
, desc_node
)
268 dwc_descriptor_complete(dwc
, desc
);
271 static void dwc_scan_descriptors(struct dw_dma
*dw
, struct dw_dma_chan
*dwc
)
274 struct dw_desc
*desc
, *_desc
;
275 struct dw_desc
*child
;
279 * Clear block interrupt flag before scanning so that we don't
280 * miss any, and read LLP before RAW_XFER to ensure it is
281 * valid if we decide to scan the list.
283 dma_writel(dw
, CLEAR
.BLOCK
, dwc
->mask
);
284 llp
= channel_readl(dwc
, LLP
);
285 status_xfer
= dma_readl(dw
, RAW
.XFER
);
287 if (status_xfer
& dwc
->mask
) {
288 /* Everything we've submitted is done */
289 dma_writel(dw
, CLEAR
.XFER
, dwc
->mask
);
290 dwc_complete_all(dw
, dwc
);
294 dev_vdbg(chan2dev(&dwc
->chan
), "scan_descriptors: llp=0x%x\n", llp
);
296 list_for_each_entry_safe(desc
, _desc
, &dwc
->active_list
, desc_node
) {
297 if (desc
->lli
.llp
== llp
)
298 /* This one is currently in progress */
301 list_for_each_entry(child
, &desc
->tx_list
, desc_node
)
302 if (child
->lli
.llp
== llp
)
303 /* Currently in progress */
307 * No descriptors so far seem to be in progress, i.e.
308 * this one must be done.
310 dwc_descriptor_complete(dwc
, desc
);
313 dev_err(chan2dev(&dwc
->chan
),
314 "BUG: All descriptors done, but channel not idle!\n");
316 /* Try to continue after resetting the channel... */
317 channel_clear_bit(dw
, CH_EN
, dwc
->mask
);
318 while (dma_readl(dw
, CH_EN
) & dwc
->mask
)
321 if (!list_empty(&dwc
->queue
)) {
322 dwc_dostart(dwc
, dwc_first_queued(dwc
));
323 list_splice_init(&dwc
->queue
, &dwc
->active_list
);
327 static void dwc_dump_lli(struct dw_dma_chan
*dwc
, struct dw_lli
*lli
)
329 dev_printk(KERN_CRIT
, chan2dev(&dwc
->chan
),
330 " desc: s0x%x d0x%x l0x%x c0x%x:%x\n",
331 lli
->sar
, lli
->dar
, lli
->llp
,
332 lli
->ctlhi
, lli
->ctllo
);
335 static void dwc_handle_error(struct dw_dma
*dw
, struct dw_dma_chan
*dwc
)
337 struct dw_desc
*bad_desc
;
338 struct dw_desc
*child
;
340 dwc_scan_descriptors(dw
, dwc
);
343 * The descriptor currently at the head of the active list is
344 * borked. Since we don't have any way to report errors, we'll
345 * just have to scream loudly and try to carry on.
347 bad_desc
= dwc_first_active(dwc
);
348 list_del_init(&bad_desc
->desc_node
);
349 list_splice_init(&dwc
->queue
, dwc
->active_list
.prev
);
351 /* Clear the error flag and try to restart the controller */
352 dma_writel(dw
, CLEAR
.ERROR
, dwc
->mask
);
353 if (!list_empty(&dwc
->active_list
))
354 dwc_dostart(dwc
, dwc_first_active(dwc
));
357 * KERN_CRITICAL may seem harsh, but since this only happens
358 * when someone submits a bad physical address in a
359 * descriptor, we should consider ourselves lucky that the
360 * controller flagged an error instead of scribbling over
361 * random memory locations.
363 dev_printk(KERN_CRIT
, chan2dev(&dwc
->chan
),
364 "Bad descriptor submitted for DMA!\n");
365 dev_printk(KERN_CRIT
, chan2dev(&dwc
->chan
),
366 " cookie: %d\n", bad_desc
->txd
.cookie
);
367 dwc_dump_lli(dwc
, &bad_desc
->lli
);
368 list_for_each_entry(child
, &bad_desc
->tx_list
, desc_node
)
369 dwc_dump_lli(dwc
, &child
->lli
);
371 /* Pretend the descriptor completed successfully */
372 dwc_descriptor_complete(dwc
, bad_desc
);
375 /* --------------------- Cyclic DMA API extensions -------------------- */
377 inline dma_addr_t
dw_dma_get_src_addr(struct dma_chan
*chan
)
379 struct dw_dma_chan
*dwc
= to_dw_dma_chan(chan
);
380 return channel_readl(dwc
, SAR
);
382 EXPORT_SYMBOL(dw_dma_get_src_addr
);
384 inline dma_addr_t
dw_dma_get_dst_addr(struct dma_chan
*chan
)
386 struct dw_dma_chan
*dwc
= to_dw_dma_chan(chan
);
387 return channel_readl(dwc
, DAR
);
389 EXPORT_SYMBOL(dw_dma_get_dst_addr
);
391 /* called with dwc->lock held and all DMAC interrupts disabled */
392 static void dwc_handle_cyclic(struct dw_dma
*dw
, struct dw_dma_chan
*dwc
,
393 u32 status_block
, u32 status_err
, u32 status_xfer
)
395 if (status_block
& dwc
->mask
) {
396 void (*callback
)(void *param
);
397 void *callback_param
;
399 dev_vdbg(chan2dev(&dwc
->chan
), "new cyclic period llp 0x%08x\n",
400 channel_readl(dwc
, LLP
));
401 dma_writel(dw
, CLEAR
.BLOCK
, dwc
->mask
);
403 callback
= dwc
->cdesc
->period_callback
;
404 callback_param
= dwc
->cdesc
->period_callback_param
;
406 spin_unlock(&dwc
->lock
);
407 callback(callback_param
);
408 spin_lock(&dwc
->lock
);
413 * Error and transfer complete are highly unlikely, and will most
414 * likely be due to a configuration error by the user.
416 if (unlikely(status_err
& dwc
->mask
) ||
417 unlikely(status_xfer
& dwc
->mask
)) {
420 dev_err(chan2dev(&dwc
->chan
), "cyclic DMA unexpected %s "
421 "interrupt, stopping DMA transfer\n",
422 status_xfer
? "xfer" : "error");
423 dev_err(chan2dev(&dwc
->chan
),
424 " SAR: 0x%x DAR: 0x%x LLP: 0x%x CTL: 0x%x:%08x\n",
425 channel_readl(dwc
, SAR
),
426 channel_readl(dwc
, DAR
),
427 channel_readl(dwc
, LLP
),
428 channel_readl(dwc
, CTL_HI
),
429 channel_readl(dwc
, CTL_LO
));
431 channel_clear_bit(dw
, CH_EN
, dwc
->mask
);
432 while (dma_readl(dw
, CH_EN
) & dwc
->mask
)
435 /* make sure DMA does not restart by loading a new list */
436 channel_writel(dwc
, LLP
, 0);
437 channel_writel(dwc
, CTL_LO
, 0);
438 channel_writel(dwc
, CTL_HI
, 0);
440 dma_writel(dw
, CLEAR
.BLOCK
, dwc
->mask
);
441 dma_writel(dw
, CLEAR
.ERROR
, dwc
->mask
);
442 dma_writel(dw
, CLEAR
.XFER
, dwc
->mask
);
444 for (i
= 0; i
< dwc
->cdesc
->periods
; i
++)
445 dwc_dump_lli(dwc
, &dwc
->cdesc
->desc
[i
]->lli
);
449 /* ------------------------------------------------------------------------- */
451 static void dw_dma_tasklet(unsigned long data
)
453 struct dw_dma
*dw
= (struct dw_dma
*)data
;
454 struct dw_dma_chan
*dwc
;
460 status_block
= dma_readl(dw
, RAW
.BLOCK
);
461 status_xfer
= dma_readl(dw
, RAW
.XFER
);
462 status_err
= dma_readl(dw
, RAW
.ERROR
);
464 dev_vdbg(dw
->dma
.dev
, "tasklet: status_block=%x status_err=%x\n",
465 status_block
, status_err
);
467 for (i
= 0; i
< dw
->dma
.chancnt
; i
++) {
469 spin_lock(&dwc
->lock
);
470 if (test_bit(DW_DMA_IS_CYCLIC
, &dwc
->flags
))
471 dwc_handle_cyclic(dw
, dwc
, status_block
, status_err
,
473 else if (status_err
& (1 << i
))
474 dwc_handle_error(dw
, dwc
);
475 else if ((status_block
| status_xfer
) & (1 << i
))
476 dwc_scan_descriptors(dw
, dwc
);
477 spin_unlock(&dwc
->lock
);
481 * Re-enable interrupts. Block Complete interrupts are only
482 * enabled if the INT_EN bit in the descriptor is set. This
483 * will trigger a scan before the whole list is done.
485 channel_set_bit(dw
, MASK
.XFER
, dw
->all_chan_mask
);
486 channel_set_bit(dw
, MASK
.BLOCK
, dw
->all_chan_mask
);
487 channel_set_bit(dw
, MASK
.ERROR
, dw
->all_chan_mask
);
490 static irqreturn_t
dw_dma_interrupt(int irq
, void *dev_id
)
492 struct dw_dma
*dw
= dev_id
;
495 dev_vdbg(dw
->dma
.dev
, "interrupt: status=0x%x\n",
496 dma_readl(dw
, STATUS_INT
));
499 * Just disable the interrupts. We'll turn them back on in the
502 channel_clear_bit(dw
, MASK
.XFER
, dw
->all_chan_mask
);
503 channel_clear_bit(dw
, MASK
.BLOCK
, dw
->all_chan_mask
);
504 channel_clear_bit(dw
, MASK
.ERROR
, dw
->all_chan_mask
);
506 status
= dma_readl(dw
, STATUS_INT
);
509 "BUG: Unexpected interrupts pending: 0x%x\n",
513 channel_clear_bit(dw
, MASK
.XFER
, (1 << 8) - 1);
514 channel_clear_bit(dw
, MASK
.BLOCK
, (1 << 8) - 1);
515 channel_clear_bit(dw
, MASK
.SRC_TRAN
, (1 << 8) - 1);
516 channel_clear_bit(dw
, MASK
.DST_TRAN
, (1 << 8) - 1);
517 channel_clear_bit(dw
, MASK
.ERROR
, (1 << 8) - 1);
520 tasklet_schedule(&dw
->tasklet
);
525 /*----------------------------------------------------------------------*/
527 static dma_cookie_t
dwc_tx_submit(struct dma_async_tx_descriptor
*tx
)
529 struct dw_desc
*desc
= txd_to_dw_desc(tx
);
530 struct dw_dma_chan
*dwc
= to_dw_dma_chan(tx
->chan
);
533 spin_lock_bh(&dwc
->lock
);
534 cookie
= dwc_assign_cookie(dwc
, desc
);
537 * REVISIT: We should attempt to chain as many descriptors as
538 * possible, perhaps even appending to those already submitted
539 * for DMA. But this is hard to do in a race-free manner.
541 if (list_empty(&dwc
->active_list
)) {
542 dev_vdbg(chan2dev(tx
->chan
), "tx_submit: started %u\n",
544 dwc_dostart(dwc
, desc
);
545 list_add_tail(&desc
->desc_node
, &dwc
->active_list
);
547 dev_vdbg(chan2dev(tx
->chan
), "tx_submit: queued %u\n",
550 list_add_tail(&desc
->desc_node
, &dwc
->queue
);
553 spin_unlock_bh(&dwc
->lock
);
558 static struct dma_async_tx_descriptor
*
559 dwc_prep_dma_memcpy(struct dma_chan
*chan
, dma_addr_t dest
, dma_addr_t src
,
560 size_t len
, unsigned long flags
)
562 struct dw_dma_chan
*dwc
= to_dw_dma_chan(chan
);
563 struct dw_desc
*desc
;
564 struct dw_desc
*first
;
565 struct dw_desc
*prev
;
568 unsigned int src_width
;
569 unsigned int dst_width
;
572 dev_vdbg(chan2dev(chan
), "prep_dma_memcpy d0x%x s0x%x l0x%zx f0x%lx\n",
573 dest
, src
, len
, flags
);
575 if (unlikely(!len
)) {
576 dev_dbg(chan2dev(chan
), "prep_dma_memcpy: length is zero!\n");
581 * We can be a lot more clever here, but this should take care
582 * of the most common optimization.
584 if (!((src
| dest
| len
) & 3))
585 src_width
= dst_width
= 2;
586 else if (!((src
| dest
| len
) & 1))
587 src_width
= dst_width
= 1;
589 src_width
= dst_width
= 0;
591 ctllo
= DWC_DEFAULT_CTLLO
592 | DWC_CTLL_DST_WIDTH(dst_width
)
593 | DWC_CTLL_SRC_WIDTH(src_width
)
599 for (offset
= 0; offset
< len
; offset
+= xfer_count
<< src_width
) {
600 xfer_count
= min_t(size_t, (len
- offset
) >> src_width
,
603 desc
= dwc_desc_get(dwc
);
607 desc
->lli
.sar
= src
+ offset
;
608 desc
->lli
.dar
= dest
+ offset
;
609 desc
->lli
.ctllo
= ctllo
;
610 desc
->lli
.ctlhi
= xfer_count
;
615 prev
->lli
.llp
= desc
->txd
.phys
;
616 dma_sync_single_for_device(chan2parent(chan
),
617 prev
->txd
.phys
, sizeof(prev
->lli
),
619 list_add_tail(&desc
->desc_node
,
626 if (flags
& DMA_PREP_INTERRUPT
)
627 /* Trigger interrupt after last block */
628 prev
->lli
.ctllo
|= DWC_CTLL_INT_EN
;
631 dma_sync_single_for_device(chan2parent(chan
),
632 prev
->txd
.phys
, sizeof(prev
->lli
),
635 first
->txd
.flags
= flags
;
641 dwc_desc_put(dwc
, first
);
645 static struct dma_async_tx_descriptor
*
646 dwc_prep_slave_sg(struct dma_chan
*chan
, struct scatterlist
*sgl
,
647 unsigned int sg_len
, enum dma_data_direction direction
,
650 struct dw_dma_chan
*dwc
= to_dw_dma_chan(chan
);
651 struct dw_dma_slave
*dws
= chan
->private;
652 struct dw_desc
*prev
;
653 struct dw_desc
*first
;
656 unsigned int reg_width
;
657 unsigned int mem_width
;
659 struct scatterlist
*sg
;
660 size_t total_len
= 0;
662 dev_vdbg(chan2dev(chan
), "prep_dma_slave\n");
664 if (unlikely(!dws
|| !sg_len
))
667 reg_width
= dws
->reg_width
;
672 ctllo
= (DWC_DEFAULT_CTLLO
673 | DWC_CTLL_DST_WIDTH(reg_width
)
678 for_each_sg(sgl
, sg
, sg_len
, i
) {
679 struct dw_desc
*desc
;
683 desc
= dwc_desc_get(dwc
);
685 dev_err(chan2dev(chan
),
686 "not enough descriptors available\n");
691 len
= sg_dma_len(sg
);
693 if (unlikely(mem
& 3 || len
& 3))
698 desc
->lli
.ctllo
= ctllo
| DWC_CTLL_SRC_WIDTH(mem_width
);
699 desc
->lli
.ctlhi
= len
>> mem_width
;
704 prev
->lli
.llp
= desc
->txd
.phys
;
705 dma_sync_single_for_device(chan2parent(chan
),
709 list_add_tail(&desc
->desc_node
,
716 case DMA_FROM_DEVICE
:
717 ctllo
= (DWC_DEFAULT_CTLLO
718 | DWC_CTLL_SRC_WIDTH(reg_width
)
724 for_each_sg(sgl
, sg
, sg_len
, i
) {
725 struct dw_desc
*desc
;
729 desc
= dwc_desc_get(dwc
);
731 dev_err(chan2dev(chan
),
732 "not enough descriptors available\n");
737 len
= sg_dma_len(sg
);
739 if (unlikely(mem
& 3 || len
& 3))
744 desc
->lli
.ctllo
= ctllo
| DWC_CTLL_DST_WIDTH(mem_width
);
745 desc
->lli
.ctlhi
= len
>> reg_width
;
750 prev
->lli
.llp
= desc
->txd
.phys
;
751 dma_sync_single_for_device(chan2parent(chan
),
755 list_add_tail(&desc
->desc_node
,
766 if (flags
& DMA_PREP_INTERRUPT
)
767 /* Trigger interrupt after last block */
768 prev
->lli
.ctllo
|= DWC_CTLL_INT_EN
;
771 dma_sync_single_for_device(chan2parent(chan
),
772 prev
->txd
.phys
, sizeof(prev
->lli
),
775 first
->len
= total_len
;
780 dwc_desc_put(dwc
, first
);
784 static int dwc_control(struct dma_chan
*chan
, enum dma_ctrl_cmd cmd
,
787 struct dw_dma_chan
*dwc
= to_dw_dma_chan(chan
);
788 struct dw_dma
*dw
= to_dw_dma(chan
->device
);
789 struct dw_desc
*desc
, *_desc
;
792 /* Only supports DMA_TERMINATE_ALL */
793 if (cmd
!= DMA_TERMINATE_ALL
)
797 * This is only called when something went wrong elsewhere, so
798 * we don't really care about the data. Just disable the
799 * channel. We still have to poll the channel enable bit due
800 * to AHB/HSB limitations.
802 spin_lock_bh(&dwc
->lock
);
804 channel_clear_bit(dw
, CH_EN
, dwc
->mask
);
806 while (dma_readl(dw
, CH_EN
) & dwc
->mask
)
809 /* active_list entries will end up before queued entries */
810 list_splice_init(&dwc
->queue
, &list
);
811 list_splice_init(&dwc
->active_list
, &list
);
813 spin_unlock_bh(&dwc
->lock
);
815 /* Flush all pending and queued descriptors */
816 list_for_each_entry_safe(desc
, _desc
, &list
, desc_node
)
817 dwc_descriptor_complete(dwc
, desc
);
822 static enum dma_status
823 dwc_tx_status(struct dma_chan
*chan
,
825 struct dma_tx_state
*txstate
)
827 struct dw_dma_chan
*dwc
= to_dw_dma_chan(chan
);
828 dma_cookie_t last_used
;
829 dma_cookie_t last_complete
;
832 last_complete
= dwc
->completed
;
833 last_used
= chan
->cookie
;
835 ret
= dma_async_is_complete(cookie
, last_complete
, last_used
);
836 if (ret
!= DMA_SUCCESS
) {
837 dwc_scan_descriptors(to_dw_dma(chan
->device
), dwc
);
839 last_complete
= dwc
->completed
;
840 last_used
= chan
->cookie
;
842 ret
= dma_async_is_complete(cookie
, last_complete
, last_used
);
845 dma_set_tx_state(txstate
, last_complete
, last_used
, 0);
850 static void dwc_issue_pending(struct dma_chan
*chan
)
852 struct dw_dma_chan
*dwc
= to_dw_dma_chan(chan
);
854 spin_lock_bh(&dwc
->lock
);
855 if (!list_empty(&dwc
->queue
))
856 dwc_scan_descriptors(to_dw_dma(chan
->device
), dwc
);
857 spin_unlock_bh(&dwc
->lock
);
860 static int dwc_alloc_chan_resources(struct dma_chan
*chan
)
862 struct dw_dma_chan
*dwc
= to_dw_dma_chan(chan
);
863 struct dw_dma
*dw
= to_dw_dma(chan
->device
);
864 struct dw_desc
*desc
;
865 struct dw_dma_slave
*dws
;
870 dev_vdbg(chan2dev(chan
), "alloc_chan_resources\n");
872 /* ASSERT: channel is idle */
873 if (dma_readl(dw
, CH_EN
) & dwc
->mask
) {
874 dev_dbg(chan2dev(chan
), "DMA channel not idle?\n");
878 dwc
->completed
= chan
->cookie
= 1;
880 cfghi
= DWC_CFGH_FIFO_MODE
;
886 * We need controller-specific data to set up slave
889 BUG_ON(!dws
->dma_dev
|| dws
->dma_dev
!= dw
->dma
.dev
);
894 channel_writel(dwc
, CFG_LO
, cfglo
);
895 channel_writel(dwc
, CFG_HI
, cfghi
);
898 * NOTE: some controllers may have additional features that we
899 * need to initialize here, like "scatter-gather" (which
900 * doesn't mean what you think it means), and status writeback.
903 spin_lock_bh(&dwc
->lock
);
904 i
= dwc
->descs_allocated
;
905 while (dwc
->descs_allocated
< NR_DESCS_PER_CHANNEL
) {
906 spin_unlock_bh(&dwc
->lock
);
908 desc
= kzalloc(sizeof(struct dw_desc
), GFP_KERNEL
);
910 dev_info(chan2dev(chan
),
911 "only allocated %d descriptors\n", i
);
912 spin_lock_bh(&dwc
->lock
);
916 INIT_LIST_HEAD(&desc
->tx_list
);
917 dma_async_tx_descriptor_init(&desc
->txd
, chan
);
918 desc
->txd
.tx_submit
= dwc_tx_submit
;
919 desc
->txd
.flags
= DMA_CTRL_ACK
;
920 desc
->txd
.phys
= dma_map_single(chan2parent(chan
), &desc
->lli
,
921 sizeof(desc
->lli
), DMA_TO_DEVICE
);
922 dwc_desc_put(dwc
, desc
);
924 spin_lock_bh(&dwc
->lock
);
925 i
= ++dwc
->descs_allocated
;
928 /* Enable interrupts */
929 channel_set_bit(dw
, MASK
.XFER
, dwc
->mask
);
930 channel_set_bit(dw
, MASK
.BLOCK
, dwc
->mask
);
931 channel_set_bit(dw
, MASK
.ERROR
, dwc
->mask
);
933 spin_unlock_bh(&dwc
->lock
);
935 dev_dbg(chan2dev(chan
),
936 "alloc_chan_resources allocated %d descriptors\n", i
);
941 static void dwc_free_chan_resources(struct dma_chan
*chan
)
943 struct dw_dma_chan
*dwc
= to_dw_dma_chan(chan
);
944 struct dw_dma
*dw
= to_dw_dma(chan
->device
);
945 struct dw_desc
*desc
, *_desc
;
948 dev_dbg(chan2dev(chan
), "free_chan_resources (descs allocated=%u)\n",
949 dwc
->descs_allocated
);
951 /* ASSERT: channel is idle */
952 BUG_ON(!list_empty(&dwc
->active_list
));
953 BUG_ON(!list_empty(&dwc
->queue
));
954 BUG_ON(dma_readl(to_dw_dma(chan
->device
), CH_EN
) & dwc
->mask
);
956 spin_lock_bh(&dwc
->lock
);
957 list_splice_init(&dwc
->free_list
, &list
);
958 dwc
->descs_allocated
= 0;
960 /* Disable interrupts */
961 channel_clear_bit(dw
, MASK
.XFER
, dwc
->mask
);
962 channel_clear_bit(dw
, MASK
.BLOCK
, dwc
->mask
);
963 channel_clear_bit(dw
, MASK
.ERROR
, dwc
->mask
);
965 spin_unlock_bh(&dwc
->lock
);
967 list_for_each_entry_safe(desc
, _desc
, &list
, desc_node
) {
968 dev_vdbg(chan2dev(chan
), " freeing descriptor %p\n", desc
);
969 dma_unmap_single(chan2parent(chan
), desc
->txd
.phys
,
970 sizeof(desc
->lli
), DMA_TO_DEVICE
);
974 dev_vdbg(chan2dev(chan
), "free_chan_resources done\n");
977 /* --------------------- Cyclic DMA API extensions -------------------- */
980 * dw_dma_cyclic_start - start the cyclic DMA transfer
981 * @chan: the DMA channel to start
983 * Must be called with soft interrupts disabled. Returns zero on success or
986 int dw_dma_cyclic_start(struct dma_chan
*chan
)
988 struct dw_dma_chan
*dwc
= to_dw_dma_chan(chan
);
989 struct dw_dma
*dw
= to_dw_dma(dwc
->chan
.device
);
991 if (!test_bit(DW_DMA_IS_CYCLIC
, &dwc
->flags
)) {
992 dev_err(chan2dev(&dwc
->chan
), "missing prep for cyclic DMA\n");
996 spin_lock(&dwc
->lock
);
998 /* assert channel is idle */
999 if (dma_readl(dw
, CH_EN
) & dwc
->mask
) {
1000 dev_err(chan2dev(&dwc
->chan
),
1001 "BUG: Attempted to start non-idle channel\n");
1002 dev_err(chan2dev(&dwc
->chan
),
1003 " SAR: 0x%x DAR: 0x%x LLP: 0x%x CTL: 0x%x:%08x\n",
1004 channel_readl(dwc
, SAR
),
1005 channel_readl(dwc
, DAR
),
1006 channel_readl(dwc
, LLP
),
1007 channel_readl(dwc
, CTL_HI
),
1008 channel_readl(dwc
, CTL_LO
));
1009 spin_unlock(&dwc
->lock
);
1013 dma_writel(dw
, CLEAR
.BLOCK
, dwc
->mask
);
1014 dma_writel(dw
, CLEAR
.ERROR
, dwc
->mask
);
1015 dma_writel(dw
, CLEAR
.XFER
, dwc
->mask
);
1017 /* setup DMAC channel registers */
1018 channel_writel(dwc
, LLP
, dwc
->cdesc
->desc
[0]->txd
.phys
);
1019 channel_writel(dwc
, CTL_LO
, DWC_CTLL_LLP_D_EN
| DWC_CTLL_LLP_S_EN
);
1020 channel_writel(dwc
, CTL_HI
, 0);
1022 channel_set_bit(dw
, CH_EN
, dwc
->mask
);
1024 spin_unlock(&dwc
->lock
);
1028 EXPORT_SYMBOL(dw_dma_cyclic_start
);
1031 * dw_dma_cyclic_stop - stop the cyclic DMA transfer
1032 * @chan: the DMA channel to stop
1034 * Must be called with soft interrupts disabled.
1036 void dw_dma_cyclic_stop(struct dma_chan
*chan
)
1038 struct dw_dma_chan
*dwc
= to_dw_dma_chan(chan
);
1039 struct dw_dma
*dw
= to_dw_dma(dwc
->chan
.device
);
1041 spin_lock(&dwc
->lock
);
1043 channel_clear_bit(dw
, CH_EN
, dwc
->mask
);
1044 while (dma_readl(dw
, CH_EN
) & dwc
->mask
)
1047 spin_unlock(&dwc
->lock
);
1049 EXPORT_SYMBOL(dw_dma_cyclic_stop
);
1052 * dw_dma_cyclic_prep - prepare the cyclic DMA transfer
1053 * @chan: the DMA channel to prepare
1054 * @buf_addr: physical DMA address where the buffer starts
1055 * @buf_len: total number of bytes for the entire buffer
1056 * @period_len: number of bytes for each period
1057 * @direction: transfer direction, to or from device
1059 * Must be called before trying to start the transfer. Returns a valid struct
1060 * dw_cyclic_desc if successful or an ERR_PTR(-errno) if not successful.
1062 struct dw_cyclic_desc
*dw_dma_cyclic_prep(struct dma_chan
*chan
,
1063 dma_addr_t buf_addr
, size_t buf_len
, size_t period_len
,
1064 enum dma_data_direction direction
)
1066 struct dw_dma_chan
*dwc
= to_dw_dma_chan(chan
);
1067 struct dw_cyclic_desc
*cdesc
;
1068 struct dw_cyclic_desc
*retval
= NULL
;
1069 struct dw_desc
*desc
;
1070 struct dw_desc
*last
= NULL
;
1071 struct dw_dma_slave
*dws
= chan
->private;
1072 unsigned long was_cyclic
;
1073 unsigned int reg_width
;
1074 unsigned int periods
;
1077 spin_lock_bh(&dwc
->lock
);
1078 if (!list_empty(&dwc
->queue
) || !list_empty(&dwc
->active_list
)) {
1079 spin_unlock_bh(&dwc
->lock
);
1080 dev_dbg(chan2dev(&dwc
->chan
),
1081 "queue and/or active list are not empty\n");
1082 return ERR_PTR(-EBUSY
);
1085 was_cyclic
= test_and_set_bit(DW_DMA_IS_CYCLIC
, &dwc
->flags
);
1086 spin_unlock_bh(&dwc
->lock
);
1088 dev_dbg(chan2dev(&dwc
->chan
),
1089 "channel already prepared for cyclic DMA\n");
1090 return ERR_PTR(-EBUSY
);
1093 retval
= ERR_PTR(-EINVAL
);
1094 reg_width
= dws
->reg_width
;
1095 periods
= buf_len
/ period_len
;
1097 /* Check for too big/unaligned periods and unaligned DMA buffer. */
1098 if (period_len
> (DWC_MAX_COUNT
<< reg_width
))
1100 if (unlikely(period_len
& ((1 << reg_width
) - 1)))
1102 if (unlikely(buf_addr
& ((1 << reg_width
) - 1)))
1104 if (unlikely(!(direction
& (DMA_TO_DEVICE
| DMA_FROM_DEVICE
))))
1107 retval
= ERR_PTR(-ENOMEM
);
1109 if (periods
> NR_DESCS_PER_CHANNEL
)
1112 cdesc
= kzalloc(sizeof(struct dw_cyclic_desc
), GFP_KERNEL
);
1116 cdesc
->desc
= kzalloc(sizeof(struct dw_desc
*) * periods
, GFP_KERNEL
);
1120 for (i
= 0; i
< periods
; i
++) {
1121 desc
= dwc_desc_get(dwc
);
1123 goto out_err_desc_get
;
1125 switch (direction
) {
1127 desc
->lli
.dar
= dws
->tx_reg
;
1128 desc
->lli
.sar
= buf_addr
+ (period_len
* i
);
1129 desc
->lli
.ctllo
= (DWC_DEFAULT_CTLLO
1130 | DWC_CTLL_DST_WIDTH(reg_width
)
1131 | DWC_CTLL_SRC_WIDTH(reg_width
)
1137 case DMA_FROM_DEVICE
:
1138 desc
->lli
.dar
= buf_addr
+ (period_len
* i
);
1139 desc
->lli
.sar
= dws
->rx_reg
;
1140 desc
->lli
.ctllo
= (DWC_DEFAULT_CTLLO
1141 | DWC_CTLL_SRC_WIDTH(reg_width
)
1142 | DWC_CTLL_DST_WIDTH(reg_width
)
1152 desc
->lli
.ctlhi
= (period_len
>> reg_width
);
1153 cdesc
->desc
[i
] = desc
;
1156 last
->lli
.llp
= desc
->txd
.phys
;
1157 dma_sync_single_for_device(chan2parent(chan
),
1158 last
->txd
.phys
, sizeof(last
->lli
),
1165 /* lets make a cyclic list */
1166 last
->lli
.llp
= cdesc
->desc
[0]->txd
.phys
;
1167 dma_sync_single_for_device(chan2parent(chan
), last
->txd
.phys
,
1168 sizeof(last
->lli
), DMA_TO_DEVICE
);
1170 dev_dbg(chan2dev(&dwc
->chan
), "cyclic prepared buf 0x%08x len %zu "
1171 "period %zu periods %d\n", buf_addr
, buf_len
,
1172 period_len
, periods
);
1174 cdesc
->periods
= periods
;
1181 dwc_desc_put(dwc
, cdesc
->desc
[i
]);
1185 clear_bit(DW_DMA_IS_CYCLIC
, &dwc
->flags
);
1186 return (struct dw_cyclic_desc
*)retval
;
1188 EXPORT_SYMBOL(dw_dma_cyclic_prep
);
1191 * dw_dma_cyclic_free - free a prepared cyclic DMA transfer
1192 * @chan: the DMA channel to free
1194 void dw_dma_cyclic_free(struct dma_chan
*chan
)
1196 struct dw_dma_chan
*dwc
= to_dw_dma_chan(chan
);
1197 struct dw_dma
*dw
= to_dw_dma(dwc
->chan
.device
);
1198 struct dw_cyclic_desc
*cdesc
= dwc
->cdesc
;
1201 dev_dbg(chan2dev(&dwc
->chan
), "cyclic free\n");
1206 spin_lock_bh(&dwc
->lock
);
1208 channel_clear_bit(dw
, CH_EN
, dwc
->mask
);
1209 while (dma_readl(dw
, CH_EN
) & dwc
->mask
)
1212 dma_writel(dw
, CLEAR
.BLOCK
, dwc
->mask
);
1213 dma_writel(dw
, CLEAR
.ERROR
, dwc
->mask
);
1214 dma_writel(dw
, CLEAR
.XFER
, dwc
->mask
);
1216 spin_unlock_bh(&dwc
->lock
);
1218 for (i
= 0; i
< cdesc
->periods
; i
++)
1219 dwc_desc_put(dwc
, cdesc
->desc
[i
]);
1224 clear_bit(DW_DMA_IS_CYCLIC
, &dwc
->flags
);
1226 EXPORT_SYMBOL(dw_dma_cyclic_free
);
1228 /*----------------------------------------------------------------------*/
1230 static void dw_dma_off(struct dw_dma
*dw
)
1232 dma_writel(dw
, CFG
, 0);
1234 channel_clear_bit(dw
, MASK
.XFER
, dw
->all_chan_mask
);
1235 channel_clear_bit(dw
, MASK
.BLOCK
, dw
->all_chan_mask
);
1236 channel_clear_bit(dw
, MASK
.SRC_TRAN
, dw
->all_chan_mask
);
1237 channel_clear_bit(dw
, MASK
.DST_TRAN
, dw
->all_chan_mask
);
1238 channel_clear_bit(dw
, MASK
.ERROR
, dw
->all_chan_mask
);
1240 while (dma_readl(dw
, CFG
) & DW_CFG_DMA_EN
)
1244 static int __init
dw_probe(struct platform_device
*pdev
)
1246 struct dw_dma_platform_data
*pdata
;
1247 struct resource
*io
;
1254 pdata
= pdev
->dev
.platform_data
;
1255 if (!pdata
|| pdata
->nr_channels
> DW_DMA_MAX_NR_CHANNELS
)
1258 io
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
1262 irq
= platform_get_irq(pdev
, 0);
1266 size
= sizeof(struct dw_dma
);
1267 size
+= pdata
->nr_channels
* sizeof(struct dw_dma_chan
);
1268 dw
= kzalloc(size
, GFP_KERNEL
);
1272 if (!request_mem_region(io
->start
, DW_REGLEN
, pdev
->dev
.driver
->name
)) {
1277 dw
->regs
= ioremap(io
->start
, DW_REGLEN
);
1283 dw
->clk
= clk_get(&pdev
->dev
, "hclk");
1284 if (IS_ERR(dw
->clk
)) {
1285 err
= PTR_ERR(dw
->clk
);
1288 clk_enable(dw
->clk
);
1290 /* force dma off, just in case */
1293 err
= request_irq(irq
, dw_dma_interrupt
, 0, "dw_dmac", dw
);
1297 platform_set_drvdata(pdev
, dw
);
1299 tasklet_init(&dw
->tasklet
, dw_dma_tasklet
, (unsigned long)dw
);
1301 dw
->all_chan_mask
= (1 << pdata
->nr_channels
) - 1;
1303 INIT_LIST_HEAD(&dw
->dma
.channels
);
1304 for (i
= 0; i
< pdata
->nr_channels
; i
++, dw
->dma
.chancnt
++) {
1305 struct dw_dma_chan
*dwc
= &dw
->chan
[i
];
1307 dwc
->chan
.device
= &dw
->dma
;
1308 dwc
->chan
.cookie
= dwc
->completed
= 1;
1309 dwc
->chan
.chan_id
= i
;
1310 list_add_tail(&dwc
->chan
.device_node
, &dw
->dma
.channels
);
1312 dwc
->ch_regs
= &__dw_regs(dw
)->CHAN
[i
];
1313 spin_lock_init(&dwc
->lock
);
1316 INIT_LIST_HEAD(&dwc
->active_list
);
1317 INIT_LIST_HEAD(&dwc
->queue
);
1318 INIT_LIST_HEAD(&dwc
->free_list
);
1320 channel_clear_bit(dw
, CH_EN
, dwc
->mask
);
1323 /* Clear/disable all interrupts on all channels. */
1324 dma_writel(dw
, CLEAR
.XFER
, dw
->all_chan_mask
);
1325 dma_writel(dw
, CLEAR
.BLOCK
, dw
->all_chan_mask
);
1326 dma_writel(dw
, CLEAR
.SRC_TRAN
, dw
->all_chan_mask
);
1327 dma_writel(dw
, CLEAR
.DST_TRAN
, dw
->all_chan_mask
);
1328 dma_writel(dw
, CLEAR
.ERROR
, dw
->all_chan_mask
);
1330 channel_clear_bit(dw
, MASK
.XFER
, dw
->all_chan_mask
);
1331 channel_clear_bit(dw
, MASK
.BLOCK
, dw
->all_chan_mask
);
1332 channel_clear_bit(dw
, MASK
.SRC_TRAN
, dw
->all_chan_mask
);
1333 channel_clear_bit(dw
, MASK
.DST_TRAN
, dw
->all_chan_mask
);
1334 channel_clear_bit(dw
, MASK
.ERROR
, dw
->all_chan_mask
);
1336 dma_cap_set(DMA_MEMCPY
, dw
->dma
.cap_mask
);
1337 dma_cap_set(DMA_SLAVE
, dw
->dma
.cap_mask
);
1338 dw
->dma
.dev
= &pdev
->dev
;
1339 dw
->dma
.device_alloc_chan_resources
= dwc_alloc_chan_resources
;
1340 dw
->dma
.device_free_chan_resources
= dwc_free_chan_resources
;
1342 dw
->dma
.device_prep_dma_memcpy
= dwc_prep_dma_memcpy
;
1344 dw
->dma
.device_prep_slave_sg
= dwc_prep_slave_sg
;
1345 dw
->dma
.device_control
= dwc_control
;
1347 dw
->dma
.device_tx_status
= dwc_tx_status
;
1348 dw
->dma
.device_issue_pending
= dwc_issue_pending
;
1350 dma_writel(dw
, CFG
, DW_CFG_DMA_EN
);
1352 printk(KERN_INFO
"%s: DesignWare DMA Controller, %d channels\n",
1353 dev_name(&pdev
->dev
), dw
->dma
.chancnt
);
1355 dma_async_device_register(&dw
->dma
);
1360 clk_disable(dw
->clk
);
1366 release_resource(io
);
1372 static int __exit
dw_remove(struct platform_device
*pdev
)
1374 struct dw_dma
*dw
= platform_get_drvdata(pdev
);
1375 struct dw_dma_chan
*dwc
, *_dwc
;
1376 struct resource
*io
;
1379 dma_async_device_unregister(&dw
->dma
);
1381 free_irq(platform_get_irq(pdev
, 0), dw
);
1382 tasklet_kill(&dw
->tasklet
);
1384 list_for_each_entry_safe(dwc
, _dwc
, &dw
->dma
.channels
,
1386 list_del(&dwc
->chan
.device_node
);
1387 channel_clear_bit(dw
, CH_EN
, dwc
->mask
);
1390 clk_disable(dw
->clk
);
1396 io
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
1397 release_mem_region(io
->start
, DW_REGLEN
);
1404 static void dw_shutdown(struct platform_device
*pdev
)
1406 struct dw_dma
*dw
= platform_get_drvdata(pdev
);
1408 dw_dma_off(platform_get_drvdata(pdev
));
1409 clk_disable(dw
->clk
);
1412 static int dw_suspend_noirq(struct device
*dev
)
1414 struct platform_device
*pdev
= to_platform_device(dev
);
1415 struct dw_dma
*dw
= platform_get_drvdata(pdev
);
1417 dw_dma_off(platform_get_drvdata(pdev
));
1418 clk_disable(dw
->clk
);
1422 static int dw_resume_noirq(struct device
*dev
)
1424 struct platform_device
*pdev
= to_platform_device(dev
);
1425 struct dw_dma
*dw
= platform_get_drvdata(pdev
);
1427 clk_enable(dw
->clk
);
1428 dma_writel(dw
, CFG
, DW_CFG_DMA_EN
);
1432 static const struct dev_pm_ops dw_dev_pm_ops
= {
1433 .suspend_noirq
= dw_suspend_noirq
,
1434 .resume_noirq
= dw_resume_noirq
,
1437 static struct platform_driver dw_driver
= {
1438 .remove
= __exit_p(dw_remove
),
1439 .shutdown
= dw_shutdown
,
1442 .pm
= &dw_dev_pm_ops
,
1446 static int __init
dw_init(void)
1448 return platform_driver_probe(&dw_driver
, dw_probe
);
1450 module_init(dw_init
);
1452 static void __exit
dw_exit(void)
1454 platform_driver_unregister(&dw_driver
);
1456 module_exit(dw_exit
);
1458 MODULE_LICENSE("GPL v2");
1459 MODULE_DESCRIPTION("Synopsys DesignWare DMA Controller driver");
1460 MODULE_AUTHOR("Haavard Skinnemoen <haavard.skinnemoen@atmel.com>");