Message ID | 1251890559-8388-1-git-send-email-nsekhar@ti.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Sekhar Nori <nsekhar@ti.com> writes: > 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 <nsekhar@ti.com> Please fold into re-spin of cpufreq changes. > --- > 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. If you send a commit ID, I'll cherry pick this from linux-next into davinci git. Kevin > 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; > -- > 1.6.2.4 > > _______________________________________________ > Davinci-linux-open-source mailing list > Davinci-linux-open-source@linux.davincidsp.com > http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
On Tue, Sep 15, 2009 at 03:01:00, Kevin Hilman wrote: > Sekhar Nori <nsekhar@ti.com> writes: > > > 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 <nsekhar@ti.com> > > Please fold into re-spin of cpufreq changes. > Okay. > > --- > > 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. > > If you send a commit ID, I'll cherry pick this from linux-next into > davinci git. > The commit ids are (in the order to be applied) d554fa442de557411197a4a2c9a2934fffcd381a (Regulator: Add TPS65023 regulator driver) 68253668e8930f6f00d51511833dca287d574471 (Regulator: Add TPS6507x regulator driver) acc72131c3e98c5e616e6bccb3d5fd89dde3fbdf (Regulator: Adding TPS65023 and TPS6507x in Kconfig and Makefile) 318a2a135c9afd03b0696209f3fff037a0b04be2 (regulator: tps650xx - build fixes for x86_64) Thanks, Sekhar
"Nori, Sekhar" <nsekhar@ti.com> writes: > On Tue, Sep 15, 2009 at 03:01:00, Kevin Hilman wrote: >> Sekhar Nori <nsekhar@ti.com> writes: >> >> > 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. >> >> If you send a commit ID, I'll cherry pick this from linux-next into >> davinci git. >> > > The commit ids are (in the order to be applied) > > d554fa442de557411197a4a2c9a2934fffcd381a (Regulator: Add TPS65023 regulator driver) > 68253668e8930f6f00d51511833dca287d574471 (Regulator: Add TPS6507x regulator driver) > acc72131c3e98c5e616e6bccb3d5fd89dde3fbdf (Regulator: Adding TPS65023 and TPS6507x in Kconfig and Makefile) > 318a2a135c9afd03b0696209f3fff037a0b04be2 (regulator: tps650xx - build fixes for x86_64) > Thanks, I picked these into davinci-backports, and will merge into master. Kevin
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;
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 <nsekhar@ti.com> --- 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(-)