Lines Matching +full:tegra210 +full:- +full:sfc
1 // SPDX-License-Identifier: GPL-2.0-only
2 // SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES.
5 // tegra210_sfc.c - Tegra210 SFC driver
23 #define UNSUPP_CONV ((void *)(-EOPNOTSUPP))
51 /* coeff RAM tables required for SFC */
3061 struct tegra210_sfc *sfc = dev_get_drvdata(dev); in tegra210_sfc_runtime_suspend() local
3063 regcache_cache_only(sfc->regmap, true); in tegra210_sfc_runtime_suspend()
3064 regcache_mark_dirty(sfc->regmap); in tegra210_sfc_runtime_suspend()
3071 struct tegra210_sfc *sfc = dev_get_drvdata(dev); in tegra210_sfc_runtime_resume() local
3073 regcache_cache_only(sfc->regmap, false); in tegra210_sfc_runtime_resume()
3074 regcache_sync(sfc->regmap); in tegra210_sfc_runtime_resume()
3095 struct tegra210_sfc *sfc = dev_get_drvdata(cmpnt->dev); in tegra210_sfc_write_coeff_ram() local
3099 if (sfc->srate_in == sfc->srate_out) in tegra210_sfc_write_coeff_ram()
3102 coeff_ram = coef_addr_table[sfc->srate_in][sfc->srate_out]; in tegra210_sfc_write_coeff_ram()
3104 dev_err(cmpnt->dev, in tegra210_sfc_write_coeff_ram()
3106 sfc->srate_in, sfc->srate_out); in tegra210_sfc_write_coeff_ram()
3111 tegra210_sfc_write_ram(sfc->regmap, coeff_ram); in tegra210_sfc_write_coeff_ram()
3113 regmap_update_bits(sfc->regmap, in tegra210_sfc_write_coeff_ram()
3121 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",
3403 .stream_name = "RX-CIF-Capture",
3415 .name = "SFC-TX-CIF",
3417 .stream_name = "TX-CIF-Playback",
3427 .stream_name = "TX-CIF-Capture",
3448 { "RX XBAR-" sname, NULL, "XBAR-TX" }, \
3449 { "RX-CIF-" sname, NULL, "RX XBAR-" sname }, \
3450 { "RX", NULL, "RX-CIF-" sname }, \
3451 { "TX-CIF-" sname, NULL, "TX" }, \
3452 { "TX XBAR-" sname, NULL, "TX-CIF-" sname }, \
3453 { "XBAR-RX", NULL, "TX XBAR-" sname }
3576 { .compatible = "nvidia,tegra210-sfc" },
3583 struct device *dev = &pdev->dev; in tegra210_sfc_platform_probe()
3584 struct tegra210_sfc *sfc; in tegra210_sfc_platform_probe() local
3588 sfc = devm_kzalloc(dev, sizeof(*sfc), GFP_KERNEL); in tegra210_sfc_platform_probe()
3589 if (!sfc) in tegra210_sfc_platform_probe()
3590 return -ENOMEM; in tegra210_sfc_platform_probe()
3592 dev_set_drvdata(dev, sfc); in tegra210_sfc_platform_probe()
3598 sfc->regmap = devm_regmap_init_mmio(dev, regs, in tegra210_sfc_platform_probe()
3600 if (IS_ERR(sfc->regmap)) { in tegra210_sfc_platform_probe()
3602 return PTR_ERR(sfc->regmap); in tegra210_sfc_platform_probe()
3605 regcache_cache_only(sfc->regmap, true); in tegra210_sfc_platform_probe()
3611 dev_err(dev, "can't register SFC component, err: %d\n", err); in tegra210_sfc_platform_probe()
3615 pm_runtime_enable(&pdev->dev); in tegra210_sfc_platform_probe()
3622 pm_runtime_disable(&pdev->dev); in tegra210_sfc_platform_remove()
3634 .name = "tegra210-sfc",
3644 MODULE_DESCRIPTION("Tegra210 SFC ASoC driver");