ASoC: tegra-alt: remove devm_clk_put() APIs

Clock resource is associated with a device and when the device
is unbound, the resource is freed. Drivers get the clock handle
by using devm_clk_get(). No need for an explicit devm_clk_put()
to release the clock, this is handled automatically when the
device lifetime ends.

Bug 200346429

Change-Id: I0885723e3a9a3fb41e54524ddacc3415f571576c
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1574311
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
This commit is contained in:
Sameer Pujar
2017-10-06 16:00:52 +05:30
parent 93e212df79
commit d8cccfd903
10 changed files with 46 additions and 231 deletions

View File

@@ -77,10 +77,6 @@ struct tegra_asoc_audio_clock_info {
u32 clk_rates[MAX_NUM_RATES]; u32 clk_rates[MAX_NUM_RATES];
}; };
struct clk *tegra_alt_asoc_utils_get_clk(struct device *dev,
bool dev_id,
const char *clk_name);
void tegra_alt_asoc_utils_clk_put(struct device *dev, struct clk *clk);
int tegra_alt_asoc_utils_set_rate(struct tegra_asoc_audio_clock_info *data, int tegra_alt_asoc_utils_set_rate(struct tegra_asoc_audio_clock_info *data,
int srate, int srate,
int mclk, int mclk,
@@ -90,7 +86,6 @@ void tegra_alt_asoc_utils_lock_clk_rate(
int lock); int lock);
int tegra_alt_asoc_utils_init(struct tegra_asoc_audio_clock_info *data, int tegra_alt_asoc_utils_init(struct tegra_asoc_audio_clock_info *data,
struct device *dev, struct snd_soc_card *card); struct device *dev, struct snd_soc_card *card);
void tegra_alt_asoc_utils_fini(struct tegra_asoc_audio_clock_info *data);
int tegra_alt_asoc_utils_set_extern_parent( int tegra_alt_asoc_utils_set_extern_parent(
struct tegra_asoc_audio_clock_info *data, const char *parent); struct tegra_asoc_audio_clock_info *data, const char *parent);

View File

@@ -1258,7 +1258,7 @@ static int tegra_machine_driver_probe(struct platform_device *pdev)
if (ret) { if (ret) {
dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
ret); ret);
goto err_fini_utils; goto err_alloc_dai_link;
} }
rtd = snd_soc_get_pcm_runtime(card, "rt565x-playback"); rtd = snd_soc_get_pcm_runtime(card, "rt565x-playback");
@@ -1283,8 +1283,6 @@ static int tegra_machine_driver_probe(struct platform_device *pdev)
return 0; return 0;
err_fini_utils:
tegra_alt_asoc_utils_fini(&machine->audio_clock);
err_alloc_dai_link: err_alloc_dai_link:
tegra_machine_remove_dai_link(); tegra_machine_remove_dai_link();
tegra_machine_remove_codec_conf(); tegra_machine_remove_codec_conf();
@@ -1295,13 +1293,11 @@ err:
static int tegra_machine_driver_remove(struct platform_device *pdev) static int tegra_machine_driver_remove(struct platform_device *pdev)
{ {
struct snd_soc_card *card = platform_get_drvdata(pdev); struct snd_soc_card *card = platform_get_drvdata(pdev);
struct tegra_machine *machine = snd_soc_card_get_drvdata(card);
snd_soc_unregister_card(card); snd_soc_unregister_card(card);
tegra_machine_remove_dai_link(); tegra_machine_remove_dai_link();
tegra_machine_remove_codec_conf(); tegra_machine_remove_codec_conf();
tegra_alt_asoc_utils_fini(&machine->audio_clock);
return 0; return 0;
} }

View File

