From patchwork Wed Sep 2 11:22:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sekhar Nori X-Patchwork-Id: 45174 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n82BOZRW006306 for ; Wed, 2 Sep 2009 11:24:36 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id n82BMif4011375; Wed, 2 Sep 2009 06:22:49 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id n82BMh4N026773; Wed, 2 Sep 2009 06:22:43 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 3CA0280628; Wed, 2 Sep 2009 06:22:43 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dbdp31.itg.ti.com (dbdp31.itg.ti.com [172.24.170.98]) by linux.omap.com (Postfix) with ESMTP id 457ED80626 for ; Wed, 2 Sep 2009 06:22:41 -0500 (CDT) Received: from psplinux051.india.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id n82BMdiB004373; Wed, 2 Sep 2009 16:52:39 +0530 (IST) Received: from psplinux051.india.ti.com (localhost [127.0.0.1]) by psplinux051.india.ti.com (8.13.1/8.13.1) with ESMTP id n82BMdNC008749; Wed, 2 Sep 2009 16:52:39 +0530 Received: (from a0875516@localhost) by psplinux051.india.ti.com (8.13.1/8.13.1/Submit) id n82BMdgG008746; Wed, 2 Sep 2009 16:52:39 +0530 From: Sekhar Nori To: davinci-linux-open-source@linux.davincidsp.com Date: Wed, 2 Sep 2009 16:52:36 +0530 Message-Id: <1251890559-8388-1-git-send-email-nsekhar@ti.com> X-Mailer: git-send-email 1.6.2.4 Cc: Subject: [PATCH 1/4] davinci: cpufreq: use cpufreq_frequency_table_target() to search freq table X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com Use framework provided cpufreq_frequency_table_target() function to index into the frequency table and provide that index information to the clock's set_rate function so it can directly obtain OPP information instead having the set_rate search through the table. The motivation behind the change is efficient support of voltage scaling. When voltage scaling is supported, the OPP table needs to be searched in the voltage change function as well to obtain information about the new voltage levels. Instead of searching the table once for frequency and once for voltage, this patch uses a framework function to search through the table and then overrides the rate parameter provided to clock set function to provide index information instead. Signed-off-by: Sekhar Nori --- This is a set of four patches adding voltage regulation support for DA850/OMAP-L138 on top of the frequency change support posted earlier. The patches depend on the latest set of 10 patches posted by me supporting frequency scaling. For testing on the on the EVM, we need the TPS65070 driver (drivers/regulator/tps6507x-regulator.c) currently being hosted on the linux-next tree. arch/arm/mach-davinci/cpufreq.c | 14 ++++++++++---- arch/arm/mach-davinci/da850.c | 23 ++++------------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/arch/arm/mach-davinci/cpufreq.c b/arch/arm/mach-davinci/cpufreq.c index 65393b9..af60d3d 100644 --- a/arch/arm/mach-davinci/cpufreq.c +++ b/arch/arm/mach-davinci/cpufreq.c @@ -74,6 +74,7 @@ static int davinci_target(struct cpufreq_policy *policy, { struct cpufreq_freqs freqs; int ret = 0; + unsigned int idx; /* * Ensure desired rate is within allowed range. Some govenors @@ -90,12 +91,19 @@ static int davinci_target(struct cpufreq_policy *policy, if (freqs.old == freqs.new) return ret; - cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); #ifdef CONFIG_CPU_FREQ_DEBUG printk(KERN_DEBUG "cpufreq-davinci: transition: %u --> %u\n", freqs.old, freqs.new); #endif - ret = clk_set_rate(armclk, freqs.new * 1000); + if (cpufreq_frequency_table_target(policy, freq_table, freqs.new, + relation, &idx)) { + return -EINVAL; + } + + cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); + + ret = clk_set_rate(armclk, idx); + cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); return ret; @@ -129,8 +137,6 @@ static int __init davinci_cpu_init(struct cpufreq_policy *policy) policy->cpuinfo.max_freq = policy->max; } - clk_set_rate(armclk, policy->cpuinfo.max_freq * 1000); - policy->min = policy->cpuinfo.min_freq; policy->max = policy->cpuinfo.max_freq; policy->cur = davinci_getspeed(0); diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c index 6906af5..0b99bcf 100644 --- a/arch/arm/mach-davinci/da850.c +++ b/arch/arm/mach-davinci/da850.c @@ -909,37 +909,22 @@ static int da850_round_armrate(struct clk *clk, unsigned long rate) return ret * 1000; } -static int da850_set_armrate(struct clk *clk, unsigned long armrate) +static int da850_set_armrate(struct clk *clk, unsigned long index) { struct clk *pllclk = &pll0_clk; - return clk_set_rate(pllclk, armrate); + return clk_set_rate(pllclk, index); } -static int da850_set_pll0rate(struct clk *clk, unsigned long armrate) +static int da850_set_pll0rate(struct clk *clk, unsigned long index) { - int i; unsigned int prediv, mult, postdiv; struct da850_opp *opp; struct pll_data *pll = clk->pll_data; unsigned int v; int ret; - /* convert to KHz */ - armrate /= 1000; - - for (i = 0; da850_freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { - if (armrate == da850_freq_table[i].frequency) - break; - } - - if (da850_freq_table[i].frequency == CPUFREQ_TABLE_END) { - printk(KERN_WARNING "%s: Unsupported ARM clock rate %ld\n", - __func__, armrate); - return -EINVAL; - } - - opp = (struct da850_opp *) da850_freq_table[i].index; + opp = (struct da850_opp *) da850_freq_table[index].index; prediv = opp->prediv; mult = opp->mult; postdiv = opp->postdiv;