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: 295776 X-Patchwork-Delegate: swarren@nvidia.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1C11D2C0079 for ; Mon, 2 Dec 2013 16:53:50 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752968Ab3LBFw6 (ORCPT ); Mon, 2 Dec 2013 00:52:58 -0500 Received: from mail-qe0-f52.google.com ([209.85.128.52]:60936 "EHLO mail-qe0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752943Ab3LBFwy (ORCPT ); Mon, 2 Dec 2013 00:52:54 -0500 Received: by mail-qe0-f52.google.com with SMTP id ne12so12898988qeb.11 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=CMAZUeluyMmAxGTq7+sM93K7eF+OVXXyUDwDFsBaMYaGGiuvnfOMCUoEjvhO5Zlen0 P19qRIsnOPOnYXtIbp/WpNmsBuAvN1pp4QugSdueRtgE7fAxAxR6U/tv9Ju8+h9O4esf qdiJPpWbn1SuT+qs/bZNDCK5Xc2h7WGS8f48OJ3jAfEcjRCKJjSjfDF0yaYUJ8XCi2b+ KM3FLIiRQaBmUIFKTRaJDNAlLek4DA1atSHU2GcNcJMpcJ1O9YKhfGxXiYGiiSQCptXT dZTTW+rf5ztc15BFeDFkAqyppujEMAJ9iciVzUUWk0MnLUz/oh30XVTyUqii98elrZLJ ieKw== X-Gm-Message-State: ALoCoQkL86JZ0jkeQslZ4iK61opwHpPVJCDJkYtg23AKLAgrP5bQa977VG3Q3loKV0FpuTAORsff 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-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org 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) {}