From patchwork Tue Mar 4 03:00:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 25636 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 978B2206F3 for ; Tue, 4 Mar 2014 03:01:21 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id j17sf15422013oag.6 for ; Mon, 03 Mar 2014 19:01:20 -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=KXyuiOs6ITlC7Yzk+evNm1mX8kC36iKYaeu4Xo234P0=; b=XhKfXEwmWFg4Shu3rPnqqtZ3GQxEf0DbD0BeMVVcB9hi3DjJ9binJI+NwEtvwN8O1G woHOyxcjr68HisO0/gJX0sWMOz5RRUHQEMrD15oN59CKMzEY3P/BdfRjftC+qf8dlL2y gmXFbuSXqylcH+RCZ8CeI3Aawd2aEfpuktokMjxSn6P0ctn2RPgw/pY4yCuwKj4bPFA4 oKzDbRRthiSe8lp0SKHcG7bchJMIZs37yNuxZaiGmVSksG4VP+2w+S5fEXgvqj7qvHcN KsAn9tyMtirzu1kDElijd3E1+P2T6pAbD4V57Z/eM3NpYmXwqCHt7o2q+myvIxAwAZWa y0vw== X-Gm-Message-State: ALoCoQkax5TIyyMjLxvXa1ZwNOiUXTf2OwTKoyfv49DgHNtaBHwFdIL/nNIaNW8yZu8EVsgDXeTd X-Received: by 10.42.250.196 with SMTP id mp4mr11825043icb.29.1393902080190; Mon, 03 Mar 2014 19:01:20 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.20.100 with SMTP id 91ls2441995qgi.18.gmail; Mon, 03 Mar 2014 19:01:20 -0800 (PST) X-Received: by 10.58.134.101 with SMTP id pj5mr182094veb.38.1393902079995; Mon, 03 Mar 2014 19:01:19 -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 fx7si5373519vcb.120.2014.03.03.19.01.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Mar 2014 19:01:19 -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 pa12so4773905veb.14 for ; Mon, 03 Mar 2014 19:01:19 -0800 (PST) X-Received: by 10.58.188.78 with SMTP id fy14mr20253622vec.23.1393902079921; Mon, 03 Mar 2014 19:01:19 -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.130.193 with SMTP id u1csp97139vcs; Mon, 3 Mar 2014 19:01:19 -0800 (PST) X-Received: by 10.67.13.134 with SMTP id ey6mr3272894pad.44.1393902078859; Mon, 03 Mar 2014 19:01:18 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tt8si12553146pbc.160.2014.03.03.19.01.18; Mon, 03 Mar 2014 19:01:18 -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 S1756174AbaCDDA4 (ORCPT + 26 others); Mon, 3 Mar 2014 22:00:56 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:46757 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756150AbaCDDAx (ORCPT ); Mon, 3 Mar 2014 22:00:53 -0500 Received: by mail-pa0-f54.google.com with SMTP id lf10so1932546pab.13 for ; Mon, 03 Mar 2014 19:00:53 -0800 (PST) X-Received: by 10.66.163.138 with SMTP id yi10mr3107469pab.95.1393902053045; Mon, 03 Mar 2014 19:00:53 -0800 (PST) Received: from localhost (z88l218.static.ctm.net. [202.175.88.218]) by mx.google.com with ESMTPSA id iv2sm20111618pbc.19.2014.03.03.19.00.49 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 03 Mar 2014 19:00:52 -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 Resend 3/5] cpufreq: exynos: Use cpufreq_generic_suspend() Date: Tue, 4 Mar 2014 11:00:28 +0800 Message-Id: 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.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 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. Signed-off-by: Viresh Kumar --- drivers/cpufreq/exynos-cpufreq.c | 96 +++------------------------------------- 1 file changed, 7 insertions(+), 89 deletions(-) diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c index fcd2914..307f02e 100644 --- a/drivers/cpufreq/exynos-cpufreq.c +++ b/drivers/cpufreq/exynos-cpufreq.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -24,12 +23,8 @@ #include "exynos-cpufreq.h" static struct exynos_dvfs_info *exynos_info; - static struct regulator *arm_regulator; - static unsigned int locking_frequency; -static bool frequency_locked; -static DEFINE_MUTEX(cpufreq_lock); static int exynos_cpufreq_get_index(unsigned int freq) { @@ -134,83 +129,13 @@ out: static int exynos_target(struct cpufreq_policy *policy, unsigned int index) { - struct cpufreq_frequency_table *freq_table = exynos_info->freq_table; - int ret = 0; - - mutex_lock(&cpufreq_lock); - - if (frequency_locked) - goto out; - - ret = exynos_cpufreq_scale(freq_table[index].frequency); - -out: - mutex_unlock(&cpufreq_lock); - - return ret; -} - -#ifdef CONFIG_PM -static int exynos_cpufreq_suspend(struct cpufreq_policy *policy) -{ - return 0; -} - -static int exynos_cpufreq_resume(struct cpufreq_policy *policy) -{ - return 0; -} -#endif - -/** - * exynos_cpufreq_pm_notifier - block CPUFREQ's activities in suspend-resume - * context - * @notifier - * @pm_event - * @v - * - * While frequency_locked == true, target() ignores every frequency but - * locking_frequency. The locking_frequency value is the initial frequency, - * which is set by the bootloader. In order to eliminate possible - * inconsistency in clock values, we save and restore frequencies during - * suspend and resume and block CPUFREQ activities. Note that the standard - * suspend/resume cannot be used as they are too deep (syscore_ops) for - * regulator actions. - */ -static int exynos_cpufreq_pm_notifier(struct notifier_block *notifier, - unsigned long pm_event, void *v) -{ - int ret; - - switch (pm_event) { - case PM_SUSPEND_PREPARE: - mutex_lock(&cpufreq_lock); - frequency_locked = true; - mutex_unlock(&cpufreq_lock); - - ret = exynos_cpufreq_scale(locking_frequency); - if (ret < 0) - return NOTIFY_BAD; - - break; - - case PM_POST_SUSPEND: - mutex_lock(&cpufreq_lock); - frequency_locked = false; - mutex_unlock(&cpufreq_lock); - break; - } - - return NOTIFY_OK; + return exynos_cpufreq_scale(exynos_info->freq_table[index].frequency); } -static struct notifier_block exynos_cpufreq_nb = { - .notifier_call = exynos_cpufreq_pm_notifier, -}; - static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy) { policy->clk = exynos_info->cpu_clk; + policy->suspend_freq = locking_frequency; return cpufreq_generic_init(policy, exynos_info->freq_table, 100000); } @@ -227,8 +152,7 @@ static struct cpufreq_driver exynos_driver = { .boost_supported = true, #endif #ifdef CONFIG_PM - .suspend = exynos_cpufreq_suspend, - .resume = exynos_cpufreq_resume, + .suspend = cpufreq_generic_suspend, #endif }; @@ -263,19 +187,13 @@ static int exynos_cpufreq_probe(struct platform_device *pdev) goto err_vdd_arm; } + /* Done here as we want to capture boot frequency */ locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000; - register_pm_notifier(&exynos_cpufreq_nb); - - if (cpufreq_register_driver(&exynos_driver)) { - pr_err("%s: failed to register cpufreq driver\n", __func__); - goto err_cpufreq; - } - - return 0; -err_cpufreq: - unregister_pm_notifier(&exynos_cpufreq_nb); + if (!cpufreq_register_driver(&exynos_driver)) + return 0; + pr_err("%s: failed to register cpufreq driver\n", __func__); regulator_put(arm_regulator); err_vdd_arm: kfree(exynos_info);