From patchwork Mon Dec 2 05:52:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21917 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D791020DB9 for ; Mon, 2 Dec 2013 05:53:05 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id o15sf10187065qap.10 for ; Sun, 01 Dec 2013 21:53:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=B3eioVkypJA7CrZmVBmnh4hgKQWOxCGkwz2hFa8kPpw=; b=h4KmITwIIV3yFKGK1BrWJ5DDUa0Uv9nv14S5lOWK0pqokyvGYWZQZqXIUUCNJ8CWe+ dgrPk09T3asriA+ky+uwgdhqZ4yw1dUQG+soLquCvrb3miBrvVYmDl4uLmMhgtpQG+Gm B4dhmEXqpZbkUvMmMcswq5aOq1t3sLzX7Yua6BlCIsrVseLFvLpLKVC/1TXzfkZNbAoE eqtkl7NrKQNP81TBmNp9LV89pFBLZevgoOFoHCwQQVZrKKsJ0N/rEgt7fZEBlslgjTjQ 2OWoocyXJbeppcqfG+LQhHidf7ig8H+gRN1E/9HUMwXy6hZghn9aGcOQfifEKWNcxqch pQrw== X-Gm-Message-State: ALoCoQkRr5Xxi9piTk3cIzt7Ds9bkhBY1HziUBQ5DVQdvIMm55nXQ/Nkm3HRJtMaekNMwzmoZg8l X-Received: by 10.236.4.69 with SMTP id 45mr30986613yhi.20.1385963585735; Sun, 01 Dec 2013 21:53:05 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.110.198 with SMTP id ic6ls4676704qeb.29.gmail; Sun, 01 Dec 2013 21:53:05 -0800 (PST) X-Received: by 10.221.64.17 with SMTP id xg17mr51312144vcb.5.1385963585648; Sun, 01 Dec 2013 21:53:05 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id td8si28962830vdc.79.2013.12.01.21.53.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:53:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so8638601veb.30 for ; Sun, 01 Dec 2013 21:53:05 -0800 (PST) X-Received: by 10.58.254.200 with SMTP id ak8mr51746949ved.12.1385963585560; Sun, 01 Dec 2013 21:53:05 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp92664vcz; Sun, 1 Dec 2013 21:53:05 -0800 (PST) X-Received: by 10.224.167.15 with SMTP id o15mr45204927qay.96.1385963585167; Sun, 01 Dec 2013 21:53:05 -0800 (PST) Received: from mail-qe0-f51.google.com (mail-qe0-f51.google.com [209.85.128.51]) by mx.google.com with ESMTPS id f9si23845906qca.35.2013.12.01.21.53.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:53:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.51 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.128.51; Received: by mail-qe0-f51.google.com with SMTP id 1so10514527qee.24 for ; Sun, 01 Dec 2013 21:53:05 -0800 (PST) X-Received: by 10.229.140.129 with SMTP id i1mr71788973qcu.13.1385963585038; Sun, 01 Dec 2013 21:53:05 -0800 (PST) Received: from localhost (git.linaro.org. [54.235.93.228]) by mx.google.com with ESMTPSA id hb2sm20862063qeb.6.2013.12.01.21.53.03 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:53:04 -0800 (PST) From: Viresh Kumar To: rjw@rjwysocki.net Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, nm@ti.com, swarren@wwwdotorg.org, kgene.kim@samsung.com, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, tianyu.lan@intel.com, jhbird.choi@samsung.com, Viresh Kumar Subject: [PATCH V4 6/6] cpufreq: Tegra: Use cpufreq_generic_suspend() Date: Mon, 2 Dec 2013 11:22:36 +0530 Message-Id: <3880db2c7dd85ec91339118b3279c57cbe7e1c0d.1385962528.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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. Acked-and-tested-by: Stephen Warren Signed-off-by: Viresh Kumar --- 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 360d1a7..9e4f0a2b 100644 --- a/drivers/cpufreq/tegra-cpufreq.c +++ b/drivers/cpufreq/tegra-cpufreq.c @@ -26,7 +26,6 @@ #include #include #include -#include 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; } @@ -189,6 +150,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)