Lines Matching full:afe

3 // Mediatek ALSA SoC AFE platform driver for 6797
15 #include "mt6797-afe-common.h"
16 #include "mt6797-afe-clk.h"
19 #include "../common/mtk-afe-platform-driver.h"
20 #include "../common/mtk-afe-fe-dai.h"
145 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); in mt6797_memif_fs() local
148 return mt6797_rate_transform(afe->dev, rate, id); in mt6797_memif_fs()
156 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); in mt6797_irq_fs() local
158 return mt6797_general_rate_transform(afe->dev, rate); in mt6797_irq_fs()
385 .name = "mt6797-afe-pcm-dai",
604 struct mtk_base_afe *afe = dev; in mt6797_afe_irq_handler() local
613 regmap_read(afe->regmap, AFE_IRQ_MCU_EN, &mcu_en); in mt6797_afe_irq_handler()
615 ret = regmap_read(afe->regmap, AFE_IRQ_MCU_STATUS, &status); in mt6797_afe_irq_handler()
617 dev_err(afe->dev, "%s(), irq status err, ret %d, status 0x%x, mcu_en 0x%x\n", in mt6797_afe_irq_handler()
628 struct mtk_base_afe_memif *memif = &afe->memif[i]; in mt6797_afe_irq_handler()
633 irq = &afe->irqs[memif->irq_usage]; in mt6797_afe_irq_handler()
641 regmap_write(afe->regmap, in mt6797_afe_irq_handler()
650 struct mtk_base_afe *afe = dev_get_drvdata(dev); in mt6797_afe_runtime_suspend() local
654 /* disable AFE */ in mt6797_afe_runtime_suspend()
655 regmap_update_bits(afe->regmap, AFE_DAC_CON0, AFE_ON_MASK_SFT, 0x0); in mt6797_afe_runtime_suspend()
657 regmap_read(afe->regmap, AFE_DAC_CON0, &afe_on_retm); in mt6797_afe_runtime_suspend()
665 dev_warn(afe->dev, "%s(), retry %d\n", __func__, retry); in mt6797_afe_runtime_suspend()
668 regmap_update_bits(afe->regmap, AFE_IRQ_MCU_CLR, 0xffff, 0xffff); in mt6797_afe_runtime_suspend()
670 return mt6797_afe_disable_clock(afe); in mt6797_afe_runtime_suspend()
675 struct mtk_base_afe *afe = dev_get_drvdata(dev); in mt6797_afe_runtime_resume() local
678 ret = mt6797_afe_enable_clock(afe); in mt6797_afe_runtime_resume()
683 regmap_write(afe->regmap, AFE_IRQ_MCU_EN, AFE_IRQ_MCU_EN_MASK_SFT); in mt6797_afe_runtime_resume()
686 regmap_update_bits(afe->regmap, AFE_MEMIF_HDALIGN, in mt6797_afe_runtime_resume()
689 regmap_update_bits(afe->regmap, AFE_MEMIF_MSB, in mt6797_afe_runtime_resume()
692 regmap_update_bits(afe->regmap, AFE_MEMIF_MSB, in mt6797_afe_runtime_resume()
696 regmap_update_bits(afe->regmap, AFE_CONN_24BIT, in mt6797_afe_runtime_resume()
699 /* enable AFE */ in mt6797_afe_runtime_resume()
700 regmap_update_bits(afe->regmap, AFE_DAC_CON0, in mt6797_afe_runtime_resume()
707 static int mt6797_dai_memif_register(struct mtk_base_afe *afe) in mt6797_dai_memif_register() argument
711 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt6797_dai_memif_register()
715 list_add(&dai->list, &afe->sub_dais); in mt6797_dai_memif_register()
737 struct mtk_base_afe *afe; in mt6797_afe_pcm_dev_probe() local
742 afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL); in mt6797_afe_pcm_dev_probe()
743 if (!afe) in mt6797_afe_pcm_dev_probe()
746 afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv), in mt6797_afe_pcm_dev_probe()
748 if (!afe->platform_priv) in mt6797_afe_pcm_dev_probe()
751 afe_priv = afe->platform_priv; in mt6797_afe_pcm_dev_probe()
752 afe->dev = &pdev->dev; in mt6797_afe_pcm_dev_probe()
753 dev = afe->dev; in mt6797_afe_pcm_dev_probe()
756 ret = mt6797_init_clock(afe); in mt6797_afe_pcm_dev_probe()
763 afe->base_addr = devm_platform_ioremap_resource(pdev, 0); in mt6797_afe_pcm_dev_probe()
764 if (IS_ERR(afe->base_addr)) in mt6797_afe_pcm_dev_probe()
765 return PTR_ERR(afe->base_addr); in mt6797_afe_pcm_dev_probe()
767 afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr, in mt6797_afe_pcm_dev_probe()
769 if (IS_ERR(afe->regmap)) in mt6797_afe_pcm_dev_probe()
770 return PTR_ERR(afe->regmap); in mt6797_afe_pcm_dev_probe()
773 afe->memif_size = MT6797_MEMIF_NUM; in mt6797_afe_pcm_dev_probe()
774 afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif), in mt6797_afe_pcm_dev_probe()
776 if (!afe->memif) in mt6797_afe_pcm_dev_probe()
779 for (i = 0; i < afe->memif_size; i++) { in mt6797_afe_pcm_dev_probe()
780 afe->memif[i].data = &memif_data[i]; in mt6797_afe_pcm_dev_probe()
781 afe->memif[i].irq_usage = -1; in mt6797_afe_pcm_dev_probe()
784 mutex_init(&afe->irq_alloc_lock); in mt6797_afe_pcm_dev_probe()
787 afe->irqs_size = MT6797_IRQ_NUM; in mt6797_afe_pcm_dev_probe()
788 afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs), in mt6797_afe_pcm_dev_probe()
790 if (!afe->irqs) in mt6797_afe_pcm_dev_probe()
793 for (i = 0; i < afe->irqs_size; i++) in mt6797_afe_pcm_dev_probe()
794 afe->irqs[i].irq_data = &irq_data[i]; in mt6797_afe_pcm_dev_probe()
802 IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); in mt6797_afe_pcm_dev_probe()
809 INIT_LIST_HEAD(&afe->sub_dais); in mt6797_afe_pcm_dev_probe()
812 ret = dai_register_cbs[i](afe); in mt6797_afe_pcm_dev_probe()
814 dev_warn(afe->dev, "dai register i %d fail, ret %d\n", in mt6797_afe_pcm_dev_probe()
821 ret = mtk_afe_combine_sub_dai(afe); in mt6797_afe_pcm_dev_probe()
823 dev_warn(afe->dev, "mtk_afe_combine_sub_dai fail, ret %d\n", in mt6797_afe_pcm_dev_probe()
828 afe->mtk_afe_hardware = &mt6797_afe_hardware; in mt6797_afe_pcm_dev_probe()
829 afe->memif_fs = mt6797_memif_fs; in mt6797_afe_pcm_dev_probe()
830 afe->irq_fs = mt6797_irq_fs; in mt6797_afe_pcm_dev_probe()
832 afe->runtime_resume = mt6797_afe_runtime_resume; in mt6797_afe_pcm_dev_probe()
833 afe->runtime_suspend = mt6797_afe_runtime_suspend; in mt6797_afe_pcm_dev_probe()
835 platform_set_drvdata(pdev, afe); in mt6797_afe_pcm_dev_probe()
850 ret = devm_snd_soc_register_component(afe->dev, in mt6797_afe_pcm_dev_probe()
852 afe->dai_drivers, in mt6797_afe_pcm_dev_probe()
853 afe->num_dai_drivers); in mt6797_afe_pcm_dev_probe()
898 MODULE_DESCRIPTION("Mediatek ALSA SoC AFE platform driver for 6797");