@@ -479,13 +479,13 @@ static int tegra186_dspk_platform_probe(struct platform_device *pdev)
if (IS_ERR_OR_NULL(dspk->clk_pll_a_out0)) { if (IS_ERR_OR_NULL(dspk->clk_pll_a_out0)) {
dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n"); dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n");
ret = -ENOENT; ret = -ENOENT;
goto err_clk_put; goto err;
} }
ret = clk_set_parent(dspk->clk_dspk, dspk->clk_pll_a_out0); ret = clk_set_parent(dspk->clk_dspk, dspk->clk_pll_a_out0);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Can't set parent of dspk clock\n"); dev_err(&pdev->dev, "Can't set parent of dspk clock\n");
goto err_plla_clk_put; goto err;
} }
} }
@@ -592,10 +592,6 @@ err_suspend:
tegra186_dspk_runtime_suspend(&pdev->dev); tegra186_dspk_runtime_suspend(&pdev->dev);
err_pm_disable: err_pm_disable:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err_plla_clk_put:
devm_clk_put(&pdev->dev, dspk->clk_pll_a_out0);
err_clk_put:
devm_clk_put(&pdev->dev, dspk->clk_dspk);
err: err:
return ret; return ret;
} }
@@ -618,9 +614,6 @@ static int tegra186_dspk_platform_remove(struct platform_device *pdev)
if (!pm_runtime_status_suspended(&pdev->dev)) if (!pm_runtime_status_suspended(&pdev->dev))
tegra186_dspk_runtime_suspend(&pdev->dev); tegra186_dspk_runtime_suspend(&pdev->dev);
devm_clk_put(&pdev->dev, dspk->clk_pll_a_out0);
devm_clk_put(&pdev->dev, dspk->clk_dspk);
return 0; return 0;
} }

View File

@@ -5147,39 +5147,13 @@ err_unregister_platform:
err_pm_disable: err_pm_disable:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err: err:
if (!adsp->soc_data->is_soc_t210)
if (!IS_ERR_OR_NULL(adsp->apb2ape_clk))
tegra_alt_asoc_utils_clk_put
(&pdev->dev, adsp->apb2ape_clk);
if (!IS_ERR_OR_NULL(adsp->ape_clk))
tegra_alt_asoc_utils_clk_put
(&pdev->dev, adsp->ape_clk);
if (!IS_ERR_OR_NULL(adsp->ahub_clk))
tegra_alt_asoc_utils_clk_put
(&pdev->dev, adsp->ahub_clk);
return ret; return ret;
} }
static int __maybe_unused tegra210_adsp_audio_platform_remove( static int __maybe_unused tegra210_adsp_audio_platform_remove(
struct platform_device *pdev) struct platform_device *pdev)
{ {
struct tegra210_adsp *adsp = dev_get_drvdata(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
if (!adsp->soc_data->is_soc_t210)
if (!IS_ERR_OR_NULL(adsp->apb2ape_clk))
tegra_alt_asoc_utils_clk_put
(&pdev->dev, adsp->apb2ape_clk);
if (!IS_ERR_OR_NULL(adsp->ape_clk))
tegra_alt_asoc_utils_clk_put
(&pdev->dev, adsp->ape_clk);
if (!IS_ERR_OR_NULL(adsp->ahub_clk))
tegra_alt_asoc_utils_clk_put
(&pdev->dev, adsp->ahub_clk);
tegra_pd_remove_device(&pdev->dev); tegra_pd_remove_device(&pdev->dev);
snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_platform(&pdev->dev);
return 0; return 0;

View File

@@ -569,13 +569,13 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev)
if (IS_ERR_OR_NULL(dmic->clk_pll_a_out0)) { if (IS_ERR_OR_NULL(dmic->clk_pll_a_out0)) {
dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n"); dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n");
ret = -ENOENT; ret = -ENOENT;
goto err_clk_put; goto err;
} }
ret = clk_set_parent(dmic->clk_dmic, dmic->clk_pll_a_out0); ret = clk_set_parent(dmic->clk_dmic, dmic->clk_pll_a_out0);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Can't set parent of dmic clock\n"); dev_err(&pdev->dev, "Can't set parent of dmic clock\n");
goto err_plla_clk_put; goto err;
} }
} }
@@ -583,7 +583,7 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev)
if (!mem) { if (!mem) {
dev_err(&pdev->dev, "No memory resource\n"); dev_err(&pdev->dev, "No memory resource\n");
ret = -ENODEV; ret = -ENODEV;
goto err_plla_clk_put; goto err;
} }
memregion = devm_request_mem_region(&pdev->dev, mem->start, memregion = devm_request_mem_region(&pdev->dev, mem->start,
@@ -591,14 +591,14 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev)
if (!memregion) { if (!memregion) {
dev_err(&pdev->dev, "Memory region already claimed\n"); dev_err(&pdev->dev, "Memory region already claimed\n");
ret = -EBUSY; ret = -EBUSY;
goto err_plla_clk_put; goto err;
} }
regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
if (!regs) { if (!regs) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err_plla_clk_put; goto err;
} }
dmic->regmap = devm_regmap_init_mmio(&pdev->dev, regs, dmic->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
@@ -606,7 +606,7 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev)
if (IS_ERR(dmic->regmap)) { if (IS_ERR(dmic->regmap)) {
dev_err(&pdev->dev, "regmap init failed\n"); dev_err(&pdev->dev, "regmap init failed\n");
ret = PTR_ERR(dmic->regmap); ret = PTR_ERR(dmic->regmap);
goto err_plla_clk_put; goto err;
} }
regcache_cache_only(dmic->regmap, true); regcache_cache_only(dmic->regmap, true);
@@ -619,7 +619,7 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev)
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Missing property nvidia,ahub-dmic-id\n"); "Missing property nvidia,ahub-dmic-id\n");
ret = -ENODEV; ret = -ENODEV;
goto err_plla_clk_put; goto err;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
@@ -686,11 +686,6 @@ err_suspend:
tegra210_dmic_runtime_suspend(&pdev->dev); tegra210_dmic_runtime_suspend(&pdev->dev);
err_pm_disable: err_pm_disable:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err_plla_clk_put:
devm_clk_put(&pdev->dev, dmic->clk_pll_a_out0);
err_clk_put:
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga()))
devm_clk_put(&pdev->dev, dmic->clk_dmic);
err: err:
return ret; return ret;
} }
@@ -713,8 +708,6 @@ static int tegra210_dmic_platform_remove(struct platform_device *pdev)
if (!pm_runtime_status_suspended(&pdev->dev)) if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_dmic_runtime_suspend(&pdev->dev); tegra210_dmic_runtime_suspend(&pdev->dev);
devm_clk_put(&pdev->dev, dmic->clk_pll_a_out0);
devm_clk_put(&pdev->dev, dmic->clk_dmic);
return 0; return 0;
} }

