omap-mcpdm.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. /*
  2. * omap-mcpdm.c -- OMAP ALSA SoC DAI driver using McPDM port
  3. *
  4. * Copyright (C) 2009 - 2011 Texas Instruments
  5. *
  6. * Author: Misael Lopez Cruz <misael.lopez@ti.com>
  7. * Contact: Jorge Eduardo Candelaria <x0107209@ti.com>
  8. * Margarita Olaya <magi.olaya@ti.com>
  9. * Peter Ujfalusi <peter.ujfalusi@ti.com>
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * version 2 as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  23. * 02110-1301 USA
  24. *
  25. */
  26. #include <linux/init.h>
  27. #include <linux/module.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/interrupt.h>
  30. #include <linux/err.h>
  31. #include <linux/io.h>
  32. #include <linux/irq.h>
  33. #include <linux/slab.h>
  34. #include <linux/pm_runtime.h>
  35. #include <linux/of_device.h>
  36. #include <sound/core.h>
  37. #include <sound/pcm.h>
  38. #include <sound/pcm_params.h>
  39. #include <sound/soc.h>
  40. #include <sound/dmaengine_pcm.h>
  41. #include "omap-mcpdm.h"
  42. #include "sdma-pcm.h"
  43. struct mcpdm_link_config {
  44. u32 link_mask; /* channel mask for the direction */
  45. u32 threshold; /* FIFO threshold */
  46. };
  47. struct omap_mcpdm {
  48. struct device *dev;
  49. unsigned long phys_base;
  50. void __iomem *io_base;
  51. int irq;
  52. struct mutex mutex;
  53. /* Playback/Capture configuration */
  54. struct mcpdm_link_config config[2];
  55. /* McPDM dn offsets for rx1, and 2 channels */
  56. u32 dn_rx_offset;
  57. /* McPDM needs to be restarted due to runtime reconfiguration */
  58. bool restart;
  59. /* pm state for suspend/resume handling */
  60. int pm_active_count;
  61. struct snd_dmaengine_dai_dma_data dma_data[2];
  62. };
  63. /*
  64. * Stream DMA parameters
  65. */
  66. static inline void omap_mcpdm_write(struct omap_mcpdm *mcpdm, u16 reg, u32 val)
  67. {
  68. writel_relaxed(val, mcpdm->io_base + reg);
  69. }
  70. static inline int omap_mcpdm_read(struct omap_mcpdm *mcpdm, u16 reg)
  71. {
  72. return readl_relaxed(mcpdm->io_base + reg);
  73. }
  74. #ifdef DEBUG
  75. static void omap_mcpdm_reg_dump(struct omap_mcpdm *mcpdm)
  76. {
  77. dev_dbg(mcpdm->dev, "***********************\n");
  78. dev_dbg(mcpdm->dev, "IRQSTATUS_RAW: 0x%04x\n",
  79. omap_mcpdm_read(mcpdm, MCPDM_REG_IRQSTATUS_RAW));
  80. dev_dbg(mcpdm->dev, "IRQSTATUS: 0x%04x\n",
  81. omap_mcpdm_read(mcpdm, MCPDM_REG_IRQSTATUS));
  82. dev_dbg(mcpdm->dev, "IRQENABLE_SET: 0x%04x\n",
  83. omap_mcpdm_read(mcpdm, MCPDM_REG_IRQENABLE_SET));
  84. dev_dbg(mcpdm->dev, "IRQENABLE_CLR: 0x%04x\n",
  85. omap_mcpdm_read(mcpdm, MCPDM_REG_IRQENABLE_CLR));
  86. dev_dbg(mcpdm->dev, "IRQWAKE_EN: 0x%04x\n",
  87. omap_mcpdm_read(mcpdm, MCPDM_REG_IRQWAKE_EN));
  88. dev_dbg(mcpdm->dev, "DMAENABLE_SET: 0x%04x\n",
  89. omap_mcpdm_read(mcpdm, MCPDM_REG_DMAENABLE_SET));
  90. dev_dbg(mcpdm->dev, "DMAENABLE_CLR: 0x%04x\n",
  91. omap_mcpdm_read(mcpdm, MCPDM_REG_DMAENABLE_CLR));
  92. dev_dbg(mcpdm->dev, "DMAWAKEEN: 0x%04x\n",
  93. omap_mcpdm_read(mcpdm, MCPDM_REG_DMAWAKEEN));
  94. dev_dbg(mcpdm->dev, "CTRL: 0x%04x\n",
  95. omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL));
  96. dev_dbg(mcpdm->dev, "DN_DATA: 0x%04x\n",
  97. omap_mcpdm_read(mcpdm, MCPDM_REG_DN_DATA));
  98. dev_dbg(mcpdm->dev, "UP_DATA: 0x%04x\n",
  99. omap_mcpdm_read(mcpdm, MCPDM_REG_UP_DATA));
  100. dev_dbg(mcpdm->dev, "FIFO_CTRL_DN: 0x%04x\n",
  101. omap_mcpdm_read(mcpdm, MCPDM_REG_FIFO_CTRL_DN));
  102. dev_dbg(mcpdm->dev, "FIFO_CTRL_UP: 0x%04x\n",
  103. omap_mcpdm_read(mcpdm, MCPDM_REG_FIFO_CTRL_UP));
  104. dev_dbg(mcpdm->dev, "***********************\n");
  105. }
  106. #else
  107. static void omap_mcpdm_reg_dump(struct omap_mcpdm *mcpdm) {}
  108. #endif
  109. /*
  110. * Enables the transfer through the PDM interface to/from the Phoenix
  111. * codec by enabling the corresponding UP or DN channels.
  112. */
  113. static void omap_mcpdm_start(struct omap_mcpdm *mcpdm)
  114. {
  115. u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL);
  116. u32 link_mask = mcpdm->config[0].link_mask | mcpdm->config[1].link_mask;
  117. ctrl |= (MCPDM_SW_DN_RST | MCPDM_SW_UP_RST);
  118. omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl);
  119. ctrl |= link_mask;
  120. omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl);
  121. ctrl &= ~(MCPDM_SW_DN_RST | MCPDM_SW_UP_RST);
  122. omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl);
  123. }
  124. /*
  125. * Disables the transfer through the PDM interface to/from the Phoenix
  126. * codec by disabling the corresponding UP or DN channels.
  127. */
  128. static void omap_mcpdm_stop(struct omap_mcpdm *mcpdm)
  129. {
  130. u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL);
  131. u32 link_mask = MCPDM_PDM_DN_MASK | MCPDM_PDM_UP_MASK;
  132. ctrl |= (MCPDM_SW_DN_RST | MCPDM_SW_UP_RST);
  133. omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl);
  134. ctrl &= ~(link_mask);
  135. omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl);
  136. ctrl &= ~(MCPDM_SW_DN_RST | MCPDM_SW_UP_RST);
  137. omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl);
  138. }
  139. /*
  140. * Is the physical McPDM interface active.
  141. */
  142. static inline int omap_mcpdm_active(struct omap_mcpdm *mcpdm)
  143. {
  144. return omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL) &
  145. (MCPDM_PDM_DN_MASK | MCPDM_PDM_UP_MASK);
  146. }
  147. /*
  148. * Configures McPDM uplink, and downlink for audio.
  149. * This function should be called before omap_mcpdm_start.
  150. */
  151. static void omap_mcpdm_open_streams(struct omap_mcpdm *mcpdm)
  152. {
  153. u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL);
  154. omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl | MCPDM_WD_EN);
  155. omap_mcpdm_write(mcpdm, MCPDM_REG_IRQENABLE_SET,
  156. MCPDM_DN_IRQ_EMPTY | MCPDM_DN_IRQ_FULL |
  157. MCPDM_UP_IRQ_EMPTY | MCPDM_UP_IRQ_FULL);
  158. /* Enable DN RX1/2 offset cancellation feature, if configured */
  159. if (mcpdm->dn_rx_offset) {
  160. u32 dn_offset = mcpdm->dn_rx_offset;
  161. omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, dn_offset);
  162. dn_offset |= (MCPDM_DN_OFST_RX1_EN | MCPDM_DN_OFST_RX2_EN);
  163. omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, dn_offset);
  164. }
  165. omap_mcpdm_write(mcpdm, MCPDM_REG_FIFO_CTRL_DN,
  166. mcpdm->config[SNDRV_PCM_STREAM_PLAYBACK].threshold);
  167. omap_mcpdm_write(mcpdm, MCPDM_REG_FIFO_CTRL_UP,
  168. mcpdm->config[SNDRV_PCM_STREAM_CAPTURE].threshold);
  169. omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_SET,
  170. MCPDM_DMA_DN_ENABLE | MCPDM_DMA_UP_ENABLE);
  171. }
  172. /*
  173. * Cleans McPDM uplink, and downlink configuration.
  174. * This function should be called when the stream is closed.
  175. */
  176. static void omap_mcpdm_close_streams(struct omap_mcpdm *mcpdm)
  177. {
  178. /* Disable irq request generation for downlink */
  179. omap_mcpdm_write(mcpdm, MCPDM_REG_IRQENABLE_CLR,
  180. MCPDM_DN_IRQ_EMPTY | MCPDM_DN_IRQ_FULL);
  181. /* Disable DMA request generation for downlink */
  182. omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_CLR, MCPDM_DMA_DN_ENABLE);
  183. /* Disable irq request generation for uplink */
  184. omap_mcpdm_write(mcpdm, MCPDM_REG_IRQENABLE_CLR,
  185. MCPDM_UP_IRQ_EMPTY | MCPDM_UP_IRQ_FULL);
  186. /* Disable DMA request generation for uplink */
  187. omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_CLR, MCPDM_DMA_UP_ENABLE);
  188. /* Disable RX1/2 offset cancellation */
  189. if (mcpdm->dn_rx_offset)
  190. omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, 0);
  191. }
  192. static irqreturn_t omap_mcpdm_irq_handler(int irq, void *dev_id)
  193. {
  194. struct omap_mcpdm *mcpdm = dev_id;
  195. int irq_status;
  196. irq_status = omap_mcpdm_read(mcpdm, MCPDM_REG_IRQSTATUS);
  197. /* Acknowledge irq event */
  198. omap_mcpdm_write(mcpdm, MCPDM_REG_IRQSTATUS, irq_status);
  199. if (irq_status & MCPDM_DN_IRQ_FULL)
  200. dev_dbg(mcpdm->dev, "DN (playback) FIFO Full\n");
  201. if (irq_status & MCPDM_DN_IRQ_EMPTY)
  202. dev_dbg(mcpdm->dev, "DN (playback) FIFO Empty\n");
  203. if (irq_status & MCPDM_DN_IRQ)
  204. dev_dbg(mcpdm->dev, "DN (playback) write request\n");
  205. if (irq_status & MCPDM_UP_IRQ_FULL)
  206. dev_dbg(mcpdm->dev, "UP (capture) FIFO Full\n");
  207. if (irq_status & MCPDM_UP_IRQ_EMPTY)
  208. dev_dbg(mcpdm->dev, "UP (capture) FIFO Empty\n");
  209. if (irq_status & MCPDM_UP_IRQ)
  210. dev_dbg(mcpdm->dev, "UP (capture) write request\n");
  211. return IRQ_HANDLED;
  212. }
  213. static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream,
  214. struct snd_soc_dai *dai)
  215. {
  216. struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai);
  217. mutex_lock(&mcpdm->mutex);
  218. if (!dai->active)
  219. omap_mcpdm_open_streams(mcpdm);
  220. mutex_unlock(&mcpdm->mutex);
  221. return 0;
  222. }
  223. static void omap_mcpdm_dai_shutdown(struct snd_pcm_substream *substream,
  224. struct snd_soc_dai *dai)
  225. {
  226. struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai);
  227. mutex_lock(&mcpdm->mutex);
  228. if (!dai->active) {
  229. if (omap_mcpdm_active(mcpdm)) {
  230. omap_mcpdm_stop(mcpdm);
  231. omap_mcpdm_close_streams(mcpdm);
  232. mcpdm->config[0].link_mask = 0;
  233. mcpdm->config[1].link_mask = 0;
  234. }
  235. }
  236. mutex_unlock(&mcpdm->mutex);
  237. }
  238. static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream,
  239. struct snd_pcm_hw_params *params,
  240. struct snd_soc_dai *dai)
  241. {
  242. struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai);
  243. int stream = substream->stream;
  244. struct snd_dmaengine_dai_dma_data *dma_data;
  245. u32 threshold;
  246. int channels;
  247. int link_mask = 0;
  248. channels = params_channels(params);
  249. switch (channels) {
  250. case 5:
  251. if (stream == SNDRV_PCM_STREAM_CAPTURE)
  252. /* up to 3 channels for capture */
  253. return -EINVAL;
  254. link_mask |= 1 << 4;
  255. /* fall through */
  256. case 4:
  257. if (stream == SNDRV_PCM_STREAM_CAPTURE)
  258. /* up to 3 channels for capture */
  259. return -EINVAL;
  260. link_mask |= 1 << 3;
  261. /* fall through */
  262. case 3:
  263. link_mask |= 1 << 2;
  264. /* fall through */
  265. case 2:
  266. link_mask |= 1 << 1;
  267. /* fall through */
  268. case 1:
  269. link_mask |= 1 << 0;
  270. break;
  271. default:
  272. /* unsupported number of channels */
  273. return -EINVAL;
  274. }
  275. dma_data = snd_soc_dai_get_dma_data(dai, substream);
  276. threshold = mcpdm->config[stream].threshold;
  277. /* Configure McPDM channels, and DMA packet size */
  278. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  279. link_mask <<= 3;
  280. /* If capture is not running assume a stereo stream to come */
  281. if (!mcpdm->config[!stream].link_mask)
  282. mcpdm->config[!stream].link_mask = 0x3;
  283. dma_data->maxburst =
  284. (MCPDM_DN_THRES_MAX - threshold) * channels;
  285. } else {
  286. /* If playback is not running assume a stereo stream to come */
  287. if (!mcpdm->config[!stream].link_mask)
  288. mcpdm->config[!stream].link_mask = (0x3 << 3);
  289. dma_data->maxburst = threshold * channels;
  290. }
  291. /* Check if we need to restart McPDM with this stream */
  292. if (mcpdm->config[stream].link_mask &&
  293. mcpdm->config[stream].link_mask != link_mask)
  294. mcpdm->restart = true;
  295. mcpdm->config[stream].link_mask = link_mask;
  296. return 0;
  297. }
  298. static int omap_mcpdm_prepare(struct snd_pcm_substream *substream,
  299. struct snd_soc_dai *dai)
  300. {
  301. struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai);
  302. if (!omap_mcpdm_active(mcpdm)) {
  303. omap_mcpdm_start(mcpdm);
  304. omap_mcpdm_reg_dump(mcpdm);
  305. } else if (mcpdm->restart) {
  306. omap_mcpdm_stop(mcpdm);
  307. omap_mcpdm_start(mcpdm);
  308. mcpdm->restart = false;
  309. omap_mcpdm_reg_dump(mcpdm);
  310. }
  311. return 0;
  312. }
  313. static const struct snd_soc_dai_ops omap_mcpdm_dai_ops = {
  314. .startup = omap_mcpdm_dai_startup,
  315. .shutdown = omap_mcpdm_dai_shutdown,
  316. .hw_params = omap_mcpdm_dai_hw_params,
  317. .prepare = omap_mcpdm_prepare,
  318. };
  319. static int omap_mcpdm_probe(struct snd_soc_dai *dai)
  320. {
  321. struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai);
  322. int ret;
  323. pm_runtime_enable(mcpdm->dev);
  324. /* Disable lines while request is ongoing */
  325. pm_runtime_get_sync(mcpdm->dev);
  326. omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, 0x00);
  327. ret = request_irq(mcpdm->irq, omap_mcpdm_irq_handler, 0, "McPDM",
  328. (void *)mcpdm);
  329. pm_runtime_put_sync(mcpdm->dev);
  330. if (ret) {
  331. dev_err(mcpdm->dev, "Request for IRQ failed\n");
  332. pm_runtime_disable(mcpdm->dev);
  333. }
  334. /* Configure McPDM threshold values */
  335. mcpdm->config[SNDRV_PCM_STREAM_PLAYBACK].threshold = 2;
  336. mcpdm->config[SNDRV_PCM_STREAM_CAPTURE].threshold =
  337. MCPDM_UP_THRES_MAX - 3;
  338. snd_soc_dai_init_dma_data(dai,
  339. &mcpdm->dma_data[SNDRV_PCM_STREAM_PLAYBACK],
  340. &mcpdm->dma_data[SNDRV_PCM_STREAM_CAPTURE]);
  341. return ret;
  342. }
  343. static int omap_mcpdm_remove(struct snd_soc_dai *dai)
  344. {
  345. struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai);
  346. free_irq(mcpdm->irq, (void *)mcpdm);
  347. pm_runtime_disable(mcpdm->dev);
  348. return 0;
  349. }
  350. #ifdef CONFIG_PM_SLEEP
  351. static int omap_mcpdm_suspend(struct snd_soc_dai *dai)
  352. {
  353. struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai);
  354. if (dai->active) {
  355. omap_mcpdm_stop(mcpdm);
  356. omap_mcpdm_close_streams(mcpdm);
  357. }
  358. mcpdm->pm_active_count = 0;
  359. while (pm_runtime_active(mcpdm->dev)) {
  360. pm_runtime_put_sync(mcpdm->dev);
  361. mcpdm->pm_active_count++;
  362. }
  363. return 0;
  364. }
  365. static int omap_mcpdm_resume(struct snd_soc_dai *dai)
  366. {
  367. struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai);
  368. if (mcpdm->pm_active_count) {
  369. while (mcpdm->pm_active_count--)
  370. pm_runtime_get_sync(mcpdm->dev);
  371. if (dai->active) {
  372. omap_mcpdm_open_streams(mcpdm);
  373. omap_mcpdm_start(mcpdm);
  374. }
  375. }
  376. return 0;
  377. }
  378. #else
  379. #define omap_mcpdm_suspend NULL
  380. #define omap_mcpdm_resume NULL
  381. #endif
  382. #define OMAP_MCPDM_RATES (SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
  383. #define OMAP_MCPDM_FORMATS SNDRV_PCM_FMTBIT_S32_LE
  384. static struct snd_soc_dai_driver omap_mcpdm_dai = {
  385. .probe = omap_mcpdm_probe,
  386. .remove = omap_mcpdm_remove,
  387. .suspend = omap_mcpdm_suspend,
  388. .resume = omap_mcpdm_resume,
  389. .probe_order = SND_SOC_COMP_ORDER_LATE,
  390. .remove_order = SND_SOC_COMP_ORDER_EARLY,
  391. .playback = {
  392. .channels_min = 1,
  393. .channels_max = 5,
  394. .rates = OMAP_MCPDM_RATES,
  395. .formats = OMAP_MCPDM_FORMATS,
  396. .sig_bits = 24,
  397. },
  398. .capture = {
  399. .channels_min = 1,
  400. .channels_max = 3,
  401. .rates = OMAP_MCPDM_RATES,
  402. .formats = OMAP_MCPDM_FORMATS,
  403. .sig_bits = 24,
  404. },
  405. .ops = &omap_mcpdm_dai_ops,
  406. };
  407. static const struct snd_soc_component_driver omap_mcpdm_component = {
  408. .name = "omap-mcpdm",
  409. };
  410. void omap_mcpdm_configure_dn_offsets(struct snd_soc_pcm_runtime *rtd,
  411. u8 rx1, u8 rx2)
  412. {
  413. struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(rtd->cpu_dai);
  414. mcpdm->dn_rx_offset = MCPDM_DNOFST_RX1(rx1) | MCPDM_DNOFST_RX2(rx2);
  415. }
  416. EXPORT_SYMBOL_GPL(omap_mcpdm_configure_dn_offsets);
  417. static int asoc_mcpdm_probe(struct platform_device *pdev)
  418. {
  419. struct omap_mcpdm *mcpdm;
  420. struct resource *res;
  421. int ret;
  422. mcpdm = devm_kzalloc(&pdev->dev, sizeof(struct omap_mcpdm), GFP_KERNEL);
  423. if (!mcpdm)
  424. return -ENOMEM;
  425. platform_set_drvdata(pdev, mcpdm);
  426. mutex_init(&mcpdm->mutex);
  427. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma");
  428. if (res == NULL)
  429. return -ENOMEM;
  430. mcpdm->dma_data[0].addr = res->start + MCPDM_REG_DN_DATA;
  431. mcpdm->dma_data[1].addr = res->start + MCPDM_REG_UP_DATA;
  432. mcpdm->dma_data[0].filter_data = "dn_link";
  433. mcpdm->dma_data[1].filter_data = "up_link";
  434. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
  435. mcpdm->io_base = devm_ioremap_resource(&pdev->dev, res);
  436. if (IS_ERR(mcpdm->io_base))
  437. return PTR_ERR(mcpdm->io_base);
  438. mcpdm->irq = platform_get_irq(pdev, 0);
  439. if (mcpdm->irq < 0)
  440. return mcpdm->irq;
  441. mcpdm->dev = &pdev->dev;
  442. ret = devm_snd_soc_register_component(&pdev->dev,
  443. &omap_mcpdm_component,
  444. &omap_mcpdm_dai, 1);
  445. if (ret)
  446. return ret;
  447. return sdma_pcm_platform_register(&pdev->dev, "dn_link", "up_link");
  448. }
  449. static const struct of_device_id omap_mcpdm_of_match[] = {
  450. { .compatible = "ti,omap4-mcpdm", },
  451. { }
  452. };
  453. MODULE_DEVICE_TABLE(of, omap_mcpdm_of_match);
  454. static struct platform_driver asoc_mcpdm_driver = {
  455. .driver = {
  456. .name = "omap-mcpdm",
  457. .of_match_table = omap_mcpdm_of_match,
  458. },
  459. .probe = asoc_mcpdm_probe,
  460. };
  461. module_platform_driver(asoc_mcpdm_driver);
  462. MODULE_ALIAS("platform:omap-mcpdm");
  463. MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>");
  464. MODULE_DESCRIPTION("OMAP PDM SoC Interface");
  465. MODULE_LICENSE("GPL");