edma.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. /*
  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. #include <linux/dmaengine.h>
  16. #include <linux/dma-mapping.h>
  17. #include <linux/err.h>
  18. #include <linux/init.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/list.h>
  21. #include <linux/module.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/slab.h>
  24. #include <linux/spinlock.h>
  25. #include <mach/edma.h>
  26. #include "dmaengine.h"
  27. #include "virt-dma.h"
  28. /*
  29. * This will go away when the private EDMA API is folded
  30. * into this driver and the platform device(s) are
  31. * instantiated in the arch code. We can only get away
  32. * with this simplification because DA8XX may not be built
  33. * in the same kernel image with other DaVinci parts. This
  34. * avoids having to sprinkle dmaengine driver platform devices
  35. * and data throughout all the existing board files.
  36. */
  37. #ifdef CONFIG_ARCH_DAVINCI_DA8XX
  38. #define EDMA_CTLRS 2
  39. #define EDMA_CHANS 32
  40. #else
  41. #define EDMA_CTLRS 1
  42. #define EDMA_CHANS 64
  43. #endif /* CONFIG_ARCH_DAVINCI_DA8XX */
  44. /* Max of 16 segments per channel to conserve PaRAM slots */
  45. #define MAX_NR_SG 16
  46. #define EDMA_MAX_SLOTS MAX_NR_SG
  47. #define EDMA_DESCRIPTORS 16
  48. struct edma_desc {
  49. struct virt_dma_desc vdesc;
  50. struct list_head node;
  51. int absync;
  52. int pset_nr;
  53. struct edmacc_param pset[0];
  54. };
  55. struct edma_cc;
  56. struct edma_chan {
  57. struct virt_dma_chan vchan;
  58. struct list_head node;
  59. struct edma_desc *edesc;
  60. struct edma_cc *ecc;
  61. int ch_num;
  62. bool alloced;
  63. int slot[EDMA_MAX_SLOTS];
  64. struct dma_slave_config cfg;
  65. };
  66. struct edma_cc {
  67. int ctlr;
  68. struct dma_device dma_slave;
  69. struct edma_chan slave_chans[EDMA_CHANS];
  70. int num_slave_chans;
  71. int dummy_slot;
  72. };
  73. static inline struct edma_cc *to_edma_cc(struct dma_device *d)
  74. {
  75. return container_of(d, struct edma_cc, dma_slave);
  76. }
  77. static inline struct edma_chan *to_edma_chan(struct dma_chan *c)
  78. {
  79. return container_of(c, struct edma_chan, vchan.chan);
  80. }
  81. static inline struct edma_desc
  82. *to_edma_desc(struct dma_async_tx_descriptor *tx)
  83. {
  84. return container_of(tx, struct edma_desc, vdesc.tx);
  85. }
  86. static void edma_desc_free(struct virt_dma_desc *vdesc)
  87. {
  88. kfree(container_of(vdesc, struct edma_desc, vdesc));
  89. }
  90. /* Dispatch a queued descriptor to the controller (caller holds lock) */
  91. static void edma_execute(struct edma_chan *echan)
  92. {
  93. struct virt_dma_desc *vdesc = vchan_next_desc(&echan->vchan);
  94. struct edma_desc *edesc;
  95. int i;
  96. if (!vdesc) {
  97. echan->edesc = NULL;
  98. return;
  99. }
  100. list_del(&vdesc->node);
  101. echan->edesc = edesc = to_edma_desc(&vdesc->tx);
  102. /* Write descriptor PaRAM set(s) */
  103. for (i = 0; i < edesc->pset_nr; i++) {
  104. edma_write_slot(echan->slot[i], &edesc->pset[i]);
  105. dev_dbg(echan->vchan.chan.device->dev,
  106. "\n pset[%d]:\n"
  107. " chnum\t%d\n"
  108. " slot\t%d\n"
  109. " opt\t%08x\n"
  110. " src\t%08x\n"
  111. " dst\t%08x\n"
  112. " abcnt\t%08x\n"
  113. " ccnt\t%08x\n"
  114. " bidx\t%08x\n"
  115. " cidx\t%08x\n"
  116. " lkrld\t%08x\n",
  117. i, echan->ch_num, echan->slot[i],
  118. edesc->pset[i].opt,
  119. edesc->pset[i].src,
  120. edesc->pset[i].dst,
  121. edesc->pset[i].a_b_cnt,
  122. edesc->pset[i].ccnt,
  123. edesc->pset[i].src_dst_bidx,
  124. edesc->pset[i].src_dst_cidx,
  125. edesc->pset[i].link_bcntrld);
  126. /* Link to the previous slot if not the last set */
  127. if (i != (edesc->pset_nr - 1))
  128. edma_link(echan->slot[i], echan->slot[i+1]);
  129. /* Final pset links to the dummy pset */
  130. else
  131. edma_link(echan->slot[i], echan->ecc->dummy_slot);
  132. }
  133. edma_start(echan->ch_num);
  134. }
  135. static int edma_terminate_all(struct edma_chan *echan)
  136. {
  137. unsigned long flags;
  138. LIST_HEAD(head);
  139. spin_lock_irqsave(&echan->vchan.lock, flags);
  140. /*
  141. * Stop DMA activity: we assume the callback will not be called
  142. * after edma_dma() returns (even if it does, it will see
  143. * echan->edesc is NULL and exit.)
  144. */
  145. if (echan->edesc) {
  146. echan->edesc = NULL;
  147. edma_stop(echan->ch_num);
  148. }
  149. vchan_get_all_descriptors(&echan->vchan, &head);
  150. spin_unlock_irqrestore(&echan->vchan.lock, flags);
  151. vchan_dma_desc_free_list(&echan->vchan, &head);
  152. return 0;
  153. }
  154. static int edma_slave_config(struct edma_chan *echan,
  155. struct dma_slave_config *cfg)
  156. {
  157. if (cfg->src_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES ||
  158. cfg->dst_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES)
  159. return -EINVAL;
  160. memcpy(&echan->cfg, cfg, sizeof(echan->cfg));
  161. return 0;
  162. }
  163. static int edma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
  164. unsigned long arg)
  165. {
  166. int ret = 0;
  167. struct dma_slave_config *config;
  168. struct edma_chan *echan = to_edma_chan(chan);
  169. switch (cmd) {
  170. case DMA_TERMINATE_ALL:
  171. edma_terminate_all(echan);
  172. break;
  173. case DMA_SLAVE_CONFIG:
  174. config = (struct dma_slave_config *)arg;
  175. ret = edma_slave_config(echan, config);
  176. break;
  177. default:
  178. ret = -ENOSYS;
  179. }
  180. return ret;
  181. }
  182. static struct dma_async_tx_descriptor *edma_prep_slave_sg(
  183. struct dma_chan *chan, struct scatterlist *sgl,
  184. unsigned int sg_len, enum dma_transfer_direction direction,
  185. unsigned long tx_flags, void *context)
  186. {
  187. struct edma_chan *echan = to_edma_chan(chan);
  188. struct device *dev = chan->device->dev;
  189. struct edma_desc *edesc;
  190. dma_addr_t dev_addr;
  191. enum dma_slave_buswidth dev_width;
  192. u32 burst;
  193. struct scatterlist *sg;
  194. int i;
  195. int acnt, bcnt, ccnt, src, dst, cidx;
  196. int src_bidx, dst_bidx, src_cidx, dst_cidx;
  197. if (unlikely(!echan || !sgl || !sg_len))
  198. return NULL;
  199. if (direction == DMA_DEV_TO_MEM) {
  200. dev_addr = echan->cfg.src_addr;
  201. dev_width = echan->cfg.src_addr_width;
  202. burst = echan->cfg.src_maxburst;
  203. } else if (direction == DMA_MEM_TO_DEV) {
  204. dev_addr = echan->cfg.dst_addr;
  205. dev_width = echan->cfg.dst_addr_width;
  206. burst = echan->cfg.dst_maxburst;
  207. } else {
  208. dev_err(dev, "%s: bad direction?\n", __func__);
  209. return NULL;
  210. }
  211. if (dev_width == DMA_SLAVE_BUSWIDTH_UNDEFINED) {
  212. dev_err(dev, "Undefined slave buswidth\n");
  213. return NULL;
  214. }
  215. if (sg_len > MAX_NR_SG) {
  216. dev_err(dev, "Exceeded max SG segments %d > %d\n",
  217. sg_len, MAX_NR_SG);
  218. return NULL;
  219. }
  220. edesc = kzalloc(sizeof(*edesc) + sg_len *
  221. sizeof(edesc->pset[0]), GFP_ATOMIC);
  222. if (!edesc) {
  223. dev_dbg(dev, "Failed to allocate a descriptor\n");
  224. return NULL;
  225. }
  226. edesc->pset_nr = sg_len;
  227. for_each_sg(sgl, sg, sg_len, i) {
  228. /* Allocate a PaRAM slot, if needed */
  229. if (echan->slot[i] < 0) {
  230. echan->slot[i] =
  231. edma_alloc_slot(EDMA_CTLR(echan->ch_num),
  232. EDMA_SLOT_ANY);
  233. if (echan->slot[i] < 0) {
  234. dev_err(dev, "Failed to allocate slot\n");
  235. return NULL;
  236. }
  237. }
  238. acnt = dev_width;
  239. /*
  240. * If the maxburst is equal to the fifo width, use
  241. * A-synced transfers. This allows for large contiguous
  242. * buffer transfers using only one PaRAM set.
  243. */
  244. if (burst == 1) {
  245. edesc->absync = false;
  246. ccnt = sg_dma_len(sg) / acnt / (SZ_64K - 1);
  247. bcnt = sg_dma_len(sg) / acnt - ccnt * (SZ_64K - 1);
  248. if (bcnt)
  249. ccnt++;
  250. else
  251. bcnt = SZ_64K - 1;
  252. cidx = acnt;
  253. /*
  254. * If maxburst is greater than the fifo address_width,
  255. * use AB-synced transfers where A count is the fifo
  256. * address_width and B count is the maxburst. In this
  257. * case, we are limited to transfers of C count frames
  258. * of (address_width * maxburst) where C count is limited
  259. * to SZ_64K-1. This places an upper bound on the length
  260. * of an SG segment that can be handled.
  261. */
  262. } else {
  263. edesc->absync = true;
  264. bcnt = burst;
  265. ccnt = sg_dma_len(sg) / (acnt * bcnt);
  266. if (ccnt > (SZ_64K - 1)) {
  267. dev_err(dev, "Exceeded max SG segment size\n");
  268. return NULL;
  269. }
  270. cidx = acnt * bcnt;
  271. }
  272. if (direction == DMA_MEM_TO_DEV) {
  273. src = sg_dma_address(sg);
  274. dst = dev_addr;
  275. src_bidx = acnt;
  276. src_cidx = cidx;
  277. dst_bidx = 0;
  278. dst_cidx = 0;
  279. } else {
  280. src = dev_addr;
  281. dst = sg_dma_address(sg);
  282. src_bidx = 0;
  283. src_cidx = 0;
  284. dst_bidx = acnt;
  285. dst_cidx = cidx;
  286. }
  287. edesc->pset[i].opt = EDMA_TCC(EDMA_CHAN_SLOT(echan->ch_num));
  288. /* Configure A or AB synchronized transfers */
  289. if (edesc->absync)
  290. edesc->pset[i].opt |= SYNCDIM;
  291. /* If this is the last set, enable completion interrupt flag */
  292. if (i == sg_len - 1)
  293. edesc->pset[i].opt |= TCINTEN;
  294. edesc->pset[i].src = src;
  295. edesc->pset[i].dst = dst;
  296. edesc->pset[i].src_dst_bidx = (dst_bidx << 16) | src_bidx;
  297. edesc->pset[i].src_dst_cidx = (dst_cidx << 16) | src_cidx;
  298. edesc->pset[i].a_b_cnt = bcnt << 16 | acnt;
  299. edesc->pset[i].ccnt = ccnt;
  300. edesc->pset[i].link_bcntrld = 0xffffffff;
  301. }
  302. return vchan_tx_prep(&echan->vchan, &edesc->vdesc, tx_flags);
  303. }
  304. static void edma_callback(unsigned ch_num, u16 ch_status, void *data)
  305. {
  306. struct edma_chan *echan = data;
  307. struct device *dev = echan->vchan.chan.device->dev;
  308. struct edma_desc *edesc;
  309. unsigned long flags;
  310. /* Stop the channel */
  311. edma_stop(echan->ch_num);
  312. switch (ch_status) {
  313. case DMA_COMPLETE:
  314. dev_dbg(dev, "transfer complete on channel %d\n", ch_num);
  315. spin_lock_irqsave(&echan->vchan.lock, flags);
  316. edesc = echan->edesc;
  317. if (edesc) {
  318. edma_execute(echan);
  319. vchan_cookie_complete(&edesc->vdesc);
  320. }
  321. spin_unlock_irqrestore(&echan->vchan.lock, flags);
  322. break;
  323. case DMA_CC_ERROR:
  324. dev_dbg(dev, "transfer error on channel %d\n", ch_num);
  325. break;
  326. default:
  327. break;
  328. }
  329. }
  330. /* Alloc channel resources */
  331. static int edma_alloc_chan_resources(struct dma_chan *chan)
  332. {
  333. struct edma_chan *echan = to_edma_chan(chan);
  334. struct device *dev = chan->device->dev;
  335. int ret;
  336. int a_ch_num;
  337. LIST_HEAD(descs);
  338. a_ch_num = edma_alloc_channel(echan->ch_num, edma_callback,
  339. chan, EVENTQ_DEFAULT);
  340. if (a_ch_num < 0) {
  341. ret = -ENODEV;
  342. goto err_no_chan;
  343. }
  344. if (a_ch_num != echan->ch_num) {
  345. dev_err(dev, "failed to allocate requested channel %u:%u\n",
  346. EDMA_CTLR(echan->ch_num),
  347. EDMA_CHAN_SLOT(echan->ch_num));
  348. ret = -ENODEV;
  349. goto err_wrong_chan;
  350. }
  351. echan->alloced = true;
  352. echan->slot[0] = echan->ch_num;
  353. dev_info(dev, "allocated channel for %u:%u\n",
  354. EDMA_CTLR(echan->ch_num), EDMA_CHAN_SLOT(echan->ch_num));
  355. return 0;
  356. err_wrong_chan:
  357. edma_free_channel(a_ch_num);
  358. err_no_chan:
  359. return ret;
  360. }
  361. /* Free channel resources */
  362. static void edma_free_chan_resources(struct dma_chan *chan)
  363. {
  364. struct edma_chan *echan = to_edma_chan(chan);
  365. struct device *dev = chan->device->dev;
  366. int i;
  367. /* Terminate transfers */
  368. edma_stop(echan->ch_num);
  369. vchan_free_chan_resources(&echan->vchan);
  370. /* Free EDMA PaRAM slots */
  371. for (i = 1; i < EDMA_MAX_SLOTS; i++) {
  372. if (echan->slot[i] >= 0) {
  373. edma_free_slot(echan->slot[i]);
  374. echan->slot[i] = -1;
  375. }
  376. }
  377. /* Free EDMA channel */
  378. if (echan->alloced) {
  379. edma_free_channel(echan->ch_num);
  380. echan->alloced = false;
  381. }
  382. dev_info(dev, "freeing channel for %u\n", echan->ch_num);
  383. }
  384. /* Send pending descriptor to hardware */
  385. static void edma_issue_pending(struct dma_chan *chan)
  386. {
  387. struct edma_chan *echan = to_edma_chan(chan);
  388. unsigned long flags;
  389. spin_lock_irqsave(&echan->vchan.lock, flags);
  390. if (vchan_issue_pending(&echan->vchan) && !echan->edesc)
  391. edma_execute(echan);
  392. spin_unlock_irqrestore(&echan->vchan.lock, flags);
  393. }
  394. static size_t edma_desc_size(struct edma_desc *edesc)
  395. {
  396. int i;
  397. size_t size;
  398. if (edesc->absync)
  399. for (size = i = 0; i < edesc->pset_nr; i++)
  400. size += (edesc->pset[i].a_b_cnt & 0xffff) *
  401. (edesc->pset[i].a_b_cnt >> 16) *
  402. edesc->pset[i].ccnt;
  403. else
  404. size = (edesc->pset[0].a_b_cnt & 0xffff) *
  405. (edesc->pset[0].a_b_cnt >> 16) +
  406. (edesc->pset[0].a_b_cnt & 0xffff) *
  407. (SZ_64K - 1) * edesc->pset[0].ccnt;
  408. return size;
  409. }
  410. /* Check request completion status */
  411. static enum dma_status edma_tx_status(struct dma_chan *chan,
  412. dma_cookie_t cookie,
  413. struct dma_tx_state *txstate)
  414. {
  415. struct edma_chan *echan = to_edma_chan(chan);
  416. struct virt_dma_desc *vdesc;
  417. enum dma_status ret;
  418. unsigned long flags;
  419. ret = dma_cookie_status(chan, cookie, txstate);
  420. if (ret == DMA_SUCCESS || !txstate)
  421. return ret;
  422. spin_lock_irqsave(&echan->vchan.lock, flags);
  423. vdesc = vchan_find_desc(&echan->vchan, cookie);
  424. if (vdesc) {
  425. txstate->residue = edma_desc_size(to_edma_desc(&vdesc->tx));
  426. } else if (echan->edesc && echan->edesc->vdesc.tx.cookie == cookie) {
  427. struct edma_desc *edesc = echan->edesc;
  428. txstate->residue = edma_desc_size(edesc);
  429. } else {
  430. txstate->residue = 0;
  431. }
  432. spin_unlock_irqrestore(&echan->vchan.lock, flags);
  433. return ret;
  434. }
  435. static void __init edma_chan_init(struct edma_cc *ecc,
  436. struct dma_device *dma,
  437. struct edma_chan *echans)
  438. {
  439. int i, j;
  440. for (i = 0; i < EDMA_CHANS; i++) {
  441. struct edma_chan *echan = &echans[i];
  442. echan->ch_num = EDMA_CTLR_CHAN(ecc->ctlr, i);
  443. echan->ecc = ecc;
  444. echan->vchan.desc_free = edma_desc_free;
  445. vchan_init(&echan->vchan, dma);
  446. INIT_LIST_HEAD(&echan->node);
  447. for (j = 0; j < EDMA_MAX_SLOTS; j++)
  448. echan->slot[j] = -1;
  449. }
  450. }
  451. static void edma_dma_init(struct edma_cc *ecc, struct dma_device *dma,
  452. struct device *dev)
  453. {
  454. dma->device_prep_slave_sg = edma_prep_slave_sg;
  455. dma->device_alloc_chan_resources = edma_alloc_chan_resources;
  456. dma->device_free_chan_resources = edma_free_chan_resources;
  457. dma->device_issue_pending = edma_issue_pending;
  458. dma->device_tx_status = edma_tx_status;
  459. dma->device_control = edma_control;
  460. dma->dev = dev;
  461. INIT_LIST_HEAD(&dma->channels);
  462. }
  463. static int edma_probe(struct platform_device *pdev)
  464. {
  465. struct edma_cc *ecc;
  466. int ret;
  467. ecc = devm_kzalloc(&pdev->dev, sizeof(*ecc), GFP_KERNEL);
  468. if (!ecc) {
  469. dev_err(&pdev->dev, "Can't allocate controller\n");
  470. return -ENOMEM;
  471. }
  472. ecc->ctlr = pdev->id;
  473. ecc->dummy_slot = edma_alloc_slot(ecc->ctlr, EDMA_SLOT_ANY);
  474. if (ecc->dummy_slot < 0) {
  475. dev_err(&pdev->dev, "Can't allocate PaRAM dummy slot\n");
  476. return -EIO;
  477. }
  478. dma_cap_zero(ecc->dma_slave.cap_mask);
  479. dma_cap_set(DMA_SLAVE, ecc->dma_slave.cap_mask);
  480. edma_dma_init(ecc, &ecc->dma_slave, &pdev->dev);
  481. edma_chan_init(ecc, &ecc->dma_slave, ecc->slave_chans);
  482. ret = dma_async_device_register(&ecc->dma_slave);
  483. if (ret)
  484. goto err_reg1;
  485. platform_set_drvdata(pdev, ecc);
  486. dev_info(&pdev->dev, "TI EDMA DMA engine driver\n");
  487. return 0;
  488. err_reg1:
  489. edma_free_slot(ecc->dummy_slot);
  490. return ret;
  491. }
  492. static int edma_remove(struct platform_device *pdev)
  493. {
  494. struct device *dev = &pdev->dev;
  495. struct edma_cc *ecc = dev_get_drvdata(dev);
  496. dma_async_device_unregister(&ecc->dma_slave);
  497. edma_free_slot(ecc->dummy_slot);
  498. return 0;
  499. }
  500. static struct platform_driver edma_driver = {
  501. .probe = edma_probe,
  502. .remove = edma_remove,
  503. .driver = {
  504. .name = "edma-dma-engine",
  505. .owner = THIS_MODULE,
  506. },
  507. };
  508. bool edma_filter_fn(struct dma_chan *chan, void *param)
  509. {
  510. if (chan->device->dev->driver == &edma_driver.driver) {
  511. struct edma_chan *echan = to_edma_chan(chan);
  512. unsigned ch_req = *(unsigned *)param;
  513. return ch_req == echan->ch_num;
  514. }
  515. return false;
  516. }
  517. EXPORT_SYMBOL(edma_filter_fn);
  518. static struct platform_device *pdev0, *pdev1;
  519. static const struct platform_device_info edma_dev_info0 = {
  520. .name = "edma-dma-engine",
  521. .id = 0,
  522. };
  523. static const struct platform_device_info edma_dev_info1 = {
  524. .name = "edma-dma-engine",
  525. .id = 1,
  526. };
  527. static int edma_init(void)
  528. {
  529. int ret = platform_driver_register(&edma_driver);
  530. if (ret == 0) {
  531. pdev0 = platform_device_register_full(&edma_dev_info0);
  532. if (IS_ERR(pdev0)) {
  533. platform_driver_unregister(&edma_driver);
  534. ret = PTR_ERR(pdev0);
  535. goto out;
  536. }
  537. pdev0->dev.dma_mask = &pdev0->dev.coherent_dma_mask;
  538. pdev0->dev.coherent_dma_mask = DMA_BIT_MASK(32);
  539. }
  540. if (EDMA_CTLRS == 2) {
  541. pdev1 = platform_device_register_full(&edma_dev_info1);
  542. if (IS_ERR(pdev1)) {
  543. platform_driver_unregister(&edma_driver);
  544. platform_device_unregister(pdev0);
  545. ret = PTR_ERR(pdev1);
  546. }
  547. pdev1->dev.dma_mask = &pdev1->dev.coherent_dma_mask;
  548. pdev1->dev.coherent_dma_mask = DMA_BIT_MASK(32);
  549. }
  550. out:
  551. return ret;
  552. }
  553. subsys_initcall(edma_init);
  554. static void __exit edma_exit(void)
  555. {
  556. platform_device_unregister(pdev0);
  557. if (pdev1)
  558. platform_device_unregister(pdev1);
  559. platform_driver_unregister(&edma_driver);
  560. }
  561. module_exit(edma_exit);
  562. MODULE_AUTHOR("Matt Porter <mporter@ti.com>");
  563. MODULE_DESCRIPTION("TI EDMA DMA engine driver");
  564. MODULE_LICENSE("GPL v2");