View File

@@ -1061,28 +1061,28 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
if (IS_ERR(i2s->clk_i2s_sync)) { if (IS_ERR(i2s->clk_i2s_sync)) {
dev_err(&pdev->dev, "Can't retrieve i2s_sync clock\n"); dev_err(&pdev->dev, "Can't retrieve i2s_sync clock\n");
ret = PTR_ERR(i2s->clk_i2s_sync); ret = PTR_ERR(i2s->clk_i2s_sync);
goto err_clk_put; goto err;
} }
i2s->clk_audio_sync = devm_clk_get(&pdev->dev, "audio_sync"); i2s->clk_audio_sync = devm_clk_get(&pdev->dev, "audio_sync");
if (IS_ERR(i2s->clk_audio_sync)) { if (IS_ERR(i2s->clk_audio_sync)) {
dev_err(&pdev->dev, "Can't retrieve audio sync clock\n"); dev_err(&pdev->dev, "Can't retrieve audio sync clock\n");
ret = PTR_ERR(i2s->clk_audio_sync); ret = PTR_ERR(i2s->clk_audio_sync);
goto err_i2s_sync_clk_put; goto err;
} }
i2s->clk_i2s_source = devm_clk_get(&pdev->dev, "pll_a_out0"); i2s->clk_i2s_source = devm_clk_get(&pdev->dev, "pll_a_out0");
if (IS_ERR(i2s->clk_i2s_source)) { if (IS_ERR(i2s->clk_i2s_source)) {
dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n"); dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n");
ret = PTR_ERR(i2s->clk_i2s_source); ret = PTR_ERR(i2s->clk_i2s_source);
goto err_audio_sync_clk_put; goto err;
} }
} }
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) { if (!mem) {
dev_err(&pdev->dev, "No memory resource\n"); dev_err(&pdev->dev, "No memory resource\n");
ret = -ENODEV; ret = -ENODEV;
goto err_pll_a_out0_clk_put; goto err;
} }
memregion = devm_request_mem_region(&pdev->dev, mem->start, memregion = devm_request_mem_region(&pdev->dev, mem->start,
@@ -1090,14 +1090,14 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
if (!memregion) { if (!memregion) {
dev_err(&pdev->dev, "Memory region already claimed\n"); dev_err(&pdev->dev, "Memory region already claimed\n");
ret = -EBUSY; ret = -EBUSY;
goto err_pll_a_out0_clk_put; goto err;
} }
regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
if (!regs) { if (!regs) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err_pll_a_out0_clk_put; goto err;
} }
i2s->regmap = devm_regmap_init_mmio(&pdev->dev, regs, i2s->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
@@ -1105,7 +1105,7 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
if (IS_ERR(i2s->regmap)) { if (IS_ERR(i2s->regmap)) {
dev_err(&pdev->dev, "regmap init failed\n"); dev_err(&pdev->dev, "regmap init failed\n");
ret = PTR_ERR(i2s->regmap); ret = PTR_ERR(i2s->regmap);
goto err_pll_a_out0_clk_put; goto err;
} }
i2s->slgc_notifier.notifier_call = _tegra210_i2s_slcg_notifier; i2s->slgc_notifier.notifier_call = _tegra210_i2s_slcg_notifier;
@@ -1120,7 +1120,7 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Missing property nvidia,ahub-i2s-id\n"); "Missing property nvidia,ahub-i2s-id\n");
ret = -ENODEV; ret = -ENODEV;
goto err_pll_a_out0_clk_put; goto err;
} }
if (of_property_read_u32(pdev->dev.of_node, if (of_property_read_u32(pdev->dev.of_node,
@@ -1152,7 +1152,7 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
sizeof(*i2s->supplies), GFP_KERNEL); sizeof(*i2s->supplies), GFP_KERNEL);
if (!i2s->supplies) { if (!i2s->supplies) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_pll_a_out0_clk_put; goto err;
} }
of_property_for_each_string(np, of_property_for_each_string(np,
"regulator-supplies", prop, supply) "regulator-supplies", prop, supply)
@@ -1219,15 +1219,6 @@ err_suspend:
tegra210_i2s_runtime_suspend(&pdev->dev); tegra210_i2s_runtime_suspend(&pdev->dev);
err_pm_disable: err_pm_disable:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err_pll_a_out0_clk_put:
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga()))
devm_clk_put(&pdev->dev, i2s->clk_i2s_source);
err_audio_sync_clk_put:
devm_clk_put(&pdev->dev, i2s->clk_audio_sync);
err_i2s_sync_clk_put:
devm_clk_put(&pdev->dev, i2s->clk_i2s_sync);
err_clk_put:
devm_clk_put(&pdev->dev, i2s->clk_i2s);
err: err:
return ret; return ret;
} }
@@ -1241,21 +1232,12 @@ static void tegra210_i2s_platform_shutdown(struct platform_device *pdev)
static int tegra210_i2s_platform_remove(struct platform_device *pdev) static int tegra210_i2s_platform_remove(struct platform_device *pdev)
{ {
struct tegra210_i2s *i2s = dev_get_drvdata(&pdev->dev);
snd_soc_unregister_codec(&pdev->dev); snd_soc_unregister_codec(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
if (!pm_runtime_status_suspended(&pdev->dev)) if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_i2s_runtime_suspend(&pdev->dev); tegra210_i2s_runtime_suspend(&pdev->dev);
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
devm_clk_put(&pdev->dev, i2s->clk_i2s);
devm_clk_put(&pdev->dev, i2s->clk_audio_sync);
devm_clk_put(&pdev->dev, i2s->clk_i2s_sync);
clk_put(i2s->clk_i2s_source);
}
return 0; return 0;
} }

