Lines Matching refs:afe

196 static int mt8173_afe_set_i2s(struct mtk_base_afe *afe, unsigned int rate)  in mt8173_afe_set_i2s()  argument
205 regmap_update_bits(afe->regmap, AFE_ADDA_TOP_CON0, 0x1, 0x1); in mt8173_afe_set_i2s()
206 regmap_update_bits(afe->regmap, AFE_ADDA2_TOP_CON0, 0x1, 0x1); in mt8173_afe_set_i2s()
213 regmap_update_bits(afe->regmap, AFE_I2S_CON2, ~AFE_I2S_CON2_EN, val); in mt8173_afe_set_i2s()
220 regmap_update_bits(afe->regmap, AFE_I2S_CON1, ~AFE_I2S_CON1_EN, val); in mt8173_afe_set_i2s()
224 static void mt8173_afe_set_i2s_enable(struct mtk_base_afe *afe, bool enable) in mt8173_afe_set_i2s_enable() argument
228 regmap_read(afe->regmap, AFE_I2S_CON2, &val); in mt8173_afe_set_i2s_enable()
233 regmap_update_bits(afe->regmap, AFE_I2S_CON2, 0x1, enable); in mt8173_afe_set_i2s_enable()
236 regmap_update_bits(afe->regmap, AFE_I2S_CON1, 0x1, enable); in mt8173_afe_set_i2s_enable()
239 static int mt8173_afe_dais_enable_clks(struct mtk_base_afe *afe, in mt8173_afe_dais_enable_clks() argument
247 dev_err(afe->dev, "Failed to enable m_ck\n"); in mt8173_afe_dais_enable_clks()
255 dev_err(afe->dev, "Failed to enable b_ck\n"); in mt8173_afe_dais_enable_clks()
262 static int mt8173_afe_dais_set_clks(struct mtk_base_afe *afe, in mt8173_afe_dais_set_clks() argument
271 dev_err(afe->dev, "Failed to set m_ck rate\n"); in mt8173_afe_dais_set_clks()
279 dev_err(afe->dev, "Failed to set b_ck rate\n"); in mt8173_afe_dais_set_clks()
286 static void mt8173_afe_dais_disable_clks(struct mtk_base_afe *afe, in mt8173_afe_dais_disable_clks() argument
296 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt8173_afe_i2s_startup() local
301 regmap_update_bits(afe->regmap, AUDIO_TOP_CON0, in mt8173_afe_i2s_startup()
309 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt8173_afe_i2s_shutdown() local
314 mt8173_afe_set_i2s_enable(afe, false); in mt8173_afe_i2s_shutdown()
315 regmap_update_bits(afe->regmap, AUDIO_TOP_CON0, in mt8173_afe_i2s_shutdown()
324 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt8173_afe_i2s_prepare() local
325 struct mt8173_afe_private *afe_priv = afe->platform_priv; in mt8173_afe_i2s_prepare()
328 mt8173_afe_dais_set_clks(afe, afe_priv->clocks[MT8173_CLK_I2S1_M], in mt8173_afe_i2s_prepare()
330 mt8173_afe_dais_set_clks(afe, afe_priv->clocks[MT8173_CLK_I2S2_M], in mt8173_afe_i2s_prepare()
333 ret = mt8173_afe_set_i2s(afe, substream->runtime->rate); in mt8173_afe_i2s_prepare()
337 mt8173_afe_set_i2s_enable(afe, true); in mt8173_afe_i2s_prepare()
345 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt8173_afe_hdmi_startup() local
346 struct mt8173_afe_private *afe_priv = afe->platform_priv; in mt8173_afe_hdmi_startup()
351 mt8173_afe_dais_enable_clks(afe, afe_priv->clocks[MT8173_CLK_I2S3_M], in mt8173_afe_hdmi_startup()
359 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt8173_afe_hdmi_shutdown() local
360 struct mt8173_afe_private *afe_priv = afe->platform_priv; in mt8173_afe_hdmi_shutdown()
365 mt8173_afe_dais_disable_clks(afe, afe_priv->clocks[MT8173_CLK_I2S3_M], in mt8173_afe_hdmi_shutdown()
373 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt8173_afe_hdmi_prepare() local
374 struct mt8173_afe_private *afe_priv = afe->platform_priv; in mt8173_afe_hdmi_prepare()
378 mt8173_afe_dais_set_clks(afe, afe_priv->clocks[MT8173_CLK_I2S3_M], in mt8173_afe_hdmi_prepare()
390 regmap_update_bits(afe->regmap, AFE_TDM_CON1, ~AFE_TDM_CON1_EN, val); in mt8173_afe_hdmi_prepare()
425 regmap_update_bits(afe->regmap, AFE_TDM_CON2, 0x0000ffff, val); in mt8173_afe_hdmi_prepare()
427 regmap_update_bits(afe->regmap, AFE_HDMI_OUT_CON0, in mt8173_afe_hdmi_prepare()
435 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt8173_afe_hdmi_trigger() local
437 dev_info(afe->dev, "%s cmd=%d %s\n", __func__, cmd, dai->name); in mt8173_afe_hdmi_trigger()
442 regmap_update_bits(afe->regmap, AUDIO_TOP_CON0, in mt8173_afe_hdmi_trigger()
446 regmap_write(afe->regmap, AFE_HDMI_CONN0, in mt8173_afe_hdmi_trigger()
457 regmap_update_bits(afe->regmap, AFE_HDMI_OUT_CON0, 0x1, 0x1); in mt8173_afe_hdmi_trigger()
460 regmap_update_bits(afe->regmap, AFE_TDM_CON1, 0x1, 0x1); in mt8173_afe_hdmi_trigger()
466 regmap_update_bits(afe->regmap, AFE_TDM_CON1, 0x1, 0); in mt8173_afe_hdmi_trigger()
469 regmap_update_bits(afe->regmap, AFE_HDMI_OUT_CON0, 0x1, 0); in mt8173_afe_hdmi_trigger()
471 regmap_update_bits(afe->regmap, AUDIO_TOP_CON0, in mt8173_afe_hdmi_trigger()
485 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); in mt8173_memif_fs() local
486 struct mtk_base_afe_memif *memif = &afe->memif[asoc_rtd_to_cpu(rtd, 0)->id]; in mt8173_memif_fs()
914 struct mtk_base_afe *afe = dev_id; in mt8173_afe_irq_handler() local
918 ret = regmap_read(afe->regmap, AFE_IRQ_STATUS, &reg_value); in mt8173_afe_irq_handler()
920 dev_err(afe->dev, "%s irq status err\n", __func__); in mt8173_afe_irq_handler()
926 struct mtk_base_afe_memif *memif = &afe->memif[i]; in mt8173_afe_irq_handler()
932 irq_p = &afe->irqs[memif->irq_usage]; in mt8173_afe_irq_handler()
942 regmap_write(afe->regmap, AFE_IRQ_CLR, in mt8173_afe_irq_handler()
950 struct mtk_base_afe *afe = dev_get_drvdata(dev); in mt8173_afe_runtime_suspend() local
951 struct mt8173_afe_private *afe_priv = afe->platform_priv; in mt8173_afe_runtime_suspend()
954 regmap_update_bits(afe->regmap, AFE_DAC_CON0, 0x1, 0); in mt8173_afe_runtime_suspend()
957 regmap_update_bits(afe->regmap, AUDIO_TOP_CON0, in mt8173_afe_runtime_suspend()
972 struct mtk_base_afe *afe = dev_get_drvdata(dev); in mt8173_afe_runtime_resume() local
973 struct mt8173_afe_private *afe_priv = afe->platform_priv; in mt8173_afe_runtime_resume()
1003 regmap_update_bits(afe->regmap, AUDIO_TOP_CON0, AUD_TCON0_PDN_AFE, 0); in mt8173_afe_runtime_resume()
1006 regmap_update_bits(afe->regmap, AFE_CONN_24BIT, in mt8173_afe_runtime_resume()
1010 regmap_update_bits(afe->regmap, AFE_IRQ_MCU_EN, 0xff, 0xff); in mt8173_afe_runtime_resume()
1013 regmap_update_bits(afe->regmap, AFE_DAC_CON0, 0x1, 0x1); in mt8173_afe_runtime_resume()
1031 static int mt8173_afe_init_audio_clk(struct mtk_base_afe *afe) in mt8173_afe_init_audio_clk() argument
1034 struct mt8173_afe_private *afe_priv = afe->platform_priv; in mt8173_afe_init_audio_clk()
1037 afe_priv->clocks[i] = devm_clk_get(afe->dev, aud_clks[i]); in mt8173_afe_init_audio_clk()
1039 dev_err(afe->dev, "%s devm_clk_get %s fail\n", in mt8173_afe_init_audio_clk()
1053 struct mtk_base_afe *afe; in mt8173_afe_pcm_dev_probe() local
1061 afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL); in mt8173_afe_pcm_dev_probe()
1062 if (!afe) in mt8173_afe_pcm_dev_probe()
1065 afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv), in mt8173_afe_pcm_dev_probe()
1067 afe_priv = afe->platform_priv; in mt8173_afe_pcm_dev_probe()
1071 afe->dev = &pdev->dev; in mt8173_afe_pcm_dev_probe()
1077 afe->base_addr = devm_platform_ioremap_resource(pdev, 0); in mt8173_afe_pcm_dev_probe()
1078 if (IS_ERR(afe->base_addr)) in mt8173_afe_pcm_dev_probe()
1079 return PTR_ERR(afe->base_addr); in mt8173_afe_pcm_dev_probe()
1081 afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr, in mt8173_afe_pcm_dev_probe()
1083 if (IS_ERR(afe->regmap)) in mt8173_afe_pcm_dev_probe()
1084 return PTR_ERR(afe->regmap); in mt8173_afe_pcm_dev_probe()
1087 ret = mt8173_afe_init_audio_clk(afe); in mt8173_afe_pcm_dev_probe()
1089 dev_err(afe->dev, "mt8173_afe_init_audio_clk fail\n"); in mt8173_afe_pcm_dev_probe()
1094 afe->memif_size = MT8173_AFE_MEMIF_NUM; in mt8173_afe_pcm_dev_probe()
1095 afe->memif = devm_kcalloc(afe->dev, afe->memif_size, in mt8173_afe_pcm_dev_probe()
1096 sizeof(*afe->memif), GFP_KERNEL); in mt8173_afe_pcm_dev_probe()
1097 if (!afe->memif) in mt8173_afe_pcm_dev_probe()
1100 afe->irqs_size = MT8173_AFE_IRQ_NUM; in mt8173_afe_pcm_dev_probe()
1101 afe->irqs = devm_kcalloc(afe->dev, afe->irqs_size, in mt8173_afe_pcm_dev_probe()
1102 sizeof(*afe->irqs), GFP_KERNEL); in mt8173_afe_pcm_dev_probe()
1103 if (!afe->irqs) in mt8173_afe_pcm_dev_probe()
1106 for (i = 0; i < afe->irqs_size; i++) { in mt8173_afe_pcm_dev_probe()
1107 afe->memif[i].data = &memif_data[i]; in mt8173_afe_pcm_dev_probe()
1108 afe->irqs[i].irq_data = &irq_data[i]; in mt8173_afe_pcm_dev_probe()
1109 afe->irqs[i].irq_occupyed = true; in mt8173_afe_pcm_dev_probe()
1110 afe->memif[i].irq_usage = i; in mt8173_afe_pcm_dev_probe()
1111 afe->memif[i].const_irq = 1; in mt8173_afe_pcm_dev_probe()
1114 afe->mtk_afe_hardware = &mt8173_afe_hardware; in mt8173_afe_pcm_dev_probe()
1115 afe->memif_fs = mt8173_memif_fs; in mt8173_afe_pcm_dev_probe()
1116 afe->irq_fs = mt8173_irq_fs; in mt8173_afe_pcm_dev_probe()
1118 platform_set_drvdata(pdev, afe); in mt8173_afe_pcm_dev_probe()
1127 afe->reg_back_up_list = mt8173_afe_backup_list; in mt8173_afe_pcm_dev_probe()
1128 afe->reg_back_up_list_num = ARRAY_SIZE(mt8173_afe_backup_list); in mt8173_afe_pcm_dev_probe()
1129 afe->runtime_resume = mt8173_afe_runtime_resume; in mt8173_afe_pcm_dev_probe()
1130 afe->runtime_suspend = mt8173_afe_runtime_suspend; in mt8173_afe_pcm_dev_probe()
1182 ret = devm_request_irq(afe->dev, irq_id, mt8173_afe_irq_handler, in mt8173_afe_pcm_dev_probe()
1183 0, "Afe_ISR_Handle", (void *)afe); in mt8173_afe_pcm_dev_probe()
1185 dev_err(afe->dev, "could not request_irq\n"); in mt8173_afe_pcm_dev_probe()