From patchwork Mon Nov 25 14:11:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21740 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f71.google.com (mail-pb0-f71.google.com [209.85.160.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AB1EC23FCB for ; Mon, 25 Nov 2013 14:12:28 +0000 (UTC) Received: by mail-pb0-f71.google.com with SMTP id uo5sf10907858pbc.6 for ; Mon, 25 Nov 2013 06:12:28 -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=FjKEjhchC5jcqIuvkKBLoGZDwCDAKiuu5jRyhrDApLQ=; b=XxFKb3lPVvxAeIN7d/hY9ft633VD7KIemnm/BD7lt37z196HbHh6m50q5sULDmjmGB d91pr4msze//KJ0j0DCg+zDgzAVSbYG+w4BtNWOO8mIHa2ygPKX193ZlgZaoF5GLaTFa 7tv9e3A1tCMyPGKBc7Lj+CQ+IUDVgYf6knDtNpFLfUiO9M+mpEQ6RXju8d6G6yWxOM4t 8ePjxXum+eOAK4mnlmtAT3J+HKc+0CFMS1STX4lNqUFYE/ElVU/IC9IdGDVutrY9s9if JzqIF438dPlYD+87furXyOBPyM4+Qh99ZHWePOmXy8/g81alARZUZGKlog8vuxXLEART ViHA== X-Gm-Message-State: ALoCoQm4VHh9oyl/a/VMdKxUqjTNjSU4sW7e8GKS3i9qWj7TZAD1dUin0sM6rTgaWCz6IhFCWgSi X-Received: by 10.66.161.195 with SMTP id xu3mr9428706pab.33.1385388747992; Mon, 25 Nov 2013 06:12:27 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.12.176 with SMTP id z16ls2101868qeb.16.gmail; Mon, 25 Nov 2013 06:12:27 -0800 (PST) X-Received: by 10.52.30.19 with SMTP id o19mr393312vdh.35.1385388747722; Mon, 25 Nov 2013 06:12:27 -0800 (PST) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id o6si17914881vcz.79.2013.11.25.06.12.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Nov 2013 06:12:27 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id lh4so2901281vcb.9 for ; Mon, 25 Nov 2013 06:12:27 -0800 (PST) X-Received: by 10.52.52.137 with SMTP id t9mr9548607vdo.22.1385388747625; Mon, 25 Nov 2013 06:12:27 -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 u4csp136156vcz; Mon, 25 Nov 2013 06:12:27 -0800 (PST) X-Received: by 10.68.176.228 with SMTP id cl4mr778717pbc.196.1385388746649; Mon, 25 Nov 2013 06:12:26 -0800 (PST) Received: from mail-pb0-f41.google.com (mail-pb0-f41.google.com [209.85.160.41]) by mx.google.com with ESMTPS id ob10si27909052pbb.37.2013.11.25.06.12.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Nov 2013 06:12:26 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.41 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.160.41; Received: by mail-pb0-f41.google.com with SMTP id jt11so5810470pbb.14 for ; Mon, 25 Nov 2013 06:12:26 -0800 (PST) X-Received: by 10.68.211.1 with SMTP id my1mr18398573pbc.55.1385388746275; Mon, 25 Nov 2013 06:12:26 -0800 (PST) Received: from localhost ([122.167.133.207]) by mx.google.com with ESMTPSA id qf7sm83336584pac.14.2013.11.25.06.12.21 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 25 Nov 2013 06:12:25 -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, jinchoi@broadcom.com, tianyu.lan@intel.com, sebastian.capella@linaro.org, jhbird.choi@samsung.com, Viresh Kumar Subject: [PATCH V3 3/6] cpufreq: Implement cpufreq_generic_suspend() Date: Mon, 25 Nov 2013 19:41:43 +0530 Message-Id: <2b3f1f76ff383697c1ee8c8eeb0029d95b53248f.1385374822.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.220.178 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. 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 026efe4a..f6da551 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1466,6 +1466,31 @@ static struct subsys_interface cpufreq_interface = { }; /* + * 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; +} + +/* * Callbacks for suspending/resuming governors as some platforms can't change * frequency after this point in suspend cycle. Because some of the devices * (like: i2c, regulators, etc) they use for changing frequency are suspended diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 6d93f91..94ccac5 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -72,6 +72,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; @@ -257,6 +259,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); void cpufreq_suspend(void); void cpufreq_resume(void); +int cpufreq_generic_suspend(struct cpufreq_policy *policy); const char *cpufreq_get_current_driver(void);