cppi41.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  1. #include <linux/delay.h>
  2. #include <linux/dmaengine.h>
  3. #include <linux/dma-mapping.h>
  4. #include <linux/platform_device.h>
  5. #include <linux/module.h>
  6. #include <linux/of.h>
  7. #include <linux/slab.h>
  8. #include <linux/of_dma.h>
  9. #include <linux/of_irq.h>
  10. #include <linux/dmapool.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/of_address.h>
  13. #include <linux/pm_runtime.h>
  14. #include "dmaengine.h"
  15. #define DESC_TYPE 27
  16. #define DESC_TYPE_HOST 0x10
  17. #define DESC_TYPE_TEARD 0x13
  18. #define TD_DESC_IS_RX (1 << 16)
  19. #define TD_DESC_DMA_NUM 10
  20. #define DESC_LENGTH_BITS_NUM 21
  21. #define DESC_TYPE_USB (5 << 26)
  22. #define DESC_PD_COMPLETE (1 << 31)
  23. /* DMA engine */
  24. #define DMA_TDFDQ 4
  25. #define DMA_TXGCR(x) (0x800 + (x) * 0x20)
  26. #define DMA_RXGCR(x) (0x808 + (x) * 0x20)
  27. #define RXHPCRA0 4
  28. #define GCR_CHAN_ENABLE (1 << 31)
  29. #define GCR_TEARDOWN (1 << 30)
  30. #define GCR_STARV_RETRY (1 << 24)
  31. #define GCR_DESC_TYPE_HOST (1 << 14)
  32. /* DMA scheduler */
  33. #define DMA_SCHED_CTRL 0
  34. #define DMA_SCHED_CTRL_EN (1 << 31)
  35. #define DMA_SCHED_WORD(x) ((x) * 4 + 0x800)
  36. #define SCHED_ENTRY0_CHAN(x) ((x) << 0)
  37. #define SCHED_ENTRY0_IS_RX (1 << 7)
  38. #define SCHED_ENTRY1_CHAN(x) ((x) << 8)
  39. #define SCHED_ENTRY1_IS_RX (1 << 15)
  40. #define SCHED_ENTRY2_CHAN(x) ((x) << 16)
  41. #define SCHED_ENTRY2_IS_RX (1 << 23)
  42. #define SCHED_ENTRY3_CHAN(x) ((x) << 24)
  43. #define SCHED_ENTRY3_IS_RX (1 << 31)
  44. /* Queue manager */
  45. /* 4 KiB of memory for descriptors, 2 for each endpoint */
  46. #define ALLOC_DECS_NUM 128
  47. #define DESCS_AREAS 1
  48. #define TOTAL_DESCS_NUM (ALLOC_DECS_NUM * DESCS_AREAS)
  49. #define QMGR_SCRATCH_SIZE (TOTAL_DESCS_NUM * 4)
  50. #define QMGR_LRAM0_BASE 0x80
  51. #define QMGR_LRAM_SIZE 0x84
  52. #define QMGR_LRAM1_BASE 0x88
  53. #define QMGR_MEMBASE(x) (0x1000 + (x) * 0x10)
  54. #define QMGR_MEMCTRL(x) (0x1004 + (x) * 0x10)
  55. #define QMGR_MEMCTRL_IDX_SH 16
  56. #define QMGR_MEMCTRL_DESC_SH 8
  57. #define QMGR_NUM_PEND 5
  58. #define QMGR_PEND(x) (0x90 + (x) * 4)
  59. #define QMGR_PENDING_SLOT_Q(x) (x / 32)
  60. #define QMGR_PENDING_BIT_Q(x) (x % 32)
  61. #define QMGR_QUEUE_A(n) (0x2000 + (n) * 0x10)
  62. #define QMGR_QUEUE_B(n) (0x2004 + (n) * 0x10)
  63. #define QMGR_QUEUE_C(n) (0x2008 + (n) * 0x10)
  64. #define QMGR_QUEUE_D(n) (0x200c + (n) * 0x10)
  65. /* Glue layer specific */
  66. /* USBSS / USB AM335x */
  67. #define USBSS_IRQ_STATUS 0x28
  68. #define USBSS_IRQ_ENABLER 0x2c
  69. #define USBSS_IRQ_CLEARR 0x30
  70. #define USBSS_IRQ_PD_COMP (1 << 2)
  71. /* Packet Descriptor */
  72. #define PD2_ZERO_LENGTH (1 << 19)
  73. struct cppi41_channel {
  74. struct dma_chan chan;
  75. struct dma_async_tx_descriptor txd;
  76. struct cppi41_dd *cdd;
  77. struct cppi41_desc *desc;
  78. dma_addr_t desc_phys;
  79. void __iomem *gcr_reg;
  80. int is_tx;
  81. u32 residue;
  82. unsigned int q_num;
  83. unsigned int q_comp_num;
  84. unsigned int port_num;
  85. unsigned td_retry;
  86. unsigned td_queued:1;
  87. unsigned td_seen:1;
  88. unsigned td_desc_seen:1;
  89. struct list_head node; /* Node for pending list */
  90. };
  91. struct cppi41_desc {
  92. u32 pd0;
  93. u32 pd1;
  94. u32 pd2;
  95. u32 pd3;
  96. u32 pd4;
  97. u32 pd5;
  98. u32 pd6;
  99. u32 pd7;
  100. } __aligned(32);
  101. struct chan_queues {
  102. u16 submit;
  103. u16 complete;
  104. };
  105. struct cppi41_dd {
  106. struct dma_device ddev;
  107. void *qmgr_scratch;
  108. dma_addr_t scratch_phys;
  109. struct cppi41_desc *cd;
  110. dma_addr_t descs_phys;
  111. u32 first_td_desc;
  112. struct cppi41_channel *chan_busy[ALLOC_DECS_NUM];
  113. void __iomem *usbss_mem;
  114. void __iomem *ctrl_mem;
  115. void __iomem *sched_mem;
  116. void __iomem *qmgr_mem;
  117. unsigned int irq;
  118. const struct chan_queues *queues_rx;
  119. const struct chan_queues *queues_tx;
  120. struct chan_queues td_queue;
  121. struct list_head pending; /* Pending queued transfers */
  122. spinlock_t lock; /* Lock for pending list */
  123. /* context for suspend/resume */
  124. unsigned int dma_tdfdq;
  125. bool is_suspended;
  126. };
  127. #define FIST_COMPLETION_QUEUE 93
  128. static struct chan_queues usb_queues_tx[] = {
  129. /* USB0 ENDP 1 */
  130. [ 0] = { .submit = 32, .complete = 93},
  131. [ 1] = { .submit = 34, .complete = 94},
  132. [ 2] = { .submit = 36, .complete = 95},
  133. [ 3] = { .submit = 38, .complete = 96},
  134. [ 4] = { .submit = 40, .complete = 97},
  135. [ 5] = { .submit = 42, .complete = 98},
  136. [ 6] = { .submit = 44, .complete = 99},
  137. [ 7] = { .submit = 46, .complete = 100},
  138. [ 8] = { .submit = 48, .complete = 101},
  139. [ 9] = { .submit = 50, .complete = 102},
  140. [10] = { .submit = 52, .complete = 103},
  141. [11] = { .submit = 54, .complete = 104},
  142. [12] = { .submit = 56, .complete = 105},
  143. [13] = { .submit = 58, .complete = 106},
  144. [14] = { .submit = 60, .complete = 107},
  145. /* USB1 ENDP1 */
  146. [15] = { .submit = 62, .complete = 125},
  147. [16] = { .submit = 64, .complete = 126},
  148. [17] = { .submit = 66, .complete = 127},
  149. [18] = { .submit = 68, .complete = 128},
  150. [19] = { .submit = 70, .complete = 129},
  151. [20] = { .submit = 72, .complete = 130},
  152. [21] = { .submit = 74, .complete = 131},
  153. [22] = { .submit = 76, .complete = 132},
  154. [23] = { .submit = 78, .complete = 133},
  155. [24] = { .submit = 80, .complete = 134},
  156. [25] = { .submit = 82, .complete = 135},
  157. [26] = { .submit = 84, .complete = 136},
  158. [27] = { .submit = 86, .complete = 137},
  159. [28] = { .submit = 88, .complete = 138},
  160. [29] = { .submit = 90, .complete = 139},
  161. };
  162. static const struct chan_queues usb_queues_rx[] = {
  163. /* USB0 ENDP 1 */
  164. [ 0] = { .submit = 1, .complete = 109},
  165. [ 1] = { .submit = 2, .complete = 110},
  166. [ 2] = { .submit = 3, .complete = 111},
  167. [ 3] = { .submit = 4, .complete = 112},
  168. [ 4] = { .submit = 5, .complete = 113},
  169. [ 5] = { .submit = 6, .complete = 114},
  170. [ 6] = { .submit = 7, .complete = 115},
  171. [ 7] = { .submit = 8, .complete = 116},
  172. [ 8] = { .submit = 9, .complete = 117},
  173. [ 9] = { .submit = 10, .complete = 118},
  174. [10] = { .submit = 11, .complete = 119},
  175. [11] = { .submit = 12, .complete = 120},
  176. [12] = { .submit = 13, .complete = 121},
  177. [13] = { .submit = 14, .complete = 122},
  178. [14] = { .submit = 15, .complete = 123},
  179. /* USB1 ENDP 1 */
  180. [15] = { .submit = 16, .complete = 141},
  181. [16] = { .submit = 17, .complete = 142},
  182. [17] = { .submit = 18, .complete = 143},
  183. [18] = { .submit = 19, .complete = 144},
  184. [19] = { .submit = 20, .complete = 145},
  185. [20] = { .submit = 21, .complete = 146},
  186. [21] = { .submit = 22, .complete = 147},
  187. [22] = { .submit = 23, .complete = 148},
  188. [23] = { .submit = 24, .complete = 149},
  189. [24] = { .submit = 25, .complete = 150},
  190. [25] = { .submit = 26, .complete = 151},
  191. [26] = { .submit = 27, .complete = 152},
  192. [27] = { .submit = 28, .complete = 153},
  193. [28] = { .submit = 29, .complete = 154},
  194. [29] = { .submit = 30, .complete = 155},
  195. };
  196. struct cppi_glue_infos {
  197. irqreturn_t (*isr)(int irq, void *data);
  198. const struct chan_queues *queues_rx;
  199. const struct chan_queues *queues_tx;
  200. struct chan_queues td_queue;
  201. };
  202. static struct cppi41_channel *to_cpp41_chan(struct dma_chan *c)
  203. {
  204. return container_of(c, struct cppi41_channel, chan);
  205. }
  206. static struct cppi41_channel *desc_to_chan(struct cppi41_dd *cdd, u32 desc)
  207. {
  208. struct cppi41_channel *c;
  209. u32 descs_size;
  210. u32 desc_num;
  211. descs_size = sizeof(struct cppi41_desc) * ALLOC_DECS_NUM;
  212. if (!((desc >= cdd->descs_phys) &&
  213. (desc < (cdd->descs_phys + descs_size)))) {
  214. return NULL;
  215. }
  216. desc_num = (desc - cdd->descs_phys) / sizeof(struct cppi41_desc);
  217. BUG_ON(desc_num >= ALLOC_DECS_NUM);
  218. c = cdd->chan_busy[desc_num];
  219. cdd->chan_busy[desc_num] = NULL;
  220. /* Usecount for chan_busy[], paired with push_desc_queue() */
  221. pm_runtime_put(cdd->ddev.dev);
  222. return c;
  223. }
  224. static void cppi_writel(u32 val, void *__iomem *mem)
  225. {
  226. __raw_writel(val, mem);
  227. }
  228. static u32 cppi_readl(void *__iomem *mem)
  229. {
  230. return __raw_readl(mem);
  231. }
  232. static u32 pd_trans_len(u32 val)
  233. {
  234. return val & ((1 << (DESC_LENGTH_BITS_NUM + 1)) - 1);
  235. }
  236. static u32 cppi41_pop_desc(struct cppi41_dd *cdd, unsigned queue_num)
  237. {
  238. u32 desc;
  239. desc = cppi_readl(cdd->qmgr_mem + QMGR_QUEUE_D(queue_num));
  240. desc &= ~0x1f;
  241. return desc;
  242. }
  243. static irqreturn_t cppi41_irq(int irq, void *data)
  244. {
  245. struct cppi41_dd *cdd = data;
  246. struct cppi41_channel *c;
  247. u32 status;
  248. int i;
  249. status = cppi_readl(cdd->usbss_mem + USBSS_IRQ_STATUS);
  250. if (!(status & USBSS_IRQ_PD_COMP))
  251. return IRQ_NONE;
  252. cppi_writel(status, cdd->usbss_mem + USBSS_IRQ_STATUS);
  253. for (i = QMGR_PENDING_SLOT_Q(FIST_COMPLETION_QUEUE); i < QMGR_NUM_PEND;
  254. i++) {
  255. u32 val;
  256. u32 q_num;
  257. val = cppi_readl(cdd->qmgr_mem + QMGR_PEND(i));
  258. if (i == QMGR_PENDING_SLOT_Q(FIST_COMPLETION_QUEUE) && val) {
  259. u32 mask;
  260. /* set corresponding bit for completetion Q 93 */
  261. mask = 1 << QMGR_PENDING_BIT_Q(FIST_COMPLETION_QUEUE);
  262. /* not set all bits for queues less than Q 93 */
  263. mask--;
  264. /* now invert and keep only Q 93+ set */
  265. val &= ~mask;
  266. }
  267. if (val)
  268. __iormb();
  269. while (val) {
  270. u32 desc, len;
  271. int error;
  272. error = pm_runtime_get(cdd->ddev.dev);
  273. if (error < 0)
  274. dev_err(cdd->ddev.dev, "%s pm runtime get: %i\n",
  275. __func__, error);
  276. q_num = __fls(val);
  277. val &= ~(1 << q_num);
  278. q_num += 32 * i;
  279. desc = cppi41_pop_desc(cdd, q_num);
  280. c = desc_to_chan(cdd, desc);
  281. if (WARN_ON(!c)) {
  282. pr_err("%s() q %d desc %08x\n", __func__,
  283. q_num, desc);
  284. continue;
  285. }
  286. if (c->desc->pd2 & PD2_ZERO_LENGTH)
  287. len = 0;
  288. else
  289. len = pd_trans_len(c->desc->pd0);
  290. c->residue = pd_trans_len(c->desc->pd6) - len;
  291. dma_cookie_complete(&c->txd);
  292. dmaengine_desc_get_callback_invoke(&c->txd, NULL);
  293. pm_runtime_mark_last_busy(cdd->ddev.dev);
  294. pm_runtime_put_autosuspend(cdd->ddev.dev);
  295. }
  296. }
  297. return IRQ_HANDLED;
  298. }
  299. static dma_cookie_t cppi41_tx_submit(struct dma_async_tx_descriptor *tx)
  300. {
  301. dma_cookie_t cookie;
  302. cookie = dma_cookie_assign(tx);
  303. return cookie;
  304. }
  305. static int cppi41_dma_alloc_chan_resources(struct dma_chan *chan)
  306. {
  307. struct cppi41_channel *c = to_cpp41_chan(chan);
  308. struct cppi41_dd *cdd = c->cdd;
  309. int error;
  310. error = pm_runtime_get_sync(cdd->ddev.dev);
  311. if (error < 0) {
  312. dev_err(cdd->ddev.dev, "%s pm runtime get: %i\n",
  313. __func__, error);
  314. pm_runtime_put_noidle(cdd->ddev.dev);
  315. return error;
  316. }
  317. dma_cookie_init(chan);
  318. dma_async_tx_descriptor_init(&c->txd, chan);
  319. c->txd.tx_submit = cppi41_tx_submit;
  320. if (!c->is_tx)
  321. cppi_writel(c->q_num, c->gcr_reg + RXHPCRA0);
  322. pm_runtime_mark_last_busy(cdd->ddev.dev);
  323. pm_runtime_put_autosuspend(cdd->ddev.dev);
  324. return 0;
  325. }
  326. static void cppi41_dma_free_chan_resources(struct dma_chan *chan)
  327. {
  328. struct cppi41_channel *c = to_cpp41_chan(chan);
  329. struct cppi41_dd *cdd = c->cdd;
  330. int error;
  331. error = pm_runtime_get_sync(cdd->ddev.dev);
  332. if (error < 0) {
  333. pm_runtime_put_noidle(cdd->ddev.dev);
  334. return;
  335. }
  336. WARN_ON(!list_empty(&cdd->pending));
  337. pm_runtime_mark_last_busy(cdd->ddev.dev);
  338. pm_runtime_put_autosuspend(cdd->ddev.dev);
  339. }
  340. static enum dma_status cppi41_dma_tx_status(struct dma_chan *chan,
  341. dma_cookie_t cookie, struct dma_tx_state *txstate)
  342. {
  343. struct cppi41_channel *c = to_cpp41_chan(chan);
  344. enum dma_status ret;
  345. /* lock */
  346. ret = dma_cookie_status(chan, cookie, txstate);
  347. if (txstate && ret == DMA_COMPLETE)
  348. txstate->residue = c->residue;
  349. /* unlock */
  350. return ret;
  351. }
  352. static void push_desc_queue(struct cppi41_channel *c)
  353. {
  354. struct cppi41_dd *cdd = c->cdd;
  355. u32 desc_num;
  356. u32 desc_phys;
  357. u32 reg;
  358. c->residue = 0;
  359. reg = GCR_CHAN_ENABLE;
  360. if (!c->is_tx) {
  361. reg |= GCR_STARV_RETRY;
  362. reg |= GCR_DESC_TYPE_HOST;
  363. reg |= c->q_comp_num;
  364. }
  365. cppi_writel(reg, c->gcr_reg);
  366. /*
  367. * We don't use writel() but __raw_writel() so we have to make sure
  368. * that the DMA descriptor in coherent memory made to the main memory
  369. * before starting the dma engine.
  370. */
  371. __iowmb();
  372. /*
  373. * DMA transfers can take at least 200ms to complete with USB mass
  374. * storage connected. To prevent autosuspend timeouts, we must use
  375. * pm_runtime_get/put() when chan_busy[] is modified. This will get
  376. * cleared in desc_to_chan() or cppi41_stop_chan() depending on the
  377. * outcome of the transfer.
  378. */
  379. pm_runtime_get(cdd->ddev.dev);
  380. desc_phys = lower_32_bits(c->desc_phys);
  381. desc_num = (desc_phys - cdd->descs_phys) / sizeof(struct cppi41_desc);
  382. WARN_ON(cdd->chan_busy[desc_num]);
  383. cdd->chan_busy[desc_num] = c;
  384. reg = (sizeof(struct cppi41_desc) - 24) / 4;
  385. reg |= desc_phys;
  386. cppi_writel(reg, cdd->qmgr_mem + QMGR_QUEUE_D(c->q_num));
  387. }
  388. /*
  389. * Caller must hold cdd->lock to prevent push_desc_queue()
  390. * getting called out of order. We have both cppi41_dma_issue_pending()
  391. * and cppi41_runtime_resume() call this function.
  392. */
  393. static void cppi41_run_queue(struct cppi41_dd *cdd)
  394. {
  395. struct cppi41_channel *c, *_c;
  396. list_for_each_entry_safe(c, _c, &cdd->pending, node) {
  397. push_desc_queue(c);
  398. list_del(&c->node);
  399. }
  400. }
  401. static void cppi41_dma_issue_pending(struct dma_chan *chan)
  402. {
  403. struct cppi41_channel *c = to_cpp41_chan(chan);
  404. struct cppi41_dd *cdd = c->cdd;
  405. unsigned long flags;
  406. int error;
  407. error = pm_runtime_get(cdd->ddev.dev);
  408. if ((error != -EINPROGRESS) && error < 0) {
  409. pm_runtime_put_noidle(cdd->ddev.dev);
  410. dev_err(cdd->ddev.dev, "Failed to pm_runtime_get: %i\n",
  411. error);
  412. return;
  413. }
  414. spin_lock_irqsave(&cdd->lock, flags);
  415. list_add_tail(&c->node, &cdd->pending);
  416. if (!cdd->is_suspended)
  417. cppi41_run_queue(cdd);
  418. spin_unlock_irqrestore(&cdd->lock, flags);
  419. pm_runtime_mark_last_busy(cdd->ddev.dev);
  420. pm_runtime_put_autosuspend(cdd->ddev.dev);
  421. }
  422. static u32 get_host_pd0(u32 length)
  423. {
  424. u32 reg;
  425. reg = DESC_TYPE_HOST << DESC_TYPE;
  426. reg |= length;
  427. return reg;
  428. }
  429. static u32 get_host_pd1(struct cppi41_channel *c)
  430. {
  431. u32 reg;
  432. reg = 0;
  433. return reg;
  434. }
  435. static u32 get_host_pd2(struct cppi41_channel *c)
  436. {
  437. u32 reg;
  438. reg = DESC_TYPE_USB;
  439. reg |= c->q_comp_num;
  440. return reg;
  441. }
  442. static u32 get_host_pd3(u32 length)
  443. {
  444. u32 reg;
  445. /* PD3 = packet size */
  446. reg = length;
  447. return reg;
  448. }
  449. static u32 get_host_pd6(u32 length)
  450. {
  451. u32 reg;
  452. /* PD6 buffer size */
  453. reg = DESC_PD_COMPLETE;
  454. reg |= length;
  455. return reg;
  456. }
  457. static u32 get_host_pd4_or_7(u32 addr)
  458. {
  459. u32 reg;
  460. reg = addr;
  461. return reg;
  462. }
  463. static u32 get_host_pd5(void)
  464. {
  465. u32 reg;
  466. reg = 0;
  467. return reg;
  468. }
  469. static struct dma_async_tx_descriptor *cppi41_dma_prep_slave_sg(
  470. struct dma_chan *chan, struct scatterlist *sgl, unsigned sg_len,
  471. enum dma_transfer_direction dir, unsigned long tx_flags, void *context)
  472. {
  473. struct cppi41_channel *c = to_cpp41_chan(chan);
  474. struct cppi41_desc *d;
  475. struct scatterlist *sg;
  476. unsigned int i;
  477. d = c->desc;
  478. for_each_sg(sgl, sg, sg_len, i) {
  479. u32 addr;
  480. u32 len;
  481. /* We need to use more than one desc once musb supports sg */
  482. addr = lower_32_bits(sg_dma_address(sg));
  483. len = sg_dma_len(sg);
  484. d->pd0 = get_host_pd0(len);
  485. d->pd1 = get_host_pd1(c);
  486. d->pd2 = get_host_pd2(c);
  487. d->pd3 = get_host_pd3(len);
  488. d->pd4 = get_host_pd4_or_7(addr);
  489. d->pd5 = get_host_pd5();
  490. d->pd6 = get_host_pd6(len);
  491. d->pd7 = get_host_pd4_or_7(addr);
  492. d++;
  493. }
  494. return &c->txd;
  495. }
  496. static void cppi41_compute_td_desc(struct cppi41_desc *d)
  497. {
  498. d->pd0 = DESC_TYPE_TEARD << DESC_TYPE;
  499. }
  500. static int cppi41_tear_down_chan(struct cppi41_channel *c)
  501. {
  502. struct cppi41_dd *cdd = c->cdd;
  503. struct cppi41_desc *td;
  504. u32 reg;
  505. u32 desc_phys;
  506. u32 td_desc_phys;
  507. td = cdd->cd;
  508. td += cdd->first_td_desc;
  509. td_desc_phys = cdd->descs_phys;
  510. td_desc_phys += cdd->first_td_desc * sizeof(struct cppi41_desc);
  511. if (!c->td_queued) {
  512. cppi41_compute_td_desc(td);
  513. __iowmb();
  514. reg = (sizeof(struct cppi41_desc) - 24) / 4;
  515. reg |= td_desc_phys;
  516. cppi_writel(reg, cdd->qmgr_mem +
  517. QMGR_QUEUE_D(cdd->td_queue.submit));
  518. reg = GCR_CHAN_ENABLE;
  519. if (!c->is_tx) {
  520. reg |= GCR_STARV_RETRY;
  521. reg |= GCR_DESC_TYPE_HOST;
  522. reg |= c->q_comp_num;
  523. }
  524. reg |= GCR_TEARDOWN;
  525. cppi_writel(reg, c->gcr_reg);
  526. c->td_queued = 1;
  527. c->td_retry = 500;
  528. }
  529. if (!c->td_seen || !c->td_desc_seen) {
  530. desc_phys = cppi41_pop_desc(cdd, cdd->td_queue.complete);
  531. if (!desc_phys)
  532. desc_phys = cppi41_pop_desc(cdd, c->q_comp_num);
  533. if (desc_phys == c->desc_phys) {
  534. c->td_desc_seen = 1;
  535. } else if (desc_phys == td_desc_phys) {
  536. u32 pd0;
  537. __iormb();
  538. pd0 = td->pd0;
  539. WARN_ON((pd0 >> DESC_TYPE) != DESC_TYPE_TEARD);
  540. WARN_ON(!c->is_tx && !(pd0 & TD_DESC_IS_RX));
  541. WARN_ON((pd0 & 0x1f) != c->port_num);
  542. c->td_seen = 1;
  543. } else if (desc_phys) {
  544. WARN_ON_ONCE(1);
  545. }
  546. }
  547. c->td_retry--;
  548. /*
  549. * If the TX descriptor / channel is in use, the caller needs to poke
  550. * his TD bit multiple times. After that he hardware releases the
  551. * transfer descriptor followed by TD descriptor. Waiting seems not to
  552. * cause any difference.
  553. * RX seems to be thrown out right away. However once the TearDown
  554. * descriptor gets through we are done. If we have seens the transfer
  555. * descriptor before the TD we fetch it from enqueue, it has to be
  556. * there waiting for us.
  557. */
  558. if (!c->td_seen && c->td_retry) {
  559. udelay(1);
  560. return -EAGAIN;
  561. }
  562. WARN_ON(!c->td_retry);
  563. if (!c->td_desc_seen) {
  564. desc_phys = cppi41_pop_desc(cdd, c->q_num);
  565. if (!desc_phys)
  566. desc_phys = cppi41_pop_desc(cdd, c->q_comp_num);
  567. WARN_ON(!desc_phys);
  568. }
  569. c->td_queued = 0;
  570. c->td_seen = 0;
  571. c->td_desc_seen = 0;
  572. cppi_writel(0, c->gcr_reg);
  573. return 0;
  574. }
  575. static int cppi41_stop_chan(struct dma_chan *chan)
  576. {
  577. struct cppi41_channel *c = to_cpp41_chan(chan);
  578. struct cppi41_dd *cdd = c->cdd;
  579. u32 desc_num;
  580. u32 desc_phys;
  581. int ret;
  582. desc_phys = lower_32_bits(c->desc_phys);
  583. desc_num = (desc_phys - cdd->descs_phys) / sizeof(struct cppi41_desc);
  584. if (!cdd->chan_busy[desc_num])
  585. return 0;
  586. ret = cppi41_tear_down_chan(c);
  587. if (ret)
  588. return ret;
  589. WARN_ON(!cdd->chan_busy[desc_num]);
  590. cdd->chan_busy[desc_num] = NULL;
  591. /* Usecount for chan_busy[], paired with push_desc_queue() */
  592. pm_runtime_put(cdd->ddev.dev);
  593. return 0;
  594. }
  595. static void cleanup_chans(struct cppi41_dd *cdd)
  596. {
  597. while (!list_empty(&cdd->ddev.channels)) {
  598. struct cppi41_channel *cchan;
  599. cchan = list_first_entry(&cdd->ddev.channels,
  600. struct cppi41_channel, chan.device_node);
  601. list_del(&cchan->chan.device_node);
  602. kfree(cchan);
  603. }
  604. }
  605. static int cppi41_add_chans(struct device *dev, struct cppi41_dd *cdd)
  606. {
  607. struct cppi41_channel *cchan;
  608. int i;
  609. int ret;
  610. u32 n_chans;
  611. ret = of_property_read_u32(dev->of_node, "#dma-channels",
  612. &n_chans);
  613. if (ret)
  614. return ret;
  615. /*
  616. * The channels can only be used as TX or as RX. So we add twice
  617. * that much dma channels because USB can only do RX or TX.
  618. */
  619. n_chans *= 2;
  620. for (i = 0; i < n_chans; i++) {
  621. cchan = kzalloc(sizeof(*cchan), GFP_KERNEL);
  622. if (!cchan)
  623. goto err;
  624. cchan->cdd = cdd;
  625. if (i & 1) {
  626. cchan->gcr_reg = cdd->ctrl_mem + DMA_TXGCR(i >> 1);
  627. cchan->is_tx = 1;
  628. } else {
  629. cchan->gcr_reg = cdd->ctrl_mem + DMA_RXGCR(i >> 1);
  630. cchan->is_tx = 0;
  631. }
  632. cchan->port_num = i >> 1;
  633. cchan->desc = &cdd->cd[i];
  634. cchan->desc_phys = cdd->descs_phys;
  635. cchan->desc_phys += i * sizeof(struct cppi41_desc);
  636. cchan->chan.device = &cdd->ddev;
  637. list_add_tail(&cchan->chan.device_node, &cdd->ddev.channels);
  638. }
  639. cdd->first_td_desc = n_chans;
  640. return 0;
  641. err:
  642. cleanup_chans(cdd);
  643. return -ENOMEM;
  644. }
  645. static void purge_descs(struct device *dev, struct cppi41_dd *cdd)
  646. {
  647. unsigned int mem_decs;
  648. int i;
  649. mem_decs = ALLOC_DECS_NUM * sizeof(struct cppi41_desc);
  650. for (i = 0; i < DESCS_AREAS; i++) {
  651. cppi_writel(0, cdd->qmgr_mem + QMGR_MEMBASE(i));
  652. cppi_writel(0, cdd->qmgr_mem + QMGR_MEMCTRL(i));
  653. dma_free_coherent(dev, mem_decs, cdd->cd,
  654. cdd->descs_phys);
  655. }
  656. }
  657. static void disable_sched(struct cppi41_dd *cdd)
  658. {
  659. cppi_writel(0, cdd->sched_mem + DMA_SCHED_CTRL);
  660. }
  661. static void deinit_cppi41(struct device *dev, struct cppi41_dd *cdd)
  662. {
  663. disable_sched(cdd);
  664. purge_descs(dev, cdd);
  665. cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM0_BASE);
  666. cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM0_BASE);
  667. dma_free_coherent(dev, QMGR_SCRATCH_SIZE, cdd->qmgr_scratch,
  668. cdd->scratch_phys);
  669. }
  670. static int init_descs(struct device *dev, struct cppi41_dd *cdd)
  671. {
  672. unsigned int desc_size;
  673. unsigned int mem_decs;
  674. int i;
  675. u32 reg;
  676. u32 idx;
  677. BUILD_BUG_ON(sizeof(struct cppi41_desc) &
  678. (sizeof(struct cppi41_desc) - 1));
  679. BUILD_BUG_ON(sizeof(struct cppi41_desc) < 32);
  680. BUILD_BUG_ON(ALLOC_DECS_NUM < 32);
  681. desc_size = sizeof(struct cppi41_desc);
  682. mem_decs = ALLOC_DECS_NUM * desc_size;
  683. idx = 0;
  684. for (i = 0; i < DESCS_AREAS; i++) {
  685. reg = idx << QMGR_MEMCTRL_IDX_SH;
  686. reg |= (ilog2(desc_size) - 5) << QMGR_MEMCTRL_DESC_SH;
  687. reg |= ilog2(ALLOC_DECS_NUM) - 5;
  688. BUILD_BUG_ON(DESCS_AREAS != 1);
  689. cdd->cd = dma_alloc_coherent(dev, mem_decs,
  690. &cdd->descs_phys, GFP_KERNEL);
  691. if (!cdd->cd)
  692. return -ENOMEM;
  693. cppi_writel(cdd->descs_phys, cdd->qmgr_mem + QMGR_MEMBASE(i));
  694. cppi_writel(reg, cdd->qmgr_mem + QMGR_MEMCTRL(i));
  695. idx += ALLOC_DECS_NUM;
  696. }
  697. return 0;
  698. }
  699. static void init_sched(struct cppi41_dd *cdd)
  700. {
  701. unsigned ch;
  702. unsigned word;
  703. u32 reg;
  704. word = 0;
  705. cppi_writel(0, cdd->sched_mem + DMA_SCHED_CTRL);
  706. for (ch = 0; ch < 15 * 2; ch += 2) {
  707. reg = SCHED_ENTRY0_CHAN(ch);
  708. reg |= SCHED_ENTRY1_CHAN(ch) | SCHED_ENTRY1_IS_RX;
  709. reg |= SCHED_ENTRY2_CHAN(ch + 1);
  710. reg |= SCHED_ENTRY3_CHAN(ch + 1) | SCHED_ENTRY3_IS_RX;
  711. cppi_writel(reg, cdd->sched_mem + DMA_SCHED_WORD(word));
  712. word++;
  713. }
  714. reg = 15 * 2 * 2 - 1;
  715. reg |= DMA_SCHED_CTRL_EN;
  716. cppi_writel(reg, cdd->sched_mem + DMA_SCHED_CTRL);
  717. }
  718. static int init_cppi41(struct device *dev, struct cppi41_dd *cdd)
  719. {
  720. int ret;
  721. BUILD_BUG_ON(QMGR_SCRATCH_SIZE > ((1 << 14) - 1));
  722. cdd->qmgr_scratch = dma_alloc_coherent(dev, QMGR_SCRATCH_SIZE,
  723. &cdd->scratch_phys, GFP_KERNEL);
  724. if (!cdd->qmgr_scratch)
  725. return -ENOMEM;
  726. cppi_writel(cdd->scratch_phys, cdd->qmgr_mem + QMGR_LRAM0_BASE);
  727. cppi_writel(QMGR_SCRATCH_SIZE, cdd->qmgr_mem + QMGR_LRAM_SIZE);
  728. cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM1_BASE);
  729. ret = init_descs(dev, cdd);
  730. if (ret)
  731. goto err_td;
  732. cppi_writel(cdd->td_queue.submit, cdd->ctrl_mem + DMA_TDFDQ);
  733. init_sched(cdd);
  734. return 0;
  735. err_td:
  736. deinit_cppi41(dev, cdd);
  737. return ret;
  738. }
  739. static struct platform_driver cpp41_dma_driver;
  740. /*
  741. * The param format is:
  742. * X Y
  743. * X: Port
  744. * Y: 0 = RX else TX
  745. */
  746. #define INFO_PORT 0
  747. #define INFO_IS_TX 1
  748. static bool cpp41_dma_filter_fn(struct dma_chan *chan, void *param)
  749. {
  750. struct cppi41_channel *cchan;
  751. struct cppi41_dd *cdd;
  752. const struct chan_queues *queues;
  753. u32 *num = param;
  754. if (chan->device->dev->driver != &cpp41_dma_driver.driver)
  755. return false;
  756. cchan = to_cpp41_chan(chan);
  757. if (cchan->port_num != num[INFO_PORT])
  758. return false;
  759. if (cchan->is_tx && !num[INFO_IS_TX])
  760. return false;
  761. cdd = cchan->cdd;
  762. if (cchan->is_tx)
  763. queues = cdd->queues_tx;
  764. else
  765. queues = cdd->queues_rx;
  766. BUILD_BUG_ON(ARRAY_SIZE(usb_queues_rx) != ARRAY_SIZE(usb_queues_tx));
  767. if (WARN_ON(cchan->port_num > ARRAY_SIZE(usb_queues_rx)))
  768. return false;
  769. cchan->q_num = queues[cchan->port_num].submit;
  770. cchan->q_comp_num = queues[cchan->port_num].complete;
  771. return true;
  772. }
  773. static struct of_dma_filter_info cpp41_dma_info = {
  774. .filter_fn = cpp41_dma_filter_fn,
  775. };
  776. static struct dma_chan *cppi41_dma_xlate(struct of_phandle_args *dma_spec,
  777. struct of_dma *ofdma)
  778. {
  779. int count = dma_spec->args_count;
  780. struct of_dma_filter_info *info = ofdma->of_dma_data;
  781. if (!info || !info->filter_fn)
  782. return NULL;
  783. if (count != 2)
  784. return NULL;
  785. return dma_request_channel(info->dma_cap, info->filter_fn,
  786. &dma_spec->args[0]);
  787. }
  788. static const struct cppi_glue_infos usb_infos = {
  789. .isr = cppi41_irq,
  790. .queues_rx = usb_queues_rx,
  791. .queues_tx = usb_queues_tx,
  792. .td_queue = { .submit = 31, .complete = 0 },
  793. };
  794. static const struct of_device_id cppi41_dma_ids[] = {
  795. { .compatible = "ti,am3359-cppi41", .data = &usb_infos},
  796. {},
  797. };
  798. MODULE_DEVICE_TABLE(of, cppi41_dma_ids);
  799. static const struct cppi_glue_infos *get_glue_info(struct device *dev)
  800. {
  801. const struct of_device_id *of_id;
  802. of_id = of_match_node(cppi41_dma_ids, dev->of_node);
  803. if (!of_id)
  804. return NULL;
  805. return of_id->data;
  806. }
  807. #define CPPI41_DMA_BUSWIDTHS (BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \
  808. BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \
  809. BIT(DMA_SLAVE_BUSWIDTH_3_BYTES) | \
  810. BIT(DMA_SLAVE_BUSWIDTH_4_BYTES))
  811. static int cppi41_dma_probe(struct platform_device *pdev)
  812. {
  813. struct cppi41_dd *cdd;
  814. struct device *dev = &pdev->dev;
  815. const struct cppi_glue_infos *glue_info;
  816. int irq;
  817. int ret;
  818. glue_info = get_glue_info(dev);
  819. if (!glue_info)
  820. return -EINVAL;
  821. cdd = devm_kzalloc(&pdev->dev, sizeof(*cdd), GFP_KERNEL);
  822. if (!cdd)
  823. return -ENOMEM;
  824. dma_cap_set(DMA_SLAVE, cdd->ddev.cap_mask);
  825. cdd->ddev.device_alloc_chan_resources = cppi41_dma_alloc_chan_resources;
  826. cdd->ddev.device_free_chan_resources = cppi41_dma_free_chan_resources;
  827. cdd->ddev.device_tx_status = cppi41_dma_tx_status;
  828. cdd->ddev.device_issue_pending = cppi41_dma_issue_pending;
  829. cdd->ddev.device_prep_slave_sg = cppi41_dma_prep_slave_sg;
  830. cdd->ddev.device_terminate_all = cppi41_stop_chan;
  831. cdd->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
  832. cdd->ddev.src_addr_widths = CPPI41_DMA_BUSWIDTHS;
  833. cdd->ddev.dst_addr_widths = CPPI41_DMA_BUSWIDTHS;
  834. cdd->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
  835. cdd->ddev.dev = dev;
  836. INIT_LIST_HEAD(&cdd->ddev.channels);
  837. cpp41_dma_info.dma_cap = cdd->ddev.cap_mask;
  838. cdd->usbss_mem = of_iomap(dev->of_node, 0);
  839. cdd->ctrl_mem = of_iomap(dev->of_node, 1);
  840. cdd->sched_mem = of_iomap(dev->of_node, 2);
  841. cdd->qmgr_mem = of_iomap(dev->of_node, 3);
  842. spin_lock_init(&cdd->lock);
  843. INIT_LIST_HEAD(&cdd->pending);
  844. platform_set_drvdata(pdev, cdd);
  845. if (!cdd->usbss_mem || !cdd->ctrl_mem || !cdd->sched_mem ||
  846. !cdd->qmgr_mem)
  847. return -ENXIO;
  848. pm_runtime_enable(dev);
  849. pm_runtime_set_autosuspend_delay(dev, 100);
  850. pm_runtime_use_autosuspend(dev);
  851. ret = pm_runtime_get_sync(dev);
  852. if (ret < 0)
  853. goto err_get_sync;
  854. cdd->queues_rx = glue_info->queues_rx;
  855. cdd->queues_tx = glue_info->queues_tx;
  856. cdd->td_queue = glue_info->td_queue;
  857. ret = init_cppi41(dev, cdd);
  858. if (ret)
  859. goto err_init_cppi;
  860. ret = cppi41_add_chans(dev, cdd);
  861. if (ret)
  862. goto err_chans;
  863. irq = irq_of_parse_and_map(dev->of_node, 0);
  864. if (!irq) {
  865. ret = -EINVAL;
  866. goto err_irq;
  867. }
  868. cppi_writel(USBSS_IRQ_PD_COMP, cdd->usbss_mem + USBSS_IRQ_ENABLER);
  869. ret = devm_request_irq(&pdev->dev, irq, glue_info->isr, IRQF_SHARED,
  870. dev_name(dev), cdd);
  871. if (ret)
  872. goto err_irq;
  873. cdd->irq = irq;
  874. ret = dma_async_device_register(&cdd->ddev);
  875. if (ret)
  876. goto err_dma_reg;
  877. ret = of_dma_controller_register(dev->of_node,
  878. cppi41_dma_xlate, &cpp41_dma_info);
  879. if (ret)
  880. goto err_of;
  881. pm_runtime_mark_last_busy(dev);
  882. pm_runtime_put_autosuspend(dev);
  883. return 0;
  884. err_of:
  885. dma_async_device_unregister(&cdd->ddev);
  886. err_dma_reg:
  887. err_irq:
  888. cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR);
  889. cleanup_chans(cdd);
  890. err_chans:
  891. deinit_cppi41(dev, cdd);
  892. err_init_cppi:
  893. pm_runtime_dont_use_autosuspend(dev);
  894. err_get_sync:
  895. pm_runtime_put_sync(dev);
  896. pm_runtime_disable(dev);
  897. iounmap(cdd->usbss_mem);
  898. iounmap(cdd->ctrl_mem);
  899. iounmap(cdd->sched_mem);
  900. iounmap(cdd->qmgr_mem);
  901. return ret;
  902. }
  903. static int cppi41_dma_remove(struct platform_device *pdev)
  904. {
  905. struct cppi41_dd *cdd = platform_get_drvdata(pdev);
  906. int error;
  907. error = pm_runtime_get_sync(&pdev->dev);
  908. if (error < 0)
  909. dev_err(&pdev->dev, "%s could not pm_runtime_get: %i\n",
  910. __func__, error);
  911. of_dma_controller_free(pdev->dev.of_node);
  912. dma_async_device_unregister(&cdd->ddev);
  913. cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR);
  914. devm_free_irq(&pdev->dev, cdd->irq, cdd);
  915. cleanup_chans(cdd);
  916. deinit_cppi41(&pdev->dev, cdd);
  917. iounmap(cdd->usbss_mem);
  918. iounmap(cdd->ctrl_mem);
  919. iounmap(cdd->sched_mem);
  920. iounmap(cdd->qmgr_mem);
  921. pm_runtime_dont_use_autosuspend(&pdev->dev);
  922. pm_runtime_put_sync(&pdev->dev);
  923. pm_runtime_disable(&pdev->dev);
  924. return 0;
  925. }
  926. static int __maybe_unused cppi41_suspend(struct device *dev)
  927. {
  928. struct cppi41_dd *cdd = dev_get_drvdata(dev);
  929. cdd->dma_tdfdq = cppi_readl(cdd->ctrl_mem + DMA_TDFDQ);
  930. cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR);
  931. disable_sched(cdd);
  932. return 0;
  933. }
  934. static int __maybe_unused cppi41_resume(struct device *dev)
  935. {
  936. struct cppi41_dd *cdd = dev_get_drvdata(dev);
  937. struct cppi41_channel *c;
  938. int i;
  939. for (i = 0; i < DESCS_AREAS; i++)
  940. cppi_writel(cdd->descs_phys, cdd->qmgr_mem + QMGR_MEMBASE(i));
  941. list_for_each_entry(c, &cdd->ddev.channels, chan.device_node)
  942. if (!c->is_tx)
  943. cppi_writel(c->q_num, c->gcr_reg + RXHPCRA0);
  944. init_sched(cdd);
  945. cppi_writel(cdd->dma_tdfdq, cdd->ctrl_mem + DMA_TDFDQ);
  946. cppi_writel(cdd->scratch_phys, cdd->qmgr_mem + QMGR_LRAM0_BASE);
  947. cppi_writel(QMGR_SCRATCH_SIZE, cdd->qmgr_mem + QMGR_LRAM_SIZE);
  948. cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM1_BASE);
  949. cppi_writel(USBSS_IRQ_PD_COMP, cdd->usbss_mem + USBSS_IRQ_ENABLER);
  950. return 0;
  951. }
  952. static int __maybe_unused cppi41_runtime_suspend(struct device *dev)
  953. {
  954. struct cppi41_dd *cdd = dev_get_drvdata(dev);
  955. unsigned long flags;
  956. spin_lock_irqsave(&cdd->lock, flags);
  957. cdd->is_suspended = true;
  958. WARN_ON(!list_empty(&cdd->pending));
  959. spin_unlock_irqrestore(&cdd->lock, flags);
  960. return 0;
  961. }
  962. static int __maybe_unused cppi41_runtime_resume(struct device *dev)
  963. {
  964. struct cppi41_dd *cdd = dev_get_drvdata(dev);
  965. unsigned long flags;
  966. spin_lock_irqsave(&cdd->lock, flags);
  967. cdd->is_suspended = false;
  968. cppi41_run_queue(cdd);
  969. spin_unlock_irqrestore(&cdd->lock, flags);
  970. return 0;
  971. }
  972. static const struct dev_pm_ops cppi41_pm_ops = {
  973. SET_LATE_SYSTEM_SLEEP_PM_OPS(cppi41_suspend, cppi41_resume)
  974. SET_RUNTIME_PM_OPS(cppi41_runtime_suspend,
  975. cppi41_runtime_resume,
  976. NULL)
  977. };
  978. static struct platform_driver cpp41_dma_driver = {
  979. .probe = cppi41_dma_probe,
  980. .remove = cppi41_dma_remove,
  981. .driver = {
  982. .name = "cppi41-dma-engine",
  983. .pm = &cppi41_pm_ops,
  984. .of_match_table = of_match_ptr(cppi41_dma_ids),
  985. },
  986. };
  987. module_platform_driver(cpp41_dma_driver);
  988. MODULE_LICENSE("GPL");
  989. MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy@linutronix.de>");