View File

@@ -361,7 +361,7 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev)
if (!mem) { if (!mem) {
dev_err(&pdev->dev, "No memory resource\n"); dev_err(&pdev->dev, "No memory resource\n");
ret = -ENODEV; ret = -ENODEV;
goto err_clk_put; goto err;
} }
memregion = devm_request_mem_region(&pdev->dev, mem->start, memregion = devm_request_mem_region(&pdev->dev, mem->start,
@@ -369,14 +369,14 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev)
if (!memregion) { if (!memregion) {
dev_err(&pdev->dev, "Memory region already claimed\n"); dev_err(&pdev->dev, "Memory region already claimed\n");
ret = -EBUSY; ret = -EBUSY;
goto err_clk_put; goto err;
} }
regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
if (!regs) { if (!regs) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err_clk_put; goto err;
} }
iqc->regmap = devm_regmap_init_mmio(&pdev->dev, regs, iqc->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
@@ -384,7 +384,7 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev)
if (IS_ERR(iqc->regmap)) { if (IS_ERR(iqc->regmap)) {
dev_err(&pdev->dev, "regmap init failed\n"); dev_err(&pdev->dev, "regmap init failed\n");
ret = PTR_ERR(iqc->regmap); ret = PTR_ERR(iqc->regmap);
goto err_clk_put; goto err;
} }
regcache_cache_only(iqc->regmap, true); regcache_cache_only(iqc->regmap, true);
@@ -394,7 +394,7 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev)
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Missing property nvidia,ahub-iqc-id\n"); "Missing property nvidia,ahub-iqc-id\n");
ret = -ENODEV; ret = -ENODEV;
goto err_clk_put; goto err;
} }
if (of_property_read_u32(pdev->dev.of_node, if (of_property_read_u32(pdev->dev.of_node,
@@ -437,8 +437,6 @@ err_suspend:
tegra210_iqc_runtime_suspend(&pdev->dev); tegra210_iqc_runtime_suspend(&pdev->dev);
err_pm_disable: err_pm_disable:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err_clk_put:
devm_clk_put(&pdev->dev, iqc->clk_iqc);
err: err:
return ret; return ret;
} }
@@ -453,8 +451,6 @@ static int tegra210_iqc_platform_remove(struct platform_device *pdev)
if (!pm_runtime_status_suspended(&pdev->dev)) if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_iqc_runtime_suspend(&pdev->dev); tegra210_iqc_runtime_suspend(&pdev->dev);
devm_clk_put(&pdev->dev, iqc->clk_iqc);
return 0; return 0;
} }

