Lines Matching refs:mcpdm
67 static inline void omap_mcpdm_write(struct omap_mcpdm *mcpdm, u16 reg, u32 val) in omap_mcpdm_write() argument
69 writel_relaxed(val, mcpdm->io_base + reg); in omap_mcpdm_write()
72 static inline int omap_mcpdm_read(struct omap_mcpdm *mcpdm, u16 reg) in omap_mcpdm_read() argument
74 return readl_relaxed(mcpdm->io_base + reg); in omap_mcpdm_read()
78 static void omap_mcpdm_reg_dump(struct omap_mcpdm *mcpdm) in omap_mcpdm_reg_dump() argument
80 dev_dbg(mcpdm->dev, "***********************\n"); in omap_mcpdm_reg_dump()
81 dev_dbg(mcpdm->dev, "IRQSTATUS_RAW: 0x%04x\n", in omap_mcpdm_reg_dump()
82 omap_mcpdm_read(mcpdm, MCPDM_REG_IRQSTATUS_RAW)); in omap_mcpdm_reg_dump()
83 dev_dbg(mcpdm->dev, "IRQSTATUS: 0x%04x\n", in omap_mcpdm_reg_dump()
84 omap_mcpdm_read(mcpdm, MCPDM_REG_IRQSTATUS)); in omap_mcpdm_reg_dump()
85 dev_dbg(mcpdm->dev, "IRQENABLE_SET: 0x%04x\n", in omap_mcpdm_reg_dump()
86 omap_mcpdm_read(mcpdm, MCPDM_REG_IRQENABLE_SET)); in omap_mcpdm_reg_dump()
87 dev_dbg(mcpdm->dev, "IRQENABLE_CLR: 0x%04x\n", in omap_mcpdm_reg_dump()
88 omap_mcpdm_read(mcpdm, MCPDM_REG_IRQENABLE_CLR)); in omap_mcpdm_reg_dump()
89 dev_dbg(mcpdm->dev, "IRQWAKE_EN: 0x%04x\n", in omap_mcpdm_reg_dump()
90 omap_mcpdm_read(mcpdm, MCPDM_REG_IRQWAKE_EN)); in omap_mcpdm_reg_dump()
91 dev_dbg(mcpdm->dev, "DMAENABLE_SET: 0x%04x\n", in omap_mcpdm_reg_dump()
92 omap_mcpdm_read(mcpdm, MCPDM_REG_DMAENABLE_SET)); in omap_mcpdm_reg_dump()
93 dev_dbg(mcpdm->dev, "DMAENABLE_CLR: 0x%04x\n", in omap_mcpdm_reg_dump()
94 omap_mcpdm_read(mcpdm, MCPDM_REG_DMAENABLE_CLR)); in omap_mcpdm_reg_dump()
95 dev_dbg(mcpdm->dev, "DMAWAKEEN: 0x%04x\n", in omap_mcpdm_reg_dump()
96 omap_mcpdm_read(mcpdm, MCPDM_REG_DMAWAKEEN)); in omap_mcpdm_reg_dump()
97 dev_dbg(mcpdm->dev, "CTRL: 0x%04x\n", in omap_mcpdm_reg_dump()
98 omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL)); in omap_mcpdm_reg_dump()
99 dev_dbg(mcpdm->dev, "DN_DATA: 0x%04x\n", in omap_mcpdm_reg_dump()
100 omap_mcpdm_read(mcpdm, MCPDM_REG_DN_DATA)); in omap_mcpdm_reg_dump()
101 dev_dbg(mcpdm->dev, "UP_DATA: 0x%04x\n", in omap_mcpdm_reg_dump()
102 omap_mcpdm_read(mcpdm, MCPDM_REG_UP_DATA)); in omap_mcpdm_reg_dump()
103 dev_dbg(mcpdm->dev, "FIFO_CTRL_DN: 0x%04x\n", in omap_mcpdm_reg_dump()
104 omap_mcpdm_read(mcpdm, MCPDM_REG_FIFO_CTRL_DN)); in omap_mcpdm_reg_dump()
105 dev_dbg(mcpdm->dev, "FIFO_CTRL_UP: 0x%04x\n", in omap_mcpdm_reg_dump()
106 omap_mcpdm_read(mcpdm, MCPDM_REG_FIFO_CTRL_UP)); in omap_mcpdm_reg_dump()
107 dev_dbg(mcpdm->dev, "***********************\n"); in omap_mcpdm_reg_dump()
110 static void omap_mcpdm_reg_dump(struct omap_mcpdm *mcpdm) {} in omap_mcpdm_reg_dump() argument
117 static void omap_mcpdm_start(struct omap_mcpdm *mcpdm) in omap_mcpdm_start() argument
119 u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL); in omap_mcpdm_start()
120 u32 link_mask = mcpdm->config[0].link_mask | mcpdm->config[1].link_mask; in omap_mcpdm_start()
123 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); in omap_mcpdm_start()
126 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); in omap_mcpdm_start()
129 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); in omap_mcpdm_start()
136 static void omap_mcpdm_stop(struct omap_mcpdm *mcpdm) in omap_mcpdm_stop() argument
138 u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL); in omap_mcpdm_stop()
142 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); in omap_mcpdm_stop()
145 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); in omap_mcpdm_stop()
148 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); in omap_mcpdm_stop()
155 static inline int omap_mcpdm_active(struct omap_mcpdm *mcpdm) in omap_mcpdm_active() argument
157 return omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL) & in omap_mcpdm_active()
165 static void omap_mcpdm_open_streams(struct omap_mcpdm *mcpdm) in omap_mcpdm_open_streams() argument
167 u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL); in omap_mcpdm_open_streams()
169 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl | MCPDM_WD_EN); in omap_mcpdm_open_streams()
171 omap_mcpdm_write(mcpdm, MCPDM_REG_IRQENABLE_SET, in omap_mcpdm_open_streams()
176 if (mcpdm->dn_rx_offset) { in omap_mcpdm_open_streams()
177 u32 dn_offset = mcpdm->dn_rx_offset; in omap_mcpdm_open_streams()
179 omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, dn_offset); in omap_mcpdm_open_streams()
181 omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, dn_offset); in omap_mcpdm_open_streams()
184 omap_mcpdm_write(mcpdm, MCPDM_REG_FIFO_CTRL_DN, in omap_mcpdm_open_streams()
185 mcpdm->config[SNDRV_PCM_STREAM_PLAYBACK].threshold); in omap_mcpdm_open_streams()
186 omap_mcpdm_write(mcpdm, MCPDM_REG_FIFO_CTRL_UP, in omap_mcpdm_open_streams()
187 mcpdm->config[SNDRV_PCM_STREAM_CAPTURE].threshold); in omap_mcpdm_open_streams()
189 omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_SET, in omap_mcpdm_open_streams()
197 static void omap_mcpdm_close_streams(struct omap_mcpdm *mcpdm) in omap_mcpdm_close_streams() argument
200 omap_mcpdm_write(mcpdm, MCPDM_REG_IRQENABLE_CLR, in omap_mcpdm_close_streams()
204 omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_CLR, MCPDM_DMA_DN_ENABLE); in omap_mcpdm_close_streams()
207 omap_mcpdm_write(mcpdm, MCPDM_REG_IRQENABLE_CLR, in omap_mcpdm_close_streams()
211 omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_CLR, MCPDM_DMA_UP_ENABLE); in omap_mcpdm_close_streams()
214 if (mcpdm->dn_rx_offset) in omap_mcpdm_close_streams()
215 omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, 0); in omap_mcpdm_close_streams()
220 struct omap_mcpdm *mcpdm = dev_id; in omap_mcpdm_irq_handler() local
223 irq_status = omap_mcpdm_read(mcpdm, MCPDM_REG_IRQSTATUS); in omap_mcpdm_irq_handler()
226 omap_mcpdm_write(mcpdm, MCPDM_REG_IRQSTATUS, irq_status); in omap_mcpdm_irq_handler()
229 dev_dbg(mcpdm->dev, "DN (playback) FIFO Full\n"); in omap_mcpdm_irq_handler()
232 dev_dbg(mcpdm->dev, "DN (playback) FIFO Empty\n"); in omap_mcpdm_irq_handler()
235 dev_dbg(mcpdm->dev, "DN (playback) write request\n"); in omap_mcpdm_irq_handler()
238 dev_dbg(mcpdm->dev, "UP (capture) FIFO Full\n"); in omap_mcpdm_irq_handler()
241 dev_dbg(mcpdm->dev, "UP (capture) FIFO Empty\n"); in omap_mcpdm_irq_handler()
244 dev_dbg(mcpdm->dev, "UP (capture) write request\n"); in omap_mcpdm_irq_handler()
252 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_dai_startup() local
254 mutex_lock(&mcpdm->mutex); in omap_mcpdm_dai_startup()
257 omap_mcpdm_open_streams(mcpdm); in omap_mcpdm_dai_startup()
259 mutex_unlock(&mcpdm->mutex); in omap_mcpdm_dai_startup()
267 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_dai_shutdown() local
272 mutex_lock(&mcpdm->mutex); in omap_mcpdm_dai_shutdown()
275 if (omap_mcpdm_active(mcpdm)) { in omap_mcpdm_dai_shutdown()
276 omap_mcpdm_stop(mcpdm); in omap_mcpdm_dai_shutdown()
277 omap_mcpdm_close_streams(mcpdm); in omap_mcpdm_dai_shutdown()
278 mcpdm->config[0].link_mask = 0; in omap_mcpdm_dai_shutdown()
279 mcpdm->config[1].link_mask = 0; in omap_mcpdm_dai_shutdown()
283 if (mcpdm->latency[stream2]) in omap_mcpdm_dai_shutdown()
284 cpu_latency_qos_update_request(&mcpdm->pm_qos_req, in omap_mcpdm_dai_shutdown()
285 mcpdm->latency[stream2]); in omap_mcpdm_dai_shutdown()
286 else if (mcpdm->latency[stream1]) in omap_mcpdm_dai_shutdown()
287 cpu_latency_qos_remove_request(&mcpdm->pm_qos_req); in omap_mcpdm_dai_shutdown()
289 mcpdm->latency[stream1] = 0; in omap_mcpdm_dai_shutdown()
291 mutex_unlock(&mcpdm->mutex); in omap_mcpdm_dai_shutdown()
298 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_dai_hw_params() local
335 threshold = mcpdm->config[stream].threshold; in omap_mcpdm_dai_hw_params()
341 if (!mcpdm->config[!stream].link_mask) in omap_mcpdm_dai_hw_params()
342 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()
360 mcpdm->latency[stream] = latency * USEC_PER_SEC / params_rate(params); in omap_mcpdm_dai_hw_params()
362 if (!mcpdm->latency[stream]) in omap_mcpdm_dai_hw_params()
363 mcpdm->latency[stream] = 10; in omap_mcpdm_dai_hw_params()
366 if (mcpdm->config[stream].link_mask && in omap_mcpdm_dai_hw_params()
367 mcpdm->config[stream].link_mask != link_mask) in omap_mcpdm_dai_hw_params()
368 mcpdm->restart = true; in omap_mcpdm_dai_hw_params()
370 mcpdm->config[stream].link_mask = link_mask; in omap_mcpdm_dai_hw_params()
378 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_prepare() local
379 struct pm_qos_request *pm_qos_req = &mcpdm->pm_qos_req; in omap_mcpdm_prepare()
383 int latency = mcpdm->latency[stream2]; in omap_mcpdm_prepare()
386 if (!latency || mcpdm->latency[stream1] < latency) in omap_mcpdm_prepare()
387 latency = mcpdm->latency[stream1]; in omap_mcpdm_prepare()
394 if (!omap_mcpdm_active(mcpdm)) { in omap_mcpdm_prepare()
395 omap_mcpdm_start(mcpdm); in omap_mcpdm_prepare()
396 omap_mcpdm_reg_dump(mcpdm); in omap_mcpdm_prepare()
397 } else if (mcpdm->restart) { in omap_mcpdm_prepare()
398 omap_mcpdm_stop(mcpdm); in omap_mcpdm_prepare()
399 omap_mcpdm_start(mcpdm); in omap_mcpdm_prepare()
400 mcpdm->restart = false; in omap_mcpdm_prepare()
401 omap_mcpdm_reg_dump(mcpdm); in omap_mcpdm_prepare()
409 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_probe() local
412 pm_runtime_enable(mcpdm->dev); in omap_mcpdm_probe()
415 pm_runtime_get_sync(mcpdm->dev); in omap_mcpdm_probe()
416 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, 0x00); in omap_mcpdm_probe()
418 ret = request_irq(mcpdm->irq, omap_mcpdm_irq_handler, 0, "McPDM", in omap_mcpdm_probe()
419 (void *)mcpdm); in omap_mcpdm_probe()
421 pm_runtime_put_sync(mcpdm->dev); in omap_mcpdm_probe()
424 dev_err(mcpdm->dev, "Request for IRQ failed\n"); in omap_mcpdm_probe()
425 pm_runtime_disable(mcpdm->dev); in omap_mcpdm_probe()
429 mcpdm->config[SNDRV_PCM_STREAM_PLAYBACK].threshold = 2; in omap_mcpdm_probe()
430 mcpdm->config[SNDRV_PCM_STREAM_CAPTURE].threshold = in omap_mcpdm_probe()
434 &mcpdm->dma_data[SNDRV_PCM_STREAM_PLAYBACK], in omap_mcpdm_probe()
435 &mcpdm->dma_data[SNDRV_PCM_STREAM_CAPTURE]); in omap_mcpdm_probe()
442 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); in omap_mcpdm_remove() local
444 free_irq(mcpdm->irq, (void *)mcpdm); in omap_mcpdm_remove()
445 pm_runtime_disable(mcpdm->dev); in omap_mcpdm_remove()
447 if (cpu_latency_qos_request_active(&mcpdm->pm_qos_req)) in omap_mcpdm_remove()
448 cpu_latency_qos_remove_request(&mcpdm->pm_qos_req); in omap_mcpdm_remove()
467 struct omap_mcpdm *mcpdm = snd_soc_component_get_drvdata(component); in omap_mcpdm_suspend() local
470 omap_mcpdm_stop(mcpdm); in omap_mcpdm_suspend()
471 omap_mcpdm_close_streams(mcpdm); in omap_mcpdm_suspend()
474 mcpdm->pm_active_count = 0; in omap_mcpdm_suspend()
475 while (pm_runtime_active(mcpdm->dev)) { in omap_mcpdm_suspend()
476 pm_runtime_put_sync(mcpdm->dev); in omap_mcpdm_suspend()
477 mcpdm->pm_active_count++; in omap_mcpdm_suspend()
485 struct omap_mcpdm *mcpdm = snd_soc_component_get_drvdata(component); in omap_mcpdm_resume() local
487 if (mcpdm->pm_active_count) { in omap_mcpdm_resume()
488 while (mcpdm->pm_active_count--) in omap_mcpdm_resume()
489 pm_runtime_get_sync(mcpdm->dev); in omap_mcpdm_resume()
492 omap_mcpdm_open_streams(mcpdm); in omap_mcpdm_resume()
493 omap_mcpdm_start(mcpdm); in omap_mcpdm_resume()
536 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(snd_soc_rtd_to_cpu(rtd, 0)); in omap_mcpdm_configure_dn_offsets() local
538 mcpdm->dn_rx_offset = MCPDM_DNOFST_RX1(rx1) | MCPDM_DNOFST_RX2(rx2); in omap_mcpdm_configure_dn_offsets()
544 struct omap_mcpdm *mcpdm; in asoc_mcpdm_probe() local
548 mcpdm = devm_kzalloc(&pdev->dev, sizeof(struct omap_mcpdm), GFP_KERNEL); in asoc_mcpdm_probe()
549 if (!mcpdm) in asoc_mcpdm_probe()
552 platform_set_drvdata(pdev, mcpdm); in asoc_mcpdm_probe()
554 mutex_init(&mcpdm->mutex); in asoc_mcpdm_probe()
560 mcpdm->dma_data[0].addr = res->start + MCPDM_REG_DN_DATA; in asoc_mcpdm_probe()
561 mcpdm->dma_data[1].addr = res->start + MCPDM_REG_UP_DATA; in asoc_mcpdm_probe()
563 mcpdm->dma_data[0].filter_data = "dn_link"; in asoc_mcpdm_probe()
564 mcpdm->dma_data[1].filter_data = "up_link"; in asoc_mcpdm_probe()
566 mcpdm->io_base = devm_platform_ioremap_resource_byname(pdev, "mpu"); in asoc_mcpdm_probe()
567 if (IS_ERR(mcpdm->io_base)) in asoc_mcpdm_probe()
568 return PTR_ERR(mcpdm->io_base); in asoc_mcpdm_probe()
570 mcpdm->irq = platform_get_irq(pdev, 0); in asoc_mcpdm_probe()
571 if (mcpdm->irq < 0) in asoc_mcpdm_probe()
572 return mcpdm->irq; in asoc_mcpdm_probe()
574 mcpdm->dev = &pdev->dev; in asoc_mcpdm_probe()