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: 3263771 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E538FBEEAE for ; Mon, 2 Dec 2013 05:53:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1EB7C202E6 for ; Mon, 2 Dec 2013 05:53:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B761202BE for ; Mon, 2 Dec 2013 05:53:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752976Ab3LBFxA (ORCPT ); Mon, 2 Dec 2013 00:53:00 -0500 Received: from mail-qe0-f50.google.com ([209.85.128.50]:45828 "EHLO mail-qe0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752947Ab3LBFwy (ORCPT ); Mon, 2 Dec 2013 00:52:54 -0500 Received: by mail-qe0-f50.google.com with SMTP id 1so10638308qec.23 for ; Sun, 01 Dec 2013 21:52:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=+V39iaSfQKAbEqc++op/OExLevHiW9hw+vmBt7eA1qo=; b=YLso6uZMR6NrJ/TlxWU8+3r7o81OvZ0csFBThvtAgFv3iRmbjlQeSS4W2Ri4PS9Kiw 1b1tFc7sfKcF+FZJW/KfTGGFimhhCf7OnwghVRB15HtW0LBt16Q4nXa+05Tg/fyzGl63 XGKuz2noy8s3zcl9O3VMmVfln1KGybTTlOGVWBgz33kLXddYv/I6Li/sFujtz4jOPqyE MqlVK538MKG9x3Vl5rJNYiLzkRLc62TExfdu9PcnBKYoIWZv3c4NZTZQ9A8lvM8N1Z27 OzhgmNmpaZ92fHWDi2jyuPoMpjY+A7wCo7qFrESFinxLu88apBejK1Q7e6AOODLxFQhv 89lQ== X-Gm-Message-State: ALoCoQkGtuuhHYAN7LiCUxl6tHXARUmKRPDU/x5lB7JatJQPjJ+SACTPVD5PwVjn2MqVptjlZWtU 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: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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) {}