View File

@@ -491,21 +491,21 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev)
if (IS_ERR(spdif->clk_pll_p_out0)) { if (IS_ERR(spdif->clk_pll_p_out0)) {
dev_err(&pdev->dev, "Can't retrieve pll_p_out0 clock\n"); dev_err(&pdev->dev, "Can't retrieve pll_p_out0 clock\n");
ret = PTR_ERR(spdif->clk_pll_p_out0); ret = PTR_ERR(spdif->clk_pll_p_out0);
goto err_spdif_plla_clk_put; goto err;
} }
spdif->clk_spdif_out = devm_clk_get(&pdev->dev, "spdif_out"); spdif->clk_spdif_out = devm_clk_get(&pdev->dev, "spdif_out");
if (IS_ERR(spdif->clk_spdif_out)) { if (IS_ERR(spdif->clk_spdif_out)) {
dev_err(&pdev->dev, "Can't retrieve spdif clock\n"); dev_err(&pdev->dev, "Can't retrieve spdif clock\n");
ret = PTR_ERR(spdif->clk_spdif_out); ret = PTR_ERR(spdif->clk_spdif_out);
goto err_spdif_pllp_clk_put; goto err;
} }
spdif->clk_spdif_in = devm_clk_get(&pdev->dev, "spdif_in"); spdif->clk_spdif_in = devm_clk_get(&pdev->dev, "spdif_in");
if (IS_ERR(spdif->clk_spdif_in)) { if (IS_ERR(spdif->clk_spdif_in)) {
dev_err(&pdev->dev, "Can't retrieve spdif clock\n"); dev_err(&pdev->dev, "Can't retrieve spdif clock\n");
ret = PTR_ERR(spdif->clk_spdif_in); ret = PTR_ERR(spdif->clk_spdif_in);
goto err_spdif_out_clk_put; goto err;
} }
} }
@@ -513,7 +513,7 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev)
if (!mem) { if (!mem) {
dev_err(&pdev->dev, "No memory resource\n"); dev_err(&pdev->dev, "No memory resource\n");
ret = -ENODEV; ret = -ENODEV;
goto err_spdif_in_clk_put; goto err;
} }
memregion = devm_request_mem_region(&pdev->dev, mem->start, memregion = devm_request_mem_region(&pdev->dev, mem->start,
@@ -521,14 +521,14 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev)
if (!memregion) { if (!memregion) {
dev_err(&pdev->dev, "Memory region already claimed\n"); dev_err(&pdev->dev, "Memory region already claimed\n");
ret = -EBUSY; ret = -EBUSY;
goto err_spdif_in_clk_put; goto err;
} }
regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
if (!regs) { if (!regs) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err_spdif_in_clk_put; goto err;
} }
spdif->regmap = devm_regmap_init_mmio(&pdev->dev, regs, spdif->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
@@ -536,7 +536,7 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev)
if (IS_ERR(spdif->regmap)) { if (IS_ERR(spdif->regmap)) {
dev_err(&pdev->dev, "regmap init failed\n"); dev_err(&pdev->dev, "regmap init failed\n");
ret = PTR_ERR(spdif->regmap); ret = PTR_ERR(spdif->regmap);
goto err_spdif_in_clk_put; goto err;
} }
regcache_cache_only(spdif->regmap, true); regcache_cache_only(spdif->regmap, true);
@@ -545,7 +545,7 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev)
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Missing property nvidia,ahub-spdif-id\n"); "Missing property nvidia,ahub-spdif-id\n");
ret = -ENODEV; ret = -ENODEV;
goto err_spdif_in_clk_put; goto err;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
@@ -613,18 +613,6 @@ err_suspend:
tegra210_spdif_runtime_suspend(&pdev->dev); tegra210_spdif_runtime_suspend(&pdev->dev);
err_pm_disable: err_pm_disable:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err_spdif_in_clk_put:
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga()))
devm_clk_put(&pdev->dev, spdif->clk_spdif_in);
err_spdif_out_clk_put:
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga()))
devm_clk_put(&pdev->dev, spdif->clk_spdif_out);
err_spdif_pllp_clk_put:
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga()))
devm_clk_put(&pdev->dev, spdif->clk_pll_p_out0);
err_spdif_plla_clk_put:
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga()))
devm_clk_put(&pdev->dev, spdif->clk_pll_a_out0);
err: err:
return ret; return ret;
} }
@@ -638,19 +626,12 @@ static void tegra210_spdif_platform_shutdown(struct platform_device *pdev)
static int tegra210_spdif_platform_remove(struct platform_device *pdev) static int tegra210_spdif_platform_remove(struct platform_device *pdev)
{ {
struct tegra210_spdif *spdif = dev_get_drvdata(&pdev->dev);
snd_soc_unregister_codec(&pdev->dev); snd_soc_unregister_codec(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
if (!pm_runtime_status_suspended(&pdev->dev)) if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_spdif_runtime_suspend(&pdev->dev); tegra210_spdif_runtime_suspend(&pdev->dev);
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
devm_clk_put(&pdev->dev, spdif->clk_spdif_out);
devm_clk_put(&pdev->dev, spdif->clk_spdif_in);
}
return 0; return 0;
} }

