blob: cfc267e819eb703b58300e3907fdd804c7911ba2 [file] [log] [blame]
Matt Porterc2dde5f2012-08-22 21:09:34 -04001/*
2 * TI EDMA DMA engine driver
3 *
4 * Copyright 2012 Texas Instruments
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/dmaengine.h>
17#include <linux/dma-mapping.h>
18#include <linux/err.h>
19#include <linux/init.h>
20#include <linux/interrupt.h>
21#include <linux/list.h>
22#include <linux/module.h>
23#include <linux/platform_device.h>
24#include <linux/slab.h>
25#include <linux/spinlock.h>
26
Matt Porter3ad7a422013-03-06 11:15:31 -050027#include <linux/platform_data/edma.h>
Matt Porterc2dde5f2012-08-22 21:09:34 -040028
29#include "dmaengine.h"
30#include "virt-dma.h"
31
32/*
33 * This will go away when the private EDMA API is folded
34 * into this driver and the platform device(s) are
35 * instantiated in the arch code. We can only get away
36 * with this simplification because DA8XX may not be built
37 * in the same kernel image with other DaVinci parts. This
38 * avoids having to sprinkle dmaengine driver platform devices
39 * and data throughout all the existing board files.
40 */
41#ifdef CONFIG_ARCH_DAVINCI_DA8XX
42#define EDMA_CTLRS 2
43#define EDMA_CHANS 32
44#else
45#define EDMA_CTLRS 1
46#define EDMA_CHANS 64
47#endif /* CONFIG_ARCH_DAVINCI_DA8XX */
48
Joel Fernandes2abd5f12013-09-23 18:05:15 -050049/*
50 * Max of 20 segments per channel to conserve PaRAM slots
51 * Also note that MAX_NR_SG should be atleast the no.of periods
52 * that are required for ASoC, otherwise DMA prep calls will
53 * fail. Today davinci-pcm is the only user of this driver and
54 * requires atleast 17 slots, so we setup the default to 20.
55 */
56#define MAX_NR_SG 20
Matt Porterc2dde5f2012-08-22 21:09:34 -040057#define EDMA_MAX_SLOTS MAX_NR_SG
58#define EDMA_DESCRIPTORS 16
59
60struct edma_desc {
61 struct virt_dma_desc vdesc;
62 struct list_head node;
Joel Fernandes50a9c702013-10-31 16:31:23 -050063 int cyclic;
Matt Porterc2dde5f2012-08-22 21:09:34 -040064 int absync;
65 int pset_nr;
Joel Fernandes53407062013-09-03 10:02:46 -050066 int processed;
Thomas Gleixnerb6205c32014-04-28 14:18:45 -050067 u32 residue;
Matt Porterc2dde5f2012-08-22 21:09:34 -040068 struct edmacc_param pset[0];
69};
70
71struct edma_cc;
72
73struct edma_chan {
74 struct virt_dma_chan vchan;
75 struct list_head node;
76 struct edma_desc *edesc;
77 struct edma_cc *ecc;
78 int ch_num;
79 bool alloced;
80 int slot[EDMA_MAX_SLOTS];
Joel Fernandesc5f47992013-08-29 18:05:43 -050081 int missed;
Matt Porter661f7cb2013-01-10 13:41:04 -050082 struct dma_slave_config cfg;
Matt Porterc2dde5f2012-08-22 21:09:34 -040083};
84
85struct edma_cc {
86 int ctlr;
87 struct dma_device dma_slave;
88 struct edma_chan slave_chans[EDMA_CHANS];
89 int num_slave_chans;
90 int dummy_slot;
91};
92
93static inline struct edma_cc *to_edma_cc(struct dma_device *d)
94{
95 return container_of(d, struct edma_cc, dma_slave);
96}
97
98static inline struct edma_chan *to_edma_chan(struct dma_chan *c)
99{
100 return container_of(c, struct edma_chan, vchan.chan);
101}
102
103static inline struct edma_desc
104*to_edma_desc(struct dma_async_tx_descriptor *tx)
105{
106 return container_of(tx, struct edma_desc, vdesc.tx);
107}
108
109static void edma_desc_free(struct virt_dma_desc *vdesc)
110{
111 kfree(container_of(vdesc, struct edma_desc, vdesc));
112}
113
114/* Dispatch a queued descriptor to the controller (caller holds lock) */
115static void edma_execute(struct edma_chan *echan)
116{
Joel Fernandes53407062013-09-03 10:02:46 -0500117 struct virt_dma_desc *vdesc;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400118 struct edma_desc *edesc;
Joel Fernandes53407062013-09-03 10:02:46 -0500119 struct device *dev = echan->vchan.chan.device->dev;
120 int i, j, left, nslots;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400121
Joel Fernandes53407062013-09-03 10:02:46 -0500122 /* If either we processed all psets or we're still not started */
123 if (!echan->edesc ||
124 echan->edesc->pset_nr == echan->edesc->processed) {
125 /* Get next vdesc */
126 vdesc = vchan_next_desc(&echan->vchan);
127 if (!vdesc) {
128 echan->edesc = NULL;
129 return;
130 }
131 list_del(&vdesc->node);
132 echan->edesc = to_edma_desc(&vdesc->tx);
Matt Porterc2dde5f2012-08-22 21:09:34 -0400133 }
134
Joel Fernandes53407062013-09-03 10:02:46 -0500135 edesc = echan->edesc;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400136
Joel Fernandes53407062013-09-03 10:02:46 -0500137 /* Find out how many left */
138 left = edesc->pset_nr - edesc->processed;
139 nslots = min(MAX_NR_SG, left);
Matt Porterc2dde5f2012-08-22 21:09:34 -0400140
141 /* Write descriptor PaRAM set(s) */
Joel Fernandes53407062013-09-03 10:02:46 -0500142 for (i = 0; i < nslots; i++) {
143 j = i + edesc->processed;
144 edma_write_slot(echan->slot[i], &edesc->pset[j]);
Peter Ujfalusi83bb3122014-04-14 14:42:02 +0300145 dev_vdbg(echan->vchan.chan.device->dev,
Matt Porterc2dde5f2012-08-22 21:09:34 -0400146 "\n pset[%d]:\n"
147 " chnum\t%d\n"
148 " slot\t%d\n"
149 " opt\t%08x\n"
150 " src\t%08x\n"
151 " dst\t%08x\n"
152 " abcnt\t%08x\n"
153 " ccnt\t%08x\n"
154 " bidx\t%08x\n"
155 " cidx\t%08x\n"
156 " lkrld\t%08x\n",
Joel Fernandes53407062013-09-03 10:02:46 -0500157 j, echan->ch_num, echan->slot[i],
158 edesc->pset[j].opt,
159 edesc->pset[j].src,
160 edesc->pset[j].dst,
161 edesc->pset[j].a_b_cnt,
162 edesc->pset[j].ccnt,
163 edesc->pset[j].src_dst_bidx,
164 edesc->pset[j].src_dst_cidx,
165 edesc->pset[j].link_bcntrld);
Matt Porterc2dde5f2012-08-22 21:09:34 -0400166 /* Link to the previous slot if not the last set */
Joel Fernandes53407062013-09-03 10:02:46 -0500167 if (i != (nslots - 1))
Matt Porterc2dde5f2012-08-22 21:09:34 -0400168 edma_link(echan->slot[i], echan->slot[i+1]);
Matt Porterc2dde5f2012-08-22 21:09:34 -0400169 }
170
Joel Fernandes53407062013-09-03 10:02:46 -0500171 edesc->processed += nslots;
172
Joel Fernandesb267b3b2013-08-29 18:05:44 -0500173 /*
174 * If this is either the last set in a set of SG-list transactions
175 * then setup a link to the dummy slot, this results in all future
176 * events being absorbed and that's OK because we're done
177 */
Joel Fernandes50a9c702013-10-31 16:31:23 -0500178 if (edesc->processed == edesc->pset_nr) {
179 if (edesc->cyclic)
180 edma_link(echan->slot[nslots-1], echan->slot[1]);
181 else
182 edma_link(echan->slot[nslots-1],
183 echan->ecc->dummy_slot);
184 }
Joel Fernandesb267b3b2013-08-29 18:05:44 -0500185
Joel Fernandes53407062013-09-03 10:02:46 -0500186 if (edesc->processed <= MAX_NR_SG) {
Peter Ujfalusi9aac9092014-04-24 10:29:50 +0300187 dev_dbg(dev, "first transfer starting on channel %d\n",
188 echan->ch_num);
Joel Fernandes53407062013-09-03 10:02:46 -0500189 edma_start(echan->ch_num);
Sekhar Nori5fc68a62014-03-19 11:25:50 +0530190 } else {
191 dev_dbg(dev, "chan: %d: completed %d elements, resuming\n",
192 echan->ch_num, edesc->processed);
193 edma_resume(echan->ch_num);
Joel Fernandes53407062013-09-03 10:02:46 -0500194 }
Joel Fernandesc5f47992013-08-29 18:05:43 -0500195
196 /*
197 * This happens due to setup times between intermediate transfers
198 * in long SG lists which have to be broken up into transfers of
199 * MAX_NR_SG
200 */
201 if (echan->missed) {
Peter Ujfalusi9aac9092014-04-24 10:29:50 +0300202 dev_dbg(dev, "missed event on channel %d\n", echan->ch_num);
Joel Fernandesc5f47992013-08-29 18:05:43 -0500203 edma_clean_channel(echan->ch_num);
204 edma_stop(echan->ch_num);
205 edma_start(echan->ch_num);
206 edma_trigger_channel(echan->ch_num);
207 echan->missed = 0;
208 }
Matt Porterc2dde5f2012-08-22 21:09:34 -0400209}
210
211static int edma_terminate_all(struct edma_chan *echan)
212{
213 unsigned long flags;
214 LIST_HEAD(head);
215
216 spin_lock_irqsave(&echan->vchan.lock, flags);
217
218 /*
219 * Stop DMA activity: we assume the callback will not be called
220 * after edma_dma() returns (even if it does, it will see
221 * echan->edesc is NULL and exit.)
222 */
223 if (echan->edesc) {
224 echan->edesc = NULL;
225 edma_stop(echan->ch_num);
226 }
227
228 vchan_get_all_descriptors(&echan->vchan, &head);
229 spin_unlock_irqrestore(&echan->vchan.lock, flags);
230 vchan_dma_desc_free_list(&echan->vchan, &head);
231
232 return 0;
233}
234
Matt Porterc2dde5f2012-08-22 21:09:34 -0400235static int edma_slave_config(struct edma_chan *echan,
Matt Porter661f7cb2013-01-10 13:41:04 -0500236 struct dma_slave_config *cfg)
Matt Porterc2dde5f2012-08-22 21:09:34 -0400237{
Matt Porter661f7cb2013-01-10 13:41:04 -0500238 if (cfg->src_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES ||
239 cfg->dst_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES)
Matt Porterc2dde5f2012-08-22 21:09:34 -0400240 return -EINVAL;
241
Matt Porter661f7cb2013-01-10 13:41:04 -0500242 memcpy(&echan->cfg, cfg, sizeof(echan->cfg));
Matt Porterc2dde5f2012-08-22 21:09:34 -0400243
244 return 0;
245}
246
Peter Ujfalusi72c7b672014-04-14 14:41:59 +0300247static int edma_dma_pause(struct edma_chan *echan)
248{
249 /* Pause/Resume only allowed with cyclic mode */
250 if (!echan->edesc->cyclic)
251 return -EINVAL;
252
253 edma_pause(echan->ch_num);
254 return 0;
255}
256
257static int edma_dma_resume(struct edma_chan *echan)
258{
259 /* Pause/Resume only allowed with cyclic mode */
260 if (!echan->edesc->cyclic)
261 return -EINVAL;
262
263 edma_resume(echan->ch_num);
264 return 0;
265}
266
Matt Porterc2dde5f2012-08-22 21:09:34 -0400267static int edma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
268 unsigned long arg)
269{
270 int ret = 0;
271 struct dma_slave_config *config;
272 struct edma_chan *echan = to_edma_chan(chan);
273
274 switch (cmd) {
275 case DMA_TERMINATE_ALL:
276 edma_terminate_all(echan);
277 break;
278 case DMA_SLAVE_CONFIG:
279 config = (struct dma_slave_config *)arg;
280 ret = edma_slave_config(echan, config);
281 break;
Peter Ujfalusi72c7b672014-04-14 14:41:59 +0300282 case DMA_PAUSE:
283 ret = edma_dma_pause(echan);
284 break;
285
286 case DMA_RESUME:
287 ret = edma_dma_resume(echan);
288 break;
289
Matt Porterc2dde5f2012-08-22 21:09:34 -0400290 default:
291 ret = -ENOSYS;
292 }
293
294 return ret;
295}
296
Joel Fernandesfd009032013-09-23 18:05:13 -0500297/*
298 * A PaRAM set configuration abstraction used by other modes
299 * @chan: Channel who's PaRAM set we're configuring
300 * @pset: PaRAM set to initialize and setup.
301 * @src_addr: Source address of the DMA
302 * @dst_addr: Destination address of the DMA
303 * @burst: In units of dev_width, how much to send
304 * @dev_width: How much is the dev_width
305 * @dma_length: Total length of the DMA transfer
306 * @direction: Direction of the transfer
307 */
308static int edma_config_pset(struct dma_chan *chan, struct edmacc_param *pset,
309 dma_addr_t src_addr, dma_addr_t dst_addr, u32 burst,
310 enum dma_slave_buswidth dev_width, unsigned int dma_length,
311 enum dma_transfer_direction direction)
312{
313 struct edma_chan *echan = to_edma_chan(chan);
314 struct device *dev = chan->device->dev;
315 int acnt, bcnt, ccnt, cidx;
316 int src_bidx, dst_bidx, src_cidx, dst_cidx;
317 int absync;
318
319 acnt = dev_width;
Peter Ujfalusib2b617d2014-04-14 14:41:58 +0300320
321 /* src/dst_maxburst == 0 is the same case as src/dst_maxburst == 1 */
322 if (!burst)
323 burst = 1;
Joel Fernandesfd009032013-09-23 18:05:13 -0500324 /*
325 * If the maxburst is equal to the fifo width, use
326 * A-synced transfers. This allows for large contiguous
327 * buffer transfers using only one PaRAM set.
328 */
329 if (burst == 1) {
330 /*
331 * For the A-sync case, bcnt and ccnt are the remainder
332 * and quotient respectively of the division of:
333 * (dma_length / acnt) by (SZ_64K -1). This is so
334 * that in case bcnt over flows, we have ccnt to use.
335 * Note: In A-sync tranfer only, bcntrld is used, but it
336 * only applies for sg_dma_len(sg) >= SZ_64K.
337 * In this case, the best way adopted is- bccnt for the
338 * first frame will be the remainder below. Then for
339 * every successive frame, bcnt will be SZ_64K-1. This
340 * is assured as bcntrld = 0xffff in end of function.
341 */
342 absync = false;
343 ccnt = dma_length / acnt / (SZ_64K - 1);
344 bcnt = dma_length / acnt - ccnt * (SZ_64K - 1);
345 /*
346 * If bcnt is non-zero, we have a remainder and hence an
347 * extra frame to transfer, so increment ccnt.
348 */
349 if (bcnt)
350 ccnt++;
351 else
352 bcnt = SZ_64K - 1;
353 cidx = acnt;
354 } else {
355 /*
356 * If maxburst is greater than the fifo address_width,
357 * use AB-synced transfers where A count is the fifo
358 * address_width and B count is the maxburst. In this
359 * case, we are limited to transfers of C count frames
360 * of (address_width * maxburst) where C count is limited
361 * to SZ_64K-1. This places an upper bound on the length
362 * of an SG segment that can be handled.
363 */
364 absync = true;
365 bcnt = burst;
366 ccnt = dma_length / (acnt * bcnt);
367 if (ccnt > (SZ_64K - 1)) {
368 dev_err(dev, "Exceeded max SG segment size\n");
369 return -EINVAL;
370 }
371 cidx = acnt * bcnt;
372 }
373
374 if (direction == DMA_MEM_TO_DEV) {
375 src_bidx = acnt;
376 src_cidx = cidx;
377 dst_bidx = 0;
378 dst_cidx = 0;
379 } else if (direction == DMA_DEV_TO_MEM) {
380 src_bidx = 0;
381 src_cidx = 0;
382 dst_bidx = acnt;
383 dst_cidx = cidx;
Joel Fernandes8cc3e302014-04-18 21:50:33 -0500384 } else if (direction == DMA_MEM_TO_MEM) {
385 src_bidx = acnt;
386 src_cidx = cidx;
387 dst_bidx = acnt;
388 dst_cidx = cidx;
Joel Fernandesfd009032013-09-23 18:05:13 -0500389 } else {
390 dev_err(dev, "%s: direction not implemented yet\n", __func__);
391 return -EINVAL;
392 }
393
394 pset->opt = EDMA_TCC(EDMA_CHAN_SLOT(echan->ch_num));
395 /* Configure A or AB synchronized transfers */
396 if (absync)
397 pset->opt |= SYNCDIM;
398
399 pset->src = src_addr;
400 pset->dst = dst_addr;
401
402 pset->src_dst_bidx = (dst_bidx << 16) | src_bidx;
403 pset->src_dst_cidx = (dst_cidx << 16) | src_cidx;
404
405 pset->a_b_cnt = bcnt << 16 | acnt;
406 pset->ccnt = ccnt;
407 /*
408 * Only time when (bcntrld) auto reload is required is for
409 * A-sync case, and in this case, a requirement of reload value
410 * of SZ_64K-1 only is assured. 'link' is initially set to NULL
411 * and then later will be populated by edma_execute.
412 */
413 pset->link_bcntrld = 0xffffffff;
414 return absync;
415}
416
Matt Porterc2dde5f2012-08-22 21:09:34 -0400417static struct dma_async_tx_descriptor *edma_prep_slave_sg(
418 struct dma_chan *chan, struct scatterlist *sgl,
419 unsigned int sg_len, enum dma_transfer_direction direction,
420 unsigned long tx_flags, void *context)
421{
422 struct edma_chan *echan = to_edma_chan(chan);
423 struct device *dev = chan->device->dev;
424 struct edma_desc *edesc;
Joel Fernandesfd009032013-09-23 18:05:13 -0500425 dma_addr_t src_addr = 0, dst_addr = 0;
Matt Porter661f7cb2013-01-10 13:41:04 -0500426 enum dma_slave_buswidth dev_width;
427 u32 burst;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400428 struct scatterlist *sg;
Joel Fernandesfd009032013-09-23 18:05:13 -0500429 int i, nslots, ret;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400430
431 if (unlikely(!echan || !sgl || !sg_len))
432 return NULL;
433
Matt Porter661f7cb2013-01-10 13:41:04 -0500434 if (direction == DMA_DEV_TO_MEM) {
Joel Fernandesfd009032013-09-23 18:05:13 -0500435 src_addr = echan->cfg.src_addr;
Matt Porter661f7cb2013-01-10 13:41:04 -0500436 dev_width = echan->cfg.src_addr_width;
437 burst = echan->cfg.src_maxburst;
438 } else if (direction == DMA_MEM_TO_DEV) {
Joel Fernandesfd009032013-09-23 18:05:13 -0500439 dst_addr = echan->cfg.dst_addr;
Matt Porter661f7cb2013-01-10 13:41:04 -0500440 dev_width = echan->cfg.dst_addr_width;
441 burst = echan->cfg.dst_maxburst;
442 } else {
Peter Ujfalusie6fad592014-04-14 14:42:05 +0300443 dev_err(dev, "%s: bad direction: %d\n", __func__, direction);
Matt Porter661f7cb2013-01-10 13:41:04 -0500444 return NULL;
445 }
446
447 if (dev_width == DMA_SLAVE_BUSWIDTH_UNDEFINED) {
Peter Ujfalusic594c892014-04-14 14:42:03 +0300448 dev_err(dev, "%s: Undefined slave buswidth\n", __func__);
Matt Porterc2dde5f2012-08-22 21:09:34 -0400449 return NULL;
450 }
451
Matt Porterc2dde5f2012-08-22 21:09:34 -0400452 edesc = kzalloc(sizeof(*edesc) + sg_len *
453 sizeof(edesc->pset[0]), GFP_ATOMIC);
454 if (!edesc) {
Peter Ujfalusic594c892014-04-14 14:42:03 +0300455 dev_err(dev, "%s: Failed to allocate a descriptor\n", __func__);
Matt Porterc2dde5f2012-08-22 21:09:34 -0400456 return NULL;
457 }
458
459 edesc->pset_nr = sg_len;
Thomas Gleixnerb6205c32014-04-28 14:18:45 -0500460 edesc->residue = 0;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400461
Joel Fernandes6fbe24d2013-08-29 18:05:40 -0500462 /* Allocate a PaRAM slot, if needed */
463 nslots = min_t(unsigned, MAX_NR_SG, sg_len);
464
465 for (i = 0; i < nslots; i++) {
Matt Porterc2dde5f2012-08-22 21:09:34 -0400466 if (echan->slot[i] < 0) {
467 echan->slot[i] =
468 edma_alloc_slot(EDMA_CTLR(echan->ch_num),
469 EDMA_SLOT_ANY);
470 if (echan->slot[i] < 0) {
Valentin Ilie4b6271a2013-10-24 16:14:22 +0300471 kfree(edesc);
Peter Ujfalusic594c892014-04-14 14:42:03 +0300472 dev_err(dev, "%s: Failed to allocate slot\n",
473 __func__);
Matt Porterc2dde5f2012-08-22 21:09:34 -0400474 return NULL;
475 }
476 }
Joel Fernandes6fbe24d2013-08-29 18:05:40 -0500477 }
478
479 /* Configure PaRAM sets for each SG */
480 for_each_sg(sgl, sg, sg_len, i) {
Joel Fernandesfd009032013-09-23 18:05:13 -0500481 /* Get address for each SG */
482 if (direction == DMA_DEV_TO_MEM)
483 dst_addr = sg_dma_address(sg);
484 else
485 src_addr = sg_dma_address(sg);
Matt Porterc2dde5f2012-08-22 21:09:34 -0400486
Joel Fernandesfd009032013-09-23 18:05:13 -0500487 ret = edma_config_pset(chan, &edesc->pset[i], src_addr,
488 dst_addr, burst, dev_width,
489 sg_dma_len(sg), direction);
Vinod Koulb967aec2013-10-30 13:07:18 +0530490 if (ret < 0) {
491 kfree(edesc);
Joel Fernandesfd009032013-09-23 18:05:13 -0500492 return NULL;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400493 }
494
Joel Fernandesfd009032013-09-23 18:05:13 -0500495 edesc->absync = ret;
Thomas Gleixnerb6205c32014-04-28 14:18:45 -0500496 edesc->residue += sg_dma_len(sg);
Joel Fernandes6fbe24d2013-08-29 18:05:40 -0500497
498 /* If this is the last in a current SG set of transactions,
499 enable interrupts so that next set is processed */
500 if (!((i+1) % MAX_NR_SG))
501 edesc->pset[i].opt |= TCINTEN;
502
Matt Porterc2dde5f2012-08-22 21:09:34 -0400503 /* If this is the last set, enable completion interrupt flag */
504 if (i == sg_len - 1)
505 edesc->pset[i].opt |= TCINTEN;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400506 }
Matt Porterc2dde5f2012-08-22 21:09:34 -0400507
Matt Porterc2dde5f2012-08-22 21:09:34 -0400508 return vchan_tx_prep(&echan->vchan, &edesc->vdesc, tx_flags);
509}
Matt Porterc2dde5f2012-08-22 21:09:34 -0400510
Joel Fernandes8cc3e302014-04-18 21:50:33 -0500511struct dma_async_tx_descriptor *edma_prep_dma_memcpy(
512 struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
513 size_t len, unsigned long tx_flags)
514{
515 int ret;
516 struct edma_desc *edesc;
517 struct device *dev = chan->device->dev;
518 struct edma_chan *echan = to_edma_chan(chan);
519
520 if (unlikely(!echan || !len))
521 return NULL;
522
523 edesc = kzalloc(sizeof(*edesc) + sizeof(edesc->pset[0]), GFP_ATOMIC);
524 if (!edesc) {
525 dev_dbg(dev, "Failed to allocate a descriptor\n");
526 return NULL;
527 }
528
529 edesc->pset_nr = 1;
530
531 ret = edma_config_pset(chan, &edesc->pset[0], src, dest, 1,
532 DMA_SLAVE_BUSWIDTH_4_BYTES, len, DMA_MEM_TO_MEM);
533 if (ret < 0)
534 return NULL;
535
536 edesc->absync = ret;
537
538 /*
539 * Enable intermediate transfer chaining to re-trigger channel
540 * on completion of every TR, and enable transfer-completion
541 * interrupt on completion of the whole transfer.
542 */
543 edesc->pset[0].opt |= ITCCHEN;
544 edesc->pset[0].opt |= TCINTEN;
545
546 return vchan_tx_prep(&echan->vchan, &edesc->vdesc, tx_flags);
547}
548
Joel Fernandes50a9c702013-10-31 16:31:23 -0500549static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
550 struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
551 size_t period_len, enum dma_transfer_direction direction,
552 unsigned long tx_flags, void *context)
553{
554 struct edma_chan *echan = to_edma_chan(chan);
555 struct device *dev = chan->device->dev;
556 struct edma_desc *edesc;
557 dma_addr_t src_addr, dst_addr;
558 enum dma_slave_buswidth dev_width;
559 u32 burst;
560 int i, ret, nslots;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400561
Joel Fernandes50a9c702013-10-31 16:31:23 -0500562 if (unlikely(!echan || !buf_len || !period_len))
563 return NULL;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400564
Joel Fernandes50a9c702013-10-31 16:31:23 -0500565 if (direction == DMA_DEV_TO_MEM) {
566 src_addr = echan->cfg.src_addr;
567 dst_addr = buf_addr;
568 dev_width = echan->cfg.src_addr_width;
569 burst = echan->cfg.src_maxburst;
570 } else if (direction == DMA_MEM_TO_DEV) {
571 src_addr = buf_addr;
572 dst_addr = echan->cfg.dst_addr;
573 dev_width = echan->cfg.dst_addr_width;
574 burst = echan->cfg.dst_maxburst;
575 } else {
Peter Ujfalusie6fad592014-04-14 14:42:05 +0300576 dev_err(dev, "%s: bad direction: %d\n", __func__, direction);
Joel Fernandes50a9c702013-10-31 16:31:23 -0500577 return NULL;
578 }
579
580 if (dev_width == DMA_SLAVE_BUSWIDTH_UNDEFINED) {
Peter Ujfalusic594c892014-04-14 14:42:03 +0300581 dev_err(dev, "%s: Undefined slave buswidth\n", __func__);
Joel Fernandes50a9c702013-10-31 16:31:23 -0500582 return NULL;
583 }
584
585 if (unlikely(buf_len % period_len)) {
586 dev_err(dev, "Period should be multiple of Buffer length\n");
587 return NULL;
588 }
589
590 nslots = (buf_len / period_len) + 1;
591
592 /*
593 * Cyclic DMA users such as audio cannot tolerate delays introduced
594 * by cases where the number of periods is more than the maximum
595 * number of SGs the EDMA driver can handle at a time. For DMA types
596 * such as Slave SGs, such delays are tolerable and synchronized,
597 * but the synchronization is difficult to achieve with Cyclic and
598 * cannot be guaranteed, so we error out early.
599 */
600 if (nslots > MAX_NR_SG)
601 return NULL;
602
603 edesc = kzalloc(sizeof(*edesc) + nslots *
604 sizeof(edesc->pset[0]), GFP_ATOMIC);
605 if (!edesc) {
Peter Ujfalusic594c892014-04-14 14:42:03 +0300606 dev_err(dev, "%s: Failed to allocate a descriptor\n", __func__);
Joel Fernandes50a9c702013-10-31 16:31:23 -0500607 return NULL;
608 }
609
610 edesc->cyclic = 1;
611 edesc->pset_nr = nslots;
Thomas Gleixnerb6205c32014-04-28 14:18:45 -0500612 edesc->residue = buf_len;
Joel Fernandes50a9c702013-10-31 16:31:23 -0500613
Peter Ujfalusi83bb3122014-04-14 14:42:02 +0300614 dev_dbg(dev, "%s: channel=%d nslots=%d period_len=%zu buf_len=%zu\n",
615 __func__, echan->ch_num, nslots, period_len, buf_len);
Joel Fernandes50a9c702013-10-31 16:31:23 -0500616
617 for (i = 0; i < nslots; i++) {
618 /* Allocate a PaRAM slot, if needed */
619 if (echan->slot[i] < 0) {
620 echan->slot[i] =
621 edma_alloc_slot(EDMA_CTLR(echan->ch_num),
622 EDMA_SLOT_ANY);
623 if (echan->slot[i] < 0) {
Christian Engelmayere3ddc972013-12-30 20:48:39 +0100624 kfree(edesc);
Peter Ujfalusic594c892014-04-14 14:42:03 +0300625 dev_err(dev, "%s: Failed to allocate slot\n",
626 __func__);
Joel Fernandes50a9c702013-10-31 16:31:23 -0500627 return NULL;
628 }
629 }
630
631 if (i == nslots - 1) {
632 memcpy(&edesc->pset[i], &edesc->pset[0],
633 sizeof(edesc->pset[0]));
634 break;
635 }
636
637 ret = edma_config_pset(chan, &edesc->pset[i], src_addr,
638 dst_addr, burst, dev_width, period_len,
639 direction);
Christian Engelmayere3ddc972013-12-30 20:48:39 +0100640 if (ret < 0) {
641 kfree(edesc);
Joel Fernandes50a9c702013-10-31 16:31:23 -0500642 return NULL;
Christian Engelmayere3ddc972013-12-30 20:48:39 +0100643 }
Joel Fernandes50a9c702013-10-31 16:31:23 -0500644
645 if (direction == DMA_DEV_TO_MEM)
646 dst_addr += period_len;
647 else
648 src_addr += period_len;
649
Peter Ujfalusi83bb3122014-04-14 14:42:02 +0300650 dev_vdbg(dev, "%s: Configure period %d of buf:\n", __func__, i);
651 dev_vdbg(dev,
Joel Fernandes50a9c702013-10-31 16:31:23 -0500652 "\n pset[%d]:\n"
653 " chnum\t%d\n"
654 " slot\t%d\n"
655 " opt\t%08x\n"
656 " src\t%08x\n"
657 " dst\t%08x\n"
658 " abcnt\t%08x\n"
659 " ccnt\t%08x\n"
660 " bidx\t%08x\n"
661 " cidx\t%08x\n"
662 " lkrld\t%08x\n",
663 i, echan->ch_num, echan->slot[i],
664 edesc->pset[i].opt,
665 edesc->pset[i].src,
666 edesc->pset[i].dst,
667 edesc->pset[i].a_b_cnt,
668 edesc->pset[i].ccnt,
669 edesc->pset[i].src_dst_bidx,
670 edesc->pset[i].src_dst_cidx,
671 edesc->pset[i].link_bcntrld);
672
673 edesc->absync = ret;
674
675 /*
676 * Enable interrupts for every period because callback
677 * has to be called for every period.
678 */
679 edesc->pset[i].opt |= TCINTEN;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400680 }
681
682 return vchan_tx_prep(&echan->vchan, &edesc->vdesc, tx_flags);
683}
684
685static void edma_callback(unsigned ch_num, u16 ch_status, void *data)
686{
687 struct edma_chan *echan = data;
688 struct device *dev = echan->vchan.chan.device->dev;
689 struct edma_desc *edesc;
Joel Fernandesc5f47992013-08-29 18:05:43 -0500690 struct edmacc_param p;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400691
Joel Fernandes50a9c702013-10-31 16:31:23 -0500692 edesc = echan->edesc;
693
694 /* Pause the channel for non-cyclic */
695 if (!edesc || (edesc && !edesc->cyclic))
696 edma_pause(echan->ch_num);
Matt Porterc2dde5f2012-08-22 21:09:34 -0400697
698 switch (ch_status) {
Vinod Kouldb60d8d2013-10-30 18:22:30 +0530699 case EDMA_DMA_COMPLETE:
Joel Fernandes406efb12014-04-17 00:58:33 -0500700 spin_lock(&echan->vchan.lock);
Matt Porterc2dde5f2012-08-22 21:09:34 -0400701
Matt Porterc2dde5f2012-08-22 21:09:34 -0400702 if (edesc) {
Joel Fernandes50a9c702013-10-31 16:31:23 -0500703 if (edesc->cyclic) {
704 vchan_cyclic_callback(&edesc->vdesc);
705 } else if (edesc->processed == edesc->pset_nr) {
Joel Fernandes53407062013-09-03 10:02:46 -0500706 dev_dbg(dev, "Transfer complete, stopping channel %d\n", ch_num);
Thomas Gleixnerb6205c32014-04-28 14:18:45 -0500707 edesc->residue = 0;
Joel Fernandes53407062013-09-03 10:02:46 -0500708 edma_stop(echan->ch_num);
709 vchan_cookie_complete(&edesc->vdesc);
Joel Fernandes50a9c702013-10-31 16:31:23 -0500710 edma_execute(echan);
Joel Fernandes53407062013-09-03 10:02:46 -0500711 } else {
712 dev_dbg(dev, "Intermediate transfer complete on channel %d\n", ch_num);
Joel Fernandes50a9c702013-10-31 16:31:23 -0500713 edma_execute(echan);
Joel Fernandes53407062013-09-03 10:02:46 -0500714 }
Matt Porterc2dde5f2012-08-22 21:09:34 -0400715 }
716
Joel Fernandes406efb12014-04-17 00:58:33 -0500717 spin_unlock(&echan->vchan.lock);
Matt Porterc2dde5f2012-08-22 21:09:34 -0400718
719 break;
Vinod Kouldb60d8d2013-10-30 18:22:30 +0530720 case EDMA_DMA_CC_ERROR:
Joel Fernandes406efb12014-04-17 00:58:33 -0500721 spin_lock(&echan->vchan.lock);
Joel Fernandesc5f47992013-08-29 18:05:43 -0500722
723 edma_read_slot(EDMA_CHAN_SLOT(echan->slot[0]), &p);
724
725 /*
726 * Issue later based on missed flag which will be sure
727 * to happen as:
728 * (1) we finished transmitting an intermediate slot and
729 * edma_execute is coming up.
730 * (2) or we finished current transfer and issue will
731 * call edma_execute.
732 *
733 * Important note: issuing can be dangerous here and
734 * lead to some nasty recursion when we are in a NULL
735 * slot. So we avoid doing so and set the missed flag.
736 */
737 if (p.a_b_cnt == 0 && p.ccnt == 0) {
738 dev_dbg(dev, "Error occurred, looks like slot is null, just setting miss\n");
739 echan->missed = 1;
740 } else {
741 /*
742 * The slot is already programmed but the event got
743 * missed, so its safe to issue it here.
744 */
745 dev_dbg(dev, "Error occurred but slot is non-null, TRIGGERING\n");
746 edma_clean_channel(echan->ch_num);
747 edma_stop(echan->ch_num);
748 edma_start(echan->ch_num);
749 edma_trigger_channel(echan->ch_num);
750 }
751
Joel Fernandes406efb12014-04-17 00:58:33 -0500752 spin_unlock(&echan->vchan.lock);
Joel Fernandesc5f47992013-08-29 18:05:43 -0500753
Matt Porterc2dde5f2012-08-22 21:09:34 -0400754 break;
755 default:
756 break;
757 }
758}
759
760/* Alloc channel resources */
761static int edma_alloc_chan_resources(struct dma_chan *chan)
762{
763 struct edma_chan *echan = to_edma_chan(chan);
764 struct device *dev = chan->device->dev;
765 int ret;
766 int a_ch_num;
767 LIST_HEAD(descs);
768
769 a_ch_num = edma_alloc_channel(echan->ch_num, edma_callback,
770 chan, EVENTQ_DEFAULT);
771
772 if (a_ch_num < 0) {
773 ret = -ENODEV;
774 goto err_no_chan;
775 }
776
777 if (a_ch_num != echan->ch_num) {
778 dev_err(dev, "failed to allocate requested channel %u:%u\n",
779 EDMA_CTLR(echan->ch_num),
780 EDMA_CHAN_SLOT(echan->ch_num));
781 ret = -ENODEV;
782 goto err_wrong_chan;
783 }
784
785 echan->alloced = true;
786 echan->slot[0] = echan->ch_num;
787
Peter Ujfalusi9aac9092014-04-24 10:29:50 +0300788 dev_dbg(dev, "allocated channel %d for %u:%u\n", echan->ch_num,
Ezequiel Garcia0e772c62013-12-13 11:06:18 -0300789 EDMA_CTLR(echan->ch_num), EDMA_CHAN_SLOT(echan->ch_num));
Matt Porterc2dde5f2012-08-22 21:09:34 -0400790
791 return 0;
792
793err_wrong_chan:
794 edma_free_channel(a_ch_num);
795err_no_chan:
796 return ret;
797}
798
799/* Free channel resources */
800static void edma_free_chan_resources(struct dma_chan *chan)
801{
802 struct edma_chan *echan = to_edma_chan(chan);
803 struct device *dev = chan->device->dev;
804 int i;
805
806 /* Terminate transfers */
807 edma_stop(echan->ch_num);
808
809 vchan_free_chan_resources(&echan->vchan);
810
811 /* Free EDMA PaRAM slots */
812 for (i = 1; i < EDMA_MAX_SLOTS; i++) {
813 if (echan->slot[i] >= 0) {
814 edma_free_slot(echan->slot[i]);
815 echan->slot[i] = -1;
816 }
817 }
818
819 /* Free EDMA channel */
820 if (echan->alloced) {
821 edma_free_channel(echan->ch_num);
822 echan->alloced = false;
823 }
824
Ezequiel Garcia0e772c62013-12-13 11:06:18 -0300825 dev_dbg(dev, "freeing channel for %u\n", echan->ch_num);
Matt Porterc2dde5f2012-08-22 21:09:34 -0400826}
827
828/* Send pending descriptor to hardware */
829static void edma_issue_pending(struct dma_chan *chan)
830{
831 struct edma_chan *echan = to_edma_chan(chan);
832 unsigned long flags;
833
834 spin_lock_irqsave(&echan->vchan.lock, flags);
835 if (vchan_issue_pending(&echan->vchan) && !echan->edesc)
836 edma_execute(echan);
837 spin_unlock_irqrestore(&echan->vchan.lock, flags);
838}
839
Matt Porterc2dde5f2012-08-22 21:09:34 -0400840/* Check request completion status */
841static enum dma_status edma_tx_status(struct dma_chan *chan,
842 dma_cookie_t cookie,
843 struct dma_tx_state *txstate)
844{
845 struct edma_chan *echan = to_edma_chan(chan);
846 struct virt_dma_desc *vdesc;
847 enum dma_status ret;
848 unsigned long flags;
849
850 ret = dma_cookie_status(chan, cookie, txstate);
Vinod Koul9d386ec2013-10-16 13:42:15 +0530851 if (ret == DMA_COMPLETE || !txstate)
Matt Porterc2dde5f2012-08-22 21:09:34 -0400852 return ret;
853
854 spin_lock_irqsave(&echan->vchan.lock, flags);
Thomas Gleixnerde135932014-04-28 14:19:51 -0500855 if (echan->edesc && echan->edesc->vdesc.tx.cookie == cookie)
Thomas Gleixnerb6205c32014-04-28 14:18:45 -0500856 txstate->residue = echan->edesc->residue;
Thomas Gleixnerde135932014-04-28 14:19:51 -0500857 else if ((vdesc = vchan_find_desc(&echan->vchan, cookie)))
858 txstate->residue = to_edma_desc(&vdesc->tx)->residue;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400859 spin_unlock_irqrestore(&echan->vchan.lock, flags);
860
861 return ret;
862}
863
864static void __init edma_chan_init(struct edma_cc *ecc,
865 struct dma_device *dma,
866 struct edma_chan *echans)
867{
868 int i, j;
869
870 for (i = 0; i < EDMA_CHANS; i++) {
871 struct edma_chan *echan = &echans[i];
872 echan->ch_num = EDMA_CTLR_CHAN(ecc->ctlr, i);
873 echan->ecc = ecc;
874 echan->vchan.desc_free = edma_desc_free;
875
876 vchan_init(&echan->vchan, dma);
877
878 INIT_LIST_HEAD(&echan->node);
879 for (j = 0; j < EDMA_MAX_SLOTS; j++)
880 echan->slot[j] = -1;
881 }
882}
883
Peter Ujfalusi2c88ee62014-04-14 14:42:01 +0300884#define EDMA_DMA_BUSWIDTHS (BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \
885 BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \
886 BIT(DMA_SLAVE_BUSWIDTH_4_BYTES))
887
888static int edma_dma_device_slave_caps(struct dma_chan *dchan,
889 struct dma_slave_caps *caps)
890{
891 caps->src_addr_widths = EDMA_DMA_BUSWIDTHS;
892 caps->dstn_addr_widths = EDMA_DMA_BUSWIDTHS;
893 caps->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
894 caps->cmd_pause = true;
895 caps->cmd_terminate = true;
896 caps->residue_granularity = DMA_RESIDUE_GRANULARITY_DESCRIPTOR;
897
898 return 0;
899}
900
Matt Porterc2dde5f2012-08-22 21:09:34 -0400901static void edma_dma_init(struct edma_cc *ecc, struct dma_device *dma,
902 struct device *dev)
903{
904 dma->device_prep_slave_sg = edma_prep_slave_sg;
Joel Fernandes50a9c702013-10-31 16:31:23 -0500905 dma->device_prep_dma_cyclic = edma_prep_dma_cyclic;
Joel Fernandes8cc3e302014-04-18 21:50:33 -0500906 dma->device_prep_dma_memcpy = edma_prep_dma_memcpy;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400907 dma->device_alloc_chan_resources = edma_alloc_chan_resources;
908 dma->device_free_chan_resources = edma_free_chan_resources;
909 dma->device_issue_pending = edma_issue_pending;
910 dma->device_tx_status = edma_tx_status;
911 dma->device_control = edma_control;
Peter Ujfalusi2c88ee62014-04-14 14:42:01 +0300912 dma->device_slave_caps = edma_dma_device_slave_caps;
Matt Porterc2dde5f2012-08-22 21:09:34 -0400913 dma->dev = dev;
914
Joel Fernandes8cc3e302014-04-18 21:50:33 -0500915 /*
916 * code using dma memcpy must make sure alignment of
917 * length is at dma->copy_align boundary.
918 */
919 dma->copy_align = DMA_SLAVE_BUSWIDTH_4_BYTES;
920
Matt Porterc2dde5f2012-08-22 21:09:34 -0400921 INIT_LIST_HEAD(&dma->channels);
922}
923
Bill Pemberton463a1f82012-11-19 13:22:55 -0500924static int edma_probe(struct platform_device *pdev)
Matt Porterc2dde5f2012-08-22 21:09:34 -0400925{
926 struct edma_cc *ecc;
927 int ret;
928
Russell King94cb0e72013-06-27 13:45:16 +0100929 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
930 if (ret)
931 return ret;
932
Matt Porterc2dde5f2012-08-22 21:09:34 -0400933 ecc = devm_kzalloc(&pdev->dev, sizeof(*ecc), GFP_KERNEL);
934 if (!ecc) {
935 dev_err(&pdev->dev, "Can't allocate controller\n");
936 return -ENOMEM;
937 }
938
939 ecc->ctlr = pdev->id;
940 ecc->dummy_slot = edma_alloc_slot(ecc->ctlr, EDMA_SLOT_ANY);
941 if (ecc->dummy_slot < 0) {
942 dev_err(&pdev->dev, "Can't allocate PaRAM dummy slot\n");
943 return -EIO;
944 }
945
946 dma_cap_zero(ecc->dma_slave.cap_mask);
947 dma_cap_set(DMA_SLAVE, ecc->dma_slave.cap_mask);
Peter Ujfalusi232b223d2014-04-14 14:42:00 +0300948 dma_cap_set(DMA_CYCLIC, ecc->dma_slave.cap_mask);
Joel Fernandes8cc3e302014-04-18 21:50:33 -0500949 dma_cap_set(DMA_MEMCPY, ecc->dma_slave.cap_mask);
Matt Porterc2dde5f2012-08-22 21:09:34 -0400950
951 edma_dma_init(ecc, &ecc->dma_slave, &pdev->dev);
952
953 edma_chan_init(ecc, &ecc->dma_slave, ecc->slave_chans);
954
955 ret = dma_async_device_register(&ecc->dma_slave);
956 if (ret)
957 goto err_reg1;
958
959 platform_set_drvdata(pdev, ecc);
960
961 dev_info(&pdev->dev, "TI EDMA DMA engine driver\n");
962
963 return 0;
964
965err_reg1:
966 edma_free_slot(ecc->dummy_slot);
967 return ret;
968}
969
Greg Kroah-Hartman4bf27b82012-12-21 15:09:59 -0800970static int edma_remove(struct platform_device *pdev)
Matt Porterc2dde5f2012-08-22 21:09:34 -0400971{
972 struct device *dev = &pdev->dev;
973 struct edma_cc *ecc = dev_get_drvdata(dev);
974
975 dma_async_device_unregister(&ecc->dma_slave);
976 edma_free_slot(ecc->dummy_slot);
977
978 return 0;
979}
980
981static struct platform_driver edma_driver = {
982 .probe = edma_probe,
Bill Pembertona7d6e3e2012-11-19 13:20:04 -0500983 .remove = edma_remove,
Matt Porterc2dde5f2012-08-22 21:09:34 -0400984 .driver = {
985 .name = "edma-dma-engine",
986 .owner = THIS_MODULE,
987 },
988};
989
990bool edma_filter_fn(struct dma_chan *chan, void *param)
991{
992 if (chan->device->dev->driver == &edma_driver.driver) {
993 struct edma_chan *echan = to_edma_chan(chan);
994 unsigned ch_req = *(unsigned *)param;
995 return ch_req == echan->ch_num;
996 }
997 return false;
998}
999EXPORT_SYMBOL(edma_filter_fn);
1000
1001static struct platform_device *pdev0, *pdev1;
1002
1003static const struct platform_device_info edma_dev_info0 = {
1004 .name = "edma-dma-engine",
1005 .id = 0,
Russell King94cb0e72013-06-27 13:45:16 +01001006 .dma_mask = DMA_BIT_MASK(32),
Matt Porterc2dde5f2012-08-22 21:09:34 -04001007};
1008
1009static const struct platform_device_info edma_dev_info1 = {
1010 .name = "edma-dma-engine",
1011 .id = 1,
Russell King94cb0e72013-06-27 13:45:16 +01001012 .dma_mask = DMA_BIT_MASK(32),
Matt Porterc2dde5f2012-08-22 21:09:34 -04001013};
1014
1015static int edma_init(void)
1016{
1017 int ret = platform_driver_register(&edma_driver);
1018
1019 if (ret == 0) {
1020 pdev0 = platform_device_register_full(&edma_dev_info0);
1021 if (IS_ERR(pdev0)) {
1022 platform_driver_unregister(&edma_driver);
1023 ret = PTR_ERR(pdev0);
1024 goto out;
1025 }
1026 }
1027
1028 if (EDMA_CTLRS == 2) {
1029 pdev1 = platform_device_register_full(&edma_dev_info1);
1030 if (IS_ERR(pdev1)) {
1031 platform_driver_unregister(&edma_driver);
1032 platform_device_unregister(pdev0);
1033 ret = PTR_ERR(pdev1);
1034 }
Matt Porterc2dde5f2012-08-22 21:09:34 -04001035 }
1036
1037out:
1038 return ret;
1039}
1040subsys_initcall(edma_init);
1041
1042static void __exit edma_exit(void)
1043{
1044 platform_device_unregister(pdev0);
1045 if (pdev1)
1046 platform_device_unregister(pdev1);
1047 platform_driver_unregister(&edma_driver);
1048}
1049module_exit(edma_exit);
1050
Josh Boyerd71505b2013-09-04 10:32:50 -04001051MODULE_AUTHOR("Matt Porter <matt.porter@linaro.org>");
Matt Porterc2dde5f2012-08-22 21:09:34 -04001052MODULE_DESCRIPTION("TI EDMA DMA engine driver");
1053MODULE_LICENSE("GPL v2");