Lines Matching full:pdm

3  * Rockchip PDM ALSA SoC Digital Audio Interface(DAI)  driver
77 static unsigned int get_pdm_clk(struct rk_pdm_dev *pdm, unsigned int sr, in get_pdm_clk() argument
93 rate = clk_round_rate(pdm->clk, clkref[i].clk); in get_pdm_clk()
103 clk = clk_round_rate(pdm->clk, PDM_SIGNOFF_CLK_RATE); in get_pdm_clk()
179 static void rockchip_pdm_rxctrl(struct rk_pdm_dev *pdm, int on) in rockchip_pdm_rxctrl() argument
182 regmap_update_bits(pdm->regmap, PDM_DMA_CTRL, in rockchip_pdm_rxctrl()
184 regmap_update_bits(pdm->regmap, PDM_SYSCONFIG, in rockchip_pdm_rxctrl()
187 regmap_update_bits(pdm->regmap, PDM_DMA_CTRL, in rockchip_pdm_rxctrl()
189 regmap_update_bits(pdm->regmap, PDM_SYSCONFIG, in rockchip_pdm_rxctrl()
199 struct rk_pdm_dev *pdm = to_info(dai); in rockchip_pdm_hw_params() local
211 clk_rate = get_pdm_clk(pdm, samplerate, &clk_src, &clk_out); in rockchip_pdm_hw_params()
215 ret = clk_set_rate(pdm->clk, clk_src); in rockchip_pdm_hw_params()
219 if (pdm->version == RK_PDM_RK3308 || in rockchip_pdm_hw_params()
220 pdm->version == RK_PDM_RV1126) { in rockchip_pdm_hw_params()
228 regmap_update_bits_check(pdm->regmap, PDM_CTRL1, in rockchip_pdm_hw_params()
233 reset_control_assert(pdm->reset); in rockchip_pdm_hw_params()
234 reset_control_deassert(pdm->reset); in rockchip_pdm_hw_params()
235 rockchip_pdm_rxctrl(pdm, 0); in rockchip_pdm_hw_params()
244 regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, in rockchip_pdm_hw_params()
249 if (pdm->version == RK_PDM_RV1126) { in rockchip_pdm_hw_params()
251 regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, PDM_CIC_RATIO_MSK, val); in rockchip_pdm_hw_params()
253 regmap_update_bits(pdm->regmap, PDM_CTRL0, in rockchip_pdm_hw_params()
257 regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, PDM_DS_RATIO_MSK, val); in rockchip_pdm_hw_params()
260 regmap_update_bits(pdm->regmap, PDM_HPF_CTRL, in rockchip_pdm_hw_params()
262 regmap_update_bits(pdm->regmap, PDM_HPF_CTRL, in rockchip_pdm_hw_params()
264 regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, PDM_CLK_EN, PDM_CLK_EN); in rockchip_pdm_hw_params()
265 if (pdm->version != RK_PDM_RK3229) in rockchip_pdm_hw_params()
266 regmap_update_bits(pdm->regmap, PDM_CTRL0, in rockchip_pdm_hw_params()
304 dev_err(pdm->dev, "invalid channel: %d\n", in rockchip_pdm_hw_params()
309 regmap_update_bits(pdm->regmap, PDM_CTRL0, in rockchip_pdm_hw_params()
313 regmap_update_bits(pdm->regmap, PDM_DMA_CTRL, PDM_DMA_RDL_MSK, in rockchip_pdm_hw_params()
322 struct rk_pdm_dev *pdm = to_info(cpu_dai); in rockchip_pdm_set_fmt() local
338 regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, mask, val); in rockchip_pdm_set_fmt()
347 struct rk_pdm_dev *pdm = to_info(dai); in rockchip_pdm_trigger() local
355 rockchip_pdm_rxctrl(pdm, 1); in rockchip_pdm_trigger()
361 rockchip_pdm_rxctrl(pdm, 0); in rockchip_pdm_trigger()
373 struct rk_pdm_dev *pdm = to_info(dai); in rockchip_pdm_dai_probe() local
375 snd_soc_dai_dma_data_set_capture(dai, &pdm->capture_dma_data); in rockchip_pdm_dai_probe()
406 .name = "rockchip-pdm",
412 struct rk_pdm_dev *pdm = dev_get_drvdata(dev); in rockchip_pdm_runtime_suspend() local
414 clk_disable_unprepare(pdm->clk); in rockchip_pdm_runtime_suspend()
415 clk_disable_unprepare(pdm->hclk); in rockchip_pdm_runtime_suspend()
422 struct rk_pdm_dev *pdm = dev_get_drvdata(dev); in rockchip_pdm_runtime_resume() local
425 ret = clk_prepare_enable(pdm->clk); in rockchip_pdm_runtime_resume()
427 dev_err(pdm->dev, "clock enable failed %d\n", ret); in rockchip_pdm_runtime_resume()
431 ret = clk_prepare_enable(pdm->hclk); in rockchip_pdm_runtime_resume()
433 clk_disable_unprepare(pdm->clk); in rockchip_pdm_runtime_resume()
434 dev_err(pdm->dev, "hclock enable failed %d\n", ret); in rockchip_pdm_runtime_resume()
528 { .compatible = "rockchip,pdm",
530 { .compatible = "rockchip,px30-pdm",
532 { .compatible = "rockchip,rk1808-pdm",
534 { .compatible = "rockchip,rk3308-pdm",
536 { .compatible = "rockchip,rk3568-pdm",
538 { .compatible = "rockchip,rv1126-pdm",
544 static int rockchip_pdm_path_parse(struct rk_pdm_dev *pdm, struct device_node *node) in rockchip_pdm_path_parse() argument
566 regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, msk, val); in rockchip_pdm_path_parse()
574 struct rk_pdm_dev *pdm; in rockchip_pdm_probe() local
579 pdm = devm_kzalloc(&pdev->dev, sizeof(*pdm), GFP_KERNEL); in rockchip_pdm_probe()
580 if (!pdm) in rockchip_pdm_probe()
583 pdm->version = (enum rk_pdm_version)device_get_match_data(&pdev->dev); in rockchip_pdm_probe()
584 if (pdm->version == RK_PDM_RK3308) { in rockchip_pdm_probe()
585 pdm->reset = devm_reset_control_get(&pdev->dev, "pdm-m"); in rockchip_pdm_probe()
586 if (IS_ERR(pdm->reset)) in rockchip_pdm_probe()
587 return PTR_ERR(pdm->reset); in rockchip_pdm_probe()
594 pdm->regmap = devm_regmap_init_mmio(&pdev->dev, regs, in rockchip_pdm_probe()
596 if (IS_ERR(pdm->regmap)) in rockchip_pdm_probe()
597 return PTR_ERR(pdm->regmap); in rockchip_pdm_probe()
599 pdm->capture_dma_data.addr = res->start + PDM_RXFIFO_DATA; in rockchip_pdm_probe()
600 pdm->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in rockchip_pdm_probe()
601 pdm->capture_dma_data.maxburst = PDM_DMA_BURST_SIZE; in rockchip_pdm_probe()
603 pdm->dev = &pdev->dev; in rockchip_pdm_probe()
604 dev_set_drvdata(&pdev->dev, pdm); in rockchip_pdm_probe()
606 pdm->clk = devm_clk_get(&pdev->dev, "pdm_clk"); in rockchip_pdm_probe()
607 if (IS_ERR(pdm->clk)) in rockchip_pdm_probe()
608 return PTR_ERR(pdm->clk); in rockchip_pdm_probe()
610 pdm->hclk = devm_clk_get(&pdev->dev, "pdm_hclk"); in rockchip_pdm_probe()
611 if (IS_ERR(pdm->hclk)) in rockchip_pdm_probe()
612 return PTR_ERR(pdm->hclk); in rockchip_pdm_probe()
614 ret = clk_prepare_enable(pdm->hclk); in rockchip_pdm_probe()
634 rockchip_pdm_rxctrl(pdm, 0); in rockchip_pdm_probe()
636 ret = rockchip_pdm_path_parse(pdm, node); in rockchip_pdm_probe()
654 clk_disable_unprepare(pdm->hclk); in rockchip_pdm_probe()
661 struct rk_pdm_dev *pdm = dev_get_drvdata(&pdev->dev); in rockchip_pdm_remove() local
667 clk_disable_unprepare(pdm->clk); in rockchip_pdm_remove()
668 clk_disable_unprepare(pdm->hclk); in rockchip_pdm_remove()
674 struct rk_pdm_dev *pdm = dev_get_drvdata(dev); in rockchip_pdm_suspend() local
676 regcache_mark_dirty(pdm->regmap); in rockchip_pdm_suspend()
683 struct rk_pdm_dev *pdm = dev_get_drvdata(dev); in rockchip_pdm_resume() local
690 ret = regcache_sync(pdm->regmap); in rockchip_pdm_resume()
708 .name = "rockchip-pdm",
717 MODULE_DESCRIPTION("Rockchip PDM Controller Driver");