lkml.org 
[lkml]   [2014]   [Feb]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH V5 7/7] cpufreq: Tegra: Use cpufreq_generic_suspend()
    Date
    Currently we have implemented PM notifiers to disable/enable ->target() routines
    functionality during suspend/resume.

    Now we have support present in cpufreq core, lets use it.

    Tested-by: Stephen Warren <swarren@nvidia.com>
    Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
    ---
    drivers/cpufreq/tegra-cpufreq.c | 46 +++++------------------------------------
    1 file changed, 5 insertions(+), 41 deletions(-)

    diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
    index e652c1b..bcfed77 100644
    --- a/drivers/cpufreq/tegra-cpufreq.c
    +++ b/drivers/cpufreq/tegra-cpufreq.c
    @@ -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 },
    @@ -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;
    @@ -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;
    @@ -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;
    }

    @@ -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)
    --
    1.7.12.rc2.18.g61b472e


    \
     
     \ /
      Last update: 2014-02-13 10:41    [W:4.162 / U:0.300 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site