From patchwork Thu Feb 13 06:50:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 24572 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C055D202E2 for ; Thu, 13 Feb 2014 06:54:59 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id m10sf21762333vbh.4 for ; Wed, 12 Feb 2014 22:54:58 -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=otCRVvu2y2CDK9sk71ouMLb3XbF4WZw9jiwFUaqr3MY=; b=DUO0MKK6DwwiwLJ/MyghlIJ387CZin1EbMnzjpsipPUmlxGNqAun7IpBmjbsX8Z4NP dydxiF/6CZEXlgqQvRt+aW7lr2ikAH+UuREMJiNW2UNduGM5i9rD1qSfpfbHe33/8y+3 W/2bBfq3hfH+oX1eMDTXgmhAPZTCAUPvobb7hybuPWB57PH02drnDSvp5LjNRh2fYAYk IZ8ZJDlWAceMwIZ2hk8j7kmbCZD7npI70P98DcKEeZl6pA8MzgN0TaK8SYF7CDpZNtZ9 7MTw8gRF0c7Bw72SDwIHtmJmDYYulfgvefy4FgM6myw3tAoZsRT9+FK9pvQd4EWq1mtj IMHg== X-Gm-Message-State: ALoCoQmwPJHkJB/8Z6aH6asGZf/YjdG7ugifuDT/aWwrskLm8TqMc5XplTtHkpvVqOXeEkXxq6U4 X-Received: by 10.58.210.3 with SMTP id mq3mr3580092vec.28.1392274498954; Wed, 12 Feb 2014 22:54:58 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.30.8 with SMTP id c8ls3256734qgc.56.gmail; Wed, 12 Feb 2014 22:54:58 -0800 (PST) X-Received: by 10.58.85.133 with SMTP id h5mr35831289vez.4.1392274498890; Wed, 12 Feb 2014 22:54:58 -0800 (PST) Received: from mail-vb0-f49.google.com (mail-vb0-f49.google.com [209.85.212.49]) by mx.google.com with ESMTPS id eo4si357292vdb.4.2014.02.12.22.54.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Feb 2014 22:54:58 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.49 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.49; Received: by mail-vb0-f49.google.com with SMTP id x14so7710667vbb.22 for ; Wed, 12 Feb 2014 22:54:58 -0800 (PST) X-Received: by 10.58.119.161 with SMTP id kv1mr18788545veb.21.1392274498801; Wed, 12 Feb 2014 22:54:58 -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.174.196 with SMTP id u4csp3327vcz; Wed, 12 Feb 2014 22:54:58 -0800 (PST) X-Received: by 10.68.218.3 with SMTP id pc3mr56621862pbc.71.1392274497882; Wed, 12 Feb 2014 22:54:57 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3si981002pbk.23.2014.02.12.22.54.45; Wed, 12 Feb 2014 22:54:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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 S1753346AbaBMGv1 (ORCPT + 11 others); Thu, 13 Feb 2014 01:51:27 -0500 Received: from mail-we0-f173.google.com ([74.125.82.173]:57285 "EHLO mail-we0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752018AbaBMGvZ (ORCPT ); Thu, 13 Feb 2014 01:51:25 -0500 Received: by mail-we0-f173.google.com with SMTP id x48so1343235wes.32 for ; Wed, 12 Feb 2014 22:51:24 -0800 (PST) X-Received: by 10.194.6.164 with SMTP id c4mr4461522wja.38.1392274284267; Wed, 12 Feb 2014 22:51:24 -0800 (PST) Received: from localhost ([213.122.173.131]) by mx.google.com with ESMTPSA id fb6sm11586604wib.2.2014.02.12.22.51.20 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 12 Feb 2014 22:51:23 -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 V5 7/7] cpufreq: Tegra: Use cpufreq_generic_suspend() Date: Thu, 13 Feb 2014 12:20:22 +0530 Message-Id: <5fde49355d4ea03dfdf2c6bdf7d63e8ef4af2166.1392273723.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-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@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.212.49 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. Tested-by: Stephen Warren Signed-off-by: Viresh Kumar --- drivers/cpufreq/tegra-cpufreq.c | 46 +++++------------------------------------ 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c index e652c1b..bcfed77 100644 --- a/drivers/cpufreq/tegra-cpufreq.c +++ b/drivers/cpufreq/tegra-cpufreq.c @@ -26,7 +26,6 @@ #include #include #include -#include static struct cpufreq_frequency_table freq_table[] = { { .frequency = 216000 }, @@ -47,9 +46,6 @@ static struct clk *pll_x_clk; static struct clk *pll_p_clk; static struct clk *emc_clk; -static DEFINE_MUTEX(tegra_cpu_lock); -static bool is_suspended; - static int tegra_cpu_clk_set_rate(unsigned long rate) { int ret; @@ -112,42 +108,9 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy, static int tegra_target(struct cpufreq_policy *policy, unsigned int index) { - int ret = -EBUSY; - - mutex_lock(&tegra_cpu_lock); - - if (!is_suspended) - ret = tegra_update_cpu_speed(policy, - freq_table[index].frequency); - - mutex_unlock(&tegra_cpu_lock); - return ret; + return tegra_update_cpu_speed(policy, freq_table[index].frequency); } -static int tegra_pm_notify(struct notifier_block *nb, unsigned long event, - void *dummy) -{ - mutex_lock(&tegra_cpu_lock); - if (event == PM_SUSPEND_PREPARE) { - struct cpufreq_policy *policy = cpufreq_cpu_get(0); - is_suspended = true; - pr_info("Tegra cpufreq suspend: setting frequency to %d kHz\n", - freq_table[0].frequency); - if (clk_get_rate(cpu_clk) / 1000 != freq_table[0].frequency) - tegra_update_cpu_speed(policy, freq_table[0].frequency); - cpufreq_cpu_put(policy); - } else if (event == PM_POST_SUSPEND) { - is_suspended = false; - } - mutex_unlock(&tegra_cpu_lock); - - return NOTIFY_OK; -} - -static struct notifier_block tegra_cpu_pm_notifier = { - .notifier_call = tegra_pm_notify, -}; - static int tegra_cpu_init(struct cpufreq_policy *policy) { int ret; @@ -166,10 +129,8 @@ static int tegra_cpu_init(struct cpufreq_policy *policy) return ret; } - if (policy->cpu == 0) - register_pm_notifier(&tegra_cpu_pm_notifier); - policy->clk = cpu_clk; + policy->suspend_freq = freq_table[0].frequency; return 0; } @@ -190,6 +151,9 @@ static struct cpufreq_driver tegra_cpufreq_driver = { .exit = tegra_cpu_exit, .name = "tegra", .attr = cpufreq_generic_attr, +#ifdef CONFIG_PM + .suspend = cpufreq_generic_suspend, +#endif }; static int __init tegra_cpufreq_init(void)