mmp_tdma.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. /*
  2. * Driver For Marvell Two-channel DMA Engine
  3. *
  4. * Copyright: Marvell International Ltd.
  5. *
  6. * The code contained herein is licensed under the GNU General Public
  7. * License. You may obtain a copy of the GNU General Public License
  8. * Version 2 or later at the following locations:
  9. *
  10. */
  11. #include <linux/module.h>
  12. #include <linux/init.h>
  13. #include <linux/types.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/dma-mapping.h>
  16. #include <linux/slab.h>
  17. #include <linux/dmaengine.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/device.h>
  20. #include <mach/regs-icu.h>
  21. #include <linux/platform_data/dma-mmp_tdma.h>
  22. #include <linux/of_device.h>
  23. #include "dmaengine.h"
  24. /*
  25. * Two-Channel DMA registers
  26. */
  27. #define TDBCR 0x00 /* Byte Count */
  28. #define TDSAR 0x10 /* Src Addr */
  29. #define TDDAR 0x20 /* Dst Addr */
  30. #define TDNDPR 0x30 /* Next Desc */
  31. #define TDCR 0x40 /* Control */
  32. #define TDCP 0x60 /* Priority*/
  33. #define TDCDPR 0x70 /* Current Desc */
  34. #define TDIMR 0x80 /* Int Mask */
  35. #define TDISR 0xa0 /* Int Status */
  36. /* Two-Channel DMA Control Register */
  37. #define TDCR_SSZ_8_BITS (0x0 << 22) /* Sample Size */
  38. #define TDCR_SSZ_12_BITS (0x1 << 22)
  39. #define TDCR_SSZ_16_BITS (0x2 << 22)
  40. #define TDCR_SSZ_20_BITS (0x3 << 22)
  41. #define TDCR_SSZ_24_BITS (0x4 << 22)
  42. #define TDCR_SSZ_32_BITS (0x5 << 22)
  43. #define TDCR_SSZ_SHIFT (0x1 << 22)
  44. #define TDCR_SSZ_MASK (0x7 << 22)
  45. #define TDCR_SSPMOD (0x1 << 21) /* SSP MOD */
  46. #define TDCR_ABR (0x1 << 20) /* Channel Abort */
  47. #define TDCR_CDE (0x1 << 17) /* Close Desc Enable */
  48. #define TDCR_PACKMOD (0x1 << 16) /* Pack Mode (ADMA Only) */
  49. #define TDCR_CHANACT (0x1 << 14) /* Channel Active */
  50. #define TDCR_FETCHND (0x1 << 13) /* Fetch Next Desc */
  51. #define TDCR_CHANEN (0x1 << 12) /* Channel Enable */
  52. #define TDCR_INTMODE (0x1 << 10) /* Interrupt Mode */
  53. #define TDCR_CHAINMOD (0x1 << 9) /* Chain Mode */
  54. #define TDCR_BURSTSZ_MSK (0x7 << 6) /* Burst Size */
  55. #define TDCR_BURSTSZ_4B (0x0 << 6)
  56. #define TDCR_BURSTSZ_8B (0x1 << 6)
  57. #define TDCR_BURSTSZ_16B (0x3 << 6)
  58. #define TDCR_BURSTSZ_32B (0x6 << 6)
  59. #define TDCR_BURSTSZ_64B (0x7 << 6)
  60. #define TDCR_BURSTSZ_SQU_32B (0x7 << 6)
  61. #define TDCR_BURSTSZ_128B (0x5 << 6)
  62. #define TDCR_DSTDIR_MSK (0x3 << 4) /* Dst Direction */
  63. #define TDCR_DSTDIR_ADDR_HOLD (0x2 << 4) /* Dst Addr Hold */
  64. #define TDCR_DSTDIR_ADDR_INC (0x0 << 4) /* Dst Addr Increment */
  65. #define TDCR_SRCDIR_MSK (0x3 << 2) /* Src Direction */
  66. #define TDCR_SRCDIR_ADDR_HOLD (0x2 << 2) /* Src Addr Hold */
  67. #define TDCR_SRCDIR_ADDR_INC (0x0 << 2) /* Src Addr Increment */
  68. #define TDCR_DSTDESCCONT (0x1 << 1)
  69. #define TDCR_SRCDESTCONT (0x1 << 0)
  70. /* Two-Channel DMA Int Mask Register */
  71. #define TDIMR_COMP (0x1 << 0)
  72. /* Two-Channel DMA Int Status Register */
  73. #define TDISR_COMP (0x1 << 0)
  74. /*
  75. * Two-Channel DMA Descriptor Struct
  76. * NOTE: desc's buf must be aligned to 16 bytes.
  77. */
  78. struct mmp_tdma_desc {
  79. u32 byte_cnt;
  80. u32 src_addr;
  81. u32 dst_addr;
  82. u32 nxt_desc;
  83. };
  84. enum mmp_tdma_type {
  85. MMP_AUD_TDMA = 0,
  86. PXA910_SQU,
  87. };
  88. #define TDMA_ALIGNMENT 3
  89. #define TDMA_MAX_XFER_BYTES SZ_64K
  90. struct mmp_tdma_chan {
  91. struct device *dev;
  92. struct dma_chan chan;
  93. struct dma_async_tx_descriptor desc;
  94. struct tasklet_struct tasklet;
  95. struct mmp_tdma_desc *desc_arr;
  96. phys_addr_t desc_arr_phys;
  97. int desc_num;
  98. enum dma_transfer_direction dir;
  99. dma_addr_t dev_addr;
  100. u32 burst_sz;
  101. enum dma_slave_buswidth buswidth;
  102. enum dma_status status;
  103. int idx;
  104. enum mmp_tdma_type type;
  105. int irq;
  106. unsigned long reg_base;
  107. size_t buf_len;
  108. size_t period_len;
  109. size_t pos;
  110. };
  111. #define TDMA_CHANNEL_NUM 2
  112. struct mmp_tdma_device {
  113. struct device *dev;
  114. void __iomem *base;
  115. struct dma_device device;
  116. struct mmp_tdma_chan *tdmac[TDMA_CHANNEL_NUM];
  117. };
  118. #define to_mmp_tdma_chan(dchan) container_of(dchan, struct mmp_tdma_chan, chan)
  119. static void mmp_tdma_chan_set_desc(struct mmp_tdma_chan *tdmac, dma_addr_t phys)
  120. {
  121. writel(phys, tdmac->reg_base + TDNDPR);
  122. writel(readl(tdmac->reg_base + TDCR) | TDCR_FETCHND,
  123. tdmac->reg_base + TDCR);
  124. }
  125. static void mmp_tdma_enable_chan(struct mmp_tdma_chan *tdmac)
  126. {
  127. /* enable irq */
  128. writel(TDIMR_COMP, tdmac->reg_base + TDIMR);
  129. /* enable dma chan */
  130. writel(readl(tdmac->reg_base + TDCR) | TDCR_CHANEN,
  131. tdmac->reg_base + TDCR);
  132. tdmac->status = DMA_IN_PROGRESS;
  133. }
  134. static void mmp_tdma_disable_chan(struct mmp_tdma_chan *tdmac)
  135. {
  136. writel(readl(tdmac->reg_base + TDCR) & ~TDCR_CHANEN,
  137. tdmac->reg_base + TDCR);
  138. tdmac->status = DMA_SUCCESS;
  139. }
  140. static void mmp_tdma_resume_chan(struct mmp_tdma_chan *tdmac)
  141. {
  142. writel(readl(tdmac->reg_base + TDCR) | TDCR_CHANEN,
  143. tdmac->reg_base + TDCR);
  144. tdmac->status = DMA_IN_PROGRESS;
  145. }
  146. static void mmp_tdma_pause_chan(struct mmp_tdma_chan *tdmac)
  147. {
  148. writel(readl(tdmac->reg_base + TDCR) & ~TDCR_CHANEN,
  149. tdmac->reg_base + TDCR);
  150. tdmac->status = DMA_PAUSED;
  151. }
  152. static int mmp_tdma_config_chan(struct mmp_tdma_chan *tdmac)
  153. {
  154. unsigned int tdcr;
  155. mmp_tdma_disable_chan(tdmac);
  156. if (tdmac->dir == DMA_MEM_TO_DEV)
  157. tdcr = TDCR_DSTDIR_ADDR_HOLD | TDCR_SRCDIR_ADDR_INC;
  158. else if (tdmac->dir == DMA_DEV_TO_MEM)
  159. tdcr = TDCR_SRCDIR_ADDR_HOLD | TDCR_DSTDIR_ADDR_INC;
  160. if (tdmac->type == MMP_AUD_TDMA) {
  161. tdcr |= TDCR_PACKMOD;
  162. switch (tdmac->burst_sz) {
  163. case 4:
  164. tdcr |= TDCR_BURSTSZ_4B;
  165. break;
  166. case 8:
  167. tdcr |= TDCR_BURSTSZ_8B;
  168. break;
  169. case 16:
  170. tdcr |= TDCR_BURSTSZ_16B;
  171. break;
  172. case 32:
  173. tdcr |= TDCR_BURSTSZ_32B;
  174. break;
  175. case 64:
  176. tdcr |= TDCR_BURSTSZ_64B;
  177. break;
  178. case 128:
  179. tdcr |= TDCR_BURSTSZ_128B;
  180. break;
  181. default:
  182. dev_err(tdmac->dev, "mmp_tdma: unknown burst size.\n");
  183. return -EINVAL;
  184. }
  185. switch (tdmac->buswidth) {
  186. case DMA_SLAVE_BUSWIDTH_1_BYTE:
  187. tdcr |= TDCR_SSZ_8_BITS;
  188. break;
  189. case DMA_SLAVE_BUSWIDTH_2_BYTES:
  190. tdcr |= TDCR_SSZ_16_BITS;
  191. break;
  192. case DMA_SLAVE_BUSWIDTH_4_BYTES:
  193. tdcr |= TDCR_SSZ_32_BITS;
  194. break;
  195. default:
  196. dev_err(tdmac->dev, "mmp_tdma: unknown bus size.\n");
  197. return -EINVAL;
  198. }
  199. } else if (tdmac->type == PXA910_SQU) {
  200. tdcr |= TDCR_BURSTSZ_SQU_32B;
  201. tdcr |= TDCR_SSPMOD;
  202. }
  203. writel(tdcr, tdmac->reg_base + TDCR);
  204. return 0;
  205. }
  206. static int mmp_tdma_clear_chan_irq(struct mmp_tdma_chan *tdmac)
  207. {
  208. u32 reg = readl(tdmac->reg_base + TDISR);
  209. if (reg & TDISR_COMP) {
  210. /* clear irq */
  211. reg &= ~TDISR_COMP;
  212. writel(reg, tdmac->reg_base + TDISR);
  213. return 0;
  214. }
  215. return -EAGAIN;
  216. }
  217. static irqreturn_t mmp_tdma_chan_handler(int irq, void *dev_id)
  218. {
  219. struct mmp_tdma_chan *tdmac = dev_id;
  220. if (mmp_tdma_clear_chan_irq(tdmac) == 0) {
  221. tdmac->pos = (tdmac->pos + tdmac->period_len) % tdmac->buf_len;
  222. tasklet_schedule(&tdmac->tasklet);
  223. return IRQ_HANDLED;
  224. } else
  225. return IRQ_NONE;
  226. }
  227. static irqreturn_t mmp_tdma_int_handler(int irq, void *dev_id)
  228. {
  229. struct mmp_tdma_device *tdev = dev_id;
  230. int i, ret;
  231. int irq_num = 0;
  232. for (i = 0; i < TDMA_CHANNEL_NUM; i++) {
  233. struct mmp_tdma_chan *tdmac = tdev->tdmac[i];
  234. ret = mmp_tdma_chan_handler(irq, tdmac);
  235. if (ret == IRQ_HANDLED)
  236. irq_num++;
  237. }
  238. if (irq_num)
  239. return IRQ_HANDLED;
  240. else
  241. return IRQ_NONE;
  242. }
  243. static void dma_do_tasklet(unsigned long data)
  244. {
  245. struct mmp_tdma_chan *tdmac = (struct mmp_tdma_chan *)data;
  246. if (tdmac->desc.callback)
  247. tdmac->desc.callback(tdmac->desc.callback_param);
  248. }
  249. static void mmp_tdma_free_descriptor(struct mmp_tdma_chan *tdmac)
  250. {
  251. struct gen_pool *gpool;
  252. int size = tdmac->desc_num * sizeof(struct mmp_tdma_desc);
  253. gpool = sram_get_gpool("asram");
  254. if (tdmac->desc_arr)
  255. gen_pool_free(gpool, (unsigned long)tdmac->desc_arr,
  256. size);
  257. tdmac->desc_arr = NULL;
  258. return;
  259. }
  260. static dma_cookie_t mmp_tdma_tx_submit(struct dma_async_tx_descriptor *tx)
  261. {
  262. struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(tx->chan);
  263. mmp_tdma_chan_set_desc(tdmac, tdmac->desc_arr_phys);
  264. return 0;
  265. }
  266. static int mmp_tdma_alloc_chan_resources(struct dma_chan *chan)
  267. {
  268. struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
  269. int ret;
  270. dma_async_tx_descriptor_init(&tdmac->desc, chan);
  271. tdmac->desc.tx_submit = mmp_tdma_tx_submit;
  272. if (tdmac->irq) {
  273. ret = devm_request_irq(tdmac->dev, tdmac->irq,
  274. mmp_tdma_chan_handler, IRQF_DISABLED, "tdma", tdmac);
  275. if (ret)
  276. return ret;
  277. }
  278. return 1;
  279. }
  280. static void mmp_tdma_free_chan_resources(struct dma_chan *chan)
  281. {
  282. struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
  283. if (tdmac->irq)
  284. devm_free_irq(tdmac->dev, tdmac->irq, tdmac);
  285. mmp_tdma_free_descriptor(tdmac);
  286. return;
  287. }
  288. struct mmp_tdma_desc *mmp_tdma_alloc_descriptor(struct mmp_tdma_chan *tdmac)
  289. {
  290. struct gen_pool *gpool;
  291. int size = tdmac->desc_num * sizeof(struct mmp_tdma_desc);
  292. gpool = sram_get_gpool("asram");
  293. if (!gpool)
  294. return NULL;
  295. tdmac->desc_arr = (void *)gen_pool_alloc(gpool, size);
  296. if (!tdmac->desc_arr)
  297. return NULL;
  298. tdmac->desc_arr_phys = gen_pool_virt_to_phys(gpool,
  299. (unsigned long)tdmac->desc_arr);
  300. return tdmac->desc_arr;
  301. }
  302. static struct dma_async_tx_descriptor *mmp_tdma_prep_dma_cyclic(
  303. struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len,
  304. size_t period_len, enum dma_transfer_direction direction,
  305. unsigned long flags, void *context)
  306. {
  307. struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
  308. struct mmp_tdma_desc *desc;
  309. int num_periods = buf_len / period_len;
  310. int i = 0, buf = 0;
  311. if (tdmac->status != DMA_SUCCESS)
  312. return NULL;
  313. if (period_len > TDMA_MAX_XFER_BYTES) {
  314. dev_err(tdmac->dev,
  315. "maximum period size exceeded: %d > %d\n",
  316. period_len, TDMA_MAX_XFER_BYTES);
  317. goto err_out;
  318. }
  319. tdmac->status = DMA_IN_PROGRESS;
  320. tdmac->desc_num = num_periods;
  321. desc = mmp_tdma_alloc_descriptor(tdmac);
  322. if (!desc)
  323. goto err_out;
  324. while (buf < buf_len) {
  325. desc = &tdmac->desc_arr[i];
  326. if (i + 1 == num_periods)
  327. desc->nxt_desc = tdmac->desc_arr_phys;
  328. else
  329. desc->nxt_desc = tdmac->desc_arr_phys +
  330. sizeof(*desc) * (i + 1);
  331. if (direction == DMA_MEM_TO_DEV) {
  332. desc->src_addr = dma_addr;
  333. desc->dst_addr = tdmac->dev_addr;
  334. } else {
  335. desc->src_addr = tdmac->dev_addr;
  336. desc->dst_addr = dma_addr;
  337. }
  338. desc->byte_cnt = period_len;
  339. dma_addr += period_len;
  340. buf += period_len;
  341. i++;
  342. }
  343. tdmac->buf_len = buf_len;
  344. tdmac->period_len = period_len;
  345. tdmac->pos = 0;
  346. return &tdmac->desc;
  347. err_out:
  348. tdmac->status = DMA_ERROR;
  349. return NULL;
  350. }
  351. static int mmp_tdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
  352. unsigned long arg)
  353. {
  354. struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
  355. struct dma_slave_config *dmaengine_cfg = (void *)arg;
  356. int ret = 0;
  357. switch (cmd) {
  358. case DMA_TERMINATE_ALL:
  359. mmp_tdma_disable_chan(tdmac);
  360. break;
  361. case DMA_PAUSE:
  362. mmp_tdma_pause_chan(tdmac);
  363. break;
  364. case DMA_RESUME:
  365. mmp_tdma_resume_chan(tdmac);
  366. break;
  367. case DMA_SLAVE_CONFIG:
  368. if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) {
  369. tdmac->dev_addr = dmaengine_cfg->src_addr;
  370. tdmac->burst_sz = dmaengine_cfg->src_maxburst;
  371. tdmac->buswidth = dmaengine_cfg->src_addr_width;
  372. } else {
  373. tdmac->dev_addr = dmaengine_cfg->dst_addr;
  374. tdmac->burst_sz = dmaengine_cfg->dst_maxburst;
  375. tdmac->buswidth = dmaengine_cfg->dst_addr_width;
  376. }
  377. tdmac->dir = dmaengine_cfg->direction;
  378. return mmp_tdma_config_chan(tdmac);
  379. default:
  380. ret = -ENOSYS;
  381. }
  382. return ret;
  383. }
  384. static enum dma_status mmp_tdma_tx_status(struct dma_chan *chan,
  385. dma_cookie_t cookie, struct dma_tx_state *txstate)
  386. {
  387. struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
  388. dma_set_residue(txstate, tdmac->buf_len - tdmac->pos);
  389. return tdmac->status;
  390. }
  391. static void mmp_tdma_issue_pending(struct dma_chan *chan)
  392. {
  393. struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
  394. mmp_tdma_enable_chan(tdmac);
  395. }
  396. static int mmp_tdma_remove(struct platform_device *pdev)
  397. {
  398. struct mmp_tdma_device *tdev = platform_get_drvdata(pdev);
  399. dma_async_device_unregister(&tdev->device);
  400. return 0;
  401. }
  402. static int mmp_tdma_chan_init(struct mmp_tdma_device *tdev,
  403. int idx, int irq, int type)
  404. {
  405. struct mmp_tdma_chan *tdmac;
  406. if (idx >= TDMA_CHANNEL_NUM) {
  407. dev_err(tdev->dev, "too many channels for device!\n");
  408. return -EINVAL;
  409. }
  410. /* alloc channel */
  411. tdmac = devm_kzalloc(tdev->dev, sizeof(*tdmac), GFP_KERNEL);
  412. if (!tdmac) {
  413. dev_err(tdev->dev, "no free memory for DMA channels!\n");
  414. return -ENOMEM;
  415. }
  416. if (irq)
  417. tdmac->irq = irq;
  418. tdmac->dev = tdev->dev;
  419. tdmac->chan.device = &tdev->device;
  420. tdmac->idx = idx;
  421. tdmac->type = type;
  422. tdmac->reg_base = (unsigned long)tdev->base + idx * 4;
  423. tdmac->status = DMA_SUCCESS;
  424. tdev->tdmac[tdmac->idx] = tdmac;
  425. tasklet_init(&tdmac->tasklet, dma_do_tasklet, (unsigned long)tdmac);
  426. /* add the channel to tdma_chan list */
  427. list_add_tail(&tdmac->chan.device_node,
  428. &tdev->device.channels);
  429. return 0;
  430. }
  431. static struct of_device_id mmp_tdma_dt_ids[] = {
  432. { .compatible = "marvell,adma-1.0", .data = (void *)MMP_AUD_TDMA},
  433. { .compatible = "marvell,pxa910-squ", .data = (void *)PXA910_SQU},
  434. {}
  435. };
  436. MODULE_DEVICE_TABLE(of, mmp_tdma_dt_ids);
  437. static int mmp_tdma_probe(struct platform_device *pdev)
  438. {
  439. enum mmp_tdma_type type;
  440. const struct of_device_id *of_id;
  441. struct mmp_tdma_device *tdev;
  442. struct resource *iores;
  443. int i, ret;
  444. int irq = 0, irq_num = 0;
  445. int chan_num = TDMA_CHANNEL_NUM;
  446. of_id = of_match_device(mmp_tdma_dt_ids, &pdev->dev);
  447. if (of_id)
  448. type = (enum mmp_tdma_type) of_id->data;
  449. else
  450. type = platform_get_device_id(pdev)->driver_data;
  451. /* always have couple channels */
  452. tdev = devm_kzalloc(&pdev->dev, sizeof(*tdev), GFP_KERNEL);
  453. if (!tdev)
  454. return -ENOMEM;
  455. tdev->dev = &pdev->dev;
  456. for (i = 0; i < chan_num; i++) {
  457. if (platform_get_irq(pdev, i) > 0)
  458. irq_num++;
  459. }
  460. iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  461. if (!iores)
  462. return -EINVAL;
  463. tdev->base = devm_request_and_ioremap(&pdev->dev, iores);
  464. if (!tdev->base)
  465. return -EADDRNOTAVAIL;
  466. INIT_LIST_HEAD(&tdev->device.channels);
  467. if (irq_num != chan_num) {
  468. irq = platform_get_irq(pdev, 0);
  469. ret = devm_request_irq(&pdev->dev, irq,
  470. mmp_tdma_int_handler, IRQF_DISABLED, "tdma", tdev);
  471. if (ret)
  472. return ret;
  473. }
  474. /* initialize channel parameters */
  475. for (i = 0; i < chan_num; i++) {
  476. irq = (irq_num != chan_num) ? 0 : platform_get_irq(pdev, i);
  477. ret = mmp_tdma_chan_init(tdev, i, irq, type);
  478. if (ret)
  479. return ret;
  480. }
  481. dma_cap_set(DMA_SLAVE, tdev->device.cap_mask);
  482. dma_cap_set(DMA_CYCLIC, tdev->device.cap_mask);
  483. tdev->device.dev = &pdev->dev;
  484. tdev->device.device_alloc_chan_resources =
  485. mmp_tdma_alloc_chan_resources;
  486. tdev->device.device_free_chan_resources =
  487. mmp_tdma_free_chan_resources;
  488. tdev->device.device_prep_dma_cyclic = mmp_tdma_prep_dma_cyclic;
  489. tdev->device.device_tx_status = mmp_tdma_tx_status;
  490. tdev->device.device_issue_pending = mmp_tdma_issue_pending;
  491. tdev->device.device_control = mmp_tdma_control;
  492. tdev->device.copy_align = TDMA_ALIGNMENT;
  493. dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
  494. platform_set_drvdata(pdev, tdev);
  495. ret = dma_async_device_register(&tdev->device);
  496. if (ret) {
  497. dev_err(tdev->device.dev, "unable to register\n");
  498. return ret;
  499. }
  500. dev_info(tdev->device.dev, "initialized\n");
  501. return 0;
  502. }
  503. static const struct platform_device_id mmp_tdma_id_table[] = {
  504. { "mmp-adma", MMP_AUD_TDMA },
  505. { "pxa910-squ", PXA910_SQU },
  506. { },
  507. };
  508. static struct platform_driver mmp_tdma_driver = {
  509. .driver = {
  510. .name = "mmp-tdma",
  511. .owner = THIS_MODULE,
  512. .of_match_table = mmp_tdma_dt_ids,
  513. },
  514. .id_table = mmp_tdma_id_table,
  515. .probe = mmp_tdma_probe,
  516. .remove = mmp_tdma_remove,
  517. };
  518. module_platform_driver(mmp_tdma_driver);
  519. MODULE_LICENSE("GPL");
  520. MODULE_DESCRIPTION("MMP Two-Channel DMA Driver");
  521. MODULE_ALIAS("platform:mmp-tdma");
  522. MODULE_AUTHOR("Leo Yan <leoy@marvell.com>");
  523. MODULE_AUTHOR("Zhangfei Gao <zhangfei.gao@marvell.com>");