Skip to content

Commit c25f318

Browse files
committed
Merge tag 'tegra-for-5.5-cpufreq' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux into arm/fixes
cpufreq: tegra: Changes for v5.5-rc1 Implements support for suspend/resume on Tegra124. * tag 'tegra-for-5.5-cpufreq' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux: cpufreq: tegra124: Add suspend and resume support Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Olof Johansson <[email protected]>
2 parents f7a1a1d + 0fb438e commit c25f318

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

drivers/cpufreq/tegra124-cpufreq.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
77

88
#include <linux/clk.h>
9+
#include <linux/cpufreq.h>
910
#include <linux/err.h>
1011
#include <linux/init.h>
1112
#include <linux/kernel.h>
@@ -128,8 +129,66 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)
128129
return ret;
129130
}
130131

132+
static int __maybe_unused tegra124_cpufreq_suspend(struct device *dev)
133+
{
134+
struct tegra124_cpufreq_priv *priv = dev_get_drvdata(dev);
135+
int err;
136+
137+
/*
138+
* PLLP rate 408Mhz is below the CPU Fmax at Vmin and is safe to
139+
* use during suspend and resume. So, switch the CPU clock source
140+
* to PLLP and disable DFLL.
141+
*/
142+
err = clk_set_parent(priv->cpu_clk, priv->pllp_clk);
143+
if (err < 0) {
144+
dev_err(dev, "failed to reparent to PLLP: %d\n", err);
145+
return err;
146+
}
147+
148+
clk_disable_unprepare(priv->dfll_clk);
149+
150+
return 0;
151+
}
152+
153+
static int __maybe_unused tegra124_cpufreq_resume(struct device *dev)
154+
{
155+
struct tegra124_cpufreq_priv *priv = dev_get_drvdata(dev);
156+
int err;
157+
158+
/*
159+
* Warmboot code powers up the CPU with PLLP clock source.
160+
* Enable DFLL clock and switch CPU clock source back to DFLL.
161+
*/
162+
err = clk_prepare_enable(priv->dfll_clk);
163+
if (err < 0) {
164+
dev_err(dev, "failed to enable DFLL clock for CPU: %d\n", err);
165+
goto disable_cpufreq;
166+
}
167+
168+
err = clk_set_parent(priv->cpu_clk, priv->dfll_clk);
169+
if (err < 0) {
170+
dev_err(dev, "failed to reparent to DFLL clock: %d\n", err);
171+
goto disable_dfll;
172+
}
173+
174+
return 0;
175+
176+
disable_dfll:
177+
clk_disable_unprepare(priv->dfll_clk);
178+
disable_cpufreq:
179+
disable_cpufreq();
180+
181+
return err;
182+
}
183+
184+
static const struct dev_pm_ops tegra124_cpufreq_pm_ops = {
185+
SET_SYSTEM_SLEEP_PM_OPS(tegra124_cpufreq_suspend,
186+
tegra124_cpufreq_resume)
187+
};
188+
131189
static struct platform_driver tegra124_cpufreq_platdrv = {
132190
.driver.name = "cpufreq-tegra124",
191+
.driver.pm = &tegra124_cpufreq_pm_ops,
133192
.probe = tegra124_cpufreq_probe,
134193
};
135194

0 commit comments

Comments
 (0)