Lines Matching refs:pdm
76 static unsigned int get_pdm_clk(struct rk_pdm_dev *pdm, unsigned int sr, in get_pdm_clk() argument
92 rate = clk_round_rate(pdm->clk, clkref[i].clk); in get_pdm_clk()
102 clk = clk_round_rate(pdm->clk, PDM_SIGNOFF_CLK_RATE); in get_pdm_clk()
129 static void rockchip_pdm_rxctrl(struct rk_pdm_dev *pdm, int on) in rockchip_pdm_rxctrl() argument
132 regmap_update_bits(pdm->regmap, PDM_DMA_CTRL, in rockchip_pdm_rxctrl()
134 regmap_update_bits(pdm->regmap, PDM_SYSCONFIG, in rockchip_pdm_rxctrl()
137 regmap_update_bits(pdm->regmap, PDM_DMA_CTRL, in rockchip_pdm_rxctrl()
139 regmap_update_bits(pdm->regmap, PDM_SYSCONFIG, in rockchip_pdm_rxctrl()
149 struct rk_pdm_dev *pdm = to_info(dai); in rockchip_pdm_hw_params() local
161 clk_rate = get_pdm_clk(pdm, samplerate, &clk_src, &clk_out); in rockchip_pdm_hw_params()
165 ret = clk_set_rate(pdm->clk, clk_src); in rockchip_pdm_hw_params()
169 if (pdm->version == RK_PDM_RK3308) { in rockchip_pdm_hw_params()
177 regmap_update_bits_check(pdm->regmap, PDM_CTRL1, in rockchip_pdm_hw_params()
182 reset_control_assert(pdm->reset); in rockchip_pdm_hw_params()
183 reset_control_deassert(pdm->reset); in rockchip_pdm_hw_params()
184 rockchip_pdm_rxctrl(pdm, 0); in rockchip_pdm_hw_params()
193 regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, in rockchip_pdm_hw_params()
198 regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, PDM_DS_RATIO_MSK, val); in rockchip_pdm_hw_params()
199 regmap_update_bits(pdm->regmap, PDM_HPF_CTRL, in rockchip_pdm_hw_params()
201 regmap_update_bits(pdm->regmap, PDM_HPF_CTRL, in rockchip_pdm_hw_params()
203 regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, PDM_CLK_EN, PDM_CLK_EN); in rockchip_pdm_hw_params()
204 if (pdm->version != RK_PDM_RK3229) in rockchip_pdm_hw_params()
205 regmap_update_bits(pdm->regmap, PDM_CTRL0, in rockchip_pdm_hw_params()
243 dev_err(pdm->dev, "invalid channel: %d\n", in rockchip_pdm_hw_params()
248 regmap_update_bits(pdm->regmap, PDM_CTRL0, in rockchip_pdm_hw_params()
252 regmap_update_bits(pdm->regmap, PDM_DMA_CTRL, PDM_DMA_RDL_MSK, in rockchip_pdm_hw_params()
261 struct rk_pdm_dev *pdm = to_info(cpu_dai); in rockchip_pdm_set_fmt() local
277 regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, mask, val); in rockchip_pdm_set_fmt()
286 struct rk_pdm_dev *pdm = to_info(dai); in rockchip_pdm_trigger() local
294 rockchip_pdm_rxctrl(pdm, 1); in rockchip_pdm_trigger()
300 rockchip_pdm_rxctrl(pdm, 0); in rockchip_pdm_trigger()
312 struct rk_pdm_dev *pdm = to_info(dai); in rockchip_pdm_dai_probe() local
314 dai->capture_dma_data = &pdm->capture_dma_data; in rockchip_pdm_dai_probe()
350 struct rk_pdm_dev *pdm = dev_get_drvdata(dev); in rockchip_pdm_runtime_suspend() local
352 clk_disable_unprepare(pdm->clk); in rockchip_pdm_runtime_suspend()
353 clk_disable_unprepare(pdm->hclk); in rockchip_pdm_runtime_suspend()
360 struct rk_pdm_dev *pdm = dev_get_drvdata(dev); in rockchip_pdm_runtime_resume() local
363 ret = clk_prepare_enable(pdm->clk); in rockchip_pdm_runtime_resume()
365 dev_err(pdm->dev, "clock enable failed %d\n", ret); in rockchip_pdm_runtime_resume()
369 ret = clk_prepare_enable(pdm->hclk); in rockchip_pdm_runtime_resume()
371 dev_err(pdm->dev, "hclock enable failed %d\n", ret); in rockchip_pdm_runtime_resume()
479 struct rk_pdm_dev *pdm; in rockchip_pdm_probe() local
484 pdm = devm_kzalloc(&pdev->dev, sizeof(*pdm), GFP_KERNEL); in rockchip_pdm_probe()
485 if (!pdm) in rockchip_pdm_probe()
490 pdm->version = (enum rk_pdm_version)match->data; in rockchip_pdm_probe()
492 if (pdm->version == RK_PDM_RK3308) { in rockchip_pdm_probe()
493 pdm->reset = devm_reset_control_get(&pdev->dev, "pdm-m"); in rockchip_pdm_probe()
494 if (IS_ERR(pdm->reset)) in rockchip_pdm_probe()
495 return PTR_ERR(pdm->reset); in rockchip_pdm_probe()
503 pdm->regmap = devm_regmap_init_mmio(&pdev->dev, regs, in rockchip_pdm_probe()
505 if (IS_ERR(pdm->regmap)) in rockchip_pdm_probe()
506 return PTR_ERR(pdm->regmap); in rockchip_pdm_probe()
508 pdm->capture_dma_data.addr = res->start + PDM_RXFIFO_DATA; in rockchip_pdm_probe()
509 pdm->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in rockchip_pdm_probe()
510 pdm->capture_dma_data.maxburst = PDM_DMA_BURST_SIZE; in rockchip_pdm_probe()
512 pdm->dev = &pdev->dev; in rockchip_pdm_probe()
513 dev_set_drvdata(&pdev->dev, pdm); in rockchip_pdm_probe()
515 pdm->clk = devm_clk_get(&pdev->dev, "pdm_clk"); in rockchip_pdm_probe()
516 if (IS_ERR(pdm->clk)) in rockchip_pdm_probe()
517 return PTR_ERR(pdm->clk); in rockchip_pdm_probe()
519 pdm->hclk = devm_clk_get(&pdev->dev, "pdm_hclk"); in rockchip_pdm_probe()
520 if (IS_ERR(pdm->hclk)) in rockchip_pdm_probe()
521 return PTR_ERR(pdm->hclk); in rockchip_pdm_probe()
523 ret = clk_prepare_enable(pdm->hclk); in rockchip_pdm_probe()
543 rockchip_pdm_rxctrl(pdm, 0); in rockchip_pdm_probe()
558 clk_disable_unprepare(pdm->hclk); in rockchip_pdm_probe()
565 struct rk_pdm_dev *pdm = dev_get_drvdata(&pdev->dev); in rockchip_pdm_remove() local
571 clk_disable_unprepare(pdm->clk); in rockchip_pdm_remove()
572 clk_disable_unprepare(pdm->hclk); in rockchip_pdm_remove()
580 struct rk_pdm_dev *pdm = dev_get_drvdata(dev); in rockchip_pdm_suspend() local
582 regcache_mark_dirty(pdm->regmap); in rockchip_pdm_suspend()
589 struct rk_pdm_dev *pdm = dev_get_drvdata(dev); in rockchip_pdm_resume() local
598 ret = regcache_sync(pdm->regmap); in rockchip_pdm_resume()