fsldma.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  1. /*
  2. * Freescale MPC85xx, MPC83xx DMA Engine support
  3. *
  4. * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
  5. *
  6. * Author:
  7. * Zhang Wei <wei.zhang@freescale.com>, Jul 2007
  8. * Ebony Zhu <ebony.zhu@freescale.com>, May 2007
  9. *
  10. * Description:
  11. * DMA engine driver for Freescale MPC8540 DMA controller, which is
  12. * also fit for MPC8560, MPC8555, MPC8548, MPC8641, and etc.
  13. * The support for MPC8349 DMA contorller is also added.
  14. *
  15. * This is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. */
  21. #include <linux/init.h>
  22. #include <linux/module.h>
  23. #include <linux/pci.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/dmaengine.h>
  26. #include <linux/delay.h>
  27. #include <linux/dma-mapping.h>
  28. #include <linux/dmapool.h>
  29. #include <linux/of_platform.h>
  30. #include "fsldma.h"
  31. static void dma_init(struct fsl_dma_chan *fsl_chan)
  32. {
  33. /* Reset the channel */
  34. DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, 0, 32);
  35. switch (fsl_chan->feature & FSL_DMA_IP_MASK) {
  36. case FSL_DMA_IP_85XX:
  37. /* Set the channel to below modes:
  38. * EIE - Error interrupt enable
  39. * EOSIE - End of segments interrupt enable (basic mode)
  40. * EOLNIE - End of links interrupt enable
  41. */
  42. DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, FSL_DMA_MR_EIE
  43. | FSL_DMA_MR_EOLNIE | FSL_DMA_MR_EOSIE, 32);
  44. break;
  45. case FSL_DMA_IP_83XX:
  46. /* Set the channel to below modes:
  47. * EOTIE - End-of-transfer interrupt enable
  48. */
  49. DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, FSL_DMA_MR_EOTIE,
  50. 32);
  51. break;
  52. }
  53. }
  54. static void set_sr(struct fsl_dma_chan *fsl_chan, u32 val)
  55. {
  56. DMA_OUT(fsl_chan, &fsl_chan->reg_base->sr, val, 32);
  57. }
  58. static u32 get_sr(struct fsl_dma_chan *fsl_chan)
  59. {
  60. return DMA_IN(fsl_chan, &fsl_chan->reg_base->sr, 32);
  61. }
  62. static void set_desc_cnt(struct fsl_dma_chan *fsl_chan,
  63. struct fsl_dma_ld_hw *hw, u32 count)
  64. {
  65. hw->count = CPU_TO_DMA(fsl_chan, count, 32);
  66. }
  67. static void set_desc_src(struct fsl_dma_chan *fsl_chan,
  68. struct fsl_dma_ld_hw *hw, dma_addr_t src)
  69. {
  70. u64 snoop_bits;
  71. snoop_bits = ((fsl_chan->feature & FSL_DMA_IP_MASK) == FSL_DMA_IP_85XX)
  72. ? ((u64)FSL_DMA_SATR_SREADTYPE_SNOOP_READ << 32) : 0;
  73. hw->src_addr = CPU_TO_DMA(fsl_chan, snoop_bits | src, 64);
  74. }
  75. static void set_desc_dest(struct fsl_dma_chan *fsl_chan,
  76. struct fsl_dma_ld_hw *hw, dma_addr_t dest)
  77. {
  78. u64 snoop_bits;
  79. snoop_bits = ((fsl_chan->feature & FSL_DMA_IP_MASK) == FSL_DMA_IP_85XX)
  80. ? ((u64)FSL_DMA_DATR_DWRITETYPE_SNOOP_WRITE << 32) : 0;
  81. hw->dst_addr = CPU_TO_DMA(fsl_chan, snoop_bits | dest, 64);
  82. }
  83. static void set_desc_next(struct fsl_dma_chan *fsl_chan,
  84. struct fsl_dma_ld_hw *hw, dma_addr_t next)
  85. {
  86. u64 snoop_bits;
  87. snoop_bits = ((fsl_chan->feature & FSL_DMA_IP_MASK) == FSL_DMA_IP_83XX)
  88. ? FSL_DMA_SNEN : 0;
  89. hw->next_ln_addr = CPU_TO_DMA(fsl_chan, snoop_bits | next, 64);
  90. }
  91. static void set_cdar(struct fsl_dma_chan *fsl_chan, dma_addr_t addr)
  92. {
  93. DMA_OUT(fsl_chan, &fsl_chan->reg_base->cdar, addr | FSL_DMA_SNEN, 64);
  94. }
  95. static dma_addr_t get_cdar(struct fsl_dma_chan *fsl_chan)
  96. {
  97. return DMA_IN(fsl_chan, &fsl_chan->reg_base->cdar, 64) & ~FSL_DMA_SNEN;
  98. }
  99. static void set_ndar(struct fsl_dma_chan *fsl_chan, dma_addr_t addr)
  100. {
  101. DMA_OUT(fsl_chan, &fsl_chan->reg_base->ndar, addr, 64);
  102. }
  103. static dma_addr_t get_ndar(struct fsl_dma_chan *fsl_chan)
  104. {
  105. return DMA_IN(fsl_chan, &fsl_chan->reg_base->ndar, 64);
  106. }
  107. static u32 get_bcr(struct fsl_dma_chan *fsl_chan)
  108. {
  109. return DMA_IN(fsl_chan, &fsl_chan->reg_base->bcr, 32);
  110. }
  111. static int dma_is_idle(struct fsl_dma_chan *fsl_chan)
  112. {
  113. u32 sr = get_sr(fsl_chan);
  114. return (!(sr & FSL_DMA_SR_CB)) || (sr & FSL_DMA_SR_CH);
  115. }
  116. static void dma_start(struct fsl_dma_chan *fsl_chan)
  117. {
  118. u32 mr_set = 0;;
  119. if (fsl_chan->feature & FSL_DMA_CHAN_PAUSE_EXT) {
  120. DMA_OUT(fsl_chan, &fsl_chan->reg_base->bcr, 0, 32);
  121. mr_set |= FSL_DMA_MR_EMP_EN;
  122. } else
  123. DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr,
  124. DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32)
  125. & ~FSL_DMA_MR_EMP_EN, 32);
  126. if (fsl_chan->feature & FSL_DMA_CHAN_START_EXT)
  127. mr_set |= FSL_DMA_MR_EMS_EN;
  128. else
  129. mr_set |= FSL_DMA_MR_CS;
  130. DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr,
  131. DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32)
  132. | mr_set, 32);
  133. }
  134. static void dma_halt(struct fsl_dma_chan *fsl_chan)
  135. {
  136. int i = 0;
  137. DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr,
  138. DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) | FSL_DMA_MR_CA,
  139. 32);
  140. DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr,
  141. DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) & ~(FSL_DMA_MR_CS
  142. | FSL_DMA_MR_EMS_EN | FSL_DMA_MR_CA), 32);
  143. while (!dma_is_idle(fsl_chan) && (i++ < 100))
  144. udelay(10);
  145. if (i >= 100 && !dma_is_idle(fsl_chan))
  146. dev_err(fsl_chan->dev, "DMA halt timeout!\n");
  147. }
  148. static void set_ld_eol(struct fsl_dma_chan *fsl_chan,
  149. struct fsl_desc_sw *desc)
  150. {
  151. desc->hw.next_ln_addr = CPU_TO_DMA(fsl_chan,
  152. DMA_TO_CPU(fsl_chan, desc->hw.next_ln_addr, 64) | FSL_DMA_EOL,
  153. 64);
  154. }
  155. static void append_ld_queue(struct fsl_dma_chan *fsl_chan,
  156. struct fsl_desc_sw *new_desc)
  157. {
  158. struct fsl_desc_sw *queue_tail = to_fsl_desc(fsl_chan->ld_queue.prev);
  159. if (list_empty(&fsl_chan->ld_queue))
  160. return;
  161. /* Link to the new descriptor physical address and
  162. * Enable End-of-segment interrupt for
  163. * the last link descriptor.
  164. * (the previous node's next link descriptor)
  165. *
  166. * For FSL_DMA_IP_83xx, the snoop enable bit need be set.
  167. */
  168. queue_tail->hw.next_ln_addr = CPU_TO_DMA(fsl_chan,
  169. new_desc->async_tx.phys | FSL_DMA_EOSIE |
  170. (((fsl_chan->feature & FSL_DMA_IP_MASK)
  171. == FSL_DMA_IP_83XX) ? FSL_DMA_SNEN : 0), 64);
  172. }
  173. /**
  174. * fsl_chan_set_src_loop_size - Set source address hold transfer size
  175. * @fsl_chan : Freescale DMA channel
  176. * @size : Address loop size, 0 for disable loop
  177. *
  178. * The set source address hold transfer size. The source
  179. * address hold or loop transfer size is when the DMA transfer
  180. * data from source address (SA), if the loop size is 4, the DMA will
  181. * read data from SA, SA + 1, SA + 2, SA + 3, then loop back to SA,
  182. * SA + 1 ... and so on.
  183. */
  184. static void fsl_chan_set_src_loop_size(struct fsl_dma_chan *fsl_chan, int size)
  185. {
  186. switch (size) {
  187. case 0:
  188. DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr,
  189. DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) &
  190. (~FSL_DMA_MR_SAHE), 32);
  191. break;
  192. case 1:
  193. case 2:
  194. case 4:
  195. case 8:
  196. DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr,
  197. DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) |
  198. FSL_DMA_MR_SAHE | (__ilog2(size) << 14),
  199. 32);
  200. break;
  201. }
  202. }
  203. /**
  204. * fsl_chan_set_dest_loop_size - Set destination address hold transfer size
  205. * @fsl_chan : Freescale DMA channel
  206. * @size : Address loop size, 0 for disable loop
  207. *
  208. * The set destination address hold transfer size. The destination
  209. * address hold or loop transfer size is when the DMA transfer
  210. * data to destination address (TA), if the loop size is 4, the DMA will
  211. * write data to TA, TA + 1, TA + 2, TA + 3, then loop back to TA,
  212. * TA + 1 ... and so on.
  213. */
  214. static void fsl_chan_set_dest_loop_size(struct fsl_dma_chan *fsl_chan, int size)
  215. {
  216. switch (size) {
  217. case 0:
  218. DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr,
  219. DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) &
  220. (~FSL_DMA_MR_DAHE), 32);
  221. break;
  222. case 1:
  223. case 2:
  224. case 4:
  225. case 8:
  226. DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr,
  227. DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) |
  228. FSL_DMA_MR_DAHE | (__ilog2(size) << 16),
  229. 32);
  230. break;
  231. }
  232. }
  233. /**
  234. * fsl_chan_toggle_ext_pause - Toggle channel external pause status
  235. * @fsl_chan : Freescale DMA channel
  236. * @size : Pause control size, 0 for disable external pause control.
  237. * The maximum is 1024.
  238. *
  239. * The Freescale DMA channel can be controlled by the external
  240. * signal DREQ#. The pause control size is how many bytes are allowed
  241. * to transfer before pausing the channel, after which a new assertion
  242. * of DREQ# resumes channel operation.
  243. */
  244. static void fsl_chan_toggle_ext_pause(struct fsl_dma_chan *fsl_chan, int size)
  245. {
  246. if (size > 1024)
  247. return;
  248. if (size) {
  249. DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr,
  250. DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32)
  251. | ((__ilog2(size) << 24) & 0x0f000000),
  252. 32);
  253. fsl_chan->feature |= FSL_DMA_CHAN_PAUSE_EXT;
  254. } else
  255. fsl_chan->feature &= ~FSL_DMA_CHAN_PAUSE_EXT;
  256. }
  257. /**
  258. * fsl_chan_toggle_ext_start - Toggle channel external start status
  259. * @fsl_chan : Freescale DMA channel
  260. * @enable : 0 is disabled, 1 is enabled.
  261. *
  262. * If enable the external start, the channel can be started by an
  263. * external DMA start pin. So the dma_start() does not start the
  264. * transfer immediately. The DMA channel will wait for the
  265. * control pin asserted.
  266. */
  267. static void fsl_chan_toggle_ext_start(struct fsl_dma_chan *fsl_chan, int enable)
  268. {
  269. if (enable)
  270. fsl_chan->feature |= FSL_DMA_CHAN_START_EXT;
  271. else
  272. fsl_chan->feature &= ~FSL_DMA_CHAN_START_EXT;
  273. }
  274. static dma_cookie_t fsl_dma_tx_submit(struct dma_async_tx_descriptor *tx)
  275. {
  276. struct fsl_desc_sw *desc = tx_to_fsl_desc(tx);
  277. struct fsl_dma_chan *fsl_chan = to_fsl_chan(tx->chan);
  278. unsigned long flags;
  279. dma_cookie_t cookie;
  280. /* cookie increment and adding to ld_queue must be atomic */
  281. spin_lock_irqsave(&fsl_chan->desc_lock, flags);
  282. cookie = fsl_chan->common.cookie;
  283. cookie++;
  284. if (cookie < 0)
  285. cookie = 1;
  286. desc->async_tx.cookie = cookie;
  287. fsl_chan->common.cookie = desc->async_tx.cookie;
  288. append_ld_queue(fsl_chan, desc);
  289. list_splice_init(&desc->async_tx.tx_list, fsl_chan->ld_queue.prev);
  290. spin_unlock_irqrestore(&fsl_chan->desc_lock, flags);
  291. return cookie;
  292. }
  293. /**
  294. * fsl_dma_alloc_descriptor - Allocate descriptor from channel's DMA pool.
  295. * @fsl_chan : Freescale DMA channel
  296. *
  297. * Return - The descriptor allocated. NULL for failed.
  298. */
  299. static struct fsl_desc_sw *fsl_dma_alloc_descriptor(
  300. struct fsl_dma_chan *fsl_chan)
  301. {
  302. dma_addr_t pdesc;
  303. struct fsl_desc_sw *desc_sw;
  304. desc_sw = dma_pool_alloc(fsl_chan->desc_pool, GFP_ATOMIC, &pdesc);
  305. if (desc_sw) {
  306. memset(desc_sw, 0, sizeof(struct fsl_desc_sw));
  307. dma_async_tx_descriptor_init(&desc_sw->async_tx,
  308. &fsl_chan->common);
  309. desc_sw->async_tx.tx_submit = fsl_dma_tx_submit;
  310. INIT_LIST_HEAD(&desc_sw->async_tx.tx_list);
  311. desc_sw->async_tx.phys = pdesc;
  312. }
  313. return desc_sw;
  314. }
  315. /**
  316. * fsl_dma_alloc_chan_resources - Allocate resources for DMA channel.
  317. * @fsl_chan : Freescale DMA channel
  318. *
  319. * This function will create a dma pool for descriptor allocation.
  320. *
  321. * Return - The number of descriptors allocated.
  322. */
  323. static int fsl_dma_alloc_chan_resources(struct dma_chan *chan,
  324. struct dma_client *client)
  325. {
  326. struct fsl_dma_chan *fsl_chan = to_fsl_chan(chan);
  327. LIST_HEAD(tmp_list);
  328. /* We need the descriptor to be aligned to 32bytes
  329. * for meeting FSL DMA specification requirement.
  330. */
  331. fsl_chan->desc_pool = dma_pool_create("fsl_dma_engine_desc_pool",
  332. fsl_chan->dev, sizeof(struct fsl_desc_sw),
  333. 32, 0);
  334. if (!fsl_chan->desc_pool) {
  335. dev_err(fsl_chan->dev, "No memory for channel %d "
  336. "descriptor dma pool.\n", fsl_chan->id);
  337. return 0;
  338. }
  339. return 1;
  340. }
  341. /**
  342. * fsl_dma_free_chan_resources - Free all resources of the channel.
  343. * @fsl_chan : Freescale DMA channel
  344. */
  345. static void fsl_dma_free_chan_resources(struct dma_chan *chan)
  346. {
  347. struct fsl_dma_chan *fsl_chan = to_fsl_chan(chan);
  348. struct fsl_desc_sw *desc, *_desc;
  349. unsigned long flags;
  350. dev_dbg(fsl_chan->dev, "Free all channel resources.\n");
  351. spin_lock_irqsave(&fsl_chan->desc_lock, flags);
  352. list_for_each_entry_safe(desc, _desc, &fsl_chan->ld_queue, node) {
  353. #ifdef FSL_DMA_LD_DEBUG
  354. dev_dbg(fsl_chan->dev,
  355. "LD %p will be released.\n", desc);
  356. #endif
  357. list_del(&desc->node);
  358. /* free link descriptor */
  359. dma_pool_free(fsl_chan->desc_pool, desc, desc->async_tx.phys);
  360. }
  361. spin_unlock_irqrestore(&fsl_chan->desc_lock, flags);
  362. dma_pool_destroy(fsl_chan->desc_pool);
  363. }
  364. static struct dma_async_tx_descriptor *
  365. fsl_dma_prep_interrupt(struct dma_chan *chan, unsigned long flags)
  366. {
  367. struct fsl_dma_chan *fsl_chan;
  368. struct fsl_desc_sw *new;
  369. if (!chan)
  370. return NULL;
  371. fsl_chan = to_fsl_chan(chan);
  372. new = fsl_dma_alloc_descriptor(fsl_chan);
  373. if (!new) {
  374. dev_err(fsl_chan->dev, "No free memory for link descriptor\n");
  375. return NULL;
  376. }
  377. new->async_tx.cookie = -EBUSY;
  378. new->async_tx.flags = flags;
  379. /* Insert the link descriptor to the LD ring */
  380. list_add_tail(&new->node, &new->async_tx.tx_list);
  381. /* Set End-of-link to the last link descriptor of new list*/
  382. set_ld_eol(fsl_chan, new);
  383. return &new->async_tx;
  384. }
  385. static struct dma_async_tx_descriptor *fsl_dma_prep_memcpy(
  386. struct dma_chan *chan, dma_addr_t dma_dest, dma_addr_t dma_src,
  387. size_t len, unsigned long flags)
  388. {
  389. struct fsl_dma_chan *fsl_chan;
  390. struct fsl_desc_sw *first = NULL, *prev = NULL, *new;
  391. size_t copy;
  392. LIST_HEAD(link_chain);
  393. if (!chan)
  394. return NULL;
  395. if (!len)
  396. return NULL;
  397. fsl_chan = to_fsl_chan(chan);
  398. do {
  399. /* Allocate the link descriptor from DMA pool */
  400. new = fsl_dma_alloc_descriptor(fsl_chan);
  401. if (!new) {
  402. dev_err(fsl_chan->dev,
  403. "No free memory for link descriptor\n");
  404. return NULL;
  405. }
  406. #ifdef FSL_DMA_LD_DEBUG
  407. dev_dbg(fsl_chan->dev, "new link desc alloc %p\n", new);
  408. #endif
  409. copy = min(len, (size_t)FSL_DMA_BCR_MAX_CNT);
  410. set_desc_cnt(fsl_chan, &new->hw, copy);
  411. set_desc_src(fsl_chan, &new->hw, dma_src);
  412. set_desc_dest(fsl_chan, &new->hw, dma_dest);
  413. if (!first)
  414. first = new;
  415. else
  416. set_desc_next(fsl_chan, &prev->hw, new->async_tx.phys);
  417. new->async_tx.cookie = 0;
  418. async_tx_ack(&new->async_tx);
  419. prev = new;
  420. len -= copy;
  421. dma_src += copy;
  422. dma_dest += copy;
  423. /* Insert the link descriptor to the LD ring */
  424. list_add_tail(&new->node, &first->async_tx.tx_list);
  425. } while (len);
  426. new->async_tx.flags = flags; /* client is in control of this ack */
  427. new->async_tx.cookie = -EBUSY;
  428. /* Set End-of-link to the last link descriptor of new list*/
  429. set_ld_eol(fsl_chan, new);
  430. return first ? &first->async_tx : NULL;
  431. }
  432. /**
  433. * fsl_dma_update_completed_cookie - Update the completed cookie.
  434. * @fsl_chan : Freescale DMA channel
  435. */
  436. static void fsl_dma_update_completed_cookie(struct fsl_dma_chan *fsl_chan)
  437. {
  438. struct fsl_desc_sw *cur_desc, *desc;
  439. dma_addr_t ld_phy;
  440. ld_phy = get_cdar(fsl_chan) & FSL_DMA_NLDA_MASK;
  441. if (ld_phy) {
  442. cur_desc = NULL;
  443. list_for_each_entry(desc, &fsl_chan->ld_queue, node)
  444. if (desc->async_tx.phys == ld_phy) {
  445. cur_desc = desc;
  446. break;
  447. }
  448. if (cur_desc && cur_desc->async_tx.cookie) {
  449. if (dma_is_idle(fsl_chan))
  450. fsl_chan->completed_cookie =
  451. cur_desc->async_tx.cookie;
  452. else
  453. fsl_chan->completed_cookie =
  454. cur_desc->async_tx.cookie - 1;
  455. }
  456. }
  457. }
  458. /**
  459. * fsl_chan_ld_cleanup - Clean up link descriptors
  460. * @fsl_chan : Freescale DMA channel
  461. *
  462. * This function clean up the ld_queue of DMA channel.
  463. * If 'in_intr' is set, the function will move the link descriptor to
  464. * the recycle list. Otherwise, free it directly.
  465. */
  466. static void fsl_chan_ld_cleanup(struct fsl_dma_chan *fsl_chan)
  467. {
  468. struct fsl_desc_sw *desc, *_desc;
  469. unsigned long flags;
  470. spin_lock_irqsave(&fsl_chan->desc_lock, flags);
  471. dev_dbg(fsl_chan->dev, "chan completed_cookie = %d\n",
  472. fsl_chan->completed_cookie);
  473. list_for_each_entry_safe(desc, _desc, &fsl_chan->ld_queue, node) {
  474. dma_async_tx_callback callback;
  475. void *callback_param;
  476. if (dma_async_is_complete(desc->async_tx.cookie,
  477. fsl_chan->completed_cookie, fsl_chan->common.cookie)
  478. == DMA_IN_PROGRESS)
  479. break;
  480. callback = desc->async_tx.callback;
  481. callback_param = desc->async_tx.callback_param;
  482. /* Remove from ld_queue list */
  483. list_del(&desc->node);
  484. dev_dbg(fsl_chan->dev, "link descriptor %p will be recycle.\n",
  485. desc);
  486. dma_pool_free(fsl_chan->desc_pool, desc, desc->async_tx.phys);
  487. /* Run the link descriptor callback function */
  488. if (callback) {
  489. spin_unlock_irqrestore(&fsl_chan->desc_lock, flags);
  490. dev_dbg(fsl_chan->dev, "link descriptor %p callback\n",
  491. desc);
  492. callback(callback_param);
  493. spin_lock_irqsave(&fsl_chan->desc_lock, flags);
  494. }
  495. }
  496. spin_unlock_irqrestore(&fsl_chan->desc_lock, flags);
  497. }
  498. /**
  499. * fsl_chan_xfer_ld_queue - Transfer link descriptors in channel ld_queue.
  500. * @fsl_chan : Freescale DMA channel
  501. */
  502. static void fsl_chan_xfer_ld_queue(struct fsl_dma_chan *fsl_chan)
  503. {
  504. struct list_head *ld_node;
  505. dma_addr_t next_dest_addr;
  506. unsigned long flags;
  507. if (!dma_is_idle(fsl_chan))
  508. return;
  509. dma_halt(fsl_chan);
  510. /* If there are some link descriptors
  511. * not transfered in queue. We need to start it.
  512. */
  513. spin_lock_irqsave(&fsl_chan->desc_lock, flags);
  514. /* Find the first un-transfer desciptor */
  515. for (ld_node = fsl_chan->ld_queue.next;
  516. (ld_node != &fsl_chan->ld_queue)
  517. && (dma_async_is_complete(
  518. to_fsl_desc(ld_node)->async_tx.cookie,
  519. fsl_chan->completed_cookie,
  520. fsl_chan->common.cookie) == DMA_SUCCESS);
  521. ld_node = ld_node->next);
  522. spin_unlock_irqrestore(&fsl_chan->desc_lock, flags);
  523. if (ld_node != &fsl_chan->ld_queue) {
  524. /* Get the ld start address from ld_queue */
  525. next_dest_addr = to_fsl_desc(ld_node)->async_tx.phys;
  526. dev_dbg(fsl_chan->dev, "xfer LDs staring from %p\n",
  527. (void *)next_dest_addr);
  528. set_cdar(fsl_chan, next_dest_addr);
  529. dma_start(fsl_chan);
  530. } else {
  531. set_cdar(fsl_chan, 0);
  532. set_ndar(fsl_chan, 0);
  533. }
  534. }
  535. /**
  536. * fsl_dma_memcpy_issue_pending - Issue the DMA start command
  537. * @fsl_chan : Freescale DMA channel
  538. */
  539. static void fsl_dma_memcpy_issue_pending(struct dma_chan *chan)
  540. {
  541. struct fsl_dma_chan *fsl_chan = to_fsl_chan(chan);
  542. #ifdef FSL_DMA_LD_DEBUG
  543. struct fsl_desc_sw *ld;
  544. unsigned long flags;
  545. spin_lock_irqsave(&fsl_chan->desc_lock, flags);
  546. if (list_empty(&fsl_chan->ld_queue)) {
  547. spin_unlock_irqrestore(&fsl_chan->desc_lock, flags);
  548. return;
  549. }
  550. dev_dbg(fsl_chan->dev, "--memcpy issue--\n");
  551. list_for_each_entry(ld, &fsl_chan->ld_queue, node) {
  552. int i;
  553. dev_dbg(fsl_chan->dev, "Ch %d, LD %08x\n",
  554. fsl_chan->id, ld->async_tx.phys);
  555. for (i = 0; i < 8; i++)
  556. dev_dbg(fsl_chan->dev, "LD offset %d: %08x\n",
  557. i, *(((u32 *)&ld->hw) + i));
  558. }
  559. dev_dbg(fsl_chan->dev, "----------------\n");
  560. spin_unlock_irqrestore(&fsl_chan->desc_lock, flags);
  561. #endif
  562. fsl_chan_xfer_ld_queue(fsl_chan);
  563. }
  564. /**
  565. * fsl_dma_is_complete - Determine the DMA status
  566. * @fsl_chan : Freescale DMA channel
  567. */
  568. static enum dma_status fsl_dma_is_complete(struct dma_chan *chan,
  569. dma_cookie_t cookie,
  570. dma_cookie_t *done,
  571. dma_cookie_t *used)
  572. {
  573. struct fsl_dma_chan *fsl_chan = to_fsl_chan(chan);
  574. dma_cookie_t last_used;
  575. dma_cookie_t last_complete;
  576. fsl_chan_ld_cleanup(fsl_chan);
  577. last_used = chan->cookie;
  578. last_complete = fsl_chan->completed_cookie;
  579. if (done)
  580. *done = last_complete;
  581. if (used)
  582. *used = last_used;
  583. return dma_async_is_complete(cookie, last_complete, last_used);
  584. }
  585. static irqreturn_t fsl_dma_chan_do_interrupt(int irq, void *data)
  586. {
  587. struct fsl_dma_chan *fsl_chan = (struct fsl_dma_chan *)data;
  588. u32 stat;
  589. int update_cookie = 0;
  590. int xfer_ld_q = 0;
  591. stat = get_sr(fsl_chan);
  592. dev_dbg(fsl_chan->dev, "event: channel %d, stat = 0x%x\n",
  593. fsl_chan->id, stat);
  594. set_sr(fsl_chan, stat); /* Clear the event register */
  595. stat &= ~(FSL_DMA_SR_CB | FSL_DMA_SR_CH);
  596. if (!stat)
  597. return IRQ_NONE;
  598. if (stat & FSL_DMA_SR_TE)
  599. dev_err(fsl_chan->dev, "Transfer Error!\n");
  600. /* Programming Error
  601. * The DMA_INTERRUPT async_tx is a NULL transfer, which will
  602. * triger a PE interrupt.
  603. */
  604. if (stat & FSL_DMA_SR_PE) {
  605. dev_dbg(fsl_chan->dev, "event: Programming Error INT\n");
  606. if (get_bcr(fsl_chan) == 0) {
  607. /* BCR register is 0, this is a DMA_INTERRUPT async_tx.
  608. * Now, update the completed cookie, and continue the
  609. * next uncompleted transfer.
  610. */
  611. update_cookie = 1;
  612. xfer_ld_q = 1;
  613. }
  614. stat &= ~FSL_DMA_SR_PE;
  615. }
  616. /* If the link descriptor segment transfer finishes,
  617. * we will recycle the used descriptor.
  618. */
  619. if (stat & FSL_DMA_SR_EOSI) {
  620. dev_dbg(fsl_chan->dev, "event: End-of-segments INT\n");
  621. dev_dbg(fsl_chan->dev, "event: clndar %p, nlndar %p\n",
  622. (void *)get_cdar(fsl_chan), (void *)get_ndar(fsl_chan));
  623. stat &= ~FSL_DMA_SR_EOSI;
  624. update_cookie = 1;
  625. }
  626. /* For MPC8349, EOCDI event need to update cookie
  627. * and start the next transfer if it exist.
  628. */
  629. if (stat & FSL_DMA_SR_EOCDI) {
  630. dev_dbg(fsl_chan->dev, "event: End-of-Chain link INT\n");
  631. stat &= ~FSL_DMA_SR_EOCDI;
  632. update_cookie = 1;
  633. xfer_ld_q = 1;
  634. }
  635. /* If it current transfer is the end-of-transfer,
  636. * we should clear the Channel Start bit for
  637. * prepare next transfer.
  638. */
  639. if (stat & FSL_DMA_SR_EOLNI) {
  640. dev_dbg(fsl_chan->dev, "event: End-of-link INT\n");
  641. stat &= ~FSL_DMA_SR_EOLNI;
  642. xfer_ld_q = 1;
  643. }
  644. if (update_cookie)
  645. fsl_dma_update_completed_cookie(fsl_chan);
  646. if (xfer_ld_q)
  647. fsl_chan_xfer_ld_queue(fsl_chan);
  648. if (stat)
  649. dev_dbg(fsl_chan->dev, "event: unhandled sr 0x%02x\n",
  650. stat);
  651. dev_dbg(fsl_chan->dev, "event: Exit\n");
  652. tasklet_schedule(&fsl_chan->tasklet);
  653. return IRQ_HANDLED;
  654. }
  655. static irqreturn_t fsl_dma_do_interrupt(int irq, void *data)
  656. {
  657. struct fsl_dma_device *fdev = (struct fsl_dma_device *)data;
  658. u32 gsr;
  659. int ch_nr;
  660. gsr = (fdev->feature & FSL_DMA_BIG_ENDIAN) ? in_be32(fdev->reg_base)
  661. : in_le32(fdev->reg_base);
  662. ch_nr = (32 - ffs(gsr)) / 8;
  663. return fdev->chan[ch_nr] ? fsl_dma_chan_do_interrupt(irq,
  664. fdev->chan[ch_nr]) : IRQ_NONE;
  665. }
  666. static void dma_do_tasklet(unsigned long data)
  667. {
  668. struct fsl_dma_chan *fsl_chan = (struct fsl_dma_chan *)data;
  669. fsl_chan_ld_cleanup(fsl_chan);
  670. }
  671. static void fsl_dma_callback_test(void *param)
  672. {
  673. struct fsl_dma_chan *fsl_chan = param;
  674. if (fsl_chan)
  675. dev_dbg(fsl_chan->dev, "selftest: callback is ok!\n");
  676. }
  677. static int fsl_dma_self_test(struct fsl_dma_chan *fsl_chan)
  678. {
  679. struct dma_chan *chan;
  680. int err = 0;
  681. dma_addr_t dma_dest, dma_src;
  682. dma_cookie_t cookie;
  683. u8 *src, *dest;
  684. int i;
  685. size_t test_size;
  686. struct dma_async_tx_descriptor *tx1, *tx2, *tx3;
  687. test_size = 4096;
  688. src = kmalloc(test_size * 2, GFP_KERNEL);
  689. if (!src) {
  690. dev_err(fsl_chan->dev,
  691. "selftest: Cannot alloc memory for test!\n");
  692. return -ENOMEM;
  693. }
  694. dest = src + test_size;
  695. for (i = 0; i < test_size; i++)
  696. src[i] = (u8) i;
  697. chan = &fsl_chan->common;
  698. if (fsl_dma_alloc_chan_resources(chan, NULL) < 1) {
  699. dev_err(fsl_chan->dev,
  700. "selftest: Cannot alloc resources for DMA\n");
  701. err = -ENODEV;
  702. goto out;
  703. }
  704. /* TX 1 */
  705. dma_src = dma_map_single(fsl_chan->dev, src, test_size / 2,
  706. DMA_TO_DEVICE);
  707. dma_dest = dma_map_single(fsl_chan->dev, dest, test_size / 2,
  708. DMA_FROM_DEVICE);
  709. tx1 = fsl_dma_prep_memcpy(chan, dma_dest, dma_src, test_size / 2, 0);
  710. async_tx_ack(tx1);
  711. cookie = fsl_dma_tx_submit(tx1);
  712. fsl_dma_memcpy_issue_pending(chan);
  713. msleep(2);
  714. if (fsl_dma_is_complete(chan, cookie, NULL, NULL) != DMA_SUCCESS) {
  715. dev_err(fsl_chan->dev, "selftest: Time out!\n");
  716. err = -ENODEV;
  717. goto free_resources;
  718. }
  719. /* Test free and re-alloc channel resources */
  720. fsl_dma_free_chan_resources(chan);
  721. if (fsl_dma_alloc_chan_resources(chan, NULL) < 1) {
  722. dev_err(fsl_chan->dev,
  723. "selftest: Cannot alloc resources for DMA\n");
  724. err = -ENODEV;
  725. goto free_resources;
  726. }
  727. /* Continue to test
  728. * TX 2
  729. */
  730. dma_src = dma_map_single(fsl_chan->dev, src + test_size / 2,
  731. test_size / 4, DMA_TO_DEVICE);
  732. dma_dest = dma_map_single(fsl_chan->dev, dest + test_size / 2,
  733. test_size / 4, DMA_FROM_DEVICE);
  734. tx2 = fsl_dma_prep_memcpy(chan, dma_dest, dma_src, test_size / 4, 0);
  735. async_tx_ack(tx2);
  736. /* TX 3 */
  737. dma_src = dma_map_single(fsl_chan->dev, src + test_size * 3 / 4,
  738. test_size / 4, DMA_TO_DEVICE);
  739. dma_dest = dma_map_single(fsl_chan->dev, dest + test_size * 3 / 4,
  740. test_size / 4, DMA_FROM_DEVICE);
  741. tx3 = fsl_dma_prep_memcpy(chan, dma_dest, dma_src, test_size / 4, 0);
  742. async_tx_ack(tx3);
  743. /* Interrupt tx test */
  744. tx1 = fsl_dma_prep_interrupt(chan, 0);
  745. async_tx_ack(tx1);
  746. cookie = fsl_dma_tx_submit(tx1);
  747. /* Test exchanging the prepared tx sort */
  748. cookie = fsl_dma_tx_submit(tx3);
  749. cookie = fsl_dma_tx_submit(tx2);
  750. if (dma_has_cap(DMA_INTERRUPT, ((struct fsl_dma_device *)
  751. dev_get_drvdata(fsl_chan->dev->parent))->common.cap_mask)) {
  752. tx3->callback = fsl_dma_callback_test;
  753. tx3->callback_param = fsl_chan;
  754. }
  755. fsl_dma_memcpy_issue_pending(chan);
  756. msleep(2);
  757. if (fsl_dma_is_complete(chan, cookie, NULL, NULL) != DMA_SUCCESS) {
  758. dev_err(fsl_chan->dev, "selftest: Time out!\n");
  759. err = -ENODEV;
  760. goto free_resources;
  761. }
  762. err = memcmp(src, dest, test_size);
  763. if (err) {
  764. for (i = 0; (*(src + i) == *(dest + i)) && (i < test_size);
  765. i++);
  766. dev_err(fsl_chan->dev, "selftest: Test failed, data %d/%ld is "
  767. "error! src 0x%x, dest 0x%x\n",
  768. i, (long)test_size, *(src + i), *(dest + i));
  769. }
  770. free_resources:
  771. fsl_dma_free_chan_resources(chan);
  772. out:
  773. kfree(src);
  774. return err;
  775. }
  776. static int __devinit of_fsl_dma_chan_probe(struct of_device *dev,
  777. const struct of_device_id *match)
  778. {
  779. struct fsl_dma_device *fdev;
  780. struct fsl_dma_chan *new_fsl_chan;
  781. int err;
  782. fdev = dev_get_drvdata(dev->dev.parent);
  783. BUG_ON(!fdev);
  784. /* alloc channel */
  785. new_fsl_chan = kzalloc(sizeof(struct fsl_dma_chan), GFP_KERNEL);
  786. if (!new_fsl_chan) {
  787. dev_err(&dev->dev, "No free memory for allocating "
  788. "dma channels!\n");
  789. return -ENOMEM;
  790. }
  791. /* get dma channel register base */
  792. err = of_address_to_resource(dev->node, 0, &new_fsl_chan->reg);
  793. if (err) {
  794. dev_err(&dev->dev, "Can't get %s property 'reg'\n",
  795. dev->node->full_name);
  796. goto err_no_reg;
  797. }
  798. new_fsl_chan->feature = *(u32 *)match->data;
  799. if (!fdev->feature)
  800. fdev->feature = new_fsl_chan->feature;
  801. /* If the DMA device's feature is different than its channels',
  802. * report the bug.
  803. */
  804. WARN_ON(fdev->feature != new_fsl_chan->feature);
  805. new_fsl_chan->dev = &dev->dev;
  806. new_fsl_chan->reg_base = ioremap(new_fsl_chan->reg.start,
  807. new_fsl_chan->reg.end - new_fsl_chan->reg.start + 1);
  808. new_fsl_chan->id = ((new_fsl_chan->reg.start - 0x100) & 0xfff) >> 7;
  809. if (new_fsl_chan->id > FSL_DMA_MAX_CHANS_PER_DEVICE) {
  810. dev_err(&dev->dev, "There is no %d channel!\n",
  811. new_fsl_chan->id);
  812. err = -EINVAL;
  813. goto err_no_chan;
  814. }
  815. fdev->chan[new_fsl_chan->id] = new_fsl_chan;
  816. tasklet_init(&new_fsl_chan->tasklet, dma_do_tasklet,
  817. (unsigned long)new_fsl_chan);
  818. /* Init the channel */
  819. dma_init(new_fsl_chan);
  820. /* Clear cdar registers */
  821. set_cdar(new_fsl_chan, 0);
  822. switch (new_fsl_chan->feature & FSL_DMA_IP_MASK) {
  823. case FSL_DMA_IP_85XX:
  824. new_fsl_chan->toggle_ext_start = fsl_chan_toggle_ext_start;
  825. new_fsl_chan->toggle_ext_pause = fsl_chan_toggle_ext_pause;
  826. case FSL_DMA_IP_83XX:
  827. new_fsl_chan->set_src_loop_size = fsl_chan_set_src_loop_size;
  828. new_fsl_chan->set_dest_loop_size = fsl_chan_set_dest_loop_size;
  829. }
  830. spin_lock_init(&new_fsl_chan->desc_lock);
  831. INIT_LIST_HEAD(&new_fsl_chan->ld_queue);
  832. new_fsl_chan->common.device = &fdev->common;
  833. /* Add the channel to DMA device channel list */
  834. list_add_tail(&new_fsl_chan->common.device_node,
  835. &fdev->common.channels);
  836. fdev->common.chancnt++;
  837. new_fsl_chan->irq = irq_of_parse_and_map(dev->node, 0);
  838. if (new_fsl_chan->irq != NO_IRQ) {
  839. err = request_irq(new_fsl_chan->irq,
  840. &fsl_dma_chan_do_interrupt, IRQF_SHARED,
  841. "fsldma-channel", new_fsl_chan);
  842. if (err) {
  843. dev_err(&dev->dev, "DMA channel %s request_irq error "
  844. "with return %d\n", dev->node->full_name, err);
  845. goto err_no_irq;
  846. }
  847. }
  848. err = fsl_dma_self_test(new_fsl_chan);
  849. if (err)
  850. goto err_self_test;
  851. dev_info(&dev->dev, "#%d (%s), irq %d\n", new_fsl_chan->id,
  852. match->compatible, new_fsl_chan->irq);
  853. return 0;
  854. err_self_test:
  855. free_irq(new_fsl_chan->irq, new_fsl_chan);
  856. err_no_irq:
  857. list_del(&new_fsl_chan->common.device_node);
  858. err_no_chan:
  859. iounmap(new_fsl_chan->reg_base);
  860. err_no_reg:
  861. kfree(new_fsl_chan);
  862. return err;
  863. }
  864. const u32 mpc8540_dma_ip_feature = FSL_DMA_IP_85XX | FSL_DMA_BIG_ENDIAN;
  865. const u32 mpc8349_dma_ip_feature = FSL_DMA_IP_83XX | FSL_DMA_LITTLE_ENDIAN;
  866. static struct of_device_id of_fsl_dma_chan_ids[] = {
  867. {
  868. .compatible = "fsl,eloplus-dma-channel",
  869. .data = (void *)&mpc8540_dma_ip_feature,
  870. },
  871. {
  872. .compatible = "fsl,elo-dma-channel",
  873. .data = (void *)&mpc8349_dma_ip_feature,
  874. },
  875. {}
  876. };
  877. static struct of_platform_driver of_fsl_dma_chan_driver = {
  878. .name = "of-fsl-dma-channel",
  879. .match_table = of_fsl_dma_chan_ids,
  880. .probe = of_fsl_dma_chan_probe,
  881. };
  882. static __init int of_fsl_dma_chan_init(void)
  883. {
  884. return of_register_platform_driver(&of_fsl_dma_chan_driver);
  885. }
  886. static int __devinit of_fsl_dma_probe(struct of_device *dev,
  887. const struct of_device_id *match)
  888. {
  889. int err;
  890. unsigned int irq;
  891. struct fsl_dma_device *fdev;
  892. fdev = kzalloc(sizeof(struct fsl_dma_device), GFP_KERNEL);
  893. if (!fdev) {
  894. dev_err(&dev->dev, "No enough memory for 'priv'\n");
  895. return -ENOMEM;
  896. }
  897. fdev->dev = &dev->dev;
  898. INIT_LIST_HEAD(&fdev->common.channels);
  899. /* get DMA controller register base */
  900. err = of_address_to_resource(dev->node, 0, &fdev->reg);
  901. if (err) {
  902. dev_err(&dev->dev, "Can't get %s property 'reg'\n",
  903. dev->node->full_name);
  904. goto err_no_reg;
  905. }
  906. dev_info(&dev->dev, "Probe the Freescale DMA driver for %s "
  907. "controller at %p...\n",
  908. match->compatible, (void *)fdev->reg.start);
  909. fdev->reg_base = ioremap(fdev->reg.start, fdev->reg.end
  910. - fdev->reg.start + 1);
  911. dma_cap_set(DMA_MEMCPY, fdev->common.cap_mask);
  912. dma_cap_set(DMA_INTERRUPT, fdev->common.cap_mask);
  913. fdev->common.device_alloc_chan_resources = fsl_dma_alloc_chan_resources;
  914. fdev->common.device_free_chan_resources = fsl_dma_free_chan_resources;
  915. fdev->common.device_prep_dma_interrupt = fsl_dma_prep_interrupt;
  916. fdev->common.device_prep_dma_memcpy = fsl_dma_prep_memcpy;
  917. fdev->common.device_is_tx_complete = fsl_dma_is_complete;
  918. fdev->common.device_issue_pending = fsl_dma_memcpy_issue_pending;
  919. fdev->common.dev = &dev->dev;
  920. irq = irq_of_parse_and_map(dev->node, 0);
  921. if (irq != NO_IRQ) {
  922. err = request_irq(irq, &fsl_dma_do_interrupt, IRQF_SHARED,
  923. "fsldma-device", fdev);
  924. if (err) {
  925. dev_err(&dev->dev, "DMA device request_irq error "
  926. "with return %d\n", err);
  927. goto err;
  928. }
  929. }
  930. dev_set_drvdata(&(dev->dev), fdev);
  931. of_platform_bus_probe(dev->node, of_fsl_dma_chan_ids, &dev->dev);
  932. dma_async_device_register(&fdev->common);
  933. return 0;
  934. err:
  935. iounmap(fdev->reg_base);
  936. err_no_reg:
  937. kfree(fdev);
  938. return err;
  939. }
  940. static struct of_device_id of_fsl_dma_ids[] = {
  941. { .compatible = "fsl,eloplus-dma", },
  942. { .compatible = "fsl,elo-dma", },
  943. {}
  944. };
  945. static struct of_platform_driver of_fsl_dma_driver = {
  946. .name = "of-fsl-dma",
  947. .match_table = of_fsl_dma_ids,
  948. .probe = of_fsl_dma_probe,
  949. };
  950. static __init int of_fsl_dma_init(void)
  951. {
  952. return of_register_platform_driver(&of_fsl_dma_driver);
  953. }
  954. subsys_initcall(of_fsl_dma_chan_init);
  955. subsys_initcall(of_fsl_dma_init);