Skip to content

Commit

Permalink
cpufreq: Tegra: Use cpufreq_generic_suspend()
Browse files Browse the repository at this point in the history
The cpufreq core now supports suspending and resuming of cpufreq
drivers and governors during systems suspend and resume, so use
the common infrastructure instead of defining special PM notifiers
for the same thing.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Stephen Warren <swarren@nvidia.com>
[rjw: Changelog]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Viresh Kumar authored and Rafael J. Wysocki committed Mar 6, 2014
1 parent 59625ba commit d351cb3
Showing 1 changed file with 5 additions and 41 deletions.
46 changes: 5 additions & 41 deletions drivers/cpufreq/tegra-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/suspend.h>

static struct cpufreq_frequency_table freq_table[] = {
{ .frequency = 216000 },
Expand All @@ -47,9 +46,6 @@ static struct clk *pll_x_clk;
static struct clk *pll_p_clk;
static struct clk *emc_clk;

static DEFINE_MUTEX(tegra_cpu_lock);
static bool is_suspended;

static int tegra_cpu_clk_set_rate(unsigned long rate)
{
int ret;
Expand Down Expand Up @@ -112,42 +108,9 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy,

static int tegra_target(struct cpufreq_policy *policy, unsigned int index)
{
int ret = -EBUSY;

mutex_lock(&tegra_cpu_lock);

if (!is_suspended)
ret = tegra_update_cpu_speed(policy,
freq_table[index].frequency);

mutex_unlock(&tegra_cpu_lock);
return ret;
return tegra_update_cpu_speed(policy, freq_table[index].frequency);
}

static int tegra_pm_notify(struct notifier_block *nb, unsigned long event,
void *dummy)
{
mutex_lock(&tegra_cpu_lock);
if (event == PM_SUSPEND_PREPARE) {
struct cpufreq_policy *policy = cpufreq_cpu_get(0);
is_suspended = true;
pr_info("Tegra cpufreq suspend: setting frequency to %d kHz\n",
freq_table[0].frequency);
if (clk_get_rate(cpu_clk) / 1000 != freq_table[0].frequency)
tegra_update_cpu_speed(policy, freq_table[0].frequency);
cpufreq_cpu_put(policy);
} else if (event == PM_POST_SUSPEND) {
is_suspended = false;
}
mutex_unlock(&tegra_cpu_lock);

return NOTIFY_OK;
}

static struct notifier_block tegra_cpu_pm_notifier = {
.notifier_call = tegra_pm_notify,
};

static int tegra_cpu_init(struct cpufreq_policy *policy)
{
int ret;
Expand All @@ -166,10 +129,8 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
return ret;
}

if (policy->cpu == 0)
register_pm_notifier(&tegra_cpu_pm_notifier);

policy->clk = cpu_clk;
policy->suspend_freq = freq_table[0].frequency;
return 0;
}

Expand All @@ -190,6 +151,9 @@ static struct cpufreq_driver tegra_cpufreq_driver = {
.exit = tegra_cpu_exit,
.name = "tegra",
.attr = cpufreq_generic_attr,
#ifdef CONFIG_PM
.suspend = cpufreq_generic_suspend,
#endif
};

static int __init tegra_cpufreq_init(void)
Expand Down

0 comments on commit d351cb3

Please sign in to comment.