Lines Matching +full:mt8192 +full:- +full:infracfg

1 // SPDX-License-Identifier: GPL-2.0
10 #include <linux/dma-mapping.h>
19 #include "../common/mtk-afe-fe-dai.h"
20 #include "../common/mtk-afe-platform-driver.h"
22 #include "mt8192-afe-common.h"
23 #include "mt8192-afe-clk.h"
24 #include "mt8192-afe-gpio.h"
25 #include "mt8192-interconnection.h"
49 int id = asoc_rtd_to_cpu(rtd, 0)->id; in mt8192_memif_fs()
51 return mt8192_rate_transform(afe->dev, rate, id); in mt8192_memif_fs()
57 return mt8192_rate_transform(afe->dev, rate, dai_id); in mt8192_get_dai_fs()
67 return mt8192_general_rate_transform(afe->dev, rate); in mt8192_irq_fs()
72 struct snd_pcm_runtime *runtime = substream->runtime; in mt8192_get_memif_pbuf_size()
74 if ((runtime->period_size * 1000) / runtime->rate > 10) in mt8192_get_memif_pbuf_size()
367 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in ul_tinyconn_event()
372 dev_info(afe->dev, "%s(), event 0x%x\n", __func__, event); in ul_tinyconn_event()
374 if (strstr(w->name, "UL1")) { in ul_tinyconn_event()
377 } else if (strstr(w->name, "UL2")) { in ul_tinyconn_event()
380 } else if (strstr(w->name, "UL3")) { in ul_tinyconn_event()
383 } else if (strstr(w->name, "UL4")) { in ul_tinyconn_event()
389 dev_warn(afe->dev, "%s(), err widget name %s, default use UL4", in ul_tinyconn_event()
390 __func__, w->name); in ul_tinyconn_event()
395 regmap_update_bits(afe->regmap, AFE_MEMIF_CONN, reg_mask_shift, in ul_tinyconn_event()
399 regmap_update_bits(afe->regmap, AFE_MEMIF_CONN, reg_mask_shift, in ul_tinyconn_event()
683 /* inter-connections */
1341 .fs_reg = -1,
1342 .fs_shift = -1,
1343 .fs_maskbit = -1,
1344 .mono_reg = -1,
1345 .mono_shift = -1,
1715 .irq_fs_reg = -1,
1716 .irq_fs_shift = -1,
1717 .irq_fs_maskbit = -1,
1752 /* these auto-gen reg has read-only bit, so put it as volatile */ in mt8192_is_volatile_reg()
2014 regmap_read(afe->regmap, AFE_IRQ_MCU_EN, &mcu_en); in mt8192_afe_irq_handler()
2016 ret = regmap_read(afe->regmap, AFE_IRQ_MCU_STATUS, &status); in mt8192_afe_irq_handler()
2021 dev_err(afe->dev, "%s(), irq status err, ret %d, status 0x%x, mcu_en 0x%x\n", in mt8192_afe_irq_handler()
2028 struct mtk_base_afe_memif *memif = &afe->memif[i]; in mt8192_afe_irq_handler()
2030 if (!memif->substream) in mt8192_afe_irq_handler()
2033 if (memif->irq_usage < 0) in mt8192_afe_irq_handler()
2036 irq = &afe->irqs[memif->irq_usage]; in mt8192_afe_irq_handler()
2038 if (status_mcu & (1 << irq->irq_data->irq_en_shift)) in mt8192_afe_irq_handler()
2039 snd_pcm_period_elapsed(memif->substream); in mt8192_afe_irq_handler()
2044 regmap_write(afe->regmap, in mt8192_afe_irq_handler()
2054 struct mt8192_afe_private *afe_priv = afe->platform_priv; in mt8192_afe_runtime_suspend()
2058 dev_info(afe->dev, "%s()\n", __func__); in mt8192_afe_runtime_suspend()
2060 if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl) in mt8192_afe_runtime_suspend()
2064 regmap_update_bits(afe->regmap, AFE_DAC_CON0, AFE_ON_MASK_SFT, 0x0); in mt8192_afe_runtime_suspend()
2066 ret = regmap_read_poll_timeout(afe->regmap, in mt8192_afe_runtime_suspend()
2073 dev_warn(afe->dev, "%s(), ret %d\n", __func__, ret); in mt8192_afe_runtime_suspend()
2076 regmap_write(afe->regmap, AFE_IRQ_MCU_CLR, 0xffffffff); in mt8192_afe_runtime_suspend()
2077 regmap_write(afe->regmap, AFE_IRQ_MCU_CLR, 0xffffffff); in mt8192_afe_runtime_suspend()
2080 regmap_write(afe->regmap, AFE_SINEGEN_CON0, 0x0); in mt8192_afe_runtime_suspend()
2081 regmap_update_bits(afe->regmap, AFE_SINEGEN_CON2, in mt8192_afe_runtime_suspend()
2086 regcache_cache_only(afe->regmap, true); in mt8192_afe_runtime_suspend()
2087 regcache_mark_dirty(afe->regmap); in mt8192_afe_runtime_suspend()
2097 struct mt8192_afe_private *afe_priv = afe->platform_priv; in mt8192_afe_runtime_resume()
2100 dev_info(afe->dev, "%s()\n", __func__); in mt8192_afe_runtime_resume()
2106 if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl) in mt8192_afe_runtime_resume()
2109 regcache_cache_only(afe->regmap, false); in mt8192_afe_runtime_resume()
2110 regcache_sync(afe->regmap); in mt8192_afe_runtime_resume()
2113 regmap_update_bits(afe_priv->infracfg, in mt8192_afe_runtime_resume()
2115 regmap_update_bits(afe->regmap, AUDIO_TOP_CON0, 0x1 << 29, 0x1 << 29); in mt8192_afe_runtime_resume()
2118 regmap_update_bits(afe->regmap, AFE_MEMIF_CON0, in mt8192_afe_runtime_resume()
2122 regmap_write(afe->regmap, AFE_CONN_24BIT, 0xffffffff); in mt8192_afe_runtime_resume()
2123 regmap_write(afe->regmap, AFE_CONN_24BIT_1, 0xffffffff); in mt8192_afe_runtime_resume()
2126 regmap_update_bits(afe->regmap, AFE_DAC_CON0, AFE_ON_MASK_SFT, 0x1); in mt8192_afe_runtime_resume()
2145 .name = "mt8192-afe-pcm-dai",
2152 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt8192_dai_memif_register()
2154 return -ENOMEM; in mt8192_dai_memif_register()
2156 list_add(&dai->list, &afe->sub_dais); in mt8192_dai_memif_register()
2158 dai->dai_drivers = mt8192_memif_dai_driver; in mt8192_dai_memif_register()
2159 dai->num_dai_drivers = ARRAY_SIZE(mt8192_memif_dai_driver); in mt8192_dai_memif_register()
2161 dai->dapm_widgets = mt8192_memif_widgets; in mt8192_dai_memif_register()
2162 dai->num_dapm_widgets = ARRAY_SIZE(mt8192_memif_widgets); in mt8192_dai_memif_register()
2163 dai->dapm_routes = mt8192_memif_routes; in mt8192_dai_memif_register()
2164 dai->num_dapm_routes = ARRAY_SIZE(mt8192_memif_routes); in mt8192_dai_memif_register()
2185 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34)); in mt8192_afe_pcm_dev_probe()
2189 afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL); in mt8192_afe_pcm_dev_probe()
2191 return -ENOMEM; in mt8192_afe_pcm_dev_probe()
2194 afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv), in mt8192_afe_pcm_dev_probe()
2196 if (!afe->platform_priv) in mt8192_afe_pcm_dev_probe()
2197 return -ENOMEM; in mt8192_afe_pcm_dev_probe()
2198 afe_priv = afe->platform_priv; in mt8192_afe_pcm_dev_probe()
2200 afe->dev = &pdev->dev; in mt8192_afe_pcm_dev_probe()
2201 dev = afe->dev; in mt8192_afe_pcm_dev_probe()
2224 pm_runtime_enable(&pdev->dev); in mt8192_afe_pcm_dev_probe()
2225 if (!pm_runtime_enabled(&pdev->dev)) in mt8192_afe_pcm_dev_probe()
2229 afe->regmap = syscon_node_to_regmap(dev->parent->of_node); in mt8192_afe_pcm_dev_probe()
2230 if (IS_ERR(afe->regmap)) { in mt8192_afe_pcm_dev_probe()
2232 ret = PTR_ERR(afe->regmap); in mt8192_afe_pcm_dev_probe()
2235 ret = regmap_attach_dev(dev, afe->regmap, &mt8192_afe_regmap_config); in mt8192_afe_pcm_dev_probe()
2242 afe_priv->pm_runtime_bypass_reg_ctl = true; in mt8192_afe_pcm_dev_probe()
2243 pm_runtime_get_sync(&pdev->dev); in mt8192_afe_pcm_dev_probe()
2245 ret = regmap_reinit_cache(afe->regmap, &mt8192_afe_regmap_config); in mt8192_afe_pcm_dev_probe()
2251 pm_runtime_put_sync(&pdev->dev); in mt8192_afe_pcm_dev_probe()
2252 afe_priv->pm_runtime_bypass_reg_ctl = false; in mt8192_afe_pcm_dev_probe()
2254 regcache_cache_only(afe->regmap, true); in mt8192_afe_pcm_dev_probe()
2255 regcache_mark_dirty(afe->regmap); in mt8192_afe_pcm_dev_probe()
2258 afe->memif_size = MT8192_MEMIF_NUM; in mt8192_afe_pcm_dev_probe()
2259 afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif), in mt8192_afe_pcm_dev_probe()
2261 if (!afe->memif) { in mt8192_afe_pcm_dev_probe()
2262 ret = -ENOMEM; in mt8192_afe_pcm_dev_probe()
2266 for (i = 0; i < afe->memif_size; i++) { in mt8192_afe_pcm_dev_probe()
2267 afe->memif[i].data = &memif_data[i]; in mt8192_afe_pcm_dev_probe()
2268 afe->memif[i].irq_usage = memif_irq_usage[i]; in mt8192_afe_pcm_dev_probe()
2269 afe->memif[i].const_irq = 1; in mt8192_afe_pcm_dev_probe()
2272 mutex_init(&afe->irq_alloc_lock); /* needed when dynamic irq */ in mt8192_afe_pcm_dev_probe()
2275 afe->irqs_size = MT8192_IRQ_NUM; in mt8192_afe_pcm_dev_probe()
2276 afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs), in mt8192_afe_pcm_dev_probe()
2278 if (!afe->irqs) { in mt8192_afe_pcm_dev_probe()
2279 ret = -ENOMEM; in mt8192_afe_pcm_dev_probe()
2283 for (i = 0; i < afe->irqs_size; i++) in mt8192_afe_pcm_dev_probe()
2284 afe->irqs[i].irq_data = &irq_data[i]; in mt8192_afe_pcm_dev_probe()
2294 IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); in mt8192_afe_pcm_dev_probe()
2301 INIT_LIST_HEAD(&afe->sub_dais); in mt8192_afe_pcm_dev_probe()
2306 dev_warn(afe->dev, "dai register i %d fail, ret %d\n", in mt8192_afe_pcm_dev_probe()
2315 dev_warn(afe->dev, "mtk_afe_combine_sub_dai fail, ret %d\n", in mt8192_afe_pcm_dev_probe()
2321 afe->mtk_afe_hardware = &mt8192_afe_hardware; in mt8192_afe_pcm_dev_probe()
2322 afe->memif_fs = mt8192_memif_fs; in mt8192_afe_pcm_dev_probe()
2323 afe->irq_fs = mt8192_irq_fs; in mt8192_afe_pcm_dev_probe()
2324 afe->get_dai_fs = mt8192_get_dai_fs; in mt8192_afe_pcm_dev_probe()
2325 afe->get_memif_pbuf_size = mt8192_get_memif_pbuf_size; in mt8192_afe_pcm_dev_probe()
2326 afe->memif_32bit_supported = 1; in mt8192_afe_pcm_dev_probe()
2328 afe->runtime_resume = mt8192_afe_runtime_resume; in mt8192_afe_pcm_dev_probe()
2329 afe->runtime_suspend = mt8192_afe_runtime_suspend; in mt8192_afe_pcm_dev_probe()
2332 ret = devm_snd_soc_register_component(&pdev->dev, in mt8192_afe_pcm_dev_probe()
2339 ret = devm_snd_soc_register_component(&pdev->dev, in mt8192_afe_pcm_dev_probe()
2341 afe->dai_drivers, in mt8192_afe_pcm_dev_probe()
2342 afe->num_dai_drivers); in mt8192_afe_pcm_dev_probe()
2351 pm_runtime_disable(&pdev->dev); in mt8192_afe_pcm_dev_probe()
2360 pm_runtime_disable(&pdev->dev); in mt8192_afe_pcm_dev_remove()
2361 if (!pm_runtime_status_suspended(&pdev->dev)) in mt8192_afe_pcm_dev_remove()
2362 mt8192_afe_runtime_suspend(&pdev->dev); in mt8192_afe_pcm_dev_remove()
2370 { .compatible = "mediatek,mt8192-audio", },
2382 .name = "mt8192-audio",