Lines Matching +full:tegra210 +full:- +full:sfc
1 // SPDX-License-Identifier: GPL-2.0-only
3 // tegra210_sfc.c - Tegra210 SFC driver
5 // Copyright (c) 2021-2023 NVIDIA CORPORATION. All rights reserved.
24 #define UNSUPP_CONV ((void *)(-EOPNOTSUPP))
52 /* coeff RAM tables required for SFC */
3062 struct tegra210_sfc *sfc = dev_get_drvdata(dev); in tegra210_sfc_runtime_suspend() local
3064 regcache_cache_only(sfc->regmap, true); in tegra210_sfc_runtime_suspend()
3065 regcache_mark_dirty(sfc->regmap); in tegra210_sfc_runtime_suspend()
3072 struct tegra210_sfc *sfc = dev_get_drvdata(dev); in tegra210_sfc_runtime_resume() local
3074 regcache_cache_only(sfc->regmap, false); in tegra210_sfc_runtime_resume()
3075 regcache_sync(sfc->regmap); in tegra210_sfc_runtime_resume()
3096 struct tegra210_sfc *sfc = dev_get_drvdata(cmpnt->dev); in tegra210_sfc_write_coeff_ram() local
3100 if (sfc->srate_in == sfc->srate_out) in tegra210_sfc_write_coeff_ram()
3103 coeff_ram = coef_addr_table[sfc->srate_in][sfc->srate_out]; in tegra210_sfc_write_coeff_ram()
3105 dev_err(cmpnt->dev, in tegra210_sfc_write_coeff_ram()
3107 sfc->srate_in, sfc->srate_out); in tegra210_sfc_write_coeff_ram()
3112 tegra210_sfc_write_ram(sfc->regmap, coeff_ram); in tegra210_sfc_write_coeff_ram()
3114 regmap_update_bits(sfc->regmap, in tegra210_sfc_write_coeff_ram()
3122 static int tegra210_sfc_set_audio_cif(struct tegra210_sfc *sfc, in tegra210_sfc_set_audio_cif() argument
3141 return -EOPNOTSUPP; in tegra210_sfc_set_audio_cif()
3154 cif_conf.stereo_conv = sfc->stereo_to_mono[path]; in tegra210_sfc_set_audio_cif()
3155 cif_conf.mono_conv = sfc->mono_to_stereo[path]; in tegra210_sfc_set_audio_cif()
3157 tegra_set_cif(sfc->regmap, reg, &cif_conf); in tegra210_sfc_set_audio_cif()
3162 static int tegra210_sfc_soft_reset(struct tegra210_sfc *sfc) in tegra210_sfc_soft_reset() argument
3172 regmap_update_bits(sfc->regmap, TEGRA210_SFC_SOFT_RESET, in tegra210_sfc_soft_reset()
3175 return regmap_read_poll_timeout(sfc->regmap, in tegra210_sfc_soft_reset()
3197 return -EOPNOTSUPP; in tegra210_sfc_rate_to_idx()
3203 struct tegra210_sfc *sfc = snd_soc_dai_get_drvdata(dai); in tegra210_sfc_startup() local
3206 regmap_update_bits(sfc->regmap, TEGRA210_SFC_COEF_RAM, in tegra210_sfc_startup()
3209 err = tegra210_sfc_soft_reset(sfc); in tegra210_sfc_startup()
3211 dev_err(dai->dev, "Failed to reset SFC in %s, err = %d\n", in tegra210_sfc_startup()
3224 struct tegra210_sfc *sfc = snd_soc_dai_get_drvdata(dai); in tegra210_sfc_in_hw_params() local
3225 struct device *dev = dai->dev; in tegra210_sfc_in_hw_params()
3229 &sfc->srate_in); in tegra210_sfc_in_hw_params()
3233 err = tegra210_sfc_set_audio_cif(sfc, params, TEGRA210_SFC_RX_CIF_CTRL); in tegra210_sfc_in_hw_params()
3235 dev_err(dev, "Can't set SFC RX CIF: %d\n", err); in tegra210_sfc_in_hw_params()
3239 regmap_write(sfc->regmap, TEGRA210_SFC_RX_FREQ, sfc->srate_in); in tegra210_sfc_in_hw_params()
3248 struct tegra210_sfc *sfc = snd_soc_dai_get_drvdata(dai); in tegra210_sfc_out_hw_params() local
3249 struct device *dev = dai->dev; in tegra210_sfc_out_hw_params()
3253 &sfc->srate_out); in tegra210_sfc_out_hw_params()
3257 err = tegra210_sfc_set_audio_cif(sfc, params, TEGRA210_SFC_TX_CIF_CTRL); in tegra210_sfc_out_hw_params()
3259 dev_err(dev, "Can't set SFC TX CIF: %d\n", err); in tegra210_sfc_out_hw_params()
3263 regmap_write(sfc->regmap, TEGRA210_SFC_TX_FREQ, sfc->srate_out); in tegra210_sfc_out_hw_params()
3271 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in tegra210_sfc_init()
3280 struct tegra210_sfc *sfc = snd_soc_component_get_drvdata(cmpnt); in tegra210_sfc_iget_stereo_to_mono() local
3282 ucontrol->value.enumerated.item[0] = sfc->stereo_to_mono[SFC_RX_PATH]; in tegra210_sfc_iget_stereo_to_mono()
3291 struct tegra210_sfc *sfc = snd_soc_component_get_drvdata(cmpnt); in tegra210_sfc_iput_stereo_to_mono() local
3292 unsigned int value = ucontrol->value.enumerated.item[0]; in tegra210_sfc_iput_stereo_to_mono()
3294 if (value == sfc->stereo_to_mono[SFC_RX_PATH]) in tegra210_sfc_iput_stereo_to_mono()
3297 sfc->stereo_to_mono[SFC_RX_PATH] = value; in tegra210_sfc_iput_stereo_to_mono()
3306 struct tegra210_sfc *sfc = snd_soc_component_get_drvdata(cmpnt); in tegra210_sfc_iget_mono_to_stereo() local
3308 ucontrol->value.enumerated.item[0] = sfc->mono_to_stereo[SFC_RX_PATH]; in tegra210_sfc_iget_mono_to_stereo()
3317 struct tegra210_sfc *sfc = snd_soc_component_get_drvdata(cmpnt); in tegra210_sfc_iput_mono_to_stereo() local
3318 unsigned int value = ucontrol->value.enumerated.item[0]; in tegra210_sfc_iput_mono_to_stereo()
3320 if (value == sfc->mono_to_stereo[SFC_RX_PATH]) in tegra210_sfc_iput_mono_to_stereo()
3323 sfc->mono_to_stereo[SFC_RX_PATH] = value; in tegra210_sfc_iput_mono_to_stereo()
3332 struct tegra210_sfc *sfc = snd_soc_component_get_drvdata(cmpnt); in tegra210_sfc_oget_stereo_to_mono() local
3334 ucontrol->value.enumerated.item[0] = sfc->stereo_to_mono[SFC_TX_PATH]; in tegra210_sfc_oget_stereo_to_mono()
3343 struct tegra210_sfc *sfc = snd_soc_component_get_drvdata(cmpnt); in tegra210_sfc_oput_stereo_to_mono() local
3344 unsigned int value = ucontrol->value.enumerated.item[0]; in tegra210_sfc_oput_stereo_to_mono()
3346 if (value == sfc->stereo_to_mono[SFC_TX_PATH]) in tegra210_sfc_oput_stereo_to_mono()
3349 sfc->stereo_to_mono[SFC_TX_PATH] = value; in tegra210_sfc_oput_stereo_to_mono()
3358 struct tegra210_sfc *sfc = snd_soc_component_get_drvdata(cmpnt); in tegra210_sfc_oget_mono_to_stereo() local
3360 ucontrol->value.enumerated.item[0] = sfc->mono_to_stereo[SFC_TX_PATH]; in tegra210_sfc_oget_mono_to_stereo()
3369 struct tegra210_sfc *sfc = snd_soc_component_get_drvdata(cmpnt); in tegra210_sfc_oput_mono_to_stereo() local
3370 unsigned int value = ucontrol->value.enumerated.item[0]; in tegra210_sfc_oput_mono_to_stereo()
3372 if (value == sfc->mono_to_stereo[SFC_TX_PATH]) in tegra210_sfc_oput_mono_to_stereo()
3375 sfc->mono_to_stereo[SFC_TX_PATH] = value; in tegra210_sfc_oput_mono_to_stereo()
3391 .name = "SFC-RX-CIF",
3393 .stream_name = "RX-CIF-Playback",
3402 .stream_name = "RX-CIF-Capture",
3413 .name = "SFC-TX-CIF",
3415 .stream_name = "TX-CIF-Playback",
3424 .stream_name = "TX-CIF-Capture",
3444 { "RX XBAR-" sname, NULL, "XBAR-TX" }, \
3445 { "RX-CIF-" sname, NULL, "RX XBAR-" sname }, \
3446 { "RX", NULL, "RX-CIF-" sname }, \
3447 { "TX-CIF-" sname, NULL, "TX" }, \
3448 { "TX XBAR-" sname, NULL, "TX-CIF-" sname }, \
3449 { "XBAR-RX", NULL, "TX XBAR-" sname }
3572 { .compatible = "nvidia,tegra210-sfc" },
3579 struct device *dev = &pdev->dev; in tegra210_sfc_platform_probe()
3580 struct tegra210_sfc *sfc; in tegra210_sfc_platform_probe() local
3584 sfc = devm_kzalloc(dev, sizeof(*sfc), GFP_KERNEL); in tegra210_sfc_platform_probe()
3585 if (!sfc) in tegra210_sfc_platform_probe()
3586 return -ENOMEM; in tegra210_sfc_platform_probe()
3588 dev_set_drvdata(dev, sfc); in tegra210_sfc_platform_probe()
3594 sfc->regmap = devm_regmap_init_mmio(dev, regs, in tegra210_sfc_platform_probe()
3596 if (IS_ERR(sfc->regmap)) { in tegra210_sfc_platform_probe()
3598 return PTR_ERR(sfc->regmap); in tegra210_sfc_platform_probe()
3601 regcache_cache_only(sfc->regmap, true); in tegra210_sfc_platform_probe()
3607 dev_err(dev, "can't register SFC component, err: %d\n", err); in tegra210_sfc_platform_probe()
3611 pm_runtime_enable(&pdev->dev); in tegra210_sfc_platform_probe()
3618 pm_runtime_disable(&pdev->dev); in tegra210_sfc_platform_remove()
3630 .name = "tegra210-sfc",
3640 MODULE_DESCRIPTION("Tegra210 SFC ASoC driver");