Lines Matching full:afe
3 * Mediatek ALSA SoC AFE platform driver for 2701
17 #include "mt2701-afe-common.h"
18 #include "mt2701-afe-clock-ctrl.h"
19 #include "../common/mtk-afe-platform-driver.h"
20 #include "../common/mtk-afe-fe-dai.h"
82 static int mt2701_dai_num_to_i2s(struct mtk_base_afe *afe, int num) in mt2701_dai_num_to_i2s() argument
84 struct mt2701_afe_private *afe_priv = afe->platform_priv; in mt2701_dai_num_to_i2s()
88 dev_err(afe->dev, "%s, num not available, num %d, val %d\n", in mt2701_dai_num_to_i2s()
109 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt2701_afe_i2s_startup() local
110 struct mt2701_afe_private *afe_priv = afe->platform_priv; in mt2701_afe_i2s_startup()
111 int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); in mt2701_afe_i2s_startup()
117 return mt2701_afe_enable_mclk(afe, mode ? 1 : i2s_num); in mt2701_afe_i2s_startup()
120 static int mt2701_afe_i2s_path_disable(struct mtk_base_afe *afe, in mt2701_afe_i2s_path_disable() argument
133 regmap_update_bits(afe->regmap, i2s_data->i2s_ctrl_reg, in mt2701_afe_i2s_path_disable()
136 mt2701_afe_disable_i2s(afe, i2s_path, stream_dir); in mt2701_afe_i2s_path_disable()
144 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt2701_afe_i2s_shutdown() local
145 struct mt2701_afe_private *afe_priv = afe->platform_priv; in mt2701_afe_i2s_shutdown()
146 int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); in mt2701_afe_i2s_shutdown()
160 mt2701_afe_i2s_path_disable(afe, i2s_path, substream->stream); in mt2701_afe_i2s_shutdown()
164 mt2701_afe_i2s_path_disable(afe, i2s_path, !substream->stream); in mt2701_afe_i2s_shutdown()
168 mt2701_afe_disable_mclk(afe, mode ? 1 : i2s_num); in mt2701_afe_i2s_shutdown()
171 static int mt2701_i2s_path_enable(struct mtk_base_afe *afe, in mt2701_i2s_path_enable() argument
176 struct mt2701_afe_private *afe_priv = afe->platform_priv; in mt2701_i2s_path_enable()
207 regmap_update_bits(afe->regmap, i2s_data->i2s_ctrl_reg, mask, val); in mt2701_i2s_path_enable()
209 regmap_update_bits(afe->regmap, reg, in mt2701_i2s_path_enable()
215 mt2701_afe_enable_i2s(afe, i2s_path, stream_dir); in mt2701_i2s_path_enable()
218 regmap_update_bits(afe->regmap, i2s_data->i2s_ctrl_reg, in mt2701_i2s_path_enable()
221 regmap_update_bits(afe->regmap, i2s_data->i2s_ctrl_reg, in mt2701_i2s_path_enable()
224 regmap_update_bits(afe->regmap, i2s_data->i2s_ctrl_reg, in mt2701_i2s_path_enable()
232 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt2701_afe_i2s_prepare() local
233 struct mt2701_afe_private *afe_priv = afe->platform_priv; in mt2701_afe_i2s_prepare()
234 int ret, i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); in mt2701_afe_i2s_prepare()
246 ret = mt2701_mclk_configuration(afe, mode ? 1 : i2s_num); in mt2701_afe_i2s_prepare()
254 mt2701_i2s_path_enable(afe, i2s_path, !substream->stream, in mt2701_afe_i2s_prepare()
257 mt2701_i2s_path_enable(afe, i2s_path, substream->stream, in mt2701_afe_i2s_prepare()
266 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt2701_afe_i2s_set_sysclk() local
267 struct mt2701_afe_private *afe_priv = afe->platform_priv; in mt2701_afe_i2s_set_sysclk()
268 int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); in mt2701_afe_i2s_set_sysclk()
288 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt2701_btmrg_startup() local
289 struct mt2701_afe_private *afe_priv = afe->platform_priv; in mt2701_btmrg_startup()
292 ret = mt2701_enable_btmrg_clk(afe); in mt2701_btmrg_startup()
305 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt2701_btmrg_hw_params() local
312 dev_err(afe->dev, "unsupported rate %d\n", stream_fs); in mt2701_btmrg_hw_params()
316 regmap_update_bits(afe->regmap, AFE_MRGIF_CON, in mt2701_btmrg_hw_params()
329 regmap_update_bits(afe->regmap, AFE_DAIBT_CON0, msk, val); in mt2701_btmrg_hw_params()
331 regmap_update_bits(afe->regmap, AFE_DAIBT_CON0, in mt2701_btmrg_hw_params()
334 regmap_update_bits(afe->regmap, AFE_MRGIF_CON, in mt2701_btmrg_hw_params()
337 regmap_update_bits(afe->regmap, AFE_MRGIF_CON, in mt2701_btmrg_hw_params()
346 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt2701_btmrg_shutdown() local
347 struct mt2701_afe_private *afe_priv = afe->platform_priv; in mt2701_btmrg_shutdown()
351 regmap_update_bits(afe->regmap, AFE_DAIBT_CON0, in mt2701_btmrg_shutdown()
353 regmap_update_bits(afe->regmap, AFE_MRGIF_CON, in mt2701_btmrg_shutdown()
355 regmap_update_bits(afe->regmap, AFE_MRGIF_CON, in mt2701_btmrg_shutdown()
357 mt2701_disable_btmrg_clk(afe); in mt2701_btmrg_shutdown()
366 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt2701_simple_fe_startup() local
372 memif_tmp = &afe->memif[MT2701_MEMIF_DLM]; in mt2701_simple_fe_startup()
374 dev_warn(afe->dev, "memif is not available"); in mt2701_simple_fe_startup()
386 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt2701_simple_fe_hw_params() local
391 regmap_update_bits(afe->regmap, in mt2701_simple_fe_hw_params()
402 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt2701_dlm_fe_startup() local
408 memif_tmp = &afe->memif[i]; in mt2701_dlm_fe_startup()
415 memif_data = afe->memif[i].data; in mt2701_dlm_fe_startup()
416 regmap_update_bits(afe->regmap, in mt2701_dlm_fe_startup()
428 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt2701_dlm_fe_shutdown() local
433 memif_data = afe->memif[i].data; in mt2701_dlm_fe_shutdown()
434 regmap_update_bits(afe->regmap, in mt2701_dlm_fe_shutdown()
447 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt2701_dlm_fe_hw_params() local
450 regmap_update_bits(afe->regmap, in mt2701_dlm_fe_hw_params()
454 regmap_update_bits(afe->regmap, in mt2701_dlm_fe_hw_params()
458 regmap_update_bits(afe->regmap, in mt2701_dlm_fe_hw_params()
469 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mt2701_dlm_fe_trigger() local
470 struct mtk_base_afe_memif *memif_tmp = &afe->memif[MT2701_MEMIF_DL1]; in mt2701_dlm_fe_trigger()
475 regmap_update_bits(afe->regmap, memif_tmp->data->enable_reg, in mt2701_dlm_fe_trigger()
483 regmap_update_bits(afe->regmap, memif_tmp->data->enable_reg, in mt2701_dlm_fe_trigger()
957 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); in mt2701_afe_pcm_probe() local
959 snd_soc_component_init_regmap(component, afe->regmap); in mt2701_afe_pcm_probe()
966 .name = "mt2701-afe-pcm-dai",
1277 struct mtk_base_afe *afe = dev; in mt2701_asys_isr() local
1282 regmap_read(afe->regmap, ASYS_IRQ_STATUS, &status); in mt2701_asys_isr()
1283 regmap_write(afe->regmap, ASYS_IRQ_CLR, status); in mt2701_asys_isr()
1286 memif = &afe->memif[id]; in mt2701_asys_isr()
1290 irq = &afe->irqs[memif->irq_usage]; in mt2701_asys_isr()
1300 struct mtk_base_afe *afe = dev_get_drvdata(dev); in mt2701_afe_runtime_suspend() local
1302 return mt2701_afe_disable_clock(afe); in mt2701_afe_runtime_suspend()
1307 struct mtk_base_afe *afe = dev_get_drvdata(dev); in mt2701_afe_runtime_resume() local
1309 return mt2701_afe_enable_clock(afe); in mt2701_afe_runtime_resume()
1314 struct mtk_base_afe *afe; in mt2701_afe_pcm_dev_probe() local
1319 afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL); in mt2701_afe_pcm_dev_probe()
1320 if (!afe) in mt2701_afe_pcm_dev_probe()
1323 afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv), in mt2701_afe_pcm_dev_probe()
1325 if (!afe->platform_priv) in mt2701_afe_pcm_dev_probe()
1328 afe_priv = afe->platform_priv; in mt2701_afe_pcm_dev_probe()
1330 afe->dev = &pdev->dev; in mt2701_afe_pcm_dev_probe()
1331 dev = afe->dev; in mt2701_afe_pcm_dev_probe()
1345 IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); in mt2701_afe_pcm_dev_probe()
1351 afe->regmap = syscon_node_to_regmap(dev->parent->of_node); in mt2701_afe_pcm_dev_probe()
1352 if (IS_ERR(afe->regmap)) { in mt2701_afe_pcm_dev_probe()
1354 return PTR_ERR(afe->regmap); in mt2701_afe_pcm_dev_probe()
1357 mutex_init(&afe->irq_alloc_lock); in mt2701_afe_pcm_dev_probe()
1360 afe->memif_size = MT2701_MEMIF_NUM; in mt2701_afe_pcm_dev_probe()
1361 afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif), in mt2701_afe_pcm_dev_probe()
1363 if (!afe->memif) in mt2701_afe_pcm_dev_probe()
1366 for (i = 0; i < afe->memif_size; i++) { in mt2701_afe_pcm_dev_probe()
1367 afe->memif[i].data = &memif_data_array[i]; in mt2701_afe_pcm_dev_probe()
1368 afe->memif[i].irq_usage = -1; in mt2701_afe_pcm_dev_probe()
1372 afe->irqs_size = MT2701_IRQ_ASYS_END; in mt2701_afe_pcm_dev_probe()
1373 afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs), in mt2701_afe_pcm_dev_probe()
1375 if (!afe->irqs) in mt2701_afe_pcm_dev_probe()
1378 for (i = 0; i < afe->irqs_size; i++) in mt2701_afe_pcm_dev_probe()
1379 afe->irqs[i].irq_data = &irq_data[i]; in mt2701_afe_pcm_dev_probe()
1389 afe->mtk_afe_hardware = &mt2701_afe_hardware; in mt2701_afe_pcm_dev_probe()
1390 afe->memif_fs = mt2701_memif_fs; in mt2701_afe_pcm_dev_probe()
1391 afe->irq_fs = mt2701_irq_fs; in mt2701_afe_pcm_dev_probe()
1392 afe->reg_back_up_list = mt2701_afe_backup_list; in mt2701_afe_pcm_dev_probe()
1393 afe->reg_back_up_list_num = ARRAY_SIZE(mt2701_afe_backup_list); in mt2701_afe_pcm_dev_probe()
1394 afe->runtime_resume = mt2701_afe_runtime_resume; in mt2701_afe_pcm_dev_probe()
1395 afe->runtime_suspend = mt2701_afe_runtime_suspend; in mt2701_afe_pcm_dev_probe()
1398 ret = mt2701_init_clock(afe); in mt2701_afe_pcm_dev_probe()
1404 platform_set_drvdata(pdev, afe); in mt2701_afe_pcm_dev_probe()
1481 MODULE_DESCRIPTION("Mediatek ALSA SoC AFE platform driver for 2701");