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: 21743 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f72.google.com (mail-pb0-f72.google.com [209.85.160.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8D3A923FCB for ; Mon, 25 Nov 2013 14:12:52 +0000 (UTC) Received: by mail-pb0-f72.google.com with SMTP id jt11sf10928084pbb.3 for ; Mon, 25 Nov 2013 06:12:51 -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=kHHRPYGWeaqNrUnefJnPNCizsLcvjTDPCZML9xen45o=; b=ILrXbuH4w3pEhi6X3S8xmnblbJq4tJmFOCs3TkSaZUAkTyoVvvI/ntCOkytoc44g/6 NRDdYh9BWnlKQOyxBrzD/OZRFgnGUXZxWlJwa7ABdukgC8DzgRL8TIG08JFAZR1xTaAv ftSg1DqeJ/WXe5VjnXn+e6kK7ZQ8owt+vwkJlv+iqUkJ4b4W32Fg7geh4Lei9uNZaL5y rDx/JjtZjEa4zt2hMP4UDlfy0WjgdwHFuUD7Ig3XCKopaRkfeAVKocELYHKJYDtHjSIK bopJSOdASOHKmDHcpzG+FPT5f5ipDLrFMGO4jDgyxz7F6WbFrKoEBUJ39oyPqtxccKuH coKw== X-Gm-Message-State: ALoCoQl8OOAcuYoJRaAqQ5j93w6wfLv/3J/n1LtJnZaxbFjrGHeGLdDpjpqt35VlzPMoWYbFd4YX X-Received: by 10.67.4.202 with SMTP id cg10mr621857pad.42.1385388771832; Mon, 25 Nov 2013 06:12:51 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.12.241 with SMTP id b17ls1689229qec.11.gmail; Mon, 25 Nov 2013 06:12:51 -0800 (PST) X-Received: by 10.220.169.203 with SMTP id a11mr1341514vcz.26.1385388771687; Mon, 25 Nov 2013 06:12:51 -0800 (PST) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id 1si17916092vel.74.2013.11.25.06.12.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Nov 2013 06:12:51 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.175 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.175; Received: by mail-ve0-f175.google.com with SMTP id jx11so2920861veb.34 for ; Mon, 25 Nov 2013 06:12:51 -0800 (PST) X-Received: by 10.221.64.17 with SMTP id xg17mr26632561vcb.5.1385388771598; Mon, 25 Nov 2013 06:12:51 -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 u4csp136189vcz; Mon, 25 Nov 2013 06:12:51 -0800 (PST) X-Received: by 10.68.190.103 with SMTP id gp7mr18249122pbc.74.1385388770566; Mon, 25 Nov 2013 06:12:50 -0800 (PST) Received: from mail-pd0-f174.google.com (mail-pd0-f174.google.com [209.85.192.174]) by mx.google.com with ESMTPS id t5si7813651pab.227.2013.11.25.06.12.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Nov 2013 06:12:50 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.174 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.174; Received: by mail-pd0-f174.google.com with SMTP id y13so5515352pdi.5 for ; Mon, 25 Nov 2013 06:12:50 -0800 (PST) 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: 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.175 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: , 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)