diff mbox

[2/4] davinci: cpufreq: add support for voltage regulation

Message ID 1251890559-8388-2-git-send-email-nsekhar@ti.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Sekhar Nori Sept. 2, 2009, 11:22 a.m. UTC
This patch adds a new function to the davinci_soc_info
structure which controls voltage level (typically CVDD).

The new set_new_voltage call will be implemented by platform
code supporting voltage change.

Signed-off-by: Sekhar Nori <nsekhar@ti.com>
---
 arch/arm/mach-davinci/cpufreq.c             |    8 ++++++++
 arch/arm/mach-davinci/include/mach/common.h |    1 +
 2 files changed, 9 insertions(+), 0 deletions(-)

Comments

Kevin Hilman Sept. 14, 2009, 9:30 p.m. UTC | #1
Sekhar Nori <nsekhar@ti.com> writes:

> This patch adds a new function to the davinci_soc_info
> structure which controls voltage level (typically CVDD).
>
> The new set_new_voltage call will be implemented by platform
> code supporting voltage change.
>
> Signed-off-by: Sekhar Nori <nsekhar@ti.com>
> ---
>  arch/arm/mach-davinci/cpufreq.c             |    8 ++++++++
>  arch/arm/mach-davinci/include/mach/common.h |    1 +
>  2 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/cpufreq.c b/arch/arm/mach-davinci/cpufreq.c
> index af60d3d..8cb0c85 100644
> --- a/arch/arm/mach-davinci/cpufreq.c
> +++ b/arch/arm/mach-davinci/cpufreq.c
> @@ -102,8 +102,16 @@ static int davinci_target(struct cpufreq_policy *policy,
>  
>  	cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
>  
> +	/* if moving to higher frequency, up the voltage beforehand */
> +	if (davinci_soc_info.set_new_voltage && freqs.new > freqs.old)
> +		davinci_soc_info.set_new_voltage(idx);
> +
>  	ret = clk_set_rate(armclk, idx);
>  
> +	/* if moving to lower freq, lower the voltage after lowering freq */
> +	if (davinci_soc_info.set_new_voltage && freqs.new < freqs.old)
> +		davinci_soc_info.set_new_voltage(idx);
> +
>  	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
>  
>  	return ret;
> diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h
> index 1487a57..49d08aa 100644
> --- a/arch/arm/mach-davinci/include/mach/common.h
> +++ b/arch/arm/mach-davinci/include/mach/common.h
> @@ -71,6 +71,7 @@ struct davinci_soc_info {
>  	dma_addr_t			sram_dma;
>  	unsigned			sram_len;
>  	void (*init_cpufreq_table) (struct cpufreq_frequency_table **);
> +	int (*set_new_voltage) (unsigned int index);
>  };

I'm not crazy about the soc_info extention with functional interface.
There should a new API for this.

Kevin
diff mbox

Patch

diff --git a/arch/arm/mach-davinci/cpufreq.c b/arch/arm/mach-davinci/cpufreq.c
index af60d3d..8cb0c85 100644
--- a/arch/arm/mach-davinci/cpufreq.c
+++ b/arch/arm/mach-davinci/cpufreq.c
@@ -102,8 +102,16 @@  static int davinci_target(struct cpufreq_policy *policy,
 
 	cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
 
+	/* if moving to higher frequency, up the voltage beforehand */
+	if (davinci_soc_info.set_new_voltage && freqs.new > freqs.old)
+		davinci_soc_info.set_new_voltage(idx);
+
 	ret = clk_set_rate(armclk, idx);
 
+	/* if moving to lower freq, lower the voltage after lowering freq */
+	if (davinci_soc_info.set_new_voltage && freqs.new < freqs.old)
+		davinci_soc_info.set_new_voltage(idx);
+
 	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
 
 	return ret;
diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h
index 1487a57..49d08aa 100644
--- a/arch/arm/mach-davinci/include/mach/common.h
+++ b/arch/arm/mach-davinci/include/mach/common.h
@@ -71,6 +71,7 @@  struct davinci_soc_info {
 	dma_addr_t			sram_dma;
 	unsigned			sram_len;
 	void (*init_cpufreq_table) (struct cpufreq_frequency_table **);
+	int (*set_new_voltage) (unsigned int index);
 };
 
 extern struct davinci_soc_info davinci_soc_info;