From patchwork Wed May 18 07:37:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 792992 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4I7bqvN028870 for ; Wed, 18 May 2011 07:38:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755085Ab1ERHiF (ORCPT ); Wed, 18 May 2011 03:38:05 -0400 Received: from na3sys009aog116.obsmtp.com ([74.125.149.240]:36149 "EHLO na3sys009aog116.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755038Ab1ERHiE (ORCPT ); Wed, 18 May 2011 03:38:04 -0400 Received: from mail-gx0-f178.google.com ([209.85.161.178]) (using TLSv1) by na3sys009aob116.postini.com ([74.125.148.12]) with SMTP ID DSNKTdN3W+iUw/MSxJdBB1rECuQ3zE2+r61g@postini.com; Wed, 18 May 2011 00:38:04 PDT Received: by gxk8 with SMTP id 8so536367gxk.37 for ; Wed, 18 May 2011 00:38:03 -0700 (PDT) Received: by 10.236.30.97 with SMTP id j61mr1637792yha.403.1305704281896; Wed, 18 May 2011 00:38:01 -0700 (PDT) Received: from localhost (dragon.ti.com [192.94.94.33]) by mx.google.com with ESMTPS id v1sm933324anh.51.2011.05.18.00.38.00 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 May 2011 00:38:01 -0700 (PDT) From: Nishanth Menon To: kevin Cc: linux-omap , Nishanth Menon Subject: [PM-WIP_CPUFREQ][PATCH 5/6 v2] OMAP2+: cpufreq: use cpufreq_frequency_table_target Date: Wed, 18 May 2011 02:37:45 -0500 Message-Id: <1305704266-17623-6-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <[PM-WIP_CPUFREQ][PATCH 0/5] Cleanups for cpufreq> References: <[PM-WIP_CPUFREQ][PATCH 0/5] Cleanups for cpufreq> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 18 May 2011 07:38:06 +0000 (UTC) Use cpufreq_frequency_table_target for finding the proper target instead of seeing if the frequency requested is divisible alone. if we have a frequency table, we should restrict ourselves to selecting the "approved" frequencies alone and only in the case where the frequency table is not available should we attempt at closest roundable clock frequency. Signed-off-by: Nishanth Menon --- arch/arm/mach-omap2/omap2plus-cpufreq.c | 38 ++++++++++++++++++++++-------- 1 files changed, 28 insertions(+), 10 deletions(-) diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c index 854f4b3..d0b4f97 100644 --- a/arch/arm/mach-omap2/omap2plus-cpufreq.c +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c @@ -77,24 +77,42 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation) { - int i, ret = 0; + unsigned int i; + int ret = 0; struct cpufreq_freqs freqs; /* Changes not allowed until all CPUs are online */ if (is_smp() && (num_online_cpus() < NR_CPUS)) return ret; - /* - * Ensure desired rate is within allowed range. Some govenors - * (ondemand) will just pass target_freq=0 to get the minimum. - */ - if (target_freq < policy->min) - target_freq = policy->min; - if (target_freq > policy->max) - target_freq = policy->max; + if (freq_table) { + ret = cpufreq_frequency_table_target(policy, freq_table, + target_freq, relation, &i); + if (ret) { + pr_debug("%s: cpu%d: no freq match for %d(ret=%d)\n", + __func__, policy->cpu, target_freq, ret); + return ret; + } + freqs.new = freq_table[i].frequency; + } else { + /* + * Ensure desired rate is within allowed range. Some govenors + * (ondemand) will just pass target_freq=0 to get the minimum. + */ + if (target_freq < policy->min) + target_freq = policy->min; + if (target_freq > policy->max) + target_freq = policy->max; + + freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000; + } + if (!freqs.new) { + pr_err("%s: cpu%d: no match for freq %d\n", __func__, + policy->cpu, target_freq); + return -EINVAL; + } freqs.old = omap_getspeed(policy->cpu); - freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000; freqs.cpu = policy->cpu; if (freqs.old == freqs.new)