shdma.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209
  1. /*
  2. * Renesas SuperH DMA Engine support
  3. *
  4. * base is drivers/dma/flsdma.c
  5. *
  6. * Copyright (C) 2009 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
  7. * Copyright (C) 2009 Renesas Solutions, Inc. All rights reserved.
  8. * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
  9. *
  10. * This is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * - DMA of SuperH does not have Hardware DMA chain mode.
  16. * - MAX DMA size is 16MB.
  17. *
  18. */
  19. #include <linux/init.h>
  20. #include <linux/module.h>
  21. #include <linux/slab.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/dmaengine.h>
  24. #include <linux/delay.h>
  25. #include <linux/dma-mapping.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/pm_runtime.h>
  28. #include <linux/sh_dma.h>
  29. #include "shdma.h"
  30. /* DMA descriptor control */
  31. enum sh_dmae_desc_status {
  32. DESC_IDLE,
  33. DESC_PREPARED,
  34. DESC_SUBMITTED,
  35. DESC_COMPLETED, /* completed, have to call callback */
  36. DESC_WAITING, /* callback called, waiting for ack / re-submit */
  37. };
  38. #define NR_DESCS_PER_CHANNEL 32
  39. /* Default MEMCPY transfer size = 2^2 = 4 bytes */
  40. #define LOG2_DEFAULT_XFER_SIZE 2
  41. /* A bitmask with bits enough for enum sh_dmae_slave_chan_id */
  42. static unsigned long sh_dmae_slave_used[BITS_TO_LONGS(SH_DMA_SLAVE_NUMBER)];
  43. static void sh_dmae_chan_ld_cleanup(struct sh_dmae_chan *sh_chan, bool all);
  44. static void sh_dmae_writel(struct sh_dmae_chan *sh_dc, u32 data, u32 reg)
  45. {
  46. __raw_writel(data, sh_dc->base + reg / sizeof(u32));
  47. }
  48. static u32 sh_dmae_readl(struct sh_dmae_chan *sh_dc, u32 reg)
  49. {
  50. return __raw_readl(sh_dc->base + reg / sizeof(u32));
  51. }
  52. static u16 dmaor_read(struct sh_dmae_device *shdev)
  53. {
  54. return __raw_readw(shdev->chan_reg + DMAOR / sizeof(u32));
  55. }
  56. static void dmaor_write(struct sh_dmae_device *shdev, u16 data)
  57. {
  58. __raw_writew(data, shdev->chan_reg + DMAOR / sizeof(u32));
  59. }
  60. /*
  61. * Reset DMA controller
  62. *
  63. * SH7780 has two DMAOR register
  64. */
  65. static void sh_dmae_ctl_stop(struct sh_dmae_device *shdev)
  66. {
  67. unsigned short dmaor = dmaor_read(shdev);
  68. dmaor_write(shdev, dmaor & ~(DMAOR_NMIF | DMAOR_AE | DMAOR_DME));
  69. }
  70. static int sh_dmae_rst(struct sh_dmae_device *shdev)
  71. {
  72. unsigned short dmaor;
  73. sh_dmae_ctl_stop(shdev);
  74. dmaor = dmaor_read(shdev) | shdev->pdata->dmaor_init;
  75. dmaor_write(shdev, dmaor);
  76. if (dmaor_read(shdev) & (DMAOR_AE | DMAOR_NMIF)) {
  77. pr_warning("dma-sh: Can't initialize DMAOR.\n");
  78. return -EINVAL;
  79. }
  80. return 0;
  81. }
  82. static bool dmae_is_busy(struct sh_dmae_chan *sh_chan)
  83. {
  84. u32 chcr = sh_dmae_readl(sh_chan, CHCR);
  85. if ((chcr & (CHCR_DE | CHCR_TE)) == CHCR_DE)
  86. return true; /* working */
  87. return false; /* waiting */
  88. }
  89. static unsigned int calc_xmit_shift(struct sh_dmae_chan *sh_chan, u32 chcr)
  90. {
  91. struct sh_dmae_device *shdev = container_of(sh_chan->common.device,
  92. struct sh_dmae_device, common);
  93. struct sh_dmae_pdata *pdata = shdev->pdata;
  94. int cnt = ((chcr & pdata->ts_low_mask) >> pdata->ts_low_shift) |
  95. ((chcr & pdata->ts_high_mask) >> pdata->ts_high_shift);
  96. if (cnt >= pdata->ts_shift_num)
  97. cnt = 0;
  98. return pdata->ts_shift[cnt];
  99. }
  100. static u32 log2size_to_chcr(struct sh_dmae_chan *sh_chan, int l2size)
  101. {
  102. struct sh_dmae_device *shdev = container_of(sh_chan->common.device,
  103. struct sh_dmae_device, common);
  104. struct sh_dmae_pdata *pdata = shdev->pdata;
  105. int i;
  106. for (i = 0; i < pdata->ts_shift_num; i++)
  107. if (pdata->ts_shift[i] == l2size)
  108. break;
  109. if (i == pdata->ts_shift_num)
  110. i = 0;
  111. return ((i << pdata->ts_low_shift) & pdata->ts_low_mask) |
  112. ((i << pdata->ts_high_shift) & pdata->ts_high_mask);
  113. }
  114. static void dmae_set_reg(struct sh_dmae_chan *sh_chan, struct sh_dmae_regs *hw)
  115. {
  116. sh_dmae_writel(sh_chan, hw->sar, SAR);
  117. sh_dmae_writel(sh_chan, hw->dar, DAR);
  118. sh_dmae_writel(sh_chan, hw->tcr >> sh_chan->xmit_shift, TCR);
  119. }
  120. static void dmae_start(struct sh_dmae_chan *sh_chan)
  121. {
  122. u32 chcr = sh_dmae_readl(sh_chan, CHCR);
  123. chcr |= CHCR_DE | CHCR_IE;
  124. sh_dmae_writel(sh_chan, chcr & ~CHCR_TE, CHCR);
  125. }
  126. static void dmae_halt(struct sh_dmae_chan *sh_chan)
  127. {
  128. u32 chcr = sh_dmae_readl(sh_chan, CHCR);
  129. chcr &= ~(CHCR_DE | CHCR_TE | CHCR_IE);
  130. sh_dmae_writel(sh_chan, chcr, CHCR);
  131. }
  132. static void dmae_init(struct sh_dmae_chan *sh_chan)
  133. {
  134. /*
  135. * Default configuration for dual address memory-memory transfer.
  136. * 0x400 represents auto-request.
  137. */
  138. u32 chcr = DM_INC | SM_INC | 0x400 | log2size_to_chcr(sh_chan,
  139. LOG2_DEFAULT_XFER_SIZE);
  140. sh_chan->xmit_shift = calc_xmit_shift(sh_chan, chcr);
  141. sh_dmae_writel(sh_chan, chcr, CHCR);
  142. }
  143. static int dmae_set_chcr(struct sh_dmae_chan *sh_chan, u32 val)
  144. {
  145. /* When DMA was working, can not set data to CHCR */
  146. if (dmae_is_busy(sh_chan))
  147. return -EBUSY;
  148. sh_chan->xmit_shift = calc_xmit_shift(sh_chan, val);
  149. sh_dmae_writel(sh_chan, val, CHCR);
  150. return 0;
  151. }
  152. static int dmae_set_dmars(struct sh_dmae_chan *sh_chan, u16 val)
  153. {
  154. struct sh_dmae_device *shdev = container_of(sh_chan->common.device,
  155. struct sh_dmae_device, common);
  156. struct sh_dmae_pdata *pdata = shdev->pdata;
  157. const struct sh_dmae_channel *chan_pdata = &pdata->channel[sh_chan->id];
  158. u16 __iomem *addr = shdev->dmars + chan_pdata->dmars / sizeof(u16);
  159. int shift = chan_pdata->dmars_bit;
  160. if (dmae_is_busy(sh_chan))
  161. return -EBUSY;
  162. __raw_writew((__raw_readw(addr) & (0xff00 >> shift)) | (val << shift),
  163. addr);
  164. return 0;
  165. }
  166. static dma_cookie_t sh_dmae_tx_submit(struct dma_async_tx_descriptor *tx)
  167. {
  168. struct sh_desc *desc = tx_to_sh_desc(tx), *chunk, *last = desc, *c;
  169. struct sh_dmae_chan *sh_chan = to_sh_chan(tx->chan);
  170. dma_async_tx_callback callback = tx->callback;
  171. dma_cookie_t cookie;
  172. spin_lock_bh(&sh_chan->desc_lock);
  173. cookie = sh_chan->common.cookie;
  174. cookie++;
  175. if (cookie < 0)
  176. cookie = 1;
  177. sh_chan->common.cookie = cookie;
  178. tx->cookie = cookie;
  179. /* Mark all chunks of this descriptor as submitted, move to the queue */
  180. list_for_each_entry_safe(chunk, c, desc->node.prev, node) {
  181. /*
  182. * All chunks are on the global ld_free, so, we have to find
  183. * the end of the chain ourselves
  184. */
  185. if (chunk != desc && (chunk->mark == DESC_IDLE ||
  186. chunk->async_tx.cookie > 0 ||
  187. chunk->async_tx.cookie == -EBUSY ||
  188. &chunk->node == &sh_chan->ld_free))
  189. break;
  190. chunk->mark = DESC_SUBMITTED;
  191. /* Callback goes to the last chunk */
  192. chunk->async_tx.callback = NULL;
  193. chunk->cookie = cookie;
  194. list_move_tail(&chunk->node, &sh_chan->ld_queue);
  195. last = chunk;
  196. }
  197. last->async_tx.callback = callback;
  198. last->async_tx.callback_param = tx->callback_param;
  199. dev_dbg(sh_chan->dev, "submit #%d@%p on %d: %x[%d] -> %x\n",
  200. tx->cookie, &last->async_tx, sh_chan->id,
  201. desc->hw.sar, desc->hw.tcr, desc->hw.dar);
  202. spin_unlock_bh(&sh_chan->desc_lock);
  203. return cookie;
  204. }
  205. /* Called with desc_lock held */
  206. static struct sh_desc *sh_dmae_get_desc(struct sh_dmae_chan *sh_chan)
  207. {
  208. struct sh_desc *desc;
  209. list_for_each_entry(desc, &sh_chan->ld_free, node)
  210. if (desc->mark != DESC_PREPARED) {
  211. BUG_ON(desc->mark != DESC_IDLE);
  212. list_del(&desc->node);
  213. return desc;
  214. }
  215. return NULL;
  216. }
  217. static const struct sh_dmae_slave_config *sh_dmae_find_slave(
  218. struct sh_dmae_chan *sh_chan, struct sh_dmae_slave *param)
  219. {
  220. struct dma_device *dma_dev = sh_chan->common.device;
  221. struct sh_dmae_device *shdev = container_of(dma_dev,
  222. struct sh_dmae_device, common);
  223. struct sh_dmae_pdata *pdata = shdev->pdata;
  224. int i;
  225. if (param->slave_id >= SH_DMA_SLAVE_NUMBER)
  226. return NULL;
  227. for (i = 0; i < pdata->slave_num; i++)
  228. if (pdata->slave[i].slave_id == param->slave_id)
  229. return pdata->slave + i;
  230. return NULL;
  231. }
  232. static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
  233. {
  234. struct sh_dmae_chan *sh_chan = to_sh_chan(chan);
  235. struct sh_desc *desc;
  236. struct sh_dmae_slave *param = chan->private;
  237. int ret;
  238. pm_runtime_get_sync(sh_chan->dev);
  239. /*
  240. * This relies on the guarantee from dmaengine that alloc_chan_resources
  241. * never runs concurrently with itself or free_chan_resources.
  242. */
  243. if (param) {
  244. const struct sh_dmae_slave_config *cfg;
  245. cfg = sh_dmae_find_slave(sh_chan, param);
  246. if (!cfg) {
  247. ret = -EINVAL;
  248. goto efindslave;
  249. }
  250. if (test_and_set_bit(param->slave_id, sh_dmae_slave_used)) {
  251. ret = -EBUSY;
  252. goto etestused;
  253. }
  254. param->config = cfg;
  255. dmae_set_dmars(sh_chan, cfg->mid_rid);
  256. dmae_set_chcr(sh_chan, cfg->chcr);
  257. } else if ((sh_dmae_readl(sh_chan, CHCR) & 0xf00) != 0x400) {
  258. dmae_init(sh_chan);
  259. }
  260. spin_lock_bh(&sh_chan->desc_lock);
  261. while (sh_chan->descs_allocated < NR_DESCS_PER_CHANNEL) {
  262. spin_unlock_bh(&sh_chan->desc_lock);
  263. desc = kzalloc(sizeof(struct sh_desc), GFP_KERNEL);
  264. if (!desc) {
  265. spin_lock_bh(&sh_chan->desc_lock);
  266. break;
  267. }
  268. dma_async_tx_descriptor_init(&desc->async_tx,
  269. &sh_chan->common);
  270. desc->async_tx.tx_submit = sh_dmae_tx_submit;
  271. desc->mark = DESC_IDLE;
  272. spin_lock_bh(&sh_chan->desc_lock);
  273. list_add(&desc->node, &sh_chan->ld_free);
  274. sh_chan->descs_allocated++;
  275. }
  276. spin_unlock_bh(&sh_chan->desc_lock);
  277. if (!sh_chan->descs_allocated) {
  278. ret = -ENOMEM;
  279. goto edescalloc;
  280. }
  281. return sh_chan->descs_allocated;
  282. edescalloc:
  283. if (param)
  284. clear_bit(param->slave_id, sh_dmae_slave_used);
  285. etestused:
  286. efindslave:
  287. pm_runtime_put(sh_chan->dev);
  288. return ret;
  289. }
  290. /*
  291. * sh_dma_free_chan_resources - Free all resources of the channel.
  292. */
  293. static void sh_dmae_free_chan_resources(struct dma_chan *chan)
  294. {
  295. struct sh_dmae_chan *sh_chan = to_sh_chan(chan);
  296. struct sh_desc *desc, *_desc;
  297. LIST_HEAD(list);
  298. int descs = sh_chan->descs_allocated;
  299. dmae_halt(sh_chan);
  300. /* Prepared and not submitted descriptors can still be on the queue */
  301. if (!list_empty(&sh_chan->ld_queue))
  302. sh_dmae_chan_ld_cleanup(sh_chan, true);
  303. if (chan->private) {
  304. /* The caller is holding dma_list_mutex */
  305. struct sh_dmae_slave *param = chan->private;
  306. clear_bit(param->slave_id, sh_dmae_slave_used);
  307. }
  308. spin_lock_bh(&sh_chan->desc_lock);
  309. list_splice_init(&sh_chan->ld_free, &list);
  310. sh_chan->descs_allocated = 0;
  311. spin_unlock_bh(&sh_chan->desc_lock);
  312. if (descs > 0)
  313. pm_runtime_put(sh_chan->dev);
  314. list_for_each_entry_safe(desc, _desc, &list, node)
  315. kfree(desc);
  316. }
  317. /**
  318. * sh_dmae_add_desc - get, set up and return one transfer descriptor
  319. * @sh_chan: DMA channel
  320. * @flags: DMA transfer flags
  321. * @dest: destination DMA address, incremented when direction equals
  322. * DMA_FROM_DEVICE or DMA_BIDIRECTIONAL
  323. * @src: source DMA address, incremented when direction equals
  324. * DMA_TO_DEVICE or DMA_BIDIRECTIONAL
  325. * @len: DMA transfer length
  326. * @first: if NULL, set to the current descriptor and cookie set to -EBUSY
  327. * @direction: needed for slave DMA to decide which address to keep constant,
  328. * equals DMA_BIDIRECTIONAL for MEMCPY
  329. * Returns 0 or an error
  330. * Locks: called with desc_lock held
  331. */
  332. static struct sh_desc *sh_dmae_add_desc(struct sh_dmae_chan *sh_chan,
  333. unsigned long flags, dma_addr_t *dest, dma_addr_t *src, size_t *len,
  334. struct sh_desc **first, enum dma_data_direction direction)
  335. {
  336. struct sh_desc *new;
  337. size_t copy_size;
  338. if (!*len)
  339. return NULL;
  340. /* Allocate the link descriptor from the free list */
  341. new = sh_dmae_get_desc(sh_chan);
  342. if (!new) {
  343. dev_err(sh_chan->dev, "No free link descriptor available\n");
  344. return NULL;
  345. }
  346. copy_size = min(*len, (size_t)SH_DMA_TCR_MAX + 1);
  347. new->hw.sar = *src;
  348. new->hw.dar = *dest;
  349. new->hw.tcr = copy_size;
  350. if (!*first) {
  351. /* First desc */
  352. new->async_tx.cookie = -EBUSY;
  353. *first = new;
  354. } else {
  355. /* Other desc - invisible to the user */
  356. new->async_tx.cookie = -EINVAL;
  357. }
  358. dev_dbg(sh_chan->dev,
  359. "chaining (%u/%u)@%x -> %x with %p, cookie %d, shift %d\n",
  360. copy_size, *len, *src, *dest, &new->async_tx,
  361. new->async_tx.cookie, sh_chan->xmit_shift);
  362. new->mark = DESC_PREPARED;
  363. new->async_tx.flags = flags;
  364. new->direction = direction;
  365. *len -= copy_size;
  366. if (direction == DMA_BIDIRECTIONAL || direction == DMA_TO_DEVICE)
  367. *src += copy_size;
  368. if (direction == DMA_BIDIRECTIONAL || direction == DMA_FROM_DEVICE)
  369. *dest += copy_size;
  370. return new;
  371. }
  372. /*
  373. * sh_dmae_prep_sg - prepare transfer descriptors from an SG list
  374. *
  375. * Common routine for public (MEMCPY) and slave DMA. The MEMCPY case is also
  376. * converted to scatter-gather to guarantee consistent locking and a correct
  377. * list manipulation. For slave DMA direction carries the usual meaning, and,
  378. * logically, the SG list is RAM and the addr variable contains slave address,
  379. * e.g., the FIFO I/O register. For MEMCPY direction equals DMA_BIDIRECTIONAL
  380. * and the SG list contains only one element and points at the source buffer.
  381. */
  382. static struct dma_async_tx_descriptor *sh_dmae_prep_sg(struct sh_dmae_chan *sh_chan,
  383. struct scatterlist *sgl, unsigned int sg_len, dma_addr_t *addr,
  384. enum dma_data_direction direction, unsigned long flags)
  385. {
  386. struct scatterlist *sg;
  387. struct sh_desc *first = NULL, *new = NULL /* compiler... */;
  388. LIST_HEAD(tx_list);
  389. int chunks = 0;
  390. int i;
  391. if (!sg_len)
  392. return NULL;
  393. for_each_sg(sgl, sg, sg_len, i)
  394. chunks += (sg_dma_len(sg) + SH_DMA_TCR_MAX) /
  395. (SH_DMA_TCR_MAX + 1);
  396. /* Have to lock the whole loop to protect against concurrent release */
  397. spin_lock_bh(&sh_chan->desc_lock);
  398. /*
  399. * Chaining:
  400. * first descriptor is what user is dealing with in all API calls, its
  401. * cookie is at first set to -EBUSY, at tx-submit to a positive
  402. * number
  403. * if more than one chunk is needed further chunks have cookie = -EINVAL
  404. * the last chunk, if not equal to the first, has cookie = -ENOSPC
  405. * all chunks are linked onto the tx_list head with their .node heads
  406. * only during this function, then they are immediately spliced
  407. * back onto the free list in form of a chain
  408. */
  409. for_each_sg(sgl, sg, sg_len, i) {
  410. dma_addr_t sg_addr = sg_dma_address(sg);
  411. size_t len = sg_dma_len(sg);
  412. if (!len)
  413. goto err_get_desc;
  414. do {
  415. dev_dbg(sh_chan->dev, "Add SG #%d@%p[%d], dma %llx\n",
  416. i, sg, len, (unsigned long long)sg_addr);
  417. if (direction == DMA_FROM_DEVICE)
  418. new = sh_dmae_add_desc(sh_chan, flags,
  419. &sg_addr, addr, &len, &first,
  420. direction);
  421. else
  422. new = sh_dmae_add_desc(sh_chan, flags,
  423. addr, &sg_addr, &len, &first,
  424. direction);
  425. if (!new)
  426. goto err_get_desc;
  427. new->chunks = chunks--;
  428. list_add_tail(&new->node, &tx_list);
  429. } while (len);
  430. }
  431. if (new != first)
  432. new->async_tx.cookie = -ENOSPC;
  433. /* Put them back on the free list, so, they don't get lost */
  434. list_splice_tail(&tx_list, &sh_chan->ld_free);
  435. spin_unlock_bh(&sh_chan->desc_lock);
  436. return &first->async_tx;
  437. err_get_desc:
  438. list_for_each_entry(new, &tx_list, node)
  439. new->mark = DESC_IDLE;
  440. list_splice(&tx_list, &sh_chan->ld_free);
  441. spin_unlock_bh(&sh_chan->desc_lock);
  442. return NULL;
  443. }
  444. static struct dma_async_tx_descriptor *sh_dmae_prep_memcpy(
  445. struct dma_chan *chan, dma_addr_t dma_dest, dma_addr_t dma_src,
  446. size_t len, unsigned long flags)
  447. {
  448. struct sh_dmae_chan *sh_chan;
  449. struct scatterlist sg;
  450. if (!chan || !len)
  451. return NULL;
  452. chan->private = NULL;
  453. sh_chan = to_sh_chan(chan);
  454. sg_init_table(&sg, 1);
  455. sg_set_page(&sg, pfn_to_page(PFN_DOWN(dma_src)), len,
  456. offset_in_page(dma_src));
  457. sg_dma_address(&sg) = dma_src;
  458. sg_dma_len(&sg) = len;
  459. return sh_dmae_prep_sg(sh_chan, &sg, 1, &dma_dest, DMA_BIDIRECTIONAL,
  460. flags);
  461. }
  462. static struct dma_async_tx_descriptor *sh_dmae_prep_slave_sg(
  463. struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len,
  464. enum dma_data_direction direction, unsigned long flags)
  465. {
  466. struct sh_dmae_slave *param;
  467. struct sh_dmae_chan *sh_chan;
  468. dma_addr_t slave_addr;
  469. if (!chan)
  470. return NULL;
  471. sh_chan = to_sh_chan(chan);
  472. param = chan->private;
  473. slave_addr = param->config->addr;
  474. /* Someone calling slave DMA on a public channel? */
  475. if (!param || !sg_len) {
  476. dev_warn(sh_chan->dev, "%s: bad parameter: %p, %d, %d\n",
  477. __func__, param, sg_len, param ? param->slave_id : -1);
  478. return NULL;
  479. }
  480. /*
  481. * if (param != NULL), this is a successfully requested slave channel,
  482. * therefore param->config != NULL too.
  483. */
  484. return sh_dmae_prep_sg(sh_chan, sgl, sg_len, &slave_addr,
  485. direction, flags);
  486. }
  487. static int sh_dmae_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
  488. unsigned long arg)
  489. {
  490. struct sh_dmae_chan *sh_chan = to_sh_chan(chan);
  491. /* Only supports DMA_TERMINATE_ALL */
  492. if (cmd != DMA_TERMINATE_ALL)
  493. return -ENXIO;
  494. if (!chan)
  495. return -EINVAL;
  496. dmae_halt(sh_chan);
  497. spin_lock_bh(&sh_chan->desc_lock);
  498. if (!list_empty(&sh_chan->ld_queue)) {
  499. /* Record partial transfer */
  500. struct sh_desc *desc = list_entry(sh_chan->ld_queue.next,
  501. struct sh_desc, node);
  502. desc->partial = (desc->hw.tcr - sh_dmae_readl(sh_chan, TCR)) <<
  503. sh_chan->xmit_shift;
  504. }
  505. spin_unlock_bh(&sh_chan->desc_lock);
  506. sh_dmae_chan_ld_cleanup(sh_chan, true);
  507. return 0;
  508. }
  509. static dma_async_tx_callback __ld_cleanup(struct sh_dmae_chan *sh_chan, bool all)
  510. {
  511. struct sh_desc *desc, *_desc;
  512. /* Is the "exposed" head of a chain acked? */
  513. bool head_acked = false;
  514. dma_cookie_t cookie = 0;
  515. dma_async_tx_callback callback = NULL;
  516. void *param = NULL;
  517. spin_lock_bh(&sh_chan->desc_lock);
  518. list_for_each_entry_safe(desc, _desc, &sh_chan->ld_queue, node) {
  519. struct dma_async_tx_descriptor *tx = &desc->async_tx;
  520. BUG_ON(tx->cookie > 0 && tx->cookie != desc->cookie);
  521. BUG_ON(desc->mark != DESC_SUBMITTED &&
  522. desc->mark != DESC_COMPLETED &&
  523. desc->mark != DESC_WAITING);
  524. /*
  525. * queue is ordered, and we use this loop to (1) clean up all
  526. * completed descriptors, and to (2) update descriptor flags of
  527. * any chunks in a (partially) completed chain
  528. */
  529. if (!all && desc->mark == DESC_SUBMITTED &&
  530. desc->cookie != cookie)
  531. break;
  532. if (tx->cookie > 0)
  533. cookie = tx->cookie;
  534. if (desc->mark == DESC_COMPLETED && desc->chunks == 1) {
  535. if (sh_chan->completed_cookie != desc->cookie - 1)
  536. dev_dbg(sh_chan->dev,
  537. "Completing cookie %d, expected %d\n",
  538. desc->cookie,
  539. sh_chan->completed_cookie + 1);
  540. sh_chan->completed_cookie = desc->cookie;
  541. }
  542. /* Call callback on the last chunk */
  543. if (desc->mark == DESC_COMPLETED && tx->callback) {
  544. desc->mark = DESC_WAITING;
  545. callback = tx->callback;
  546. param = tx->callback_param;
  547. dev_dbg(sh_chan->dev, "descriptor #%d@%p on %d callback\n",
  548. tx->cookie, tx, sh_chan->id);
  549. BUG_ON(desc->chunks != 1);
  550. break;
  551. }
  552. if (tx->cookie > 0 || tx->cookie == -EBUSY) {
  553. if (desc->mark == DESC_COMPLETED) {
  554. BUG_ON(tx->cookie < 0);
  555. desc->mark = DESC_WAITING;
  556. }
  557. head_acked = async_tx_test_ack(tx);
  558. } else {
  559. switch (desc->mark) {
  560. case DESC_COMPLETED:
  561. desc->mark = DESC_WAITING;
  562. /* Fall through */
  563. case DESC_WAITING:
  564. if (head_acked)
  565. async_tx_ack(&desc->async_tx);
  566. }
  567. }
  568. dev_dbg(sh_chan->dev, "descriptor %p #%d completed.\n",
  569. tx, tx->cookie);
  570. if (((desc->mark == DESC_COMPLETED ||
  571. desc->mark == DESC_WAITING) &&
  572. async_tx_test_ack(&desc->async_tx)) || all) {
  573. /* Remove from ld_queue list */
  574. desc->mark = DESC_IDLE;
  575. list_move(&desc->node, &sh_chan->ld_free);
  576. }
  577. }
  578. spin_unlock_bh(&sh_chan->desc_lock);
  579. if (callback)
  580. callback(param);
  581. return callback;
  582. }
  583. /*
  584. * sh_chan_ld_cleanup - Clean up link descriptors
  585. *
  586. * This function cleans up the ld_queue of DMA channel.
  587. */
  588. static void sh_dmae_chan_ld_cleanup(struct sh_dmae_chan *sh_chan, bool all)
  589. {
  590. while (__ld_cleanup(sh_chan, all))
  591. ;
  592. }
  593. static void sh_chan_xfer_ld_queue(struct sh_dmae_chan *sh_chan)
  594. {
  595. struct sh_desc *desc;
  596. spin_lock_bh(&sh_chan->desc_lock);
  597. /* DMA work check */
  598. if (dmae_is_busy(sh_chan)) {
  599. spin_unlock_bh(&sh_chan->desc_lock);
  600. return;
  601. }
  602. /* Find the first not transferred desciptor */
  603. list_for_each_entry(desc, &sh_chan->ld_queue, node)
  604. if (desc->mark == DESC_SUBMITTED) {
  605. dev_dbg(sh_chan->dev, "Queue #%d to %d: %u@%x -> %x\n",
  606. desc->async_tx.cookie, sh_chan->id,
  607. desc->hw.tcr, desc->hw.sar, desc->hw.dar);
  608. /* Get the ld start address from ld_queue */
  609. dmae_set_reg(sh_chan, &desc->hw);
  610. dmae_start(sh_chan);
  611. break;
  612. }
  613. spin_unlock_bh(&sh_chan->desc_lock);
  614. }
  615. static void sh_dmae_memcpy_issue_pending(struct dma_chan *chan)
  616. {
  617. struct sh_dmae_chan *sh_chan = to_sh_chan(chan);
  618. sh_chan_xfer_ld_queue(sh_chan);
  619. }
  620. static enum dma_status sh_dmae_tx_status(struct dma_chan *chan,
  621. dma_cookie_t cookie,
  622. struct dma_tx_state *txstate)
  623. {
  624. struct sh_dmae_chan *sh_chan = to_sh_chan(chan);
  625. dma_cookie_t last_used;
  626. dma_cookie_t last_complete;
  627. enum dma_status status;
  628. sh_dmae_chan_ld_cleanup(sh_chan, false);
  629. last_used = chan->cookie;
  630. last_complete = sh_chan->completed_cookie;
  631. BUG_ON(last_complete < 0);
  632. dma_set_tx_state(txstate, last_complete, last_used, 0);
  633. spin_lock_bh(&sh_chan->desc_lock);
  634. status = dma_async_is_complete(cookie, last_complete, last_used);
  635. /*
  636. * If we don't find cookie on the queue, it has been aborted and we have
  637. * to report error
  638. */
  639. if (status != DMA_SUCCESS) {
  640. struct sh_desc *desc;
  641. status = DMA_ERROR;
  642. list_for_each_entry(desc, &sh_chan->ld_queue, node)
  643. if (desc->cookie == cookie) {
  644. status = DMA_IN_PROGRESS;
  645. break;
  646. }
  647. }
  648. spin_unlock_bh(&sh_chan->desc_lock);
  649. return status;
  650. }
  651. static irqreturn_t sh_dmae_interrupt(int irq, void *data)
  652. {
  653. irqreturn_t ret = IRQ_NONE;
  654. struct sh_dmae_chan *sh_chan = (struct sh_dmae_chan *)data;
  655. u32 chcr = sh_dmae_readl(sh_chan, CHCR);
  656. if (chcr & CHCR_TE) {
  657. /* DMA stop */
  658. dmae_halt(sh_chan);
  659. ret = IRQ_HANDLED;
  660. tasklet_schedule(&sh_chan->tasklet);
  661. }
  662. return ret;
  663. }
  664. #if defined(CONFIG_CPU_SH4)
  665. static irqreturn_t sh_dmae_err(int irq, void *data)
  666. {
  667. struct sh_dmae_device *shdev = (struct sh_dmae_device *)data;
  668. int i;
  669. /* halt the dma controller */
  670. sh_dmae_ctl_stop(shdev);
  671. /* We cannot detect, which channel caused the error, have to reset all */
  672. for (i = 0; i < SH_DMAC_MAX_CHANNELS; i++) {
  673. struct sh_dmae_chan *sh_chan = shdev->chan[i];
  674. if (sh_chan) {
  675. struct sh_desc *desc;
  676. /* Stop the channel */
  677. dmae_halt(sh_chan);
  678. /* Complete all */
  679. list_for_each_entry(desc, &sh_chan->ld_queue, node) {
  680. struct dma_async_tx_descriptor *tx = &desc->async_tx;
  681. desc->mark = DESC_IDLE;
  682. if (tx->callback)
  683. tx->callback(tx->callback_param);
  684. }
  685. list_splice_init(&sh_chan->ld_queue, &sh_chan->ld_free);
  686. }
  687. }
  688. sh_dmae_rst(shdev);
  689. return IRQ_HANDLED;
  690. }
  691. #endif
  692. static void dmae_do_tasklet(unsigned long data)
  693. {
  694. struct sh_dmae_chan *sh_chan = (struct sh_dmae_chan *)data;
  695. struct sh_desc *desc;
  696. u32 sar_buf = sh_dmae_readl(sh_chan, SAR);
  697. u32 dar_buf = sh_dmae_readl(sh_chan, DAR);
  698. spin_lock(&sh_chan->desc_lock);
  699. list_for_each_entry(desc, &sh_chan->ld_queue, node) {
  700. if (desc->mark == DESC_SUBMITTED &&
  701. ((desc->direction == DMA_FROM_DEVICE &&
  702. (desc->hw.dar + desc->hw.tcr) == dar_buf) ||
  703. (desc->hw.sar + desc->hw.tcr) == sar_buf)) {
  704. dev_dbg(sh_chan->dev, "done #%d@%p dst %u\n",
  705. desc->async_tx.cookie, &desc->async_tx,
  706. desc->hw.dar);
  707. desc->mark = DESC_COMPLETED;
  708. break;
  709. }
  710. }
  711. spin_unlock(&sh_chan->desc_lock);
  712. /* Next desc */
  713. sh_chan_xfer_ld_queue(sh_chan);
  714. sh_dmae_chan_ld_cleanup(sh_chan, false);
  715. }
  716. static int __devinit sh_dmae_chan_probe(struct sh_dmae_device *shdev, int id,
  717. int irq, unsigned long flags)
  718. {
  719. int err;
  720. const struct sh_dmae_channel *chan_pdata = &shdev->pdata->channel[id];
  721. struct platform_device *pdev = to_platform_device(shdev->common.dev);
  722. struct sh_dmae_chan *new_sh_chan;
  723. /* alloc channel */
  724. new_sh_chan = kzalloc(sizeof(struct sh_dmae_chan), GFP_KERNEL);
  725. if (!new_sh_chan) {
  726. dev_err(shdev->common.dev,
  727. "No free memory for allocating dma channels!\n");
  728. return -ENOMEM;
  729. }
  730. /* copy struct dma_device */
  731. new_sh_chan->common.device = &shdev->common;
  732. new_sh_chan->dev = shdev->common.dev;
  733. new_sh_chan->id = id;
  734. new_sh_chan->irq = irq;
  735. new_sh_chan->base = shdev->chan_reg + chan_pdata->offset / sizeof(u32);
  736. /* Init DMA tasklet */
  737. tasklet_init(&new_sh_chan->tasklet, dmae_do_tasklet,
  738. (unsigned long)new_sh_chan);
  739. /* Init the channel */
  740. dmae_init(new_sh_chan);
  741. spin_lock_init(&new_sh_chan->desc_lock);
  742. /* Init descripter manage list */
  743. INIT_LIST_HEAD(&new_sh_chan->ld_queue);
  744. INIT_LIST_HEAD(&new_sh_chan->ld_free);
  745. /* Add the channel to DMA device channel list */
  746. list_add_tail(&new_sh_chan->common.device_node,
  747. &shdev->common.channels);
  748. shdev->common.chancnt++;
  749. if (pdev->id >= 0)
  750. snprintf(new_sh_chan->dev_id, sizeof(new_sh_chan->dev_id),
  751. "sh-dmae%d.%d", pdev->id, new_sh_chan->id);
  752. else
  753. snprintf(new_sh_chan->dev_id, sizeof(new_sh_chan->dev_id),
  754. "sh-dma%d", new_sh_chan->id);
  755. /* set up channel irq */
  756. err = request_irq(irq, &sh_dmae_interrupt, flags,
  757. new_sh_chan->dev_id, new_sh_chan);
  758. if (err) {
  759. dev_err(shdev->common.dev, "DMA channel %d request_irq error "
  760. "with return %d\n", id, err);
  761. goto err_no_irq;
  762. }
  763. shdev->chan[id] = new_sh_chan;
  764. return 0;
  765. err_no_irq:
  766. /* remove from dmaengine device node */
  767. list_del(&new_sh_chan->common.device_node);
  768. kfree(new_sh_chan);
  769. return err;
  770. }
  771. static void sh_dmae_chan_remove(struct sh_dmae_device *shdev)
  772. {
  773. int i;
  774. for (i = shdev->common.chancnt - 1 ; i >= 0 ; i--) {
  775. if (shdev->chan[i]) {
  776. struct sh_dmae_chan *sh_chan = shdev->chan[i];
  777. free_irq(sh_chan->irq, sh_chan);
  778. list_del(&sh_chan->common.device_node);
  779. kfree(sh_chan);
  780. shdev->chan[i] = NULL;
  781. }
  782. }
  783. shdev->common.chancnt = 0;
  784. }
  785. static int __init sh_dmae_probe(struct platform_device *pdev)
  786. {
  787. struct sh_dmae_pdata *pdata = pdev->dev.platform_data;
  788. unsigned long irqflags = IRQF_DISABLED,
  789. chan_flag[SH_DMAC_MAX_CHANNELS] = {};
  790. int errirq, chan_irq[SH_DMAC_MAX_CHANNELS];
  791. int err, i, irq_cnt = 0, irqres = 0;
  792. struct sh_dmae_device *shdev;
  793. struct resource *chan, *dmars, *errirq_res, *chanirq_res;
  794. /* get platform data */
  795. if (!pdata || !pdata->channel_num)
  796. return -ENODEV;
  797. chan = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  798. /* DMARS area is optional, if absent, this controller cannot do slave DMA */
  799. dmars = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  800. /*
  801. * IRQ resources:
  802. * 1. there always must be at least one IRQ IO-resource. On SH4 it is
  803. * the error IRQ, in which case it is the only IRQ in this resource:
  804. * start == end. If it is the only IRQ resource, all channels also
  805. * use the same IRQ.
  806. * 2. DMA channel IRQ resources can be specified one per resource or in
  807. * ranges (start != end)
  808. * 3. iff all events (channels and, optionally, error) on this
  809. * controller use the same IRQ, only one IRQ resource can be
  810. * specified, otherwise there must be one IRQ per channel, even if
  811. * some of them are equal
  812. * 4. if all IRQs on this controller are equal or if some specific IRQs
  813. * specify IORESOURCE_IRQ_SHAREABLE in their resources, they will be
  814. * requested with the IRQF_SHARED flag
  815. */
  816. errirq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  817. if (!chan || !errirq_res)
  818. return -ENODEV;
  819. if (!request_mem_region(chan->start, resource_size(chan), pdev->name)) {
  820. dev_err(&pdev->dev, "DMAC register region already claimed\n");
  821. return -EBUSY;
  822. }
  823. if (dmars && !request_mem_region(dmars->start, resource_size(dmars), pdev->name)) {
  824. dev_err(&pdev->dev, "DMAC DMARS region already claimed\n");
  825. err = -EBUSY;
  826. goto ermrdmars;
  827. }
  828. err = -ENOMEM;
  829. shdev = kzalloc(sizeof(struct sh_dmae_device), GFP_KERNEL);
  830. if (!shdev) {
  831. dev_err(&pdev->dev, "Not enough memory\n");
  832. goto ealloc;
  833. }
  834. shdev->chan_reg = ioremap(chan->start, resource_size(chan));
  835. if (!shdev->chan_reg)
  836. goto emapchan;
  837. if (dmars) {
  838. shdev->dmars = ioremap(dmars->start, resource_size(dmars));
  839. if (!shdev->dmars)
  840. goto emapdmars;
  841. }
  842. /* platform data */
  843. shdev->pdata = pdata;
  844. pm_runtime_enable(&pdev->dev);
  845. pm_runtime_get_sync(&pdev->dev);
  846. /* reset dma controller */
  847. err = sh_dmae_rst(shdev);
  848. if (err)
  849. goto rst_err;
  850. INIT_LIST_HEAD(&shdev->common.channels);
  851. dma_cap_set(DMA_MEMCPY, shdev->common.cap_mask);
  852. if (dmars)
  853. dma_cap_set(DMA_SLAVE, shdev->common.cap_mask);
  854. shdev->common.device_alloc_chan_resources
  855. = sh_dmae_alloc_chan_resources;
  856. shdev->common.device_free_chan_resources = sh_dmae_free_chan_resources;
  857. shdev->common.device_prep_dma_memcpy = sh_dmae_prep_memcpy;
  858. shdev->common.device_tx_status = sh_dmae_tx_status;
  859. shdev->common.device_issue_pending = sh_dmae_memcpy_issue_pending;
  860. /* Compulsory for DMA_SLAVE fields */
  861. shdev->common.device_prep_slave_sg = sh_dmae_prep_slave_sg;
  862. shdev->common.device_control = sh_dmae_control;
  863. shdev->common.dev = &pdev->dev;
  864. /* Default transfer size of 32 bytes requires 32-byte alignment */
  865. shdev->common.copy_align = LOG2_DEFAULT_XFER_SIZE;
  866. #if defined(CONFIG_CPU_SH4)
  867. chanirq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
  868. if (!chanirq_res)
  869. chanirq_res = errirq_res;
  870. else
  871. irqres++;
  872. if (chanirq_res == errirq_res ||
  873. (errirq_res->flags & IORESOURCE_BITS) == IORESOURCE_IRQ_SHAREABLE)
  874. irqflags = IRQF_SHARED;
  875. errirq = errirq_res->start;
  876. err = request_irq(errirq, sh_dmae_err, irqflags,
  877. "DMAC Address Error", shdev);
  878. if (err) {
  879. dev_err(&pdev->dev,
  880. "DMA failed requesting irq #%d, error %d\n",
  881. errirq, err);
  882. goto eirq_err;
  883. }
  884. #else
  885. chanirq_res = errirq_res;
  886. #endif /* CONFIG_CPU_SH4 */
  887. if (chanirq_res->start == chanirq_res->end &&
  888. !platform_get_resource(pdev, IORESOURCE_IRQ, 1)) {
  889. /* Special case - all multiplexed */
  890. for (; irq_cnt < pdata->channel_num; irq_cnt++) {
  891. chan_irq[irq_cnt] = chanirq_res->start;
  892. chan_flag[irq_cnt] = IRQF_SHARED;
  893. }
  894. } else {
  895. do {
  896. for (i = chanirq_res->start; i <= chanirq_res->end; i++) {
  897. if ((errirq_res->flags & IORESOURCE_BITS) ==
  898. IORESOURCE_IRQ_SHAREABLE)
  899. chan_flag[irq_cnt] = IRQF_SHARED;
  900. else
  901. chan_flag[irq_cnt] = IRQF_DISABLED;
  902. dev_dbg(&pdev->dev,
  903. "Found IRQ %d for channel %d\n",
  904. i, irq_cnt);
  905. chan_irq[irq_cnt++] = i;
  906. }
  907. chanirq_res = platform_get_resource(pdev,
  908. IORESOURCE_IRQ, ++irqres);
  909. } while (irq_cnt < pdata->channel_num && chanirq_res);
  910. }
  911. if (irq_cnt < pdata->channel_num)
  912. goto eirqres;
  913. /* Create DMA Channel */
  914. for (i = 0; i < pdata->channel_num; i++) {
  915. err = sh_dmae_chan_probe(shdev, i, chan_irq[i], chan_flag[i]);
  916. if (err)
  917. goto chan_probe_err;
  918. }
  919. pm_runtime_put(&pdev->dev);
  920. platform_set_drvdata(pdev, shdev);
  921. dma_async_device_register(&shdev->common);
  922. return err;
  923. chan_probe_err:
  924. sh_dmae_chan_remove(shdev);
  925. eirqres:
  926. #if defined(CONFIG_CPU_SH4)
  927. free_irq(errirq, shdev);
  928. eirq_err:
  929. #endif
  930. rst_err:
  931. pm_runtime_put(&pdev->dev);
  932. if (dmars)
  933. iounmap(shdev->dmars);
  934. emapdmars:
  935. iounmap(shdev->chan_reg);
  936. emapchan:
  937. kfree(shdev);
  938. ealloc:
  939. if (dmars)
  940. release_mem_region(dmars->start, resource_size(dmars));
  941. ermrdmars:
  942. release_mem_region(chan->start, resource_size(chan));
  943. return err;
  944. }
  945. static int __exit sh_dmae_remove(struct platform_device *pdev)
  946. {
  947. struct sh_dmae_device *shdev = platform_get_drvdata(pdev);
  948. struct resource *res;
  949. int errirq = platform_get_irq(pdev, 0);
  950. dma_async_device_unregister(&shdev->common);
  951. if (errirq > 0)
  952. free_irq(errirq, shdev);
  953. /* channel data remove */
  954. sh_dmae_chan_remove(shdev);
  955. pm_runtime_disable(&pdev->dev);
  956. if (shdev->dmars)
  957. iounmap(shdev->dmars);
  958. iounmap(shdev->chan_reg);
  959. kfree(shdev);
  960. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  961. if (res)
  962. release_mem_region(res->start, resource_size(res));
  963. res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  964. if (res)
  965. release_mem_region(res->start, resource_size(res));
  966. return 0;
  967. }
  968. static void sh_dmae_shutdown(struct platform_device *pdev)
  969. {
  970. struct sh_dmae_device *shdev = platform_get_drvdata(pdev);
  971. sh_dmae_ctl_stop(shdev);
  972. }
  973. static struct platform_driver sh_dmae_driver = {
  974. .remove = __exit_p(sh_dmae_remove),
  975. .shutdown = sh_dmae_shutdown,
  976. .driver = {
  977. .name = "sh-dma-engine",
  978. },
  979. };
  980. static int __init sh_dmae_init(void)
  981. {
  982. return platform_driver_probe(&sh_dmae_driver, sh_dmae_probe);
  983. }
  984. module_init(sh_dmae_init);
  985. static void __exit sh_dmae_exit(void)
  986. {
  987. platform_driver_unregister(&sh_dmae_driver);
  988. }
  989. module_exit(sh_dmae_exit);
  990. MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>");
  991. MODULE_DESCRIPTION("Renesas SH DMA Engine driver");
  992. MODULE_LICENSE("GPL");