mmp_tdma.c 15 KB

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