From patchwork Tue Mar 4 03:00:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 25637 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 48E4B20E1E for ; Tue, 4 Mar 2014 03:01:22 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id wo20sf22805425obc.2 for ; Mon, 03 Mar 2014 19:01:22 -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 :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=HcueFbG9AW90ZMgi1XynZ0GO7AviZOcCayRFi0iu/2o=; b=azIQeAZY0Pa21LBU03fN06AzYO9LpwzcLuT22cnDE9fL9aCY97WdEhakeFn2epcDsw rV472/IIU1wAjGqQgobtd/7aM+kZYHpQ+WxBBgc61m79mliytsVt1OBC9eCEtOXDBPJT Ati+9xZ9CVfnhg8d58rk0eZDuyf1fJuZAehGFJ/rLNcTD0g24hvHIKftE3AXLVPUWVKf bxQfXAl3nX1HZHTwNUdNRFkhbHN21dlu5qQZ2NN9PX5f0YJIo8HX9m5AKYV1VYm4wj2X fqcWLD91wHPQtUXLQwfAauAgLLFT8VpvGwYwvgaoHOTXMzQfYqEo1GgTtAMzAK/WEmlr G8hg== X-Gm-Message-State: ALoCoQmL1k1BxBXRZ75gosz8hFDACfgXmZmJnOGSIMmIiUvpDDpo2GWf/D7zpxTfpz0Gxp/emmJ/ X-Received: by 10.42.110.198 with SMTP id r6mr12625458icp.33.1393902082492; Mon, 03 Mar 2014 19:01:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.239 with SMTP id l102ls2490857qgd.5.gmail; Mon, 03 Mar 2014 19:01:22 -0800 (PST) X-Received: by 10.58.186.132 with SMTP id fk4mr19544725vec.9.1393902082347; Mon, 03 Mar 2014 19:01:22 -0800 (PST) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id xj4si3861670vec.56.2014.03.03.19.01.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Mar 2014 19:01:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.173 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.173; Received: by mail-ve0-f173.google.com with SMTP id oy12so2690529veb.32 for ; Mon, 03 Mar 2014 19:01:22 -0800 (PST) X-Received: by 10.58.190.99 with SMTP id gp3mr281350vec.32.1393902082262; Mon, 03 Mar 2014 19:01:22 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.130.193 with SMTP id u1csp97146vcs; Mon, 3 Mar 2014 19:01:21 -0800 (PST) X-Received: by 10.66.241.73 with SMTP id wg9mr3179387pac.69.1393902081354; Mon, 03 Mar 2014 19:01:21 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tt8si12553146pbc.160.2014.03.03.19.01.20; Mon, 03 Mar 2014 19:01:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756223AbaCDDBO (ORCPT + 26 others); Mon, 3 Mar 2014 22:01:14 -0500 Received: from mail-pb0-f47.google.com ([209.85.160.47]:62538 "EHLO mail-pb0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756179AbaCDDBL (ORCPT ); Mon, 3 Mar 2014 22:01:11 -0500 Received: by mail-pb0-f47.google.com with SMTP id up15so4562436pbc.6 for ; Mon, 03 Mar 2014 19:01:11 -0800 (PST) X-Received: by 10.66.155.7 with SMTP id vs7mr3287527pab.42.1393902071043; Mon, 03 Mar 2014 19:01:11 -0800 (PST) Received: from localhost (z88l218.static.ctm.net. [202.175.88.218]) by mx.google.com with ESMTPSA id my6sm41694989pbc.36.2014.03.03.19.01.02 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 03 Mar 2014 19:01:10 -0800 (PST) From: Viresh Kumar To: rjw@rjwysocki.net Cc: linaro-kernel@lists.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, jinchoi@broadcom.com, tianyu.lan@intel.com, sebastian.capella@linaro.org, jhbird.choi@samsung.com, Viresh Kumar Subject: [PATCH V6 Resend 5/5] cpufreq: Tegra: Use cpufreq_generic_suspend() Date: Tue, 4 Mar 2014 11:00:30 +0800 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.173 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 Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org 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. 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 e652c1b..bcfed77 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; } @@ -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)