From patchwork Mon Dec 2 05:52:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21914 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DF09F20DB9 for ; Mon, 2 Dec 2013 05:52:53 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id o6sf41344558oag.3 for ; Sun, 01 Dec 2013 21:52:53 -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=+V39iaSfQKAbEqc++op/OExLevHiW9hw+vmBt7eA1qo=; b=D27TKQp2B+nY07FMFJ4oX/gpsHSgpS+4/HyH25x7OMmjqXQU2DFSVGMyBUf0/4qMPs BBES+1OiQ5W0C4GW3LB2Wvpn1XFaIoAHZvc66hrsvO3P8A6Wg13AFu0F60qYATTNxxoj vrNYwhMKM3HC0bGR+l5HfymgsXdqjIxSgPaU4otMQir+Mo09qWLlsw2P3WBR2sNYEqRu jLFwiWGDxFEtN1AEIuHbs9XdTXLwOxL7qUsagnzLpbS0JcVIESmoKOQN4djc/Pr95ocY SOZ6mUXlDzooIjSbqFRBnqI5B/D1wUSeopq9RC5CPwM2sT/WUSY8JT6Vp7UyudliwX2U L+Ww== X-Gm-Message-State: ALoCoQm4+SZgvRCDE+ix2SB7nk3Mhl7ra09qt+L/ZLXSQn3sM3ERbFDzcuEABFZqbSgaBJMi3huQ X-Received: by 10.43.78.135 with SMTP id zm7mr117717icb.27.1385963573518; Sun, 01 Dec 2013 21:52:53 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.104.76 with SMTP id gc12ls2854322qeb.44.gmail; Sun, 01 Dec 2013 21:52:53 -0800 (PST) X-Received: by 10.221.51.206 with SMTP id vj14mr51744677vcb.17.1385963573427; Sun, 01 Dec 2013 21:52:53 -0800 (PST) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id x1si493953vdo.16.2013.12.01.21.52.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:52:53 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.169 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.169; Received: by mail-ve0-f169.google.com with SMTP id c14so8464009vea.14 for ; Sun, 01 Dec 2013 21:52:53 -0800 (PST) X-Received: by 10.220.49.8 with SMTP id t8mr175882vcf.49.1385963573359; Sun, 01 Dec 2013 21:52:53 -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 u4csp92654vcz; Sun, 1 Dec 2013 21:52:53 -0800 (PST) X-Received: by 10.224.65.130 with SMTP id j2mr37569197qai.4.1385963573001; Sun, 01 Dec 2013 21:52:53 -0800 (PST) Received: from mail-qe0-f41.google.com (mail-qe0-f41.google.com [209.85.128.41]) by mx.google.com with ESMTPS id i10si44589598qen.48.2013.12.01.21.52.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:52:52 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.41 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.128.41; Received: by mail-qe0-f41.google.com with SMTP id gh4so10391370qeb.0 for ; Sun, 01 Dec 2013 21:52:52 -0800 (PST) X-Received: by 10.49.104.210 with SMTP id gg18mr47543308qeb.54.1385963572859; Sun, 01 Dec 2013 21:52:52 -0800 (PST) Received: from localhost (git.linaro.org. [54.235.93.228]) by mx.google.com with ESMTPSA id x10sm119903376qas.5.2013.12.01.21.52.51 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:52:52 -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 3/6] cpufreq: Implement cpufreq_generic_suspend() Date: Mon, 2 Dec 2013 11:22:33 +0530 Message-Id: <8f43348fdf8b796c6b53291e039710e91ec9ca56.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.169 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: , Multiple platforms need to set CPU to a particular frequency before suspending system. And so they need a common infrastructure which is provided by this patch. Those platforms just need to initialize their ->suspend() pointers with the generic routine. Tested-by: Stephen Warren Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 25 +++++++++++++++++++++++++ include/linux/cpufreq.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 443c053..ae4923e 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1530,6 +1530,31 @@ static struct subsys_interface cpufreq_interface = { .remove_dev = cpufreq_remove_dev, }; +/* + * In case platform wants some specific frequency to be configured + * during suspend.. + */ +int cpufreq_generic_suspend(struct cpufreq_policy *policy) +{ + int ret; + + if (!policy->suspend_freq) { + pr_err("%s: suspend_freq can't be zero\n", __func__); + return -EINVAL; + } + + pr_debug("%s: Setting suspend-freq: %u\n", __func__, + policy->suspend_freq); + + ret = __cpufreq_driver_target(policy, policy->suspend_freq, + CPUFREQ_RELATION_H); + if (ret) + pr_err("%s: unable to set suspend-freq: %u. err: %d\n", + __func__, policy->suspend_freq, ret); + + return ret; +} + /** * cpufreq_suspend() - Suspend CPUFreq governors * diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index b26bfab..ce6f06f 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -74,6 +74,8 @@ struct cpufreq_policy { unsigned int max; /* in kHz */ unsigned int cur; /* in kHz, only needed if cpufreq * governors are used */ + unsigned int suspend_freq; /* freq to set during suspend */ + unsigned int policy; /* see above */ struct cpufreq_governor *governor; /* see below */ void *governor_data; @@ -285,6 +287,7 @@ cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy) #ifdef CONFIG_CPU_FREQ void cpufreq_suspend(void); void cpufreq_resume(void); +int cpufreq_generic_suspend(struct cpufreq_policy *policy); #else static inline void cpufreq_suspend(void) {} static inline void cpufreq_resume(void) {}