View File

@@ -328,11 +328,6 @@ int tegra_xbar_remove(struct platform_device *pdev)
tegra_pd_remove_device(&pdev->dev); tegra_pd_remove_device(&pdev->dev);
devm_clk_put(&pdev->dev, xbar->clk);
devm_clk_put(&pdev->dev, xbar->clk_parent);
devm_clk_put(&pdev->dev, xbar->clk_ape);
devm_clk_put(&pdev->dev, xbar->clk_apb2ape);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(tegra_xbar_remove); EXPORT_SYMBOL_GPL(tegra_xbar_remove);
@@ -378,21 +373,21 @@ int tegra_xbar_probe(struct platform_device *pdev,
if (IS_ERR(xbar->clk_parent)) { if (IS_ERR(xbar->clk_parent)) {
dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n"); dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n");
ret = PTR_ERR(xbar->clk_parent); ret = PTR_ERR(xbar->clk_parent);
goto err_clk_put; goto err;
} }
xbar->clk_apb2ape = devm_clk_get(&pdev->dev, "apb2ape"); xbar->clk_apb2ape = devm_clk_get(&pdev->dev, "apb2ape");
if (IS_ERR(xbar->clk_apb2ape)) { if (IS_ERR(xbar->clk_apb2ape)) {
dev_err(&pdev->dev, "Can't retrieve apb2ape clock\n"); dev_err(&pdev->dev, "Can't retrieve apb2ape clock\n");
ret = PTR_ERR(xbar->clk_apb2ape); ret = PTR_ERR(xbar->clk_apb2ape);
goto err_clk_put_parent; goto err;
} }
xbar->clk_ape = devm_clk_get(&pdev->dev, "xbar.ape"); xbar->clk_ape = devm_clk_get(&pdev->dev, "xbar.ape");
if (IS_ERR(xbar->clk_ape)) { if (IS_ERR(xbar->clk_ape)) {
dev_err(&pdev->dev, "Can't retrieve ape clock\n"); dev_err(&pdev->dev, "Can't retrieve ape clock\n");
ret = PTR_ERR(xbar->clk_ape); ret = PTR_ERR(xbar->clk_ape);
goto err_clk_put_apb2ape; goto err;
} }
} }
@@ -400,14 +395,14 @@ int tegra_xbar_probe(struct platform_device *pdev,
if (IS_ERR(parent_clk)) { if (IS_ERR(parent_clk)) {
dev_err(&pdev->dev, "Can't get parent clock for xbar\n"); dev_err(&pdev->dev, "Can't get parent clock for xbar\n");
ret = PTR_ERR(parent_clk); ret = PTR_ERR(parent_clk);
goto err_clk_put_ape; goto err;
} }
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
ret = clk_set_parent(xbar->clk, xbar->clk_parent); ret = clk_set_parent(xbar->clk, xbar->clk_parent);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Failed to set parent clock with pll_a_out0\n"); dev_err(&pdev->dev, "Failed to set parent clock with pll_a_out0\n");
goto err_clk_put_ape; goto err;
} }
} }
@@ -457,15 +452,6 @@ err_pm_disable:
tegra_pd_remove_device(&pdev->dev); tegra_pd_remove_device(&pdev->dev);
err_clk_set_parent: err_clk_set_parent:
clk_set_parent(xbar->clk, parent_clk); clk_set_parent(xbar->clk, parent_clk);
err_clk_put_ape:
devm_clk_put(&pdev->dev, xbar->clk_ape);
err_clk_put_apb2ape:
devm_clk_put(&pdev->dev, xbar->clk_apb2ape);
err_clk_put_parent:
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga()))
devm_clk_put(&pdev->dev, xbar->clk_parent);
err_clk_put:
devm_clk_put(&pdev->dev, xbar->clk);
err: err:
return ret; return ret;
} }

View File

@@ -41,24 +41,6 @@
static bool is_switch_registered; static bool is_switch_registered;
#endif #endif
struct clk *tegra_alt_asoc_utils_get_clk(struct device *dev,
bool dev_id,
const char *clk_name)
{
struct clk *clk;
clk = devm_clk_get(dev, clk_name);
return clk;
}
EXPORT_SYMBOL_GPL(tegra_alt_asoc_utils_get_clk);
void tegra_alt_asoc_utils_clk_put(struct device *dev, struct clk *clk)
{
devm_clk_put(dev, clk);
}
EXPORT_SYMBOL_GPL(tegra_alt_asoc_utils_clk_put);
int tegra_alt_asoc_utils_set_rate(struct tegra_asoc_audio_clock_info *data, int tegra_alt_asoc_utils_set_rate(struct tegra_asoc_audio_clock_info *data,
int srate, int srate,
int mclk, int mclk,
@@ -229,54 +211,40 @@ int tegra_alt_asoc_utils_init(struct tegra_asoc_audio_clock_info *data,
/* DT boot, but unknown SoC */ /* DT boot, but unknown SoC */
return -EINVAL; return -EINVAL;
/* pll_p_out1 is not used for ahub for T210,T186 */ data->clk_m = devm_clk_get(dev, "clk_m");
if (data->soc < TEGRA_ASOC_UTILS_SOC_TEGRA210) {
data->clk_pll_p_out1 = clk_get_sys(NULL, "pll_p_out1");
if (IS_ERR(data->clk_pll_p_out1)) {
dev_err(data->dev, "Can't retrieve clk pll_p_out1\n");
ret = PTR_ERR(data->clk_pll_p_out1);
goto err;
}
}
data->clk_m = tegra_alt_asoc_utils_get_clk(dev, false, "clk_m");
if (IS_ERR(data->clk_m)) { if (IS_ERR(data->clk_m)) {
dev_err(data->dev, "Can't retrieve clk clk_m\n"); dev_err(data->dev, "Can't retrieve clk clk_m\n");
ret = PTR_ERR(data->clk_m); ret = PTR_ERR(data->clk_m);
goto err; goto err;
} }
data->clk_pll_a = tegra_alt_asoc_utils_get_clk(dev, false, "pll_a"); data->clk_pll_a = devm_clk_get(dev, "pll_a");
if (IS_ERR(data->clk_pll_a)) { if (IS_ERR(data->clk_pll_a)) {
dev_err(data->dev, "Can't retrieve clk pll_a\n"); dev_err(data->dev, "Can't retrieve clk pll_a\n");
ret = PTR_ERR(data->clk_pll_a); ret = PTR_ERR(data->clk_pll_a);
goto err_put_pll_p_out1; goto err;
} }
data->clk_pll_a_out0 = tegra_alt_asoc_utils_get_clk(dev, false, data->clk_pll_a_out0 = devm_clk_get(dev, "pll_a_out0");
"pll_a_out0");
if (IS_ERR(data->clk_pll_a_out0)) { if (IS_ERR(data->clk_pll_a_out0)) {
dev_err(data->dev, "Can't retrieve clk pll_a_out0\n"); dev_err(data->dev, "Can't retrieve clk pll_a_out0\n");
ret = PTR_ERR(data->clk_pll_a_out0); ret = PTR_ERR(data->clk_pll_a_out0);
goto err_put_pll_a; goto err;
} }
data->clk_cdev1 = tegra_alt_asoc_utils_get_clk(dev, true, data->clk_cdev1 = devm_clk_get(dev, "extern1");
"extern1");
if (IS_ERR(data->clk_cdev1)) { if (IS_ERR(data->clk_cdev1)) {
dev_err(data->dev, "Can't retrieve clk cdev1\n"); dev_err(data->dev, "Can't retrieve clk cdev1\n");
ret = PTR_ERR(data->clk_cdev1); ret = PTR_ERR(data->clk_cdev1);
goto err_put_pll_a_out0; goto err;
} }
if (data->soc > TEGRA_ASOC_UTILS_SOC_TEGRA210) { if (data->soc > TEGRA_ASOC_UTILS_SOC_TEGRA210) {
data->clk_ahub = tegra_alt_asoc_utils_get_clk(dev, false, data->clk_ahub = devm_clk_get(dev, "ahub");
"ahub");
if (IS_ERR(data->clk_ahub)) { if (IS_ERR(data->clk_ahub)) {
dev_err(data->dev, "Can't retrieve clk ahub\n"); dev_err(data->dev, "Can't retrieve clk ahub\n");
ret = PTR_ERR(data->clk_ahub); ret = PTR_ERR(data->clk_ahub);
goto err_put_cdev1; goto err;
} }
#if defined(CONFIG_COMMON_CLK) #if defined(CONFIG_COMMON_CLK)
@@ -292,36 +260,8 @@ int tegra_alt_asoc_utils_init(struct tegra_asoc_audio_clock_info *data,
#endif #endif
} }
if (data->soc < TEGRA_ASOC_UTILS_SOC_TEGRA210) {
ret = tegra_alt_asoc_utils_set_rate(data, 48000,
256 * 48000, 256 * 48000);
if (ret)
goto err_put_ahub;
}
if (data->soc < TEGRA_ASOC_UTILS_SOC_TEGRA186) {
ret = clk_prepare_enable(data->clk_cdev1);
if (ret) {
dev_err(data->dev, "Can't enable clk cdev1/extern1");
goto err_put_ahub;
}
data->clk_cdev1_state = 1;
}
return 0; return 0;
err_put_ahub:
if (data->soc > TEGRA_ASOC_UTILS_SOC_TEGRA210)
tegra_alt_asoc_utils_clk_put(dev, data->clk_ahub);
err_put_cdev1:
tegra_alt_asoc_utils_clk_put(dev, data->clk_cdev1);
err_put_pll_a_out0:
tegra_alt_asoc_utils_clk_put(dev, data->clk_pll_a_out0);
err_put_pll_a:
tegra_alt_asoc_utils_clk_put(dev, data->clk_pll_a);
err_put_pll_p_out1:
if (data->soc < TEGRA_ASOC_UTILS_SOC_TEGRA210)
clk_put(data->clk_pll_p_out1);
err: err:
return ret; return ret;
} }
@@ -387,27 +327,6 @@ int tegra_alt_asoc_utils_set_extern_parent(
} }
EXPORT_SYMBOL_GPL(tegra_alt_asoc_utils_set_extern_parent); EXPORT_SYMBOL_GPL(tegra_alt_asoc_utils_set_extern_parent);
void tegra_alt_asoc_utils_fini(struct tegra_asoc_audio_clock_info *data)
{
if (data->clk_cdev1_state)
clk_disable_unprepare(data->clk_cdev1);
if (data->soc > TEGRA_ASOC_UTILS_SOC_TEGRA210)
if (!IS_ERR(data->clk_ahub))
tegra_alt_asoc_utils_clk_put(data->dev, data->clk_ahub);
if (!IS_ERR(data->clk_pll_a_out0))
tegra_alt_asoc_utils_clk_put(data->dev, data->clk_pll_a_out0);
if (!IS_ERR(data->clk_pll_a))
tegra_alt_asoc_utils_clk_put(data->dev, data->clk_pll_a);
if (data->soc < TEGRA_ASOC_UTILS_SOC_TEGRA210)
if (!IS_ERR(data->clk_pll_p_out1))
clk_put(data->clk_pll_p_out1);
}
EXPORT_SYMBOL_GPL(tegra_alt_asoc_utils_fini);
#ifdef CONFIG_SWITCH #ifdef CONFIG_SWITCH
int tegra_alt_asoc_switch_register(struct switch_dev *sdev) int tegra_alt_asoc_switch_register(struct switch_dev *sdev)
{ {