Sekhar Nori <[email protected]> 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 <[email protected]>
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
> [email protected]
> http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source