Lines Matching full:afe

3  * MediaTek ALSA SoC AFE platform driver for MT7986
17 #include "mt7986-afe-common.h"
19 #include "../common/mtk-afe-platform-driver.h"
20 #include "../common/mtk-afe-fe-dai.h"
111 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); in mt7986_memif_fs() local
113 return mt7986_afe_rate_transform(afe->dev, rate); in mt7986_memif_fs()
121 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); in mt7986_irq_fs() local
123 return mt7986_afe_rate_transform(afe->dev, rate); in mt7986_irq_fs()
194 .name = "mt7986-afe-pcm-dai",
321 static int mt7986_init_clock(struct mtk_base_afe *afe) in mt7986_init_clock() argument
323 struct mt7986_afe_private *afe_priv = afe->platform_priv; in mt7986_init_clock()
326 afe_priv->clks = devm_kcalloc(afe->dev, CLK_NUM, in mt7986_init_clock()
335 ret = devm_clk_bulk_get(afe->dev, afe_priv->num_clks, afe_priv->clks); in mt7986_init_clock()
337 return dev_err_probe(afe->dev, ret, "Failed to get clocks\n"); in mt7986_init_clock()
344 struct mtk_base_afe *afe = dev; in mt7986_afe_irq_handler() local
351 regmap_read(afe->regmap, AFE_IRQ_MCU_EN, &mcu_en); in mt7986_afe_irq_handler()
353 ret = regmap_read(afe->regmap, AFE_IRQ_MCU_STATUS, &status); in mt7986_afe_irq_handler()
358 dev_err(afe->dev, "%s(), irq status err, ret %d, status 0x%x, mcu_en 0x%x\n", in mt7986_afe_irq_handler()
366 struct mtk_base_afe_memif *memif = &afe->memif[i]; in mt7986_afe_irq_handler()
374 irq = &afe->irqs[memif->irq_usage]; in mt7986_afe_irq_handler()
382 regmap_write(afe->regmap, AFE_IRQ_MCU_CLR, status_mcu); in mt7986_afe_irq_handler()
389 struct mtk_base_afe *afe = dev_get_drvdata(dev); in mt7986_afe_runtime_suspend() local
390 struct mt7986_afe_private *afe_priv = afe->platform_priv; in mt7986_afe_runtime_suspend()
392 if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl) in mt7986_afe_runtime_suspend()
396 regmap_update_bits(afe->regmap, AUDIO_TOP_CON4, 0x3fff, 0x3fff); in mt7986_afe_runtime_suspend()
397 regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_APLL2_EN_MASK, 0); in mt7986_afe_runtime_suspend()
398 regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_26M_EN_MASK, 0); in mt7986_afe_runtime_suspend()
401 regmap_update_bits(afe->regmap, AFE_IRQ_MCU_CLR, 0xffff, 0xffff); in mt7986_afe_runtime_suspend()
411 struct mtk_base_afe *afe = dev_get_drvdata(dev); in mt7986_afe_runtime_resume() local
412 struct mt7986_afe_private *afe_priv = afe->platform_priv; in mt7986_afe_runtime_resume()
417 return dev_err_probe(afe->dev, ret, "Failed to enable clocks\n"); in mt7986_afe_runtime_resume()
419 if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl) in mt7986_afe_runtime_resume()
423 regmap_update_bits(afe->regmap, AUDIO_TOP_CON4, 0x3fff, 0); in mt7986_afe_runtime_resume()
424 regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_APLL2_EN_MASK, in mt7986_afe_runtime_resume()
426 regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_26M_EN_MASK, in mt7986_afe_runtime_resume()
432 static int mt7986_dai_memif_register(struct mtk_base_afe *afe) in mt7986_dai_memif_register() argument
436 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt7986_dai_memif_register()
440 list_add(&dai->list, &afe->sub_dais); in mt7986_dai_memif_register()
461 struct mtk_base_afe *afe; in mt7986_afe_pcm_dev_probe() local
466 afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL); in mt7986_afe_pcm_dev_probe()
467 if (!afe) in mt7986_afe_pcm_dev_probe()
469 platform_set_drvdata(pdev, afe); in mt7986_afe_pcm_dev_probe()
471 afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv), in mt7986_afe_pcm_dev_probe()
473 if (!afe->platform_priv) in mt7986_afe_pcm_dev_probe()
476 afe_priv = afe->platform_priv; in mt7986_afe_pcm_dev_probe()
477 afe->dev = &pdev->dev; in mt7986_afe_pcm_dev_probe()
478 dev = afe->dev; in mt7986_afe_pcm_dev_probe()
480 afe->base_addr = devm_platform_ioremap_resource(pdev, 0); in mt7986_afe_pcm_dev_probe()
481 if (IS_ERR(afe->base_addr)) in mt7986_afe_pcm_dev_probe()
482 return PTR_ERR(afe->base_addr); in mt7986_afe_pcm_dev_probe()
485 ret = mt7986_init_clock(afe); in mt7986_afe_pcm_dev_probe()
497 afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr, in mt7986_afe_pcm_dev_probe()
501 if (IS_ERR(afe->regmap)) in mt7986_afe_pcm_dev_probe()
502 return PTR_ERR(afe->regmap); in mt7986_afe_pcm_dev_probe()
507 afe->memif_size = MT7986_MEMIF_NUM; in mt7986_afe_pcm_dev_probe()
508 afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif), in mt7986_afe_pcm_dev_probe()
510 if (!afe->memif) in mt7986_afe_pcm_dev_probe()
513 for (i = 0; i < afe->memif_size; i++) { in mt7986_afe_pcm_dev_probe()
514 afe->memif[i].data = &memif_data[i]; in mt7986_afe_pcm_dev_probe()
515 afe->memif[i].irq_usage = -1; in mt7986_afe_pcm_dev_probe()
518 mutex_init(&afe->irq_alloc_lock); in mt7986_afe_pcm_dev_probe()
521 afe->irqs_size = MT7986_IRQ_NUM; in mt7986_afe_pcm_dev_probe()
522 afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs), in mt7986_afe_pcm_dev_probe()
524 if (!afe->irqs) in mt7986_afe_pcm_dev_probe()
527 for (i = 0; i < afe->irqs_size; i++) in mt7986_afe_pcm_dev_probe()
528 afe->irqs[i].irq_data = &irq_data[i]; in mt7986_afe_pcm_dev_probe()
536 IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); in mt7986_afe_pcm_dev_probe()
541 INIT_LIST_HEAD(&afe->sub_dais); in mt7986_afe_pcm_dev_probe()
544 ret = dai_register_cbs[i](afe); in mt7986_afe_pcm_dev_probe()
550 ret = mtk_afe_combine_sub_dai(afe); in mt7986_afe_pcm_dev_probe()
554 afe->mtk_afe_hardware = &mt7986_afe_hardware; in mt7986_afe_pcm_dev_probe()
555 afe->memif_fs = mt7986_memif_fs; in mt7986_afe_pcm_dev_probe()
556 afe->irq_fs = mt7986_irq_fs; in mt7986_afe_pcm_dev_probe()
558 afe->runtime_resume = mt7986_afe_runtime_resume; in mt7986_afe_pcm_dev_probe()
559 afe->runtime_suspend = mt7986_afe_runtime_suspend; in mt7986_afe_pcm_dev_probe()
566 return dev_err_probe(dev, ret, "Cannot register AFE component\n"); in mt7986_afe_pcm_dev_probe()
568 ret = devm_snd_soc_register_component(afe->dev, in mt7986_afe_pcm_dev_probe()
570 afe->dai_drivers, in mt7986_afe_pcm_dev_probe()
571 afe->num_dai_drivers); in mt7986_afe_pcm_dev_probe()
586 { .compatible = "mediatek,mt7986-afe" },
607 MODULE_DESCRIPTION("MediaTek SoC AFE platform driver for ALSA MT7986");