1 // SPDX-License-Identifier: GPL-2.0+
3 // Copyright (c) 2013-2014 Freescale Semiconductor, Inc
4 // Copyright (c) 2017 Sysam, Angelo Dureghello <angelo@sysam.it>
6 #include <linux/dmapool.h>
7 #include <linux/module.h>
8 #include <linux/slab.h>
9 #include <linux/dma-mapping.h>
11 #include "fsl-edma-common.h"
17 #define EDMA_SERQ 0x1B
18 #define EDMA_CERQ 0x1A
19 #define EDMA_SEEI 0x19
20 #define EDMA_CEEI 0x18
21 #define EDMA_CINT 0x1F
22 #define EDMA_CERR 0x1E
23 #define EDMA_SSRT 0x1D
24 #define EDMA_CDNE 0x1C
25 #define EDMA_INTR 0x24
28 #define EDMA64_ERQH 0x08
29 #define EDMA64_EEIH 0x10
30 #define EDMA64_SERQ 0x18
31 #define EDMA64_CERQ 0x19
32 #define EDMA64_SEEI 0x1a
33 #define EDMA64_CEEI 0x1b
34 #define EDMA64_CINT 0x1c
35 #define EDMA64_CERR 0x1d
36 #define EDMA64_SSRT 0x1e
37 #define EDMA64_CDNE 0x1f
38 #define EDMA64_INTH 0x20
39 #define EDMA64_INTL 0x24
40 #define EDMA64_ERRH 0x28
41 #define EDMA64_ERRL 0x2c
43 #define EDMA_TCD 0x1000
45 static void fsl_edma_enable_request(struct fsl_edma_chan *fsl_chan)
47 struct edma_regs *regs = &fsl_chan->edma->regs;
48 u32 ch = fsl_chan->vchan.chan.chan_id;
50 if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_WRAP_IO) {
51 edma_writeb(fsl_chan->edma, EDMA_SEEI_SEEI(ch), regs->seei);
52 edma_writeb(fsl_chan->edma, ch, regs->serq);
54 /* ColdFire is big endian, and accesses natively
55 * big endian I/O peripherals
57 iowrite8(EDMA_SEEI_SEEI(ch), regs->seei);
58 iowrite8(ch, regs->serq);
62 void fsl_edma_disable_request(struct fsl_edma_chan *fsl_chan)
64 struct edma_regs *regs = &fsl_chan->edma->regs;
65 u32 ch = fsl_chan->vchan.chan.chan_id;
67 if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_WRAP_IO) {
68 edma_writeb(fsl_chan->edma, ch, regs->cerq);
69 edma_writeb(fsl_chan->edma, EDMA_CEEI_CEEI(ch), regs->ceei);
71 /* ColdFire is big endian, and accesses natively
72 * big endian I/O peripherals
74 iowrite8(ch, regs->cerq);
75 iowrite8(EDMA_CEEI_CEEI(ch), regs->ceei);
79 static void mux_configure8(struct fsl_edma_chan *fsl_chan, void __iomem *addr,
80 u32 off, u32 slot, bool enable)
85 val8 = EDMAMUX_CHCFG_ENBL | slot;
87 val8 = EDMAMUX_CHCFG_DIS;
89 iowrite8(val8, addr + off);
92 static void mux_configure32(struct fsl_edma_chan *fsl_chan, void __iomem *addr,
93 u32 off, u32 slot, bool enable)
98 val = EDMAMUX_CHCFG_ENBL << 24 | slot;
100 val = EDMAMUX_CHCFG_DIS;
102 iowrite32(val, addr + off * 4);
105 void fsl_edma_chan_mux(struct fsl_edma_chan *fsl_chan,
106 unsigned int slot, bool enable)
108 u32 ch = fsl_chan->vchan.chan.chan_id;
109 void __iomem *muxaddr;
110 unsigned int chans_per_mux, ch_off;
111 int endian_diff[4] = {3, 1, -1, -3};
112 u32 dmamux_nr = fsl_chan->edma->drvdata->dmamuxs;
114 chans_per_mux = fsl_chan->edma->n_chans / dmamux_nr;
115 ch_off = fsl_chan->vchan.chan.chan_id % chans_per_mux;
117 if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_MUX_SWAP)
118 ch_off += endian_diff[ch_off % 4];
120 muxaddr = fsl_chan->edma->muxbase[ch / chans_per_mux];
121 slot = EDMAMUX_CHCFG_SOURCE(slot);
123 if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_CONFIG32)
124 mux_configure32(fsl_chan, muxaddr, ch_off, slot, enable);
126 mux_configure8(fsl_chan, muxaddr, ch_off, slot, enable);
129 static unsigned int fsl_edma_get_tcd_attr(enum dma_slave_buswidth addr_width)
131 switch (addr_width) {
133 return EDMA_TCD_ATTR_SSIZE_8BIT | EDMA_TCD_ATTR_DSIZE_8BIT;
135 return EDMA_TCD_ATTR_SSIZE_16BIT | EDMA_TCD_ATTR_DSIZE_16BIT;
137 return EDMA_TCD_ATTR_SSIZE_32BIT | EDMA_TCD_ATTR_DSIZE_32BIT;
139 return EDMA_TCD_ATTR_SSIZE_64BIT | EDMA_TCD_ATTR_DSIZE_64BIT;
141 return EDMA_TCD_ATTR_SSIZE_32BIT | EDMA_TCD_ATTR_DSIZE_32BIT;
145 void fsl_edma_free_desc(struct virt_dma_desc *vdesc)
147 struct fsl_edma_desc *fsl_desc;
150 fsl_desc = to_fsl_edma_desc(vdesc);
151 for (i = 0; i < fsl_desc->n_tcds; i++)
152 dma_pool_free(fsl_desc->echan->tcd_pool, fsl_desc->tcd[i].vtcd,
153 fsl_desc->tcd[i].ptcd);
157 int fsl_edma_terminate_all(struct dma_chan *chan)
159 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
163 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
164 fsl_edma_disable_request(fsl_chan);
165 fsl_chan->edesc = NULL;
166 fsl_chan->idle = true;
167 vchan_get_all_descriptors(&fsl_chan->vchan, &head);
168 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
169 vchan_dma_desc_free_list(&fsl_chan->vchan, &head);
173 int fsl_edma_pause(struct dma_chan *chan)
175 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
178 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
179 if (fsl_chan->edesc) {
180 fsl_edma_disable_request(fsl_chan);
181 fsl_chan->status = DMA_PAUSED;
182 fsl_chan->idle = true;
184 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
188 int fsl_edma_resume(struct dma_chan *chan)
190 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
193 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
194 if (fsl_chan->edesc) {
195 fsl_edma_enable_request(fsl_chan);
196 fsl_chan->status = DMA_IN_PROGRESS;
197 fsl_chan->idle = false;
199 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
203 static void fsl_edma_unprep_slave_dma(struct fsl_edma_chan *fsl_chan)
205 if (fsl_chan->dma_dir != DMA_NONE)
206 dma_unmap_resource(fsl_chan->vchan.chan.device->dev,
207 fsl_chan->dma_dev_addr,
208 fsl_chan->dma_dev_size,
209 fsl_chan->dma_dir, 0);
210 fsl_chan->dma_dir = DMA_NONE;
213 static bool fsl_edma_prep_slave_dma(struct fsl_edma_chan *fsl_chan,
214 enum dma_transfer_direction dir)
216 struct device *dev = fsl_chan->vchan.chan.device->dev;
217 enum dma_data_direction dma_dir;
218 phys_addr_t addr = 0;
223 dma_dir = DMA_FROM_DEVICE;
224 addr = fsl_chan->cfg.dst_addr;
225 size = fsl_chan->cfg.dst_maxburst;
228 dma_dir = DMA_TO_DEVICE;
229 addr = fsl_chan->cfg.src_addr;
230 size = fsl_chan->cfg.src_maxburst;
237 /* Already mapped for this config? */
238 if (fsl_chan->dma_dir == dma_dir)
241 fsl_edma_unprep_slave_dma(fsl_chan);
243 fsl_chan->dma_dev_addr = dma_map_resource(dev, addr, size, dma_dir, 0);
244 if (dma_mapping_error(dev, fsl_chan->dma_dev_addr))
246 fsl_chan->dma_dev_size = size;
247 fsl_chan->dma_dir = dma_dir;
252 int fsl_edma_slave_config(struct dma_chan *chan,
253 struct dma_slave_config *cfg)
255 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
257 memcpy(&fsl_chan->cfg, cfg, sizeof(*cfg));
258 fsl_edma_unprep_slave_dma(fsl_chan);
263 static size_t fsl_edma_desc_residue(struct fsl_edma_chan *fsl_chan,
264 struct virt_dma_desc *vdesc, bool in_progress)
266 struct fsl_edma_desc *edesc = fsl_chan->edesc;
267 struct edma_regs *regs = &fsl_chan->edma->regs;
268 u32 ch = fsl_chan->vchan.chan.chan_id;
269 enum dma_transfer_direction dir = edesc->dirn;
270 dma_addr_t cur_addr, dma_addr;
274 /* calculate the total size in this desc */
275 for (len = i = 0; i < fsl_chan->edesc->n_tcds; i++)
276 len += le32_to_cpu(edesc->tcd[i].vtcd->nbytes)
277 * le16_to_cpu(edesc->tcd[i].vtcd->biter);
282 if (dir == DMA_MEM_TO_DEV)
283 cur_addr = edma_readl(fsl_chan->edma, ®s->tcd[ch].saddr);
285 cur_addr = edma_readl(fsl_chan->edma, ®s->tcd[ch].daddr);
287 /* figure out the finished and calculate the residue */
288 for (i = 0; i < fsl_chan->edesc->n_tcds; i++) {
289 size = le32_to_cpu(edesc->tcd[i].vtcd->nbytes)
290 * le16_to_cpu(edesc->tcd[i].vtcd->biter);
291 if (dir == DMA_MEM_TO_DEV)
292 dma_addr = le32_to_cpu(edesc->tcd[i].vtcd->saddr);
294 dma_addr = le32_to_cpu(edesc->tcd[i].vtcd->daddr);
297 if (cur_addr >= dma_addr && cur_addr < dma_addr + size) {
298 len += dma_addr + size - cur_addr;
306 enum dma_status fsl_edma_tx_status(struct dma_chan *chan,
307 dma_cookie_t cookie, struct dma_tx_state *txstate)
309 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
310 struct virt_dma_desc *vdesc;
311 enum dma_status status;
314 status = dma_cookie_status(chan, cookie, txstate);
315 if (status == DMA_COMPLETE)
319 return fsl_chan->status;
321 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
322 vdesc = vchan_find_desc(&fsl_chan->vchan, cookie);
323 if (fsl_chan->edesc && cookie == fsl_chan->edesc->vdesc.tx.cookie)
325 fsl_edma_desc_residue(fsl_chan, vdesc, true);
328 fsl_edma_desc_residue(fsl_chan, vdesc, false);
330 txstate->residue = 0;
332 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
334 return fsl_chan->status;
337 static void fsl_edma_set_tcd_regs(struct fsl_edma_chan *fsl_chan,
338 struct fsl_edma_hw_tcd *tcd)
340 struct fsl_edma_engine *edma = fsl_chan->edma;
341 struct edma_regs *regs = &fsl_chan->edma->regs;
342 u32 ch = fsl_chan->vchan.chan.chan_id;
346 * TCD parameters are stored in struct fsl_edma_hw_tcd in little
347 * endian format. However, we need to load the TCD registers in
348 * big- or little-endian obeying the eDMA engine model endian,
349 * and this is performed from specific edma_write functions
351 edma_writew(edma, 0, ®s->tcd[ch].csr);
353 edma_writel(edma, (s32)tcd->saddr, ®s->tcd[ch].saddr);
354 edma_writel(edma, (s32)tcd->daddr, ®s->tcd[ch].daddr);
356 edma_writew(edma, (s16)tcd->attr, ®s->tcd[ch].attr);
357 edma_writew(edma, tcd->soff, ®s->tcd[ch].soff);
359 edma_writel(edma, (s32)tcd->nbytes, ®s->tcd[ch].nbytes);
360 edma_writel(edma, (s32)tcd->slast, ®s->tcd[ch].slast);
362 edma_writew(edma, (s16)tcd->citer, ®s->tcd[ch].citer);
363 edma_writew(edma, (s16)tcd->biter, ®s->tcd[ch].biter);
364 edma_writew(edma, (s16)tcd->doff, ®s->tcd[ch].doff);
366 edma_writel(edma, (s32)tcd->dlast_sga,
367 ®s->tcd[ch].dlast_sga);
369 if (fsl_chan->is_sw) {
370 csr = le16_to_cpu(tcd->csr);
371 csr |= EDMA_TCD_CSR_START;
372 tcd->csr = cpu_to_le16(csr);
375 edma_writew(edma, (s16)tcd->csr, ®s->tcd[ch].csr);
379 void fsl_edma_fill_tcd(struct fsl_edma_hw_tcd *tcd, u32 src, u32 dst,
380 u16 attr, u16 soff, u32 nbytes, u32 slast, u16 citer,
381 u16 biter, u16 doff, u32 dlast_sga, bool major_int,
382 bool disable_req, bool enable_sg)
387 * eDMA hardware SGs require the TCDs to be stored in little
388 * endian format irrespective of the register endian model.
389 * So we put the value in little endian in memory, waiting
390 * for fsl_edma_set_tcd_regs doing the swap.
392 tcd->saddr = cpu_to_le32(src);
393 tcd->daddr = cpu_to_le32(dst);
395 tcd->attr = cpu_to_le16(attr);
397 tcd->soff = cpu_to_le16(soff);
399 tcd->nbytes = cpu_to_le32(nbytes);
400 tcd->slast = cpu_to_le32(slast);
402 tcd->citer = cpu_to_le16(EDMA_TCD_CITER_CITER(citer));
403 tcd->doff = cpu_to_le16(doff);
405 tcd->dlast_sga = cpu_to_le32(dlast_sga);
407 tcd->biter = cpu_to_le16(EDMA_TCD_BITER_BITER(biter));
409 csr |= EDMA_TCD_CSR_INT_MAJOR;
412 csr |= EDMA_TCD_CSR_D_REQ;
415 csr |= EDMA_TCD_CSR_E_SG;
417 tcd->csr = cpu_to_le16(csr);
420 static struct fsl_edma_desc *fsl_edma_alloc_desc(struct fsl_edma_chan *fsl_chan,
423 struct fsl_edma_desc *fsl_desc;
426 fsl_desc = kzalloc(struct_size(fsl_desc, tcd, sg_len), GFP_NOWAIT);
430 fsl_desc->echan = fsl_chan;
431 fsl_desc->n_tcds = sg_len;
432 for (i = 0; i < sg_len; i++) {
433 fsl_desc->tcd[i].vtcd = dma_pool_alloc(fsl_chan->tcd_pool,
434 GFP_NOWAIT, &fsl_desc->tcd[i].ptcd);
435 if (!fsl_desc->tcd[i].vtcd)
442 dma_pool_free(fsl_chan->tcd_pool, fsl_desc->tcd[i].vtcd,
443 fsl_desc->tcd[i].ptcd);
448 struct dma_async_tx_descriptor *fsl_edma_prep_dma_cyclic(
449 struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len,
450 size_t period_len, enum dma_transfer_direction direction,
453 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
454 struct fsl_edma_desc *fsl_desc;
455 dma_addr_t dma_buf_next;
457 u32 src_addr, dst_addr, last_sg, nbytes;
458 u16 soff, doff, iter;
460 if (!is_slave_direction(direction))
463 if (!fsl_edma_prep_slave_dma(fsl_chan, direction))
466 sg_len = buf_len / period_len;
467 fsl_desc = fsl_edma_alloc_desc(fsl_chan, sg_len);
470 fsl_desc->iscyclic = true;
471 fsl_desc->dirn = direction;
473 dma_buf_next = dma_addr;
474 if (direction == DMA_MEM_TO_DEV) {
476 fsl_edma_get_tcd_attr(fsl_chan->cfg.dst_addr_width);
477 nbytes = fsl_chan->cfg.dst_addr_width *
478 fsl_chan->cfg.dst_maxburst;
481 fsl_edma_get_tcd_attr(fsl_chan->cfg.src_addr_width);
482 nbytes = fsl_chan->cfg.src_addr_width *
483 fsl_chan->cfg.src_maxburst;
486 iter = period_len / nbytes;
488 for (i = 0; i < sg_len; i++) {
489 if (dma_buf_next >= dma_addr + buf_len)
490 dma_buf_next = dma_addr;
492 /* get next sg's physical address */
493 last_sg = fsl_desc->tcd[(i + 1) % sg_len].ptcd;
495 if (direction == DMA_MEM_TO_DEV) {
496 src_addr = dma_buf_next;
497 dst_addr = fsl_chan->dma_dev_addr;
498 soff = fsl_chan->cfg.dst_addr_width;
501 src_addr = fsl_chan->dma_dev_addr;
502 dst_addr = dma_buf_next;
504 doff = fsl_chan->cfg.src_addr_width;
507 fsl_edma_fill_tcd(fsl_desc->tcd[i].vtcd, src_addr, dst_addr,
508 fsl_chan->attr, soff, nbytes, 0, iter,
509 iter, doff, last_sg, true, false, true);
510 dma_buf_next += period_len;
513 return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags);
516 struct dma_async_tx_descriptor *fsl_edma_prep_slave_sg(
517 struct dma_chan *chan, struct scatterlist *sgl,
518 unsigned int sg_len, enum dma_transfer_direction direction,
519 unsigned long flags, void *context)
521 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
522 struct fsl_edma_desc *fsl_desc;
523 struct scatterlist *sg;
524 u32 src_addr, dst_addr, last_sg, nbytes;
525 u16 soff, doff, iter;
528 if (!is_slave_direction(direction))
531 if (!fsl_edma_prep_slave_dma(fsl_chan, direction))
534 fsl_desc = fsl_edma_alloc_desc(fsl_chan, sg_len);
537 fsl_desc->iscyclic = false;
538 fsl_desc->dirn = direction;
540 if (direction == DMA_MEM_TO_DEV) {
542 fsl_edma_get_tcd_attr(fsl_chan->cfg.dst_addr_width);
543 nbytes = fsl_chan->cfg.dst_addr_width *
544 fsl_chan->cfg.dst_maxburst;
547 fsl_edma_get_tcd_attr(fsl_chan->cfg.src_addr_width);
548 nbytes = fsl_chan->cfg.src_addr_width *
549 fsl_chan->cfg.src_maxburst;
552 for_each_sg(sgl, sg, sg_len, i) {
553 if (direction == DMA_MEM_TO_DEV) {
554 src_addr = sg_dma_address(sg);
555 dst_addr = fsl_chan->dma_dev_addr;
556 soff = fsl_chan->cfg.dst_addr_width;
559 src_addr = fsl_chan->dma_dev_addr;
560 dst_addr = sg_dma_address(sg);
562 doff = fsl_chan->cfg.src_addr_width;
565 iter = sg_dma_len(sg) / nbytes;
566 if (i < sg_len - 1) {
567 last_sg = fsl_desc->tcd[(i + 1)].ptcd;
568 fsl_edma_fill_tcd(fsl_desc->tcd[i].vtcd, src_addr,
569 dst_addr, fsl_chan->attr, soff,
570 nbytes, 0, iter, iter, doff, last_sg,
574 fsl_edma_fill_tcd(fsl_desc->tcd[i].vtcd, src_addr,
575 dst_addr, fsl_chan->attr, soff,
576 nbytes, 0, iter, iter, doff, last_sg,
581 return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags);
584 struct dma_async_tx_descriptor *fsl_edma_prep_memcpy(struct dma_chan *chan,
585 dma_addr_t dma_dst, dma_addr_t dma_src,
586 size_t len, unsigned long flags)
588 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
589 struct fsl_edma_desc *fsl_desc;
591 fsl_desc = fsl_edma_alloc_desc(fsl_chan, 1);
594 fsl_desc->iscyclic = false;
596 fsl_chan->is_sw = true;
598 /* To match with copy_align and max_seg_size so 1 tcd is enough */
599 fsl_edma_fill_tcd(fsl_desc->tcd[0].vtcd, dma_src, dma_dst,
600 EDMA_TCD_ATTR_SSIZE_32BYTE | EDMA_TCD_ATTR_DSIZE_32BYTE,
601 32, len, 0, 1, 1, 32, 0, true, true, false);
603 return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags);
606 void fsl_edma_xfer_desc(struct fsl_edma_chan *fsl_chan)
608 struct virt_dma_desc *vdesc;
610 lockdep_assert_held(&fsl_chan->vchan.lock);
612 vdesc = vchan_next_desc(&fsl_chan->vchan);
615 fsl_chan->edesc = to_fsl_edma_desc(vdesc);
616 fsl_edma_set_tcd_regs(fsl_chan, fsl_chan->edesc->tcd[0].vtcd);
617 fsl_edma_enable_request(fsl_chan);
618 fsl_chan->status = DMA_IN_PROGRESS;
619 fsl_chan->idle = false;
622 void fsl_edma_issue_pending(struct dma_chan *chan)
624 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
627 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
629 if (unlikely(fsl_chan->pm_state != RUNNING)) {
630 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
631 /* cannot submit due to suspend */
635 if (vchan_issue_pending(&fsl_chan->vchan) && !fsl_chan->edesc)
636 fsl_edma_xfer_desc(fsl_chan);
638 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
641 int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
643 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
645 fsl_chan->tcd_pool = dma_pool_create("tcd_pool", chan->device->dev,
646 sizeof(struct fsl_edma_hw_tcd),
651 void fsl_edma_free_chan_resources(struct dma_chan *chan)
653 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
654 struct fsl_edma_engine *edma = fsl_chan->edma;
658 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
659 fsl_edma_disable_request(fsl_chan);
660 if (edma->drvdata->dmamuxs)
661 fsl_edma_chan_mux(fsl_chan, 0, false);
662 fsl_chan->edesc = NULL;
663 vchan_get_all_descriptors(&fsl_chan->vchan, &head);
664 fsl_edma_unprep_slave_dma(fsl_chan);
665 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
667 vchan_dma_desc_free_list(&fsl_chan->vchan, &head);
668 dma_pool_destroy(fsl_chan->tcd_pool);
669 fsl_chan->tcd_pool = NULL;
670 fsl_chan->is_sw = false;
673 void fsl_edma_cleanup_vchan(struct dma_device *dmadev)
675 struct fsl_edma_chan *chan, *_chan;
677 list_for_each_entry_safe(chan, _chan,
678 &dmadev->channels, vchan.chan.device_node) {
679 list_del(&chan->vchan.chan.device_node);
680 tasklet_kill(&chan->vchan.task);
685 * On the 32 channels Vybrid/mpc577x edma version, register offsets are
686 * different compared to ColdFire mcf5441x 64 channels edma.
688 * This function sets up register offsets as per proper declared version
689 * so must be called in xxx_edma_probe() just after setting the
690 * edma "version" and "membase" appropriately.
692 void fsl_edma_setup_regs(struct fsl_edma_engine *edma)
694 bool is64 = !!(edma->drvdata->flags & FSL_EDMA_DRV_EDMA64);
696 edma->regs.cr = edma->membase + EDMA_CR;
697 edma->regs.es = edma->membase + EDMA_ES;
698 edma->regs.erql = edma->membase + EDMA_ERQ;
699 edma->regs.eeil = edma->membase + EDMA_EEI;
701 edma->regs.serq = edma->membase + (is64 ? EDMA64_SERQ : EDMA_SERQ);
702 edma->regs.cerq = edma->membase + (is64 ? EDMA64_CERQ : EDMA_CERQ);
703 edma->regs.seei = edma->membase + (is64 ? EDMA64_SEEI : EDMA_SEEI);
704 edma->regs.ceei = edma->membase + (is64 ? EDMA64_CEEI : EDMA_CEEI);
705 edma->regs.cint = edma->membase + (is64 ? EDMA64_CINT : EDMA_CINT);
706 edma->regs.cerr = edma->membase + (is64 ? EDMA64_CERR : EDMA_CERR);
707 edma->regs.ssrt = edma->membase + (is64 ? EDMA64_SSRT : EDMA_SSRT);
708 edma->regs.cdne = edma->membase + (is64 ? EDMA64_CDNE : EDMA_CDNE);
709 edma->regs.intl = edma->membase + (is64 ? EDMA64_INTL : EDMA_INTR);
710 edma->regs.errl = edma->membase + (is64 ? EDMA64_ERRL : EDMA_ERR);
713 edma->regs.erqh = edma->membase + EDMA64_ERQH;
714 edma->regs.eeih = edma->membase + EDMA64_EEIH;
715 edma->regs.errh = edma->membase + EDMA64_ERRH;
716 edma->regs.inth = edma->membase + EDMA64_INTH;
719 edma->regs.tcd = edma->membase + EDMA_TCD;
722 MODULE_LICENSE("GPL v2");