Lines Matching refs:mcpdm
79 static inline void omap_mcpdm_write(struct omap_mcpdm *mcpdm, u16 reg, u32 val) in omap_mcpdm_write() argument
81 writel_relaxed(val, mcpdm->io_base + reg); in omap_mcpdm_write()
84 static inline int omap_mcpdm_read(struct omap_mcpdm *mcpdm, u16 reg) in omap_mcpdm_read() argument
86 return readl_relaxed(mcpdm->io_base + reg); in omap_mcpdm_read()
90 static void omap_mcpdm_reg_dump(struct omap_mcpdm *mcpdm) in omap_mcpdm_reg_dump() argument
92 dev_dbg(mcpdm->dev, "***********************\n"); in omap_mcpdm_reg_dump()
93 dev_dbg(mcpdm->dev, "IRQSTATUS_RAW: 0x%04x\n", in omap_mcpdm_reg_dump()
94 omap_mcpdm_read(mcpdm, MCPDM_REG_IRQSTATUS_RAW)); in omap_mcpdm_reg_dump()
95 dev_dbg(mcpdm->dev, "IRQSTATUS: 0x%04x\n", in omap_mcpdm_reg_dump()
96 omap_mcpdm_read(mcpdm, MCPDM_REG_IRQSTATUS)); in omap_mcpdm_reg_dump()
97 dev_dbg(mcpdm->dev, "IRQENABLE_SET: 0x%04x\n", in omap_mcpdm_reg_dump()
98 omap_mcpdm_read(mcpdm, MCPDM_REG_IRQENABLE_SET)); in omap_mcpdm_reg_dump()
99 dev_dbg(mcpdm->dev, "IRQENABLE_CLR: 0x%04x\n", in omap_mcpdm_reg_dump()
100 omap_mcpdm_read(mcpdm, MCPDM_REG_IRQENABLE_CLR)); in omap_mcpdm_reg_dump()
101 dev_dbg(mcpdm->dev, "IRQWAKE_EN: 0x%04x\n", in omap_mcpdm_reg_dump()
102 omap_mcpdm_read(mcpdm, MCPDM_REG_IRQWAKE_EN)); in omap_mcpdm_reg_dump()
103 dev_dbg(mcpdm->dev, "DMAENABLE_SET: 0x%04x\n", in omap_mcpdm_reg_dump()
104 omap_mcpdm_read(mcpdm, MCPDM_REG_DMAENABLE_SET)); in omap_mcpdm_reg_dump()
105 dev_dbg(mcpdm->dev, "DMAENABLE_CLR: 0x%04x\n", in omap_mcpdm_reg_dump()
106 omap_mcpdm_read(mcpdm, MCPDM_REG_DMAENABLE_CLR)); in omap_mcpdm_reg_dump()
107 dev_dbg(mcpdm->dev, "DMAWAKEEN: 0x%04x\n", in omap_mcpdm_reg_dump()
108 omap_mcpdm_read(mcpdm, MCPDM_REG_DMAWAKEEN)); in omap_mcpdm_reg_dump()
109 dev_dbg(mcpdm->dev, "CTRL: 0x%04x\n", in omap_mcpdm_reg_dump()
110 omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL)); in omap_mcpdm_reg_dump()
111 dev_dbg(mcpdm->dev, "DN_DATA: 0x%04x\n", in omap_mcpdm_reg_dump()
112 omap_mcpdm_read(mcpdm, MCPDM_REG_DN_DATA)); in omap_mcpdm_reg_dump()
113 dev_dbg(mcpdm->dev, "UP_DATA: 0x%04x\n", in omap_mcpdm_reg_dump()
114 omap_mcpdm_read(mcpdm, MCPDM_REG_UP_DATA)); in omap_mcpdm_reg_dump()
115 dev_dbg(mcpdm->dev, "FIFO_CTRL_DN: 0x%04x\n", in omap_mcpdm_reg_dump()
116 omap_mcpdm_read(mcpdm, MCPDM_REG_FIFO_CTRL_DN)); in omap_mcpdm_reg_dump()
117 dev_dbg(mcpdm->dev, "FIFO_CTRL_UP: 0x%04x\n", in omap_mcpdm_reg_dump()
118 omap_mcpdm_read(mcpdm, MCPDM_REG_FIFO_CTRL_UP)); in omap_mcpdm_reg_dump()
119 dev_dbg(mcpdm->dev, "***********************\n"); in omap_mcpdm_reg_dump()
122 static void omap_mcpdm_reg_dump(struct omap_mcpdm *mcpdm) {} in omap_mcpdm_reg_dump() argument
129 static void omap_mcpdm_start(struct omap_mcpdm *mcpdm) in omap_mcpdm_start() argument
131 u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL); in omap_mcpdm_start()
132 u32 link_mask = mcpdm->config[0].link_mask | mcpdm->config[1].link_mask; in omap_mcpdm_start()
135 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); in omap_mcpdm_start()
138 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); in omap_mcpdm_start()
141 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); in omap_mcpdm_start()
148 static void omap_mcpdm_stop(struct omap_mcpdm *mcpdm) in omap_mcpdm_stop() argument
150 u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL); in omap_mcpdm_stop()
154 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); in omap_mcpdm_stop()
157 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); in omap_mcpdm_stop()
160 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); in omap_mcpdm_stop()
167 static inline int omap_mcpdm_active(struct omap_mcpdm *mcpdm) in omap_mcpdm_active() argument
169 return omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL) & in omap_mcpdm_active()
177 static void omap_mcpdm_open_streams(struct omap_mcpdm *mcpdm) in omap_mcpdm_open_streams() argument
179 u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL); in omap_mcpdm_open_streams()
181 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl | MCPDM_WD_EN); in omap_mcpdm_open_streams()
183 omap_mcpdm_write(mcpdm, MCPDM_REG_IRQENABLE_SET, in omap_mcpdm_open_streams()
188 if (mcpdm->dn_rx_offset) { in omap_mcpdm_open_streams()
189 u32 dn_offset = mcpdm->dn_rx_offset; in omap_mcpdm_open_streams()
191 omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, dn_offset); in omap_mcpdm_open_streams()
193 omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, dn_offset); in omap_mcpdm_open_streams()
196 omap_mcpdm_write(mcpdm, MCPDM_REG_FIFO_CTRL_DN, in omap_mcpdm_open_streams()
197 mcpdm->config[SNDRV_PCM_STREAM_PLAYBACK].threshold); in omap_mcpdm_open_streams()
198 omap_mcpdm_write(mcpdm, MCPDM_REG_FIFO_CTRL_UP, in omap_mcpdm_open_streams()
199 mcpdm->config[SNDRV_PCM_STREAM_CAPTURE].threshold); in omap_mcpdm_open_streams()
201 omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_SET, in omap_mcpdm_open_streams()
209 static void omap_mcpdm_close_streams(struct omap_mcpdm *mcpdm) in omap_mcpdm_close_streams() argument
212 omap_mcpdm_write(mcpdm, MCPDM_REG_IRQENABLE_CLR, in omap_mcpdm_close_streams()
216 omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_CLR, MCPDM_DMA_DN_ENABLE); in omap_mcpdm_close_streams()
219 omap_mcpdm_write(mcpdm, MCPDM_REG_IRQENABLE_CLR, in omap_mcpdm_close_streams()
223 omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_CLR, MCPDM_DMA_UP_ENABLE); in omap_mcpdm_close_streams()
226 if (mcpdm->dn_rx_offset) in omap_mcpdm_close_streams()
227 omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, 0); in omap_mcpdm_close_streams()
232 struct omap_mcpdm *mcpdm = dev_id; in omap_mcpdm_irq_handler() local
235 irq_status = omap_mcpdm_read(mcpdm, MCPDM_REG_IRQSTATUS); in omap_mcpdm_irq_handler()
238 omap_mcpdm_write(mcpdm, MCPDM_REG_IRQSTATUS, irq_status); in omap_mcpdm_irq_handler()
241 dev_dbg(mcpdm->dev, "DN (playback) FIFO Full\n"); in omap_mcpdm_irq_handler()
244 dev_dbg(mcpdm->dev, "DN (playback) FIFO Empty\n"); in omap_mcpdm_irq_handler()
247 dev_dbg(mcpdm->dev, "DN (playback) write request\n"); in omap_mcpdm_irq_handler()
250 dev_dbg(mcpdm->dev, "UP (capture) FIFO Full\n"); in omap_mcpdm_irq_handler()
253 dev_dbg(mcpdm->dev, "UP (capture) FIFO Empty\n"); in omap_mcpdm_irq_handler()
256 dev_dbg(mcpdm->dev, "UP (capture) write request\n"); in omap_mcpdm_irq_handler()
264 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_dai_startup() local
266 mutex_lock(&mcpdm->mutex); in omap_mcpdm_dai_startup()
269 omap_mcpdm_open_streams(mcpdm); in omap_mcpdm_dai_startup()
271 mutex_unlock(&mcpdm->mutex); in omap_mcpdm_dai_startup()
279 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_dai_shutdown() local
281 mutex_lock(&mcpdm->mutex); in omap_mcpdm_dai_shutdown()
284 if (omap_mcpdm_active(mcpdm)) { in omap_mcpdm_dai_shutdown()
285 omap_mcpdm_stop(mcpdm); in omap_mcpdm_dai_shutdown()
286 omap_mcpdm_close_streams(mcpdm); in omap_mcpdm_dai_shutdown()
287 mcpdm->config[0].link_mask = 0; in omap_mcpdm_dai_shutdown()
288 mcpdm->config[1].link_mask = 0; in omap_mcpdm_dai_shutdown()
292 mutex_unlock(&mcpdm->mutex); in omap_mcpdm_dai_shutdown()
299 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_dai_hw_params() local
336 threshold = mcpdm->config[stream].threshold; in omap_mcpdm_dai_hw_params()
342 if (!mcpdm->config[!stream].link_mask) in omap_mcpdm_dai_hw_params()
343 mcpdm->config[!stream].link_mask = 0x3; in omap_mcpdm_dai_hw_params()
349 if (!mcpdm->config[!stream].link_mask) in omap_mcpdm_dai_hw_params()
350 mcpdm->config[!stream].link_mask = (0x3 << 3); in omap_mcpdm_dai_hw_params()
356 if (mcpdm->config[stream].link_mask && in omap_mcpdm_dai_hw_params()
357 mcpdm->config[stream].link_mask != link_mask) in omap_mcpdm_dai_hw_params()
358 mcpdm->restart = true; in omap_mcpdm_dai_hw_params()
360 mcpdm->config[stream].link_mask = link_mask; in omap_mcpdm_dai_hw_params()
368 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_prepare() local
370 if (!omap_mcpdm_active(mcpdm)) { in omap_mcpdm_prepare()
371 omap_mcpdm_start(mcpdm); in omap_mcpdm_prepare()
372 omap_mcpdm_reg_dump(mcpdm); in omap_mcpdm_prepare()
373 } else if (mcpdm->restart) { in omap_mcpdm_prepare()
374 omap_mcpdm_stop(mcpdm); in omap_mcpdm_prepare()
375 omap_mcpdm_start(mcpdm); in omap_mcpdm_prepare()
376 mcpdm->restart = false; in omap_mcpdm_prepare()
377 omap_mcpdm_reg_dump(mcpdm); in omap_mcpdm_prepare()
392 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_probe() local
395 pm_runtime_enable(mcpdm->dev); in omap_mcpdm_probe()
398 pm_runtime_get_sync(mcpdm->dev); in omap_mcpdm_probe()
399 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, 0x00); in omap_mcpdm_probe()
401 ret = request_irq(mcpdm->irq, omap_mcpdm_irq_handler, 0, "McPDM", in omap_mcpdm_probe()
402 (void *)mcpdm); in omap_mcpdm_probe()
404 pm_runtime_put_sync(mcpdm->dev); in omap_mcpdm_probe()
407 dev_err(mcpdm->dev, "Request for IRQ failed\n"); in omap_mcpdm_probe()
408 pm_runtime_disable(mcpdm->dev); in omap_mcpdm_probe()
412 mcpdm->config[SNDRV_PCM_STREAM_PLAYBACK].threshold = 2; in omap_mcpdm_probe()
413 mcpdm->config[SNDRV_PCM_STREAM_CAPTURE].threshold = in omap_mcpdm_probe()
417 &mcpdm->dma_data[SNDRV_PCM_STREAM_PLAYBACK], in omap_mcpdm_probe()
418 &mcpdm->dma_data[SNDRV_PCM_STREAM_CAPTURE]); in omap_mcpdm_probe()
425 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_remove() local
427 free_irq(mcpdm->irq, (void *)mcpdm); in omap_mcpdm_remove()
428 pm_runtime_disable(mcpdm->dev); in omap_mcpdm_remove()
436 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_suspend() local
439 omap_mcpdm_stop(mcpdm); in omap_mcpdm_suspend()
440 omap_mcpdm_close_streams(mcpdm); in omap_mcpdm_suspend()
443 mcpdm->pm_active_count = 0; in omap_mcpdm_suspend()
444 while (pm_runtime_active(mcpdm->dev)) { in omap_mcpdm_suspend()
445 pm_runtime_put_sync(mcpdm->dev); in omap_mcpdm_suspend()
446 mcpdm->pm_active_count++; in omap_mcpdm_suspend()
454 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_resume() local
456 if (mcpdm->pm_active_count) { in omap_mcpdm_resume()
457 while (mcpdm->pm_active_count--) in omap_mcpdm_resume()
458 pm_runtime_get_sync(mcpdm->dev); in omap_mcpdm_resume()
461 omap_mcpdm_open_streams(mcpdm); in omap_mcpdm_resume()
462 omap_mcpdm_start(mcpdm); in omap_mcpdm_resume()
508 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(rtd->cpu_dai); in omap_mcpdm_configure_dn_offsets() local
510 mcpdm->dn_rx_offset = MCPDM_DNOFST_RX1(rx1) | MCPDM_DNOFST_RX2(rx2); in omap_mcpdm_configure_dn_offsets()
516 struct omap_mcpdm *mcpdm; in asoc_mcpdm_probe() local
520 mcpdm = devm_kzalloc(&pdev->dev, sizeof(struct omap_mcpdm), GFP_KERNEL); in asoc_mcpdm_probe()
521 if (!mcpdm) in asoc_mcpdm_probe()
524 platform_set_drvdata(pdev, mcpdm); in asoc_mcpdm_probe()
526 mutex_init(&mcpdm->mutex); in asoc_mcpdm_probe()
532 mcpdm->dma_data[0].addr = res->start + MCPDM_REG_DN_DATA; in asoc_mcpdm_probe()
533 mcpdm->dma_data[1].addr = res->start + MCPDM_REG_UP_DATA; in asoc_mcpdm_probe()
535 mcpdm->dma_data[0].filter_data = "dn_link"; in asoc_mcpdm_probe()
536 mcpdm->dma_data[1].filter_data = "up_link"; in asoc_mcpdm_probe()
539 mcpdm->io_base = devm_ioremap_resource(&pdev->dev, res); in asoc_mcpdm_probe()
540 if (IS_ERR(mcpdm->io_base)) in asoc_mcpdm_probe()
541 return PTR_ERR(mcpdm->io_base); in asoc_mcpdm_probe()
543 mcpdm->irq = platform_get_irq(pdev, 0); in asoc_mcpdm_probe()
544 if (mcpdm->irq < 0) in asoc_mcpdm_probe()
545 return mcpdm->irq; in asoc_mcpdm_probe()
547 mcpdm->dev = &pdev->dev; in asoc_mcpdm_probe()