diff options
Diffstat (limited to 'sound/soc/tegra/tegra186_asrc.c')
| -rw-r--r-- | sound/soc/tegra/tegra186_asrc.c | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/sound/soc/tegra/tegra186_asrc.c b/sound/soc/tegra/tegra186_asrc.c index 9f12faaa609d..2c0220e14a57 100644 --- a/sound/soc/tegra/tegra186_asrc.c +++ b/sound/soc/tegra/tegra186_asrc.c @@ -1,16 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-only +// SPDX-FileCopyrightText: Copyright (c) 2022-2025 NVIDIA CORPORATION. All rights reserved. // // tegra186_asrc.c - Tegra186 ASRC driver -// -// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. #include <linux/clk.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/io.h> +#include <linux/mod_devicetable.h> #include <linux/module.h> -#include <linux/of.h> -#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> @@ -77,7 +75,7 @@ static void tegra186_asrc_lock_stream(struct tegra186_asrc *asrc, 1); } -static int __maybe_unused tegra186_asrc_runtime_suspend(struct device *dev) +static int tegra186_asrc_runtime_suspend(struct device *dev) { struct tegra186_asrc *asrc = dev_get_drvdata(dev); @@ -87,7 +85,7 @@ static int __maybe_unused tegra186_asrc_runtime_suspend(struct device *dev) return 0; } -static int __maybe_unused tegra186_asrc_runtime_resume(struct device *dev) +static int tegra186_asrc_runtime_resume(struct device *dev) { struct tegra186_asrc *asrc = dev_get_drvdata(dev); int id; @@ -100,7 +98,7 @@ static int __maybe_unused tegra186_asrc_runtime_resume(struct device *dev) * sync is done after this to restore other settings. */ regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_SCRATCH_ADDR, - TEGRA186_ASRC_ARAM_START_ADDR); + asrc->soc_data->aram_start_addr); regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_ENB, TEGRA186_ASRC_GLOBAL_EN); @@ -243,7 +241,7 @@ static int tegra186_asrc_get_ratio_source(struct snd_kcontrol *kcontrol, { struct soc_enum *asrc_private = (struct soc_enum *)kcontrol->private_value; - struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol); struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt); unsigned int id = asrc_private->reg / TEGRA186_ASRC_STREAM_STRIDE; @@ -257,7 +255,7 @@ static int tegra186_asrc_put_ratio_source(struct snd_kcontrol *kcontrol, { struct soc_enum *asrc_private = (struct soc_enum *)kcontrol->private_value; - struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol); struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt); unsigned int id = asrc_private->reg / TEGRA186_ASRC_STREAM_STRIDE; bool change = false; @@ -277,7 +275,7 @@ static int tegra186_asrc_get_ratio_int(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *asrc_private = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol); struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt); unsigned int id = asrc_private->reg / TEGRA186_ASRC_STREAM_STRIDE; @@ -295,7 +293,7 @@ static int tegra186_asrc_put_ratio_int(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *asrc_private = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol); struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt); unsigned int id = asrc_private->reg / TEGRA186_ASRC_STREAM_STRIDE; bool change = false; @@ -325,7 +323,7 @@ static int tegra186_asrc_get_ratio_frac(struct snd_kcontrol *kcontrol, { struct soc_mreg_control *asrc_private = (struct soc_mreg_control *)kcontrol->private_value; - struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol); struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt); unsigned int id = asrc_private->regbase / TEGRA186_ASRC_STREAM_STRIDE; @@ -343,7 +341,7 @@ static int tegra186_asrc_put_ratio_frac(struct snd_kcontrol *kcontrol, { struct soc_mreg_control *asrc_private = (struct soc_mreg_control *)kcontrol->private_value; - struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol); struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt); unsigned int id = asrc_private->regbase / TEGRA186_ASRC_STREAM_STRIDE; bool change = false; @@ -373,7 +371,7 @@ static int tegra186_asrc_get_hwcomp_disable(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *asrc_private = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol); struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt); unsigned int id = asrc_private->reg / TEGRA186_ASRC_STREAM_STRIDE; @@ -387,7 +385,7 @@ static int tegra186_asrc_put_hwcomp_disable(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *asrc_private = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol); struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt); unsigned int id = asrc_private->reg / TEGRA186_ASRC_STREAM_STRIDE; int value = ucontrol->value.integer.value[0]; @@ -405,7 +403,7 @@ static int tegra186_asrc_get_input_threshold(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *asrc_private = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol); struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt); unsigned int id = asrc_private->reg / TEGRA186_ASRC_STREAM_STRIDE; @@ -419,7 +417,7 @@ static int tegra186_asrc_put_input_threshold(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *asrc_private = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol); struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt); unsigned int id = asrc_private->reg / TEGRA186_ASRC_STREAM_STRIDE; int value = (asrc->lane[id].input_thresh & ~(0x3)) | @@ -438,7 +436,7 @@ static int tegra186_asrc_get_output_threshold(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *asrc_private = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol); struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt); unsigned int id = asrc_private->reg / TEGRA186_ASRC_STREAM_STRIDE; @@ -452,7 +450,7 @@ static int tegra186_asrc_put_output_threshold(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *asrc_private = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol); struct tegra186_asrc *asrc = snd_soc_component_get_drvdata(cmpnt); unsigned int id = asrc_private->reg / TEGRA186_ASRC_STREAM_STRIDE; int value = (asrc->lane[id].output_thresh & ~(0x3)) | @@ -955,8 +953,17 @@ static const struct regmap_config tegra186_asrc_regmap_config = { .cache_type = REGCACHE_FLAT, }; +static const struct tegra_asrc_soc_data soc_data_tegra186 = { + .aram_start_addr = TEGRA186_ASRC_ARAM_START_ADDR, +}; + +static const struct tegra_asrc_soc_data soc_data_tegra264 = { + .aram_start_addr = TEGRA264_ASRC_ARAM_START_ADDR, +}; + static const struct of_device_id tegra186_asrc_of_match[] = { - { .compatible = "nvidia,tegra186-asrc" }, + { .compatible = "nvidia,tegra186-asrc", .data = &soc_data_tegra186 }, + { .compatible = "nvidia,tegra264-asrc", .data = &soc_data_tegra264 }, {}, }; MODULE_DEVICE_TABLE(of, tegra186_asrc_of_match); @@ -986,6 +993,8 @@ static int tegra186_asrc_platform_probe(struct platform_device *pdev) return PTR_ERR(asrc->regmap); } + asrc->soc_data = of_device_get_match_data(&pdev->dev); + regcache_cache_only(asrc->regmap, true); regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_CFG, @@ -1016,25 +1025,22 @@ static int tegra186_asrc_platform_probe(struct platform_device *pdev) return 0; } -static int tegra186_asrc_platform_remove(struct platform_device *pdev) +static void tegra186_asrc_platform_remove(struct platform_device *pdev) { pm_runtime_disable(&pdev->dev); - - return 0; } static const struct dev_pm_ops tegra186_asrc_pm_ops = { - SET_RUNTIME_PM_OPS(tegra186_asrc_runtime_suspend, - tegra186_asrc_runtime_resume, NULL) - SET_LATE_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) + RUNTIME_PM_OPS(tegra186_asrc_runtime_suspend, + tegra186_asrc_runtime_resume, NULL) + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) }; static struct platform_driver tegra186_asrc_driver = { .driver = { .name = "tegra186-asrc", .of_match_table = tegra186_asrc_of_match, - .pm = &tegra186_asrc_pm_ops, + .pm = pm_ptr(&tegra186_asrc_pm_ops), }, .probe = tegra186_asrc_platform_probe, .remove = tegra186_asrc_platform_remove, |
