From patchwork Mon Nov 25 14:11:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 3231841 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A45D49F693 for ; Mon, 25 Nov 2013 14:13:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E9B0120177 for ; Mon, 25 Nov 2013 14:13:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ADAAB20173 for ; Mon, 25 Nov 2013 14:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756994Ab3KYOMy (ORCPT ); Mon, 25 Nov 2013 09:12:54 -0500 Received: from mail-pb0-f46.google.com ([209.85.160.46]:39139 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755029Ab3KYOMu (ORCPT ); Mon, 25 Nov 2013 09:12:50 -0500 Received: by mail-pb0-f46.google.com with SMTP id md12so5743593pbc.5 for ; Mon, 25 Nov 2013 06:12:50 -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=kHHRPYGWeaqNrUnefJnPNCizsLcvjTDPCZML9xen45o=; b=k2kVSJHPIeFbWndqfniD24yvvIxUB8zbOqsw3jj+zE6OiFZtDOVkYu8MbWVLVgRx87 ZwPVgCLO5A6+G3QfAPyNYUgMysoPrO6z9Ve4jDbSZERdEWmiN6nf8ESf+ln+lo02lrKx 0OsxyMLn2m4Qu/sJURYS4NZ67iz/Z6jKXiB3lXiGqF2TnjZq5zA85E7v3MUimrZ3H4Mh 4Zpl6bhdeX1RMsF8Q+gqxP6UfyG6onubGnJLIChnEa+hyqgcWAjjsgQHmpVEVh9OvWZz yLyycC+QbuvUgJbSs1O8XdiSBFQoXDnBQKjJltOndoj5gsnZvLycSTJ4rAgwhyAqQ062 AuIw== X-Gm-Message-State: ALoCoQlTLdYYDetW2OuwRVkhnGIEizb5WuNj7dZyiuLHe4MTMLURRsW0TsQh3enz18AicIS6qfNq X-Received: by 10.66.197.135 with SMTP id iu7mr2893910pac.149.1385388770052; Mon, 25 Nov 2013 06:12:50 -0800 (PST) Received: from localhost ([122.167.133.207]) by mx.google.com with ESMTPSA id kd1sm83353171pab.20.2013.11.25.06.12.45 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 25 Nov 2013 06:12:49 -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 6/6] cpufreq: Tegra: Use cpufreq_generic_suspend() Date: Mon, 25 Nov 2013 19:41:46 +0530 Message-Id: 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 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/tegra-cpufreq.c | 54 +++++------------------------------------ 1 file changed, 6 insertions(+), 48 deletions(-) diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c index f42df7e..336368b 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 }, @@ -48,8 +47,6 @@ static struct clk *pll_p_clk; static struct clk *emc_clk; static unsigned long target_cpu_speed[NUM_CPUS]; -static DEFINE_MUTEX(tegra_cpu_lock); -static bool is_suspended; static unsigned int tegra_getspeed(unsigned int cpu) { @@ -137,50 +134,10 @@ static unsigned long tegra_cpu_highest_speed(void) static int tegra_target(struct cpufreq_policy *policy, unsigned int index) { - unsigned int freq; - int ret = 0; - - mutex_lock(&tegra_cpu_lock); - - if (is_suspended) { - ret = -EBUSY; - goto out; - } - - freq = freq_table[index].frequency; - - target_cpu_speed[policy->cpu] = freq; - - ret = tegra_update_cpu_speed(policy, tegra_cpu_highest_speed()); - -out: - mutex_unlock(&tegra_cpu_lock); - return ret; + target_cpu_speed[policy->cpu] = freq_table[index].frequency; + return tegra_update_cpu_speed(policy, tegra_cpu_highest_speed()); } -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); - 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; @@ -192,6 +149,7 @@ static int tegra_cpu_init(struct cpufreq_policy *policy) clk_prepare_enable(cpu_clk); target_cpu_speed[policy->cpu] = tegra_getspeed(policy->cpu); + policy->suspend_freq = freq_table[0].frequency; /* FIXME: what's the actual transition time? */ ret = cpufreq_generic_init(policy, freq_table, 300 * 1000); @@ -201,9 +159,6 @@ static int tegra_cpu_init(struct cpufreq_policy *policy) return ret; } - if (policy->cpu == 0) - register_pm_notifier(&tegra_cpu_pm_notifier); - return 0; } @@ -223,6 +178,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)