edma.c 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767
  1. /*
  2. * EDMA3 support for DaVinci
  3. *
  4. * Copyright (C) 2006-2009 Texas Instruments.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20. #include <linux/err.h>
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/module.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/io.h>
  27. #include <linux/slab.h>
  28. #include <linux/edma.h>
  29. #include <linux/err.h>
  30. #include <linux/of_address.h>
  31. #include <linux/of_device.h>
  32. #include <linux/of_dma.h>
  33. #include <linux/of_irq.h>
  34. #include <linux/pm_runtime.h>
  35. #include <linux/platform_data/edma.h>
  36. /* Offsets matching "struct edmacc_param" */
  37. #define PARM_OPT 0x00
  38. #define PARM_SRC 0x04
  39. #define PARM_A_B_CNT 0x08
  40. #define PARM_DST 0x0c
  41. #define PARM_SRC_DST_BIDX 0x10
  42. #define PARM_LINK_BCNTRLD 0x14
  43. #define PARM_SRC_DST_CIDX 0x18
  44. #define PARM_CCNT 0x1c
  45. #define PARM_SIZE 0x20
  46. /* Offsets for EDMA CC global channel registers and their shadows */
  47. #define SH_ER 0x00 /* 64 bits */
  48. #define SH_ECR 0x08 /* 64 bits */
  49. #define SH_ESR 0x10 /* 64 bits */
  50. #define SH_CER 0x18 /* 64 bits */
  51. #define SH_EER 0x20 /* 64 bits */
  52. #define SH_EECR 0x28 /* 64 bits */
  53. #define SH_EESR 0x30 /* 64 bits */
  54. #define SH_SER 0x38 /* 64 bits */
  55. #define SH_SECR 0x40 /* 64 bits */
  56. #define SH_IER 0x50 /* 64 bits */
  57. #define SH_IECR 0x58 /* 64 bits */
  58. #define SH_IESR 0x60 /* 64 bits */
  59. #define SH_IPR 0x68 /* 64 bits */
  60. #define SH_ICR 0x70 /* 64 bits */
  61. #define SH_IEVAL 0x78
  62. #define SH_QER 0x80
  63. #define SH_QEER 0x84
  64. #define SH_QEECR 0x88
  65. #define SH_QEESR 0x8c
  66. #define SH_QSER 0x90
  67. #define SH_QSECR 0x94
  68. #define SH_SIZE 0x200
  69. /* Offsets for EDMA CC global registers */
  70. #define EDMA_REV 0x0000
  71. #define EDMA_CCCFG 0x0004
  72. #define EDMA_QCHMAP 0x0200 /* 8 registers */
  73. #define EDMA_DMAQNUM 0x0240 /* 8 registers (4 on OMAP-L1xx) */
  74. #define EDMA_QDMAQNUM 0x0260
  75. #define EDMA_QUETCMAP 0x0280
  76. #define EDMA_QUEPRI 0x0284
  77. #define EDMA_EMR 0x0300 /* 64 bits */
  78. #define EDMA_EMCR 0x0308 /* 64 bits */
  79. #define EDMA_QEMR 0x0310
  80. #define EDMA_QEMCR 0x0314
  81. #define EDMA_CCERR 0x0318
  82. #define EDMA_CCERRCLR 0x031c
  83. #define EDMA_EEVAL 0x0320
  84. #define EDMA_DRAE 0x0340 /* 4 x 64 bits*/
  85. #define EDMA_QRAE 0x0380 /* 4 registers */
  86. #define EDMA_QUEEVTENTRY 0x0400 /* 2 x 16 registers */
  87. #define EDMA_QSTAT 0x0600 /* 2 registers */
  88. #define EDMA_QWMTHRA 0x0620
  89. #define EDMA_QWMTHRB 0x0624
  90. #define EDMA_CCSTAT 0x0640
  91. #define EDMA_M 0x1000 /* global channel registers */
  92. #define EDMA_ECR 0x1008
  93. #define EDMA_ECRH 0x100C
  94. #define EDMA_SHADOW0 0x2000 /* 4 regions shadowing global channels */
  95. #define EDMA_PARM 0x4000 /* 128 param entries */
  96. #define PARM_OFFSET(param_no) (EDMA_PARM + ((param_no) << 5))
  97. #define EDMA_DCHMAP 0x0100 /* 64 registers */
  98. #define CHMAP_EXIST BIT(24)
  99. #define EDMA_MAX_DMACH 64
  100. #define EDMA_MAX_PARAMENTRY 512
  101. /*****************************************************************************/
  102. static void __iomem *edmacc_regs_base[EDMA_MAX_CC];
  103. static inline unsigned int edma_read(unsigned ctlr, int offset)
  104. {
  105. return (unsigned int)__raw_readl(edmacc_regs_base[ctlr] + offset);
  106. }
  107. static inline void edma_write(unsigned ctlr, int offset, int val)
  108. {
  109. __raw_writel(val, edmacc_regs_base[ctlr] + offset);
  110. }
  111. static inline void edma_modify(unsigned ctlr, int offset, unsigned and,
  112. unsigned or)
  113. {
  114. unsigned val = edma_read(ctlr, offset);
  115. val &= and;
  116. val |= or;
  117. edma_write(ctlr, offset, val);
  118. }
  119. static inline void edma_and(unsigned ctlr, int offset, unsigned and)
  120. {
  121. unsigned val = edma_read(ctlr, offset);
  122. val &= and;
  123. edma_write(ctlr, offset, val);
  124. }
  125. static inline void edma_or(unsigned ctlr, int offset, unsigned or)
  126. {
  127. unsigned val = edma_read(ctlr, offset);
  128. val |= or;
  129. edma_write(ctlr, offset, val);
  130. }
  131. static inline unsigned int edma_read_array(unsigned ctlr, int offset, int i)
  132. {
  133. return edma_read(ctlr, offset + (i << 2));
  134. }
  135. static inline void edma_write_array(unsigned ctlr, int offset, int i,
  136. unsigned val)
  137. {
  138. edma_write(ctlr, offset + (i << 2), val);
  139. }
  140. static inline void edma_modify_array(unsigned ctlr, int offset, int i,
  141. unsigned and, unsigned or)
  142. {
  143. edma_modify(ctlr, offset + (i << 2), and, or);
  144. }
  145. static inline void edma_or_array(unsigned ctlr, int offset, int i, unsigned or)
  146. {
  147. edma_or(ctlr, offset + (i << 2), or);
  148. }
  149. static inline void edma_or_array2(unsigned ctlr, int offset, int i, int j,
  150. unsigned or)
  151. {
  152. edma_or(ctlr, offset + ((i*2 + j) << 2), or);
  153. }
  154. static inline void edma_write_array2(unsigned ctlr, int offset, int i, int j,
  155. unsigned val)
  156. {
  157. edma_write(ctlr, offset + ((i*2 + j) << 2), val);
  158. }
  159. static inline unsigned int edma_shadow0_read(unsigned ctlr, int offset)
  160. {
  161. return edma_read(ctlr, EDMA_SHADOW0 + offset);
  162. }
  163. static inline unsigned int edma_shadow0_read_array(unsigned ctlr, int offset,
  164. int i)
  165. {
  166. return edma_read(ctlr, EDMA_SHADOW0 + offset + (i << 2));
  167. }
  168. static inline void edma_shadow0_write(unsigned ctlr, int offset, unsigned val)
  169. {
  170. edma_write(ctlr, EDMA_SHADOW0 + offset, val);
  171. }
  172. static inline void edma_shadow0_write_array(unsigned ctlr, int offset, int i,
  173. unsigned val)
  174. {
  175. edma_write(ctlr, EDMA_SHADOW0 + offset + (i << 2), val);
  176. }
  177. static inline unsigned int edma_parm_read(unsigned ctlr, int offset,
  178. int param_no)
  179. {
  180. return edma_read(ctlr, EDMA_PARM + offset + (param_no << 5));
  181. }
  182. static inline void edma_parm_write(unsigned ctlr, int offset, int param_no,
  183. unsigned val)
  184. {
  185. edma_write(ctlr, EDMA_PARM + offset + (param_no << 5), val);
  186. }
  187. static inline void edma_parm_modify(unsigned ctlr, int offset, int param_no,
  188. unsigned and, unsigned or)
  189. {
  190. edma_modify(ctlr, EDMA_PARM + offset + (param_no << 5), and, or);
  191. }
  192. static inline void edma_parm_and(unsigned ctlr, int offset, int param_no,
  193. unsigned and)
  194. {
  195. edma_and(ctlr, EDMA_PARM + offset + (param_no << 5), and);
  196. }
  197. static inline void edma_parm_or(unsigned ctlr, int offset, int param_no,
  198. unsigned or)
  199. {
  200. edma_or(ctlr, EDMA_PARM + offset + (param_no << 5), or);
  201. }
  202. static inline void set_bits(int offset, int len, unsigned long *p)
  203. {
  204. for (; len > 0; len--)
  205. set_bit(offset + (len - 1), p);
  206. }
  207. static inline void clear_bits(int offset, int len, unsigned long *p)
  208. {
  209. for (; len > 0; len--)
  210. clear_bit(offset + (len - 1), p);
  211. }
  212. /*****************************************************************************/
  213. /* actual number of DMA channels and slots on this silicon */
  214. struct edma {
  215. /* how many dma resources of each type */
  216. unsigned num_channels;
  217. unsigned num_region;
  218. unsigned num_slots;
  219. unsigned num_tc;
  220. unsigned num_cc;
  221. enum dma_event_q default_queue;
  222. /* list of channels with no even trigger; terminated by "-1" */
  223. const s8 *noevent;
  224. /* The edma_inuse bit for each PaRAM slot is clear unless the
  225. * channel is in use ... by ARM or DSP, for QDMA, or whatever.
  226. */
  227. DECLARE_BITMAP(edma_inuse, EDMA_MAX_PARAMENTRY);
  228. /* The edma_unused bit for each channel is clear unless
  229. * it is not being used on this platform. It uses a bit
  230. * of SOC-specific initialization code.
  231. */
  232. DECLARE_BITMAP(edma_unused, EDMA_MAX_DMACH);
  233. unsigned irq_res_start;
  234. unsigned irq_res_end;
  235. struct dma_interrupt_data {
  236. void (*callback)(unsigned channel, unsigned short ch_status,
  237. void *data);
  238. void *data;
  239. } intr_data[EDMA_MAX_DMACH];
  240. };
  241. static struct edma *edma_cc[EDMA_MAX_CC];
  242. static int arch_num_cc;
  243. /* dummy param set used to (re)initialize parameter RAM slots */
  244. static const struct edmacc_param dummy_paramset = {
  245. .link_bcntrld = 0xffff,
  246. .ccnt = 1,
  247. };
  248. /*****************************************************************************/
  249. static void map_dmach_queue(unsigned ctlr, unsigned ch_no,
  250. enum dma_event_q queue_no)
  251. {
  252. int bit = (ch_no & 0x7) * 4;
  253. /* default to low priority queue */
  254. if (queue_no == EVENTQ_DEFAULT)
  255. queue_no = edma_cc[ctlr]->default_queue;
  256. queue_no &= 7;
  257. edma_modify_array(ctlr, EDMA_DMAQNUM, (ch_no >> 3),
  258. ~(0x7 << bit), queue_no << bit);
  259. }
  260. static void __init map_queue_tc(unsigned ctlr, int queue_no, int tc_no)
  261. {
  262. int bit = queue_no * 4;
  263. edma_modify(ctlr, EDMA_QUETCMAP, ~(0x7 << bit), ((tc_no & 0x7) << bit));
  264. }
  265. static void __init assign_priority_to_queue(unsigned ctlr, int queue_no,
  266. int priority)
  267. {
  268. int bit = queue_no * 4;
  269. edma_modify(ctlr, EDMA_QUEPRI, ~(0x7 << bit),
  270. ((priority & 0x7) << bit));
  271. }
  272. /**
  273. * map_dmach_param - Maps channel number to param entry number
  274. *
  275. * This maps the dma channel number to param entry numberter. In
  276. * other words using the DMA channel mapping registers a param entry
  277. * can be mapped to any channel
  278. *
  279. * Callers are responsible for ensuring the channel mapping logic is
  280. * included in that particular EDMA variant (Eg : dm646x)
  281. *
  282. */
  283. static void __init map_dmach_param(unsigned ctlr)
  284. {
  285. int i;
  286. for (i = 0; i < EDMA_MAX_DMACH; i++)
  287. edma_write_array(ctlr, EDMA_DCHMAP , i , (i << 5));
  288. }
  289. static inline void
  290. setup_dma_interrupt(unsigned lch,
  291. void (*callback)(unsigned channel, u16 ch_status, void *data),
  292. void *data)
  293. {
  294. unsigned ctlr;
  295. ctlr = EDMA_CTLR(lch);
  296. lch = EDMA_CHAN_SLOT(lch);
  297. if (!callback)
  298. edma_shadow0_write_array(ctlr, SH_IECR, lch >> 5,
  299. BIT(lch & 0x1f));
  300. edma_cc[ctlr]->intr_data[lch].callback = callback;
  301. edma_cc[ctlr]->intr_data[lch].data = data;
  302. if (callback) {
  303. edma_shadow0_write_array(ctlr, SH_ICR, lch >> 5,
  304. BIT(lch & 0x1f));
  305. edma_shadow0_write_array(ctlr, SH_IESR, lch >> 5,
  306. BIT(lch & 0x1f));
  307. }
  308. }
  309. static int irq2ctlr(int irq)
  310. {
  311. if (irq >= edma_cc[0]->irq_res_start && irq <= edma_cc[0]->irq_res_end)
  312. return 0;
  313. else if (irq >= edma_cc[1]->irq_res_start &&
  314. irq <= edma_cc[1]->irq_res_end)
  315. return 1;
  316. return -1;
  317. }
  318. /******************************************************************************
  319. *
  320. * DMA interrupt handler
  321. *
  322. *****************************************************************************/
  323. static irqreturn_t dma_irq_handler(int irq, void *data)
  324. {
  325. int ctlr;
  326. u32 sh_ier;
  327. u32 sh_ipr;
  328. u32 bank;
  329. ctlr = irq2ctlr(irq);
  330. if (ctlr < 0)
  331. return IRQ_NONE;
  332. dev_dbg(data, "dma_irq_handler\n");
  333. sh_ipr = edma_shadow0_read_array(ctlr, SH_IPR, 0);
  334. if (!sh_ipr) {
  335. sh_ipr = edma_shadow0_read_array(ctlr, SH_IPR, 1);
  336. if (!sh_ipr)
  337. return IRQ_NONE;
  338. sh_ier = edma_shadow0_read_array(ctlr, SH_IER, 1);
  339. bank = 1;
  340. } else {
  341. sh_ier = edma_shadow0_read_array(ctlr, SH_IER, 0);
  342. bank = 0;
  343. }
  344. do {
  345. u32 slot;
  346. u32 channel;
  347. dev_dbg(data, "IPR%d %08x\n", bank, sh_ipr);
  348. slot = __ffs(sh_ipr);
  349. sh_ipr &= ~(BIT(slot));
  350. if (sh_ier & BIT(slot)) {
  351. channel = (bank << 5) | slot;
  352. /* Clear the corresponding IPR bits */
  353. edma_shadow0_write_array(ctlr, SH_ICR, bank,
  354. BIT(slot));
  355. if (edma_cc[ctlr]->intr_data[channel].callback)
  356. edma_cc[ctlr]->intr_data[channel].callback(
  357. channel, DMA_COMPLETE,
  358. edma_cc[ctlr]->intr_data[channel].data);
  359. }
  360. } while (sh_ipr);
  361. edma_shadow0_write(ctlr, SH_IEVAL, 1);
  362. return IRQ_HANDLED;
  363. }
  364. /******************************************************************************
  365. *
  366. * DMA error interrupt handler
  367. *
  368. *****************************************************************************/
  369. static irqreturn_t dma_ccerr_handler(int irq, void *data)
  370. {
  371. int i;
  372. int ctlr;
  373. unsigned int cnt = 0;
  374. ctlr = irq2ctlr(irq);
  375. if (ctlr < 0)
  376. return IRQ_NONE;
  377. dev_dbg(data, "dma_ccerr_handler\n");
  378. if ((edma_read_array(ctlr, EDMA_EMR, 0) == 0) &&
  379. (edma_read_array(ctlr, EDMA_EMR, 1) == 0) &&
  380. (edma_read(ctlr, EDMA_QEMR) == 0) &&
  381. (edma_read(ctlr, EDMA_CCERR) == 0))
  382. return IRQ_NONE;
  383. while (1) {
  384. int j = -1;
  385. if (edma_read_array(ctlr, EDMA_EMR, 0))
  386. j = 0;
  387. else if (edma_read_array(ctlr, EDMA_EMR, 1))
  388. j = 1;
  389. if (j >= 0) {
  390. dev_dbg(data, "EMR%d %08x\n", j,
  391. edma_read_array(ctlr, EDMA_EMR, j));
  392. for (i = 0; i < 32; i++) {
  393. int k = (j << 5) + i;
  394. if (edma_read_array(ctlr, EDMA_EMR, j) &
  395. BIT(i)) {
  396. /* Clear the corresponding EMR bits */
  397. edma_write_array(ctlr, EDMA_EMCR, j,
  398. BIT(i));
  399. /* Clear any SER */
  400. edma_shadow0_write_array(ctlr, SH_SECR,
  401. j, BIT(i));
  402. if (edma_cc[ctlr]->intr_data[k].
  403. callback) {
  404. edma_cc[ctlr]->intr_data[k].
  405. callback(k,
  406. DMA_CC_ERROR,
  407. edma_cc[ctlr]->intr_data
  408. [k].data);
  409. }
  410. }
  411. }
  412. } else if (edma_read(ctlr, EDMA_QEMR)) {
  413. dev_dbg(data, "QEMR %02x\n",
  414. edma_read(ctlr, EDMA_QEMR));
  415. for (i = 0; i < 8; i++) {
  416. if (edma_read(ctlr, EDMA_QEMR) & BIT(i)) {
  417. /* Clear the corresponding IPR bits */
  418. edma_write(ctlr, EDMA_QEMCR, BIT(i));
  419. edma_shadow0_write(ctlr, SH_QSECR,
  420. BIT(i));
  421. /* NOTE: not reported!! */
  422. }
  423. }
  424. } else if (edma_read(ctlr, EDMA_CCERR)) {
  425. dev_dbg(data, "CCERR %08x\n",
  426. edma_read(ctlr, EDMA_CCERR));
  427. /* FIXME: CCERR.BIT(16) ignored! much better
  428. * to just write CCERRCLR with CCERR value...
  429. */
  430. for (i = 0; i < 8; i++) {
  431. if (edma_read(ctlr, EDMA_CCERR) & BIT(i)) {
  432. /* Clear the corresponding IPR bits */
  433. edma_write(ctlr, EDMA_CCERRCLR, BIT(i));
  434. /* NOTE: not reported!! */
  435. }
  436. }
  437. }
  438. if ((edma_read_array(ctlr, EDMA_EMR, 0) == 0) &&
  439. (edma_read_array(ctlr, EDMA_EMR, 1) == 0) &&
  440. (edma_read(ctlr, EDMA_QEMR) == 0) &&
  441. (edma_read(ctlr, EDMA_CCERR) == 0))
  442. break;
  443. cnt++;
  444. if (cnt > 10)
  445. break;
  446. }
  447. edma_write(ctlr, EDMA_EEVAL, 1);
  448. return IRQ_HANDLED;
  449. }
  450. static int reserve_contiguous_slots(int ctlr, unsigned int id,
  451. unsigned int num_slots,
  452. unsigned int start_slot)
  453. {
  454. int i, j;
  455. unsigned int count = num_slots;
  456. int stop_slot = start_slot;
  457. DECLARE_BITMAP(tmp_inuse, EDMA_MAX_PARAMENTRY);
  458. for (i = start_slot; i < edma_cc[ctlr]->num_slots; ++i) {
  459. j = EDMA_CHAN_SLOT(i);
  460. if (!test_and_set_bit(j, edma_cc[ctlr]->edma_inuse)) {
  461. /* Record our current beginning slot */
  462. if (count == num_slots)
  463. stop_slot = i;
  464. count--;
  465. set_bit(j, tmp_inuse);
  466. if (count == 0)
  467. break;
  468. } else {
  469. clear_bit(j, tmp_inuse);
  470. if (id == EDMA_CONT_PARAMS_FIXED_EXACT) {
  471. stop_slot = i;
  472. break;
  473. } else {
  474. count = num_slots;
  475. }
  476. }
  477. }
  478. /*
  479. * We have to clear any bits that we set
  480. * if we run out parameter RAM slots, i.e we do find a set
  481. * of contiguous parameter RAM slots but do not find the exact number
  482. * requested as we may reach the total number of parameter RAM slots
  483. */
  484. if (i == edma_cc[ctlr]->num_slots)
  485. stop_slot = i;
  486. j = start_slot;
  487. for_each_set_bit_from(j, tmp_inuse, stop_slot)
  488. clear_bit(j, edma_cc[ctlr]->edma_inuse);
  489. if (count)
  490. return -EBUSY;
  491. for (j = i - num_slots + 1; j <= i; ++j)
  492. memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(j),
  493. &dummy_paramset, PARM_SIZE);
  494. return EDMA_CTLR_CHAN(ctlr, i - num_slots + 1);
  495. }
  496. static int prepare_unused_channel_list(struct device *dev, void *data)
  497. {
  498. struct platform_device *pdev = to_platform_device(dev);
  499. int i, ctlr;
  500. for (i = 0; i < pdev->num_resources; i++) {
  501. if ((pdev->resource[i].flags & IORESOURCE_DMA) &&
  502. (int)pdev->resource[i].start >= 0) {
  503. ctlr = EDMA_CTLR(pdev->resource[i].start);
  504. clear_bit(EDMA_CHAN_SLOT(pdev->resource[i].start),
  505. edma_cc[ctlr]->edma_unused);
  506. }
  507. }
  508. return 0;
  509. }
  510. /*-----------------------------------------------------------------------*/
  511. static bool unused_chan_list_done;
  512. /* Resource alloc/free: dma channels, parameter RAM slots */
  513. /**
  514. * edma_alloc_channel - allocate DMA channel and paired parameter RAM
  515. * @channel: specific channel to allocate; negative for "any unmapped channel"
  516. * @callback: optional; to be issued on DMA completion or errors
  517. * @data: passed to callback
  518. * @eventq_no: an EVENTQ_* constant, used to choose which Transfer
  519. * Controller (TC) executes requests using this channel. Use
  520. * EVENTQ_DEFAULT unless you really need a high priority queue.
  521. *
  522. * This allocates a DMA channel and its associated parameter RAM slot.
  523. * The parameter RAM is initialized to hold a dummy transfer.
  524. *
  525. * Normal use is to pass a specific channel number as @channel, to make
  526. * use of hardware events mapped to that channel. When the channel will
  527. * be used only for software triggering or event chaining, channels not
  528. * mapped to hardware events (or mapped to unused events) are preferable.
  529. *
  530. * DMA transfers start from a channel using edma_start(), or by
  531. * chaining. When the transfer described in that channel's parameter RAM
  532. * slot completes, that slot's data may be reloaded through a link.
  533. *
  534. * DMA errors are only reported to the @callback associated with the
  535. * channel driving that transfer, but transfer completion callbacks can
  536. * be sent to another channel under control of the TCC field in
  537. * the option word of the transfer's parameter RAM set. Drivers must not
  538. * use DMA transfer completion callbacks for channels they did not allocate.
  539. * (The same applies to TCC codes used in transfer chaining.)
  540. *
  541. * Returns the number of the channel, else negative errno.
  542. */
  543. int edma_alloc_channel(int channel,
  544. void (*callback)(unsigned channel, u16 ch_status, void *data),
  545. void *data,
  546. enum dma_event_q eventq_no)
  547. {
  548. unsigned i, done = 0, ctlr = 0;
  549. int ret = 0;
  550. if (!unused_chan_list_done) {
  551. /*
  552. * Scan all the platform devices to find out the EDMA channels
  553. * used and clear them in the unused list, making the rest
  554. * available for ARM usage.
  555. */
  556. ret = bus_for_each_dev(&platform_bus_type, NULL, NULL,
  557. prepare_unused_channel_list);
  558. if (ret < 0)
  559. return ret;
  560. unused_chan_list_done = true;
  561. }
  562. if (channel >= 0) {
  563. ctlr = EDMA_CTLR(channel);
  564. channel = EDMA_CHAN_SLOT(channel);
  565. }
  566. if (channel < 0) {
  567. for (i = 0; i < arch_num_cc; i++) {
  568. channel = 0;
  569. for (;;) {
  570. channel = find_next_bit(edma_cc[i]->edma_unused,
  571. edma_cc[i]->num_channels,
  572. channel);
  573. if (channel == edma_cc[i]->num_channels)
  574. break;
  575. if (!test_and_set_bit(channel,
  576. edma_cc[i]->edma_inuse)) {
  577. done = 1;
  578. ctlr = i;
  579. break;
  580. }
  581. channel++;
  582. }
  583. if (done)
  584. break;
  585. }
  586. if (!done)
  587. return -ENOMEM;
  588. } else if (channel >= edma_cc[ctlr]->num_channels) {
  589. return -EINVAL;
  590. } else if (test_and_set_bit(channel, edma_cc[ctlr]->edma_inuse)) {
  591. return -EBUSY;
  592. }
  593. /* ensure access through shadow region 0 */
  594. edma_or_array2(ctlr, EDMA_DRAE, 0, channel >> 5, BIT(channel & 0x1f));
  595. /* ensure no events are pending */
  596. edma_stop(EDMA_CTLR_CHAN(ctlr, channel));
  597. memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(channel),
  598. &dummy_paramset, PARM_SIZE);
  599. if (callback)
  600. setup_dma_interrupt(EDMA_CTLR_CHAN(ctlr, channel),
  601. callback, data);
  602. map_dmach_queue(ctlr, channel, eventq_no);
  603. return EDMA_CTLR_CHAN(ctlr, channel);
  604. }
  605. EXPORT_SYMBOL(edma_alloc_channel);
  606. /**
  607. * edma_free_channel - deallocate DMA channel
  608. * @channel: dma channel returned from edma_alloc_channel()
  609. *
  610. * This deallocates the DMA channel and associated parameter RAM slot
  611. * allocated by edma_alloc_channel().
  612. *
  613. * Callers are responsible for ensuring the channel is inactive, and
  614. * will not be reactivated by linking, chaining, or software calls to
  615. * edma_start().
  616. */
  617. void edma_free_channel(unsigned channel)
  618. {
  619. unsigned ctlr;
  620. ctlr = EDMA_CTLR(channel);
  621. channel = EDMA_CHAN_SLOT(channel);
  622. if (channel >= edma_cc[ctlr]->num_channels)
  623. return;
  624. setup_dma_interrupt(channel, NULL, NULL);
  625. /* REVISIT should probably take out of shadow region 0 */
  626. memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(channel),
  627. &dummy_paramset, PARM_SIZE);
  628. clear_bit(channel, edma_cc[ctlr]->edma_inuse);
  629. }
  630. EXPORT_SYMBOL(edma_free_channel);
  631. /**
  632. * edma_alloc_slot - allocate DMA parameter RAM
  633. * @slot: specific slot to allocate; negative for "any unused slot"
  634. *
  635. * This allocates a parameter RAM slot, initializing it to hold a
  636. * dummy transfer. Slots allocated using this routine have not been
  637. * mapped to a hardware DMA channel, and will normally be used by
  638. * linking to them from a slot associated with a DMA channel.
  639. *
  640. * Normal use is to pass EDMA_SLOT_ANY as the @slot, but specific
  641. * slots may be allocated on behalf of DSP firmware.
  642. *
  643. * Returns the number of the slot, else negative errno.
  644. */
  645. int edma_alloc_slot(unsigned ctlr, int slot)
  646. {
  647. if (!edma_cc[ctlr])
  648. return -EINVAL;
  649. if (slot >= 0)
  650. slot = EDMA_CHAN_SLOT(slot);
  651. if (slot < 0) {
  652. slot = edma_cc[ctlr]->num_channels;
  653. for (;;) {
  654. slot = find_next_zero_bit(edma_cc[ctlr]->edma_inuse,
  655. edma_cc[ctlr]->num_slots, slot);
  656. if (slot == edma_cc[ctlr]->num_slots)
  657. return -ENOMEM;
  658. if (!test_and_set_bit(slot, edma_cc[ctlr]->edma_inuse))
  659. break;
  660. }
  661. } else if (slot < edma_cc[ctlr]->num_channels ||
  662. slot >= edma_cc[ctlr]->num_slots) {
  663. return -EINVAL;
  664. } else if (test_and_set_bit(slot, edma_cc[ctlr]->edma_inuse)) {
  665. return -EBUSY;
  666. }
  667. memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(slot),
  668. &dummy_paramset, PARM_SIZE);
  669. return EDMA_CTLR_CHAN(ctlr, slot);
  670. }
  671. EXPORT_SYMBOL(edma_alloc_slot);
  672. /**
  673. * edma_free_slot - deallocate DMA parameter RAM
  674. * @slot: parameter RAM slot returned from edma_alloc_slot()
  675. *
  676. * This deallocates the parameter RAM slot allocated by edma_alloc_slot().
  677. * Callers are responsible for ensuring the slot is inactive, and will
  678. * not be activated.
  679. */
  680. void edma_free_slot(unsigned slot)
  681. {
  682. unsigned ctlr;
  683. ctlr = EDMA_CTLR(slot);
  684. slot = EDMA_CHAN_SLOT(slot);
  685. if (slot < edma_cc[ctlr]->num_channels ||
  686. slot >= edma_cc[ctlr]->num_slots)
  687. return;
  688. memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(slot),
  689. &dummy_paramset, PARM_SIZE);
  690. clear_bit(slot, edma_cc[ctlr]->edma_inuse);
  691. }
  692. EXPORT_SYMBOL(edma_free_slot);
  693. /**
  694. * edma_alloc_cont_slots- alloc contiguous parameter RAM slots
  695. * The API will return the starting point of a set of
  696. * contiguous parameter RAM slots that have been requested
  697. *
  698. * @id: can only be EDMA_CONT_PARAMS_ANY or EDMA_CONT_PARAMS_FIXED_EXACT
  699. * or EDMA_CONT_PARAMS_FIXED_NOT_EXACT
  700. * @count: number of contiguous Paramter RAM slots
  701. * @slot - the start value of Parameter RAM slot that should be passed if id
  702. * is EDMA_CONT_PARAMS_FIXED_EXACT or EDMA_CONT_PARAMS_FIXED_NOT_EXACT
  703. *
  704. * If id is EDMA_CONT_PARAMS_ANY then the API starts looking for a set of
  705. * contiguous Parameter RAM slots from parameter RAM 64 in the case of
  706. * DaVinci SOCs and 32 in the case of DA8xx SOCs.
  707. *
  708. * If id is EDMA_CONT_PARAMS_FIXED_EXACT then the API starts looking for a
  709. * set of contiguous parameter RAM slots from the "slot" that is passed as an
  710. * argument to the API.
  711. *
  712. * If id is EDMA_CONT_PARAMS_FIXED_NOT_EXACT then the API initially tries
  713. * starts looking for a set of contiguous parameter RAMs from the "slot"
  714. * that is passed as an argument to the API. On failure the API will try to
  715. * find a set of contiguous Parameter RAM slots from the remaining Parameter
  716. * RAM slots
  717. */
  718. int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count)
  719. {
  720. /*
  721. * The start slot requested should be greater than
  722. * the number of channels and lesser than the total number
  723. * of slots
  724. */
  725. if ((id != EDMA_CONT_PARAMS_ANY) &&
  726. (slot < edma_cc[ctlr]->num_channels ||
  727. slot >= edma_cc[ctlr]->num_slots))
  728. return -EINVAL;
  729. /*
  730. * The number of parameter RAM slots requested cannot be less than 1
  731. * and cannot be more than the number of slots minus the number of
  732. * channels
  733. */
  734. if (count < 1 || count >
  735. (edma_cc[ctlr]->num_slots - edma_cc[ctlr]->num_channels))
  736. return -EINVAL;
  737. switch (id) {
  738. case EDMA_CONT_PARAMS_ANY:
  739. return reserve_contiguous_slots(ctlr, id, count,
  740. edma_cc[ctlr]->num_channels);
  741. case EDMA_CONT_PARAMS_FIXED_EXACT:
  742. case EDMA_CONT_PARAMS_FIXED_NOT_EXACT:
  743. return reserve_contiguous_slots(ctlr, id, count, slot);
  744. default:
  745. return -EINVAL;
  746. }
  747. }
  748. EXPORT_SYMBOL(edma_alloc_cont_slots);
  749. /**
  750. * edma_free_cont_slots - deallocate DMA parameter RAM slots
  751. * @slot: first parameter RAM of a set of parameter RAM slots to be freed
  752. * @count: the number of contiguous parameter RAM slots to be freed
  753. *
  754. * This deallocates the parameter RAM slots allocated by
  755. * edma_alloc_cont_slots.
  756. * Callers/applications need to keep track of sets of contiguous
  757. * parameter RAM slots that have been allocated using the edma_alloc_cont_slots
  758. * API.
  759. * Callers are responsible for ensuring the slots are inactive, and will
  760. * not be activated.
  761. */
  762. int edma_free_cont_slots(unsigned slot, int count)
  763. {
  764. unsigned ctlr, slot_to_free;
  765. int i;
  766. ctlr = EDMA_CTLR(slot);
  767. slot = EDMA_CHAN_SLOT(slot);
  768. if (slot < edma_cc[ctlr]->num_channels ||
  769. slot >= edma_cc[ctlr]->num_slots ||
  770. count < 1)
  771. return -EINVAL;
  772. for (i = slot; i < slot + count; ++i) {
  773. ctlr = EDMA_CTLR(i);
  774. slot_to_free = EDMA_CHAN_SLOT(i);
  775. memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(slot_to_free),
  776. &dummy_paramset, PARM_SIZE);
  777. clear_bit(slot_to_free, edma_cc[ctlr]->edma_inuse);
  778. }
  779. return 0;
  780. }
  781. EXPORT_SYMBOL(edma_free_cont_slots);
  782. /*-----------------------------------------------------------------------*/
  783. /* Parameter RAM operations (i) -- read/write partial slots */
  784. /**
  785. * edma_set_src - set initial DMA source address in parameter RAM slot
  786. * @slot: parameter RAM slot being configured
  787. * @src_port: physical address of source (memory, controller FIFO, etc)
  788. * @addressMode: INCR, except in very rare cases
  789. * @fifoWidth: ignored unless @addressMode is FIFO, else specifies the
  790. * width to use when addressing the fifo (e.g. W8BIT, W32BIT)
  791. *
  792. * Note that the source address is modified during the DMA transfer
  793. * according to edma_set_src_index().
  794. */
  795. void edma_set_src(unsigned slot, dma_addr_t src_port,
  796. enum address_mode mode, enum fifo_width width)
  797. {
  798. unsigned ctlr;
  799. ctlr = EDMA_CTLR(slot);
  800. slot = EDMA_CHAN_SLOT(slot);
  801. if (slot < edma_cc[ctlr]->num_slots) {
  802. unsigned int i = edma_parm_read(ctlr, PARM_OPT, slot);
  803. if (mode) {
  804. /* set SAM and program FWID */
  805. i = (i & ~(EDMA_FWID)) | (SAM | ((width & 0x7) << 8));
  806. } else {
  807. /* clear SAM */
  808. i &= ~SAM;
  809. }
  810. edma_parm_write(ctlr, PARM_OPT, slot, i);
  811. /* set the source port address
  812. in source register of param structure */
  813. edma_parm_write(ctlr, PARM_SRC, slot, src_port);
  814. }
  815. }
  816. EXPORT_SYMBOL(edma_set_src);
  817. /**
  818. * edma_set_dest - set initial DMA destination address in parameter RAM slot
  819. * @slot: parameter RAM slot being configured
  820. * @dest_port: physical address of destination (memory, controller FIFO, etc)
  821. * @addressMode: INCR, except in very rare cases
  822. * @fifoWidth: ignored unless @addressMode is FIFO, else specifies the
  823. * width to use when addressing the fifo (e.g. W8BIT, W32BIT)
  824. *
  825. * Note that the destination address is modified during the DMA transfer
  826. * according to edma_set_dest_index().
  827. */
  828. void edma_set_dest(unsigned slot, dma_addr_t dest_port,
  829. enum address_mode mode, enum fifo_width width)
  830. {
  831. unsigned ctlr;
  832. ctlr = EDMA_CTLR(slot);
  833. slot = EDMA_CHAN_SLOT(slot);
  834. if (slot < edma_cc[ctlr]->num_slots) {
  835. unsigned int i = edma_parm_read(ctlr, PARM_OPT, slot);
  836. if (mode) {
  837. /* set DAM and program FWID */
  838. i = (i & ~(EDMA_FWID)) | (DAM | ((width & 0x7) << 8));
  839. } else {
  840. /* clear DAM */
  841. i &= ~DAM;
  842. }
  843. edma_parm_write(ctlr, PARM_OPT, slot, i);
  844. /* set the destination port address
  845. in dest register of param structure */
  846. edma_parm_write(ctlr, PARM_DST, slot, dest_port);
  847. }
  848. }
  849. EXPORT_SYMBOL(edma_set_dest);
  850. /**
  851. * edma_get_position - returns the current transfer points
  852. * @slot: parameter RAM slot being examined
  853. * @src: pointer to source port position
  854. * @dst: pointer to destination port position
  855. *
  856. * Returns current source and destination addresses for a particular
  857. * parameter RAM slot. Its channel should not be active when this is called.
  858. */
  859. void edma_get_position(unsigned slot, dma_addr_t *src, dma_addr_t *dst)
  860. {
  861. struct edmacc_param temp;
  862. unsigned ctlr;
  863. ctlr = EDMA_CTLR(slot);
  864. slot = EDMA_CHAN_SLOT(slot);
  865. edma_read_slot(EDMA_CTLR_CHAN(ctlr, slot), &temp);
  866. if (src != NULL)
  867. *src = temp.src;
  868. if (dst != NULL)
  869. *dst = temp.dst;
  870. }
  871. EXPORT_SYMBOL(edma_get_position);
  872. /**
  873. * edma_set_src_index - configure DMA source address indexing
  874. * @slot: parameter RAM slot being configured
  875. * @src_bidx: byte offset between source arrays in a frame
  876. * @src_cidx: byte offset between source frames in a block
  877. *
  878. * Offsets are specified to support either contiguous or discontiguous
  879. * memory transfers, or repeated access to a hardware register, as needed.
  880. * When accessing hardware registers, both offsets are normally zero.
  881. */
  882. void edma_set_src_index(unsigned slot, s16 src_bidx, s16 src_cidx)
  883. {
  884. unsigned ctlr;
  885. ctlr = EDMA_CTLR(slot);
  886. slot = EDMA_CHAN_SLOT(slot);
  887. if (slot < edma_cc[ctlr]->num_slots) {
  888. edma_parm_modify(ctlr, PARM_SRC_DST_BIDX, slot,
  889. 0xffff0000, src_bidx);
  890. edma_parm_modify(ctlr, PARM_SRC_DST_CIDX, slot,
  891. 0xffff0000, src_cidx);
  892. }
  893. }
  894. EXPORT_SYMBOL(edma_set_src_index);
  895. /**
  896. * edma_set_dest_index - configure DMA destination address indexing
  897. * @slot: parameter RAM slot being configured
  898. * @dest_bidx: byte offset between destination arrays in a frame
  899. * @dest_cidx: byte offset between destination frames in a block
  900. *
  901. * Offsets are specified to support either contiguous or discontiguous
  902. * memory transfers, or repeated access to a hardware register, as needed.
  903. * When accessing hardware registers, both offsets are normally zero.
  904. */
  905. void edma_set_dest_index(unsigned slot, s16 dest_bidx, s16 dest_cidx)
  906. {
  907. unsigned ctlr;
  908. ctlr = EDMA_CTLR(slot);
  909. slot = EDMA_CHAN_SLOT(slot);
  910. if (slot < edma_cc[ctlr]->num_slots) {
  911. edma_parm_modify(ctlr, PARM_SRC_DST_BIDX, slot,
  912. 0x0000ffff, dest_bidx << 16);
  913. edma_parm_modify(ctlr, PARM_SRC_DST_CIDX, slot,
  914. 0x0000ffff, dest_cidx << 16);
  915. }
  916. }
  917. EXPORT_SYMBOL(edma_set_dest_index);
  918. /**
  919. * edma_set_transfer_params - configure DMA transfer parameters
  920. * @slot: parameter RAM slot being configured
  921. * @acnt: how many bytes per array (at least one)
  922. * @bcnt: how many arrays per frame (at least one)
  923. * @ccnt: how many frames per block (at least one)
  924. * @bcnt_rld: used only for A-Synchronized transfers; this specifies
  925. * the value to reload into bcnt when it decrements to zero
  926. * @sync_mode: ASYNC or ABSYNC
  927. *
  928. * See the EDMA3 documentation to understand how to configure and link
  929. * transfers using the fields in PaRAM slots. If you are not doing it
  930. * all at once with edma_write_slot(), you will use this routine
  931. * plus two calls each for source and destination, setting the initial
  932. * address and saying how to index that address.
  933. *
  934. * An example of an A-Synchronized transfer is a serial link using a
  935. * single word shift register. In that case, @acnt would be equal to
  936. * that word size; the serial controller issues a DMA synchronization
  937. * event to transfer each word, and memory access by the DMA transfer
  938. * controller will be word-at-a-time.
  939. *
  940. * An example of an AB-Synchronized transfer is a device using a FIFO.
  941. * In that case, @acnt equals the FIFO width and @bcnt equals its depth.
  942. * The controller with the FIFO issues DMA synchronization events when
  943. * the FIFO threshold is reached, and the DMA transfer controller will
  944. * transfer one frame to (or from) the FIFO. It will probably use
  945. * efficient burst modes to access memory.
  946. */
  947. void edma_set_transfer_params(unsigned slot,
  948. u16 acnt, u16 bcnt, u16 ccnt,
  949. u16 bcnt_rld, enum sync_dimension sync_mode)
  950. {
  951. unsigned ctlr;
  952. ctlr = EDMA_CTLR(slot);
  953. slot = EDMA_CHAN_SLOT(slot);
  954. if (slot < edma_cc[ctlr]->num_slots) {
  955. edma_parm_modify(ctlr, PARM_LINK_BCNTRLD, slot,
  956. 0x0000ffff, bcnt_rld << 16);
  957. if (sync_mode == ASYNC)
  958. edma_parm_and(ctlr, PARM_OPT, slot, ~SYNCDIM);
  959. else
  960. edma_parm_or(ctlr, PARM_OPT, slot, SYNCDIM);
  961. /* Set the acount, bcount, ccount registers */
  962. edma_parm_write(ctlr, PARM_A_B_CNT, slot, (bcnt << 16) | acnt);
  963. edma_parm_write(ctlr, PARM_CCNT, slot, ccnt);
  964. }
  965. }
  966. EXPORT_SYMBOL(edma_set_transfer_params);
  967. /**
  968. * edma_link - link one parameter RAM slot to another
  969. * @from: parameter RAM slot originating the link
  970. * @to: parameter RAM slot which is the link target
  971. *
  972. * The originating slot should not be part of any active DMA transfer.
  973. */
  974. void edma_link(unsigned from, unsigned to)
  975. {
  976. unsigned ctlr_from, ctlr_to;
  977. ctlr_from = EDMA_CTLR(from);
  978. from = EDMA_CHAN_SLOT(from);
  979. ctlr_to = EDMA_CTLR(to);
  980. to = EDMA_CHAN_SLOT(to);
  981. if (from >= edma_cc[ctlr_from]->num_slots)
  982. return;
  983. if (to >= edma_cc[ctlr_to]->num_slots)
  984. return;
  985. edma_parm_modify(ctlr_from, PARM_LINK_BCNTRLD, from, 0xffff0000,
  986. PARM_OFFSET(to));
  987. }
  988. EXPORT_SYMBOL(edma_link);
  989. /**
  990. * edma_unlink - cut link from one parameter RAM slot
  991. * @from: parameter RAM slot originating the link
  992. *
  993. * The originating slot should not be part of any active DMA transfer.
  994. * Its link is set to 0xffff.
  995. */
  996. void edma_unlink(unsigned from)
  997. {
  998. unsigned ctlr;
  999. ctlr = EDMA_CTLR(from);
  1000. from = EDMA_CHAN_SLOT(from);
  1001. if (from >= edma_cc[ctlr]->num_slots)
  1002. return;
  1003. edma_parm_or(ctlr, PARM_LINK_BCNTRLD, from, 0xffff);
  1004. }
  1005. EXPORT_SYMBOL(edma_unlink);
  1006. /*-----------------------------------------------------------------------*/
  1007. /* Parameter RAM operations (ii) -- read/write whole parameter sets */
  1008. /**
  1009. * edma_write_slot - write parameter RAM data for slot
  1010. * @slot: number of parameter RAM slot being modified
  1011. * @param: data to be written into parameter RAM slot
  1012. *
  1013. * Use this to assign all parameters of a transfer at once. This
  1014. * allows more efficient setup of transfers than issuing multiple
  1015. * calls to set up those parameters in small pieces, and provides
  1016. * complete control over all transfer options.
  1017. */
  1018. void edma_write_slot(unsigned slot, const struct edmacc_param *param)
  1019. {
  1020. unsigned ctlr;
  1021. ctlr = EDMA_CTLR(slot);
  1022. slot = EDMA_CHAN_SLOT(slot);
  1023. if (slot >= edma_cc[ctlr]->num_slots)
  1024. return;
  1025. memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(slot), param,
  1026. PARM_SIZE);
  1027. }
  1028. EXPORT_SYMBOL(edma_write_slot);
  1029. /**
  1030. * edma_read_slot - read parameter RAM data from slot
  1031. * @slot: number of parameter RAM slot being copied
  1032. * @param: where to store copy of parameter RAM data
  1033. *
  1034. * Use this to read data from a parameter RAM slot, perhaps to
  1035. * save them as a template for later reuse.
  1036. */
  1037. void edma_read_slot(unsigned slot, struct edmacc_param *param)
  1038. {
  1039. unsigned ctlr;
  1040. ctlr = EDMA_CTLR(slot);
  1041. slot = EDMA_CHAN_SLOT(slot);
  1042. if (slot >= edma_cc[ctlr]->num_slots)
  1043. return;
  1044. memcpy_fromio(param, edmacc_regs_base[ctlr] + PARM_OFFSET(slot),
  1045. PARM_SIZE);
  1046. }
  1047. EXPORT_SYMBOL(edma_read_slot);
  1048. /*-----------------------------------------------------------------------*/
  1049. /* Various EDMA channel control operations */
  1050. /**
  1051. * edma_pause - pause dma on a channel
  1052. * @channel: on which edma_start() has been called
  1053. *
  1054. * This temporarily disables EDMA hardware events on the specified channel,
  1055. * preventing them from triggering new transfers on its behalf
  1056. */
  1057. void edma_pause(unsigned channel)
  1058. {
  1059. unsigned ctlr;
  1060. ctlr = EDMA_CTLR(channel);
  1061. channel = EDMA_CHAN_SLOT(channel);
  1062. if (channel < edma_cc[ctlr]->num_channels) {
  1063. unsigned int mask = BIT(channel & 0x1f);
  1064. edma_shadow0_write_array(ctlr, SH_EECR, channel >> 5, mask);
  1065. }
  1066. }
  1067. EXPORT_SYMBOL(edma_pause);
  1068. /**
  1069. * edma_resume - resumes dma on a paused channel
  1070. * @channel: on which edma_pause() has been called
  1071. *
  1072. * This re-enables EDMA hardware events on the specified channel.
  1073. */
  1074. void edma_resume(unsigned channel)
  1075. {
  1076. unsigned ctlr;
  1077. ctlr = EDMA_CTLR(channel);
  1078. channel = EDMA_CHAN_SLOT(channel);
  1079. if (channel < edma_cc[ctlr]->num_channels) {
  1080. unsigned int mask = BIT(channel & 0x1f);
  1081. edma_shadow0_write_array(ctlr, SH_EESR, channel >> 5, mask);
  1082. }
  1083. }
  1084. EXPORT_SYMBOL(edma_resume);
  1085. /**
  1086. * edma_start - start dma on a channel
  1087. * @channel: channel being activated
  1088. *
  1089. * Channels with event associations will be triggered by their hardware
  1090. * events, and channels without such associations will be triggered by
  1091. * software. (At this writing there is no interface for using software
  1092. * triggers except with channels that don't support hardware triggers.)
  1093. *
  1094. * Returns zero on success, else negative errno.
  1095. */
  1096. int edma_start(unsigned channel)
  1097. {
  1098. unsigned ctlr;
  1099. ctlr = EDMA_CTLR(channel);
  1100. channel = EDMA_CHAN_SLOT(channel);
  1101. if (channel < edma_cc[ctlr]->num_channels) {
  1102. int j = channel >> 5;
  1103. unsigned int mask = BIT(channel & 0x1f);
  1104. /* EDMA channels without event association */
  1105. if (test_bit(channel, edma_cc[ctlr]->edma_unused)) {
  1106. pr_debug("EDMA: ESR%d %08x\n", j,
  1107. edma_shadow0_read_array(ctlr, SH_ESR, j));
  1108. edma_shadow0_write_array(ctlr, SH_ESR, j, mask);
  1109. return 0;
  1110. }
  1111. /* EDMA channel with event association */
  1112. pr_debug("EDMA: ER%d %08x\n", j,
  1113. edma_shadow0_read_array(ctlr, SH_ER, j));
  1114. /* Clear any pending event or error */
  1115. edma_write_array(ctlr, EDMA_ECR, j, mask);
  1116. edma_write_array(ctlr, EDMA_EMCR, j, mask);
  1117. /* Clear any SER */
  1118. edma_shadow0_write_array(ctlr, SH_SECR, j, mask);
  1119. edma_shadow0_write_array(ctlr, SH_EESR, j, mask);
  1120. pr_debug("EDMA: EER%d %08x\n", j,
  1121. edma_shadow0_read_array(ctlr, SH_EER, j));
  1122. return 0;
  1123. }
  1124. return -EINVAL;
  1125. }
  1126. EXPORT_SYMBOL(edma_start);
  1127. /**
  1128. * edma_stop - stops dma on the channel passed
  1129. * @channel: channel being deactivated
  1130. *
  1131. * When @lch is a channel, any active transfer is paused and
  1132. * all pending hardware events are cleared. The current transfer
  1133. * may not be resumed, and the channel's Parameter RAM should be
  1134. * reinitialized before being reused.
  1135. */
  1136. void edma_stop(unsigned channel)
  1137. {
  1138. unsigned ctlr;
  1139. ctlr = EDMA_CTLR(channel);
  1140. channel = EDMA_CHAN_SLOT(channel);
  1141. if (channel < edma_cc[ctlr]->num_channels) {
  1142. int j = channel >> 5;
  1143. unsigned int mask = BIT(channel & 0x1f);
  1144. edma_shadow0_write_array(ctlr, SH_EECR, j, mask);
  1145. edma_shadow0_write_array(ctlr, SH_ECR, j, mask);
  1146. edma_shadow0_write_array(ctlr, SH_SECR, j, mask);
  1147. edma_write_array(ctlr, EDMA_EMCR, j, mask);
  1148. pr_debug("EDMA: EER%d %08x\n", j,
  1149. edma_shadow0_read_array(ctlr, SH_EER, j));
  1150. /* REVISIT: consider guarding against inappropriate event
  1151. * chaining by overwriting with dummy_paramset.
  1152. */
  1153. }
  1154. }
  1155. EXPORT_SYMBOL(edma_stop);
  1156. /******************************************************************************
  1157. *
  1158. * It cleans ParamEntry qand bring back EDMA to initial state if media has
  1159. * been removed before EDMA has finished.It is usedful for removable media.
  1160. * Arguments:
  1161. * ch_no - channel no
  1162. *
  1163. * Return: zero on success, or corresponding error no on failure
  1164. *
  1165. * FIXME this should not be needed ... edma_stop() should suffice.
  1166. *
  1167. *****************************************************************************/
  1168. void edma_clean_channel(unsigned channel)
  1169. {
  1170. unsigned ctlr;
  1171. ctlr = EDMA_CTLR(channel);
  1172. channel = EDMA_CHAN_SLOT(channel);
  1173. if (channel < edma_cc[ctlr]->num_channels) {
  1174. int j = (channel >> 5);
  1175. unsigned int mask = BIT(channel & 0x1f);
  1176. pr_debug("EDMA: EMR%d %08x\n", j,
  1177. edma_read_array(ctlr, EDMA_EMR, j));
  1178. edma_shadow0_write_array(ctlr, SH_ECR, j, mask);
  1179. /* Clear the corresponding EMR bits */
  1180. edma_write_array(ctlr, EDMA_EMCR, j, mask);
  1181. /* Clear any SER */
  1182. edma_shadow0_write_array(ctlr, SH_SECR, j, mask);
  1183. edma_write(ctlr, EDMA_CCERRCLR, BIT(16) | BIT(1) | BIT(0));
  1184. }
  1185. }
  1186. EXPORT_SYMBOL(edma_clean_channel);
  1187. /*
  1188. * edma_clear_event - clear an outstanding event on the DMA channel
  1189. * Arguments:
  1190. * channel - channel number
  1191. */
  1192. void edma_clear_event(unsigned channel)
  1193. {
  1194. unsigned ctlr;
  1195. ctlr = EDMA_CTLR(channel);
  1196. channel = EDMA_CHAN_SLOT(channel);
  1197. if (channel >= edma_cc[ctlr]->num_channels)
  1198. return;
  1199. if (channel < 32)
  1200. edma_write(ctlr, EDMA_ECR, BIT(channel));
  1201. else
  1202. edma_write(ctlr, EDMA_ECRH, BIT(channel - 32));
  1203. }
  1204. EXPORT_SYMBOL(edma_clear_event);
  1205. #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DMADEVICES)
  1206. static int edma_of_read_u32_to_s16_array(const struct device_node *np,
  1207. const char *propname, s16 *out_values,
  1208. size_t sz)
  1209. {
  1210. int ret;
  1211. ret = of_property_read_u16_array(np, propname, out_values, sz);
  1212. if (ret)
  1213. return ret;
  1214. /* Terminate it */
  1215. *out_values++ = -1;
  1216. *out_values++ = -1;
  1217. return 0;
  1218. }
  1219. static int edma_xbar_event_map(struct device *dev,
  1220. struct device_node *node,
  1221. struct edma_soc_info *pdata, int len)
  1222. {
  1223. int ret, i;
  1224. struct resource res;
  1225. void __iomem *xbar;
  1226. const s16 (*xbar_chans)[2];
  1227. u32 shift, offset, mux;
  1228. xbar_chans = devm_kzalloc(dev,
  1229. len/sizeof(s16) + 2*sizeof(s16),
  1230. GFP_KERNEL);
  1231. if (!xbar_chans)
  1232. return -ENOMEM;
  1233. ret = of_address_to_resource(node, 1, &res);
  1234. if (ret)
  1235. return -EIO;
  1236. xbar = devm_ioremap(dev, res.start, resource_size(&res));
  1237. if (!xbar)
  1238. return -ENOMEM;
  1239. ret = edma_of_read_u32_to_s16_array(node,
  1240. "ti,edma-xbar-event-map",
  1241. (s16 *)xbar_chans,
  1242. len/sizeof(u32));
  1243. if (ret)
  1244. return -EIO;
  1245. for (i = 0; xbar_chans[i][0] != -1; i++) {
  1246. shift = (xbar_chans[i][1] & 0x03) << 3;
  1247. offset = xbar_chans[i][1] & 0xfffffffc;
  1248. mux = readl(xbar + offset);
  1249. mux &= ~(0xff << shift);
  1250. mux |= xbar_chans[i][0] << shift;
  1251. writel(mux, (xbar + offset));
  1252. }
  1253. pdata->xbar_chans = xbar_chans;
  1254. return 0;
  1255. }
  1256. static int edma_of_parse_dt(struct device *dev,
  1257. struct device_node *node,
  1258. struct edma_soc_info *pdata)
  1259. {
  1260. int ret = 0, i;
  1261. u32 value;
  1262. struct property *prop;
  1263. size_t sz;
  1264. struct edma_rsv_info *rsv_info;
  1265. s8 (*queue_tc_map)[2], (*queue_priority_map)[2];
  1266. memset(pdata, 0, sizeof(struct edma_soc_info));
  1267. ret = of_property_read_u32(node, "dma-channels", &value);
  1268. if (ret < 0)
  1269. return ret;
  1270. pdata->n_channel = value;
  1271. ret = of_property_read_u32(node, "ti,edma-regions", &value);
  1272. if (ret < 0)
  1273. return ret;
  1274. pdata->n_region = value;
  1275. ret = of_property_read_u32(node, "ti,edma-slots", &value);
  1276. if (ret < 0)
  1277. return ret;
  1278. pdata->n_slot = value;
  1279. pdata->n_cc = 1;
  1280. rsv_info = devm_kzalloc(dev, sizeof(struct edma_rsv_info), GFP_KERNEL);
  1281. if (!rsv_info)
  1282. return -ENOMEM;
  1283. pdata->rsv = rsv_info;
  1284. queue_tc_map = devm_kzalloc(dev, 8*sizeof(s8), GFP_KERNEL);
  1285. if (!queue_tc_map)
  1286. return -ENOMEM;
  1287. for (i = 0; i < 3; i++) {
  1288. queue_tc_map[i][0] = i;
  1289. queue_tc_map[i][1] = i;
  1290. }
  1291. queue_tc_map[i][0] = -1;
  1292. queue_tc_map[i][1] = -1;
  1293. pdata->queue_tc_mapping = queue_tc_map;
  1294. queue_priority_map = devm_kzalloc(dev, 8*sizeof(s8), GFP_KERNEL);
  1295. if (!queue_priority_map)
  1296. return -ENOMEM;
  1297. for (i = 0; i < 3; i++) {
  1298. queue_priority_map[i][0] = i;
  1299. queue_priority_map[i][1] = i;
  1300. }
  1301. queue_priority_map[i][0] = -1;
  1302. queue_priority_map[i][1] = -1;
  1303. pdata->queue_priority_mapping = queue_priority_map;
  1304. pdata->default_queue = 0;
  1305. prop = of_find_property(node, "ti,edma-xbar-event-map", &sz);
  1306. if (prop)
  1307. ret = edma_xbar_event_map(dev, node, pdata, sz);
  1308. return ret;
  1309. }
  1310. static struct of_dma_filter_info edma_filter_info = {
  1311. .filter_fn = edma_filter_fn,
  1312. };
  1313. static struct edma_soc_info *edma_setup_info_from_dt(struct device *dev,
  1314. struct device_node *node)
  1315. {
  1316. struct edma_soc_info *info;
  1317. int ret;
  1318. info = devm_kzalloc(dev, sizeof(struct edma_soc_info), GFP_KERNEL);
  1319. if (!info)
  1320. return ERR_PTR(-ENOMEM);
  1321. ret = edma_of_parse_dt(dev, node, info);
  1322. if (ret)
  1323. return ERR_PTR(ret);
  1324. dma_cap_set(DMA_SLAVE, edma_filter_info.dma_cap);
  1325. of_dma_controller_register(dev->of_node, of_dma_simple_xlate,
  1326. &edma_filter_info);
  1327. return info;
  1328. }
  1329. #else
  1330. static struct edma_soc_info *edma_setup_info_from_dt(struct device *dev,
  1331. struct device_node *node)
  1332. {
  1333. return ERR_PTR(-ENOSYS);
  1334. }
  1335. #endif
  1336. static int edma_probe(struct platform_device *pdev)
  1337. {
  1338. struct edma_soc_info **info = pdev->dev.platform_data;
  1339. struct edma_soc_info *ninfo[EDMA_MAX_CC] = {NULL};
  1340. s8 (*queue_priority_mapping)[2];
  1341. s8 (*queue_tc_mapping)[2];
  1342. int i, j, off, ln, found = 0;
  1343. int status = -1;
  1344. const s16 (*rsv_chans)[2];
  1345. const s16 (*rsv_slots)[2];
  1346. const s16 (*xbar_chans)[2];
  1347. int irq[EDMA_MAX_CC] = {0, 0};
  1348. int err_irq[EDMA_MAX_CC] = {0, 0};
  1349. struct resource *r[EDMA_MAX_CC] = {NULL};
  1350. struct resource res[EDMA_MAX_CC];
  1351. char res_name[10];
  1352. char irq_name[10];
  1353. struct device_node *node = pdev->dev.of_node;
  1354. struct device *dev = &pdev->dev;
  1355. int ret;
  1356. if (node) {
  1357. /* Check if this is a second instance registered */
  1358. if (arch_num_cc) {
  1359. dev_err(dev, "only one EDMA instance is supported via DT\n");
  1360. return -ENODEV;
  1361. }
  1362. ninfo[0] = edma_setup_info_from_dt(dev, node);
  1363. if (IS_ERR(ninfo[0])) {
  1364. dev_err(dev, "failed to get DT data\n");
  1365. return PTR_ERR(ninfo[0]);
  1366. }
  1367. info = ninfo;
  1368. }
  1369. if (!info)
  1370. return -ENODEV;
  1371. pm_runtime_enable(dev);
  1372. ret = pm_runtime_get_sync(dev);
  1373. if (ret < 0) {
  1374. dev_err(dev, "pm_runtime_get_sync() failed\n");
  1375. return ret;
  1376. }
  1377. for (j = 0; j < EDMA_MAX_CC; j++) {
  1378. if (!info[j]) {
  1379. if (!found)
  1380. return -ENODEV;
  1381. break;
  1382. }
  1383. if (node) {
  1384. ret = of_address_to_resource(node, j, &res[j]);
  1385. if (!ret)
  1386. r[j] = &res[j];
  1387. } else {
  1388. sprintf(res_name, "edma_cc%d", j);
  1389. r[j] = platform_get_resource_byname(pdev,
  1390. IORESOURCE_MEM,
  1391. res_name);
  1392. }
  1393. if (!r[j]) {
  1394. if (found)
  1395. break;
  1396. else
  1397. return -ENODEV;
  1398. } else {
  1399. found = 1;
  1400. }
  1401. edmacc_regs_base[j] = devm_ioremap_resource(&pdev->dev, r[j]);
  1402. if (IS_ERR(edmacc_regs_base[j]))
  1403. return PTR_ERR(edmacc_regs_base[j]);
  1404. edma_cc[j] = devm_kzalloc(&pdev->dev, sizeof(struct edma),
  1405. GFP_KERNEL);
  1406. if (!edma_cc[j])
  1407. return -ENOMEM;
  1408. edma_cc[j]->num_channels = min_t(unsigned, info[j]->n_channel,
  1409. EDMA_MAX_DMACH);
  1410. edma_cc[j]->num_slots = min_t(unsigned, info[j]->n_slot,
  1411. EDMA_MAX_PARAMENTRY);
  1412. edma_cc[j]->num_cc = min_t(unsigned, info[j]->n_cc,
  1413. EDMA_MAX_CC);
  1414. edma_cc[j]->default_queue = info[j]->default_queue;
  1415. dev_dbg(&pdev->dev, "DMA REG BASE ADDR=%p\n",
  1416. edmacc_regs_base[j]);
  1417. for (i = 0; i < edma_cc[j]->num_slots; i++)
  1418. memcpy_toio(edmacc_regs_base[j] + PARM_OFFSET(i),
  1419. &dummy_paramset, PARM_SIZE);
  1420. /* Mark all channels as unused */
  1421. memset(edma_cc[j]->edma_unused, 0xff,
  1422. sizeof(edma_cc[j]->edma_unused));
  1423. if (info[j]->rsv) {
  1424. /* Clear the reserved channels in unused list */
  1425. rsv_chans = info[j]->rsv->rsv_chans;
  1426. if (rsv_chans) {
  1427. for (i = 0; rsv_chans[i][0] != -1; i++) {
  1428. off = rsv_chans[i][0];
  1429. ln = rsv_chans[i][1];
  1430. clear_bits(off, ln,
  1431. edma_cc[j]->edma_unused);
  1432. }
  1433. }
  1434. /* Set the reserved slots in inuse list */
  1435. rsv_slots = info[j]->rsv->rsv_slots;
  1436. if (rsv_slots) {
  1437. for (i = 0; rsv_slots[i][0] != -1; i++) {
  1438. off = rsv_slots[i][0];
  1439. ln = rsv_slots[i][1];
  1440. set_bits(off, ln,
  1441. edma_cc[j]->edma_inuse);
  1442. }
  1443. }
  1444. }
  1445. /* Clear the xbar mapped channels in unused list */
  1446. xbar_chans = info[j]->xbar_chans;
  1447. if (xbar_chans) {
  1448. for (i = 0; xbar_chans[i][1] != -1; i++) {
  1449. off = xbar_chans[i][1];
  1450. clear_bits(off, 1,
  1451. edma_cc[j]->edma_unused);
  1452. }
  1453. }
  1454. if (node) {
  1455. irq[j] = irq_of_parse_and_map(node, 0);
  1456. } else {
  1457. sprintf(irq_name, "edma%d", j);
  1458. irq[j] = platform_get_irq_byname(pdev, irq_name);
  1459. }
  1460. edma_cc[j]->irq_res_start = irq[j];
  1461. status = devm_request_irq(&pdev->dev, irq[j],
  1462. dma_irq_handler, 0, "edma",
  1463. &pdev->dev);
  1464. if (status < 0) {
  1465. dev_dbg(&pdev->dev,
  1466. "devm_request_irq %d failed --> %d\n",
  1467. irq[j], status);
  1468. return status;
  1469. }
  1470. if (node) {
  1471. err_irq[j] = irq_of_parse_and_map(node, 2);
  1472. } else {
  1473. sprintf(irq_name, "edma%d_err", j);
  1474. err_irq[j] = platform_get_irq_byname(pdev, irq_name);
  1475. }
  1476. edma_cc[j]->irq_res_end = err_irq[j];
  1477. status = devm_request_irq(&pdev->dev, err_irq[j],
  1478. dma_ccerr_handler, 0,
  1479. "edma_error", &pdev->dev);
  1480. if (status < 0) {
  1481. dev_dbg(&pdev->dev,
  1482. "devm_request_irq %d failed --> %d\n",
  1483. err_irq[j], status);
  1484. return status;
  1485. }
  1486. for (i = 0; i < edma_cc[j]->num_channels; i++)
  1487. map_dmach_queue(j, i, info[j]->default_queue);
  1488. queue_tc_mapping = info[j]->queue_tc_mapping;
  1489. queue_priority_mapping = info[j]->queue_priority_mapping;
  1490. /* Event queue to TC mapping */
  1491. for (i = 0; queue_tc_mapping[i][0] != -1; i++)
  1492. map_queue_tc(j, queue_tc_mapping[i][0],
  1493. queue_tc_mapping[i][1]);
  1494. /* Event queue priority mapping */
  1495. for (i = 0; queue_priority_mapping[i][0] != -1; i++)
  1496. assign_priority_to_queue(j,
  1497. queue_priority_mapping[i][0],
  1498. queue_priority_mapping[i][1]);
  1499. /* Map the channel to param entry if channel mapping logic
  1500. * exist
  1501. */
  1502. if (edma_read(j, EDMA_CCCFG) & CHMAP_EXIST)
  1503. map_dmach_param(j);
  1504. for (i = 0; i < info[j]->n_region; i++) {
  1505. edma_write_array2(j, EDMA_DRAE, i, 0, 0x0);
  1506. edma_write_array2(j, EDMA_DRAE, i, 1, 0x0);
  1507. edma_write_array(j, EDMA_QRAE, i, 0x0);
  1508. }
  1509. arch_num_cc++;
  1510. }
  1511. return 0;
  1512. }
  1513. static const struct of_device_id edma_of_ids[] = {
  1514. { .compatible = "ti,edma3", },
  1515. {}
  1516. };
  1517. static struct platform_driver edma_driver = {
  1518. .driver = {
  1519. .name = "edma",
  1520. .of_match_table = edma_of_ids,
  1521. },
  1522. .probe = edma_probe,
  1523. };
  1524. static int __init edma_init(void)
  1525. {
  1526. return platform_driver_probe(&edma_driver, edma_probe);
  1527. }
  1528. arch_initcall(edma_init);