Lines Matching full:micfil
82 { .compatible = "fsl,imx8mm-micfil", .data = &fsl_micfil_imx8mm },
83 { .compatible = "fsl,imx8mp-micfil", .data = &fsl_micfil_imx8mp },
103 static int micfil_set_quality(struct fsl_micfil *micfil) in micfil_set_quality() argument
107 switch (micfil->quality) { in micfil_set_quality()
128 return regmap_update_bits(micfil->regmap, REG_MICFIL_CTRL2, in micfil_set_quality()
137 struct fsl_micfil *micfil = snd_soc_component_get_drvdata(cmpnt); in micfil_quality_get() local
139 ucontrol->value.integer.value[0] = micfil->quality; in micfil_quality_get()
148 struct fsl_micfil *micfil = snd_soc_component_get_drvdata(cmpnt); in micfil_quality_set() local
150 micfil->quality = ucontrol->value.integer.value[0]; in micfil_quality_set()
152 return micfil_set_quality(micfil); in micfil_quality_set()
172 SOC_ENUM_EXT("MICFIL Quality Select",
184 struct fsl_micfil *micfil = dev_get_drvdata(dev); in fsl_micfil_reset() local
187 ret = regmap_clear_bits(micfil->regmap, REG_MICFIL_CTRL1, in fsl_micfil_reset()
192 ret = regmap_set_bits(micfil->regmap, REG_MICFIL_CTRL1, in fsl_micfil_reset()
203 ret = regmap_clear_bits(micfil->regmap, REG_MICFIL_CTRL1, in fsl_micfil_reset()
212 ret = regmap_write_bits(micfil->regmap, REG_MICFIL_STAT, 0xFF, 0xFF); in fsl_micfil_reset()
222 struct fsl_micfil *micfil = snd_soc_dai_get_drvdata(dai); in fsl_micfil_startup() local
224 if (!micfil) { in fsl_micfil_startup()
225 dev_err(dai->dev, "micfil dai priv_data not set\n"); in fsl_micfil_startup()
235 struct fsl_micfil *micfil = snd_soc_dai_get_drvdata(dai); in fsl_micfil_trigger() local
236 struct device *dev = &micfil->pdev->dev; in fsl_micfil_trigger()
255 ret = regmap_update_bits(micfil->regmap, REG_MICFIL_CTRL1, in fsl_micfil_trigger()
262 ret = regmap_set_bits(micfil->regmap, REG_MICFIL_CTRL1, in fsl_micfil_trigger()
272 ret = regmap_clear_bits(micfil->regmap, REG_MICFIL_CTRL1, in fsl_micfil_trigger()
277 ret = regmap_update_bits(micfil->regmap, REG_MICFIL_CTRL1, in fsl_micfil_trigger()
289 static int fsl_micfil_reparent_rootclk(struct fsl_micfil *micfil, unsigned int sample_rate) in fsl_micfil_reparent_rootclk() argument
291 struct device *dev = &micfil->pdev->dev; in fsl_micfil_reparent_rootclk()
297 clk = micfil->mclk; in fsl_micfil_reparent_rootclk()
301 fsl_asoc_reparent_pll_clocks(dev, clk, micfil->pll8k_clk, in fsl_micfil_reparent_rootclk()
302 micfil->pll11k_clk, ratio); in fsl_micfil_reparent_rootclk()
314 struct fsl_micfil *micfil = snd_soc_dai_get_drvdata(dai); in fsl_micfil_hw_params() local
322 ret = regmap_clear_bits(micfil->regmap, REG_MICFIL_CTRL1, in fsl_micfil_hw_params()
328 ret = regmap_update_bits(micfil->regmap, REG_MICFIL_CTRL1, in fsl_micfil_hw_params()
333 ret = fsl_micfil_reparent_rootclk(micfil, rate); in fsl_micfil_hw_params()
337 ret = clk_set_rate(micfil->mclk, rate * clk_div * osr * 8); in fsl_micfil_hw_params()
341 ret = micfil_set_quality(micfil); in fsl_micfil_hw_params()
345 ret = regmap_update_bits(micfil->regmap, REG_MICFIL_CTRL2, in fsl_micfil_hw_params()
350 micfil->dma_params_rx.peripheral_config = &micfil->sdmacfg; in fsl_micfil_hw_params()
351 micfil->dma_params_rx.peripheral_size = sizeof(micfil->sdmacfg); in fsl_micfil_hw_params()
352 micfil->sdmacfg.n_fifos_src = channels; in fsl_micfil_hw_params()
353 micfil->sdmacfg.sw_done = true; in fsl_micfil_hw_params()
354 micfil->dma_params_rx.maxburst = channels * MICFIL_DMA_MAXBURST_RX; in fsl_micfil_hw_params()
367 struct fsl_micfil *micfil = dev_get_drvdata(cpu_dai->dev); in fsl_micfil_dai_probe() local
372 micfil->quality = QUALITY_VLOW0; in fsl_micfil_dai_probe()
375 regmap_write(micfil->regmap, REG_MICFIL_OUT_CTRL, 0x22222222); in fsl_micfil_dai_probe()
380 ret = regmap_update_bits(micfil->regmap, REG_MICFIL_DC_CTRL, in fsl_micfil_dai_probe()
386 micfil->dc_remover = MICFIL_DC_BYPASS; in fsl_micfil_dai_probe()
389 &micfil->dma_params_rx); in fsl_micfil_dai_probe()
392 ret = regmap_update_bits(micfil->regmap, REG_MICFIL_FIFO_CTRL, in fsl_micfil_dai_probe()
394 FIELD_PREP(MICFIL_FIFO_CTRL_FIFOWMK, micfil->soc->fifo_depth - 1)); in fsl_micfil_dai_probe()
414 .name = "fsl-micfil-dai",
540 struct fsl_micfil *micfil = (struct fsl_micfil *)devid; in micfil_isr() local
541 struct platform_device *pdev = micfil->pdev; in micfil_isr()
548 regmap_read(micfil->regmap, REG_MICFIL_STAT, &stat_reg); in micfil_isr()
549 regmap_read(micfil->regmap, REG_MICFIL_CTRL1, &ctrl1_reg); in micfil_isr()
550 regmap_read(micfil->regmap, REG_MICFIL_FIFO_STAT, &fifo_stat_reg); in micfil_isr()
563 regmap_write_bits(micfil->regmap, in micfil_isr()
586 struct fsl_micfil *micfil = (struct fsl_micfil *)devid; in micfil_err_isr() local
587 struct platform_device *pdev = micfil->pdev; in micfil_err_isr()
590 regmap_read(micfil->regmap, REG_MICFIL_STAT, &stat_reg); in micfil_err_isr()
600 regmap_write_bits(micfil->regmap, REG_MICFIL_STAT, in micfil_err_isr()
610 struct fsl_micfil *micfil; in fsl_micfil_probe() local
615 micfil = devm_kzalloc(&pdev->dev, sizeof(*micfil), GFP_KERNEL); in fsl_micfil_probe()
616 if (!micfil) in fsl_micfil_probe()
619 micfil->pdev = pdev; in fsl_micfil_probe()
620 strncpy(micfil->name, np->name, sizeof(micfil->name) - 1); in fsl_micfil_probe()
622 micfil->soc = of_device_get_match_data(&pdev->dev); in fsl_micfil_probe()
627 micfil->mclk = devm_clk_get(&pdev->dev, "ipg_clk_app"); in fsl_micfil_probe()
628 if (IS_ERR(micfil->mclk)) { in fsl_micfil_probe()
630 PTR_ERR(micfil->mclk)); in fsl_micfil_probe()
631 return PTR_ERR(micfil->mclk); in fsl_micfil_probe()
634 micfil->busclk = devm_clk_get(&pdev->dev, "ipg_clk"); in fsl_micfil_probe()
635 if (IS_ERR(micfil->busclk)) { in fsl_micfil_probe()
637 PTR_ERR(micfil->busclk)); in fsl_micfil_probe()
638 return PTR_ERR(micfil->busclk); in fsl_micfil_probe()
641 fsl_asoc_get_pll_clocks(&pdev->dev, &micfil->pll8k_clk, in fsl_micfil_probe()
642 &micfil->pll11k_clk); in fsl_micfil_probe()
649 micfil->regmap = devm_regmap_init_mmio(&pdev->dev, in fsl_micfil_probe()
652 if (IS_ERR(micfil->regmap)) { in fsl_micfil_probe()
653 dev_err(&pdev->dev, "failed to init MICFIL regmap: %ld\n", in fsl_micfil_probe()
654 PTR_ERR(micfil->regmap)); in fsl_micfil_probe()
655 return PTR_ERR(micfil->regmap); in fsl_micfil_probe()
662 &micfil->dataline); in fsl_micfil_probe()
664 micfil->dataline = 1; in fsl_micfil_probe()
666 if (micfil->dataline & ~micfil->soc->dataline) { in fsl_micfil_probe()
668 micfil->soc->dataline); in fsl_micfil_probe()
674 micfil->irq[i] = platform_get_irq(pdev, i); in fsl_micfil_probe()
675 if (micfil->irq[i] < 0) in fsl_micfil_probe()
676 return micfil->irq[i]; in fsl_micfil_probe()
680 ret = devm_request_irq(&pdev->dev, micfil->irq[0], in fsl_micfil_probe()
682 micfil->name, micfil); in fsl_micfil_probe()
685 micfil->irq[0]); in fsl_micfil_probe()
690 ret = devm_request_irq(&pdev->dev, micfil->irq[1], in fsl_micfil_probe()
692 micfil->name, micfil); in fsl_micfil_probe()
695 micfil->irq[1]); in fsl_micfil_probe()
699 micfil->dma_params_rx.chan_name = "rx"; in fsl_micfil_probe()
700 micfil->dma_params_rx.addr = res->start + REG_MICFIL_DATACH0; in fsl_micfil_probe()
701 micfil->dma_params_rx.maxburst = MICFIL_DMA_MAXBURST_RX; in fsl_micfil_probe()
703 platform_set_drvdata(pdev, micfil); in fsl_micfil_probe()
706 regcache_cache_only(micfil->regmap, true); in fsl_micfil_probe()
718 fsl_micfil_dai.capture.formats = micfil->soc->formats; in fsl_micfil_probe()
732 struct fsl_micfil *micfil = dev_get_drvdata(dev); in fsl_micfil_runtime_suspend() local
734 regcache_cache_only(micfil->regmap, true); in fsl_micfil_runtime_suspend()
736 clk_disable_unprepare(micfil->mclk); in fsl_micfil_runtime_suspend()
737 clk_disable_unprepare(micfil->busclk); in fsl_micfil_runtime_suspend()
744 struct fsl_micfil *micfil = dev_get_drvdata(dev); in fsl_micfil_runtime_resume() local
747 ret = clk_prepare_enable(micfil->busclk); in fsl_micfil_runtime_resume()
751 ret = clk_prepare_enable(micfil->mclk); in fsl_micfil_runtime_resume()
753 clk_disable_unprepare(micfil->busclk); in fsl_micfil_runtime_resume()
757 regcache_cache_only(micfil->regmap, false); in fsl_micfil_runtime_resume()
758 regcache_mark_dirty(micfil->regmap); in fsl_micfil_runtime_resume()
759 regcache_sync(micfil->regmap); in fsl_micfil_runtime_resume()
789 .name = "fsl-micfil-dai",
797 MODULE_DESCRIPTION("NXP PDM Microphone Interface (MICFIL) driver");