From 110147c8c5136e1768a382da8896cf7f8b518982 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 13 May 2013 13:26:12 -0600 Subject: ASoC: tegra: always use clk_get() in utility code Now that all of the Tegra device trees have been updated to represent the required audio clocks, remove the compatibility code from the Tegra ASoC utility code, and always use clk_get() rather than clk_get_sys(). Signed-off-by: Stephen Warren Signed-off-by: Mark Brown --- sound/soc/tegra/tegra_asoc_utils.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'sound/soc/tegra') diff --git a/sound/soc/tegra/tegra_asoc_utils.c b/sound/soc/tegra/tegra_asoc_utils.c index 24fb001be7f..d173880f290 100644 --- a/sound/soc/tegra/tegra_asoc_utils.c +++ b/sound/soc/tegra/tegra_asoc_utils.c @@ -173,7 +173,6 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, struct device *dev) { int ret; - bool new_clocks = false; data->dev = dev; @@ -181,40 +180,28 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA20; else if (of_machine_is_compatible("nvidia,tegra30")) data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA30; - else if (of_machine_is_compatible("nvidia,tegra114")) { + else if (of_machine_is_compatible("nvidia,tegra114")) data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA114; - new_clocks = true; - } else { + else { dev_err(data->dev, "SoC unknown to Tegra ASoC utils\n"); return -EINVAL; } - if (new_clocks) - data->clk_pll_a = clk_get(dev, "pll_a"); - else - data->clk_pll_a = clk_get_sys(NULL, "pll_a"); + data->clk_pll_a = clk_get(dev, "pll_a"); if (IS_ERR(data->clk_pll_a)) { dev_err(data->dev, "Can't retrieve clk pll_a\n"); ret = PTR_ERR(data->clk_pll_a); goto err; } - if (new_clocks) - data->clk_pll_a_out0 = clk_get(dev, "pll_a_out0"); - else - data->clk_pll_a_out0 = clk_get_sys(NULL, "pll_a_out0"); + data->clk_pll_a_out0 = clk_get(dev, "pll_a_out0"); if (IS_ERR(data->clk_pll_a_out0)) { dev_err(data->dev, "Can't retrieve clk pll_a_out0\n"); ret = PTR_ERR(data->clk_pll_a_out0); goto err_put_pll_a; } - if (new_clocks) - data->clk_cdev1 = clk_get(dev, "mclk"); - else if (data->soc == TEGRA_ASOC_UTILS_SOC_TEGRA20) - data->clk_cdev1 = clk_get_sys(NULL, "cdev1"); - else - data->clk_cdev1 = clk_get_sys("extern1", NULL); + data->clk_cdev1 = clk_get(dev, "mclk"); if (IS_ERR(data->clk_cdev1)) { dev_err(data->dev, "Can't retrieve clk cdev1\n"); ret = PTR_ERR(data->clk_cdev1); -- cgit v1.2.3-70-g09d2 From 2f41a3f48a1400234a4213851453dcb4274322f5 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 3 Jun 2013 11:37:41 -0600 Subject: ASoC: tegra: implement suspend/resume for Tegra30 AHUB Add tegra30_ahub_{suspend,resume}. These use regcache functions to restore all HW registers after power loss during a suspend/resume cycle. Signed-off-by: Stephen Warren Signed-off-by: Mark Brown --- sound/soc/tegra/tegra30_ahub.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'sound/soc/tegra') diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c index 23e592f453f..0f4787c24e4 100644 --- a/sound/soc/tegra/tegra30_ahub.c +++ b/sound/soc/tegra/tegra30_ahub.c @@ -627,9 +627,30 @@ static int tegra30_ahub_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int tegra30_ahub_suspend(struct device *dev) +{ + regcache_mark_dirty(ahub->regmap_ahub); + regcache_mark_dirty(ahub->regmap_apbif); + + return 0; +} + +static int tegra30_ahub_resume(struct device *dev) +{ + int ret; + + ret = regcache_sync(ahub->regmap_ahub); + ret |= regcache_sync(ahub->regmap_apbif); + + return ret; +} +#endif + static const struct dev_pm_ops tegra30_ahub_pm_ops = { SET_RUNTIME_PM_OPS(tegra30_ahub_runtime_suspend, tegra30_ahub_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(tegra30_ahub_suspend, tegra30_ahub_resume) }; static struct platform_driver tegra30_ahub_driver = { -- cgit v1.2.3-70-g09d2 From 5c5b08286fa4d782e44cae8738cf4328a29c4326 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 3 Jun 2013 11:37:42 -0600 Subject: ASoC: tegra: implement suspend/resume for Tegra30 I2S Add tegra30_i2s_{suspend,resume}. These use regcache functions to restore all HW registers after power loss during a suspend/resume cycle. Signed-off-by: Stephen Warren Signed-off-by: Mark Brown --- sound/soc/tegra/tegra30_i2s.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sound/soc/tegra') diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c index 31d092d83c7..bd0ebc09c8b 100644 --- a/sound/soc/tegra/tegra30_i2s.c +++ b/sound/soc/tegra/tegra30_i2s.c @@ -514,6 +514,24 @@ static int tegra30_i2s_platform_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int tegra30_i2s_suspend(struct device *dev) +{ + struct tegra30_i2s *i2s = dev_get_drvdata(dev); + + regcache_mark_dirty(i2s->regmap); + + return 0; +} + +static int tegra30_i2s_resume(struct device *dev) +{ + struct tegra30_i2s *i2s = dev_get_drvdata(dev); + + return regcache_sync(i2s->regmap); +} +#endif + static const struct of_device_id tegra30_i2s_of_match[] = { { .compatible = "nvidia,tegra30-i2s", }, {}, @@ -522,6 +540,7 @@ static const struct of_device_id tegra30_i2s_of_match[] = { static const struct dev_pm_ops tegra30_i2s_pm_ops = { SET_RUNTIME_PM_OPS(tegra30_i2s_runtime_suspend, tegra30_i2s_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(tegra30_i2s_suspend, tegra30_i2s_resume) }; static struct platform_driver tegra30_i2s_driver = { -- cgit v1.2.3-70-g09d2 From 249e66c32679a24706ec182256a79bf7b1dac9a2 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Tue, 4 Jun 2013 12:58:14 -0600 Subject: ASoC: tegra: add runtime PM to resume functions Tegra HW needs clocks etc. active when touching registers. Make sure they are active during resume, by calling pm_runtime_get_sync() before touching HW. Signed-off-by: Stephen Warren Signed-off-by: Mark Brown --- sound/soc/tegra/tegra30_ahub.c | 4 ++++ sound/soc/tegra/tegra30_i2s.c | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'sound/soc/tegra') diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c index 0f4787c24e4..d554d46d08b 100644 --- a/sound/soc/tegra/tegra30_ahub.c +++ b/sound/soc/tegra/tegra30_ahub.c @@ -640,8 +640,12 @@ static int tegra30_ahub_resume(struct device *dev) { int ret; + ret = pm_runtime_get_sync(dev); + if (ret < 0) + return ret; ret = regcache_sync(ahub->regmap_ahub); ret |= regcache_sync(ahub->regmap_apbif); + pm_runtime_put(dev); return ret; } diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c index bd0ebc09c8b..d04146cad61 100644 --- a/sound/soc/tegra/tegra30_i2s.c +++ b/sound/soc/tegra/tegra30_i2s.c @@ -527,8 +527,15 @@ static int tegra30_i2s_suspend(struct device *dev) static int tegra30_i2s_resume(struct device *dev) { struct tegra30_i2s *i2s = dev_get_drvdata(dev); + int ret; - return regcache_sync(i2s->regmap); + ret = pm_runtime_get_sync(dev); + if (ret < 0) + return ret; + ret = regcache_sync(i2s->regmap); + pm_runtime_put(dev); + + return ret; } #endif -- cgit v1.2.3-70-g09d2