From patchwork Mon Feb 17 09:25:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 24754 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0DEB3202B2 for ; Mon, 17 Feb 2014 09:26:55 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id w8sf28490754qac.4 for ; Mon, 17 Feb 2014 01:26:55 -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=ksYodEZ04dq02+IPuXwIwBHaCPnxXJe4czTNtZU4gVE3CG5z1etZIGyoQFB34+7FXP JJoROq8m44zEa0SzqWu6K1KdbwlsyO1FBLveYvY/834O80xre5zJPFSYU8tstDa2n1x+ N8kw8I7vfcPWhi2fCCheooPN6G2a0Gp/0e0+BRNFvgj11+Vg/0/mVVM6onhPS8oGm0E8 YV9qs0jQxSxmkExLrxVZeNb754FY3EevjXBBoUHTwg+RB4feYXNUcKtJ2xLZVUIGLLE9 uP6P+s2E0Fb0o3AuVC6lEH4Ig29P5Yk3uz3TI3jEnUpWT9NpT3HodnaYcWr3zLKRpAsl 0Wwg== X-Gm-Message-State: ALoCoQk+LLlvBvIi4BUBJQXDGwyyno8ZOgv0EVLhEPmWLcXaz5UaUb5ZCdzOV3s6/XamkUiRF1DB X-Received: by 10.52.187.41 with SMTP id fp9mr8588616vdc.5.1392629215211; Mon, 17 Feb 2014 01:26:55 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.90.80 with SMTP id w74ls854434qgd.95.gmail; Mon, 17 Feb 2014 01:26:55 -0800 (PST) X-Received: by 10.220.250.203 with SMTP id mp11mr16161599vcb.2.1392629215072; Mon, 17 Feb 2014 01:26:55 -0800 (PST) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id si7si4345728vdc.37.2014.02.17.01.26.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 01:26:55 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.174 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.174; Received: by mail-ve0-f174.google.com with SMTP id pa12so11688678veb.19 for ; Mon, 17 Feb 2014 01:26:55 -0800 (PST) X-Received: by 10.52.164.39 with SMTP id yn7mr10483998vdb.25.1392629215002; Mon, 17 Feb 2014 01:26:55 -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.174.196 with SMTP id u4csp123687vcz; Mon, 17 Feb 2014 01:26:54 -0800 (PST) X-Received: by 10.66.180.200 with SMTP id dq8mr25504047pac.104.1392629214059; Mon, 17 Feb 2014 01:26:54 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kr1si763361pbc.205.2014.02.17.01.26.53; Mon, 17 Feb 2014 01:26:53 -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 S1753058AbaBQJ0o (ORCPT + 27 others); Mon, 17 Feb 2014 04:26:44 -0500 Received: from mail-wi0-f180.google.com ([209.85.212.180]:50061 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752945AbaBQJ0J (ORCPT ); Mon, 17 Feb 2014 04:26:09 -0500 Received: by mail-wi0-f180.google.com with SMTP id hm4so2154064wib.1 for ; Mon, 17 Feb 2014 01:26:08 -0800 (PST) X-Received: by 10.180.106.40 with SMTP id gr8mr11847774wib.31.1392629167830; Mon, 17 Feb 2014 01:26:07 -0800 (PST) Received: from localhost ([213.122.173.131]) by mx.google.com with ESMTPSA id ha1sm35238655wjc.23.2014.02.17.01.26.03 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 17 Feb 2014 01:26:07 -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 7/7] cpufreq: Tegra: Use cpufreq_generic_suspend() Date: Mon, 17 Feb 2014 14:55:13 +0530 Message-Id: <8eb6b1be23d978dbaccb43d33c8c2665ee2e941c.1392629003.git.viresh.kumar@linaro.org> 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.174 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)