Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-06 Thread Shawn Guo
On Thu, Nov 07, 2013 at 03:32:09AM +, Rongjun Ying wrote:
> I think my patch is better.

Well, unfortunately your patch is plainly wrong, because there are
in-tree users of voltage-tolerance right now.  How can you simply remove
it from driver with ignoring these users?

$ git grep voltage-tolerance arch/arm/boot/dts
arch/arm/boot/dts/am33xx.dtsi:  voltage-tolerance = <2>; /* 2 
percentage */
arch/arm/boot/dts/imx27.dtsi:   voltage-tolerance = <5>;
arch/arm/boot/dts/r8a73a4-ape6evm-reference.dts:voltage-tolerance = 
<1>; /* 1% */
arch/arm/boot/dts/r8a73a4-ape6evm.dts:  voltage-tolerance = <1>; /* 1% */
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts:   
voltage-tolerance = <1>; /* 1% */

Shawn

> All soc have a max work voltage. If regulator IC can't supply min voltage, 
> It can supply max voltage to soc.
> As my patch, not need overwrite OPP in .dts.
> As your comment above, almost all board need overwrite OPP, unless the 
> regulator 
> IC can supply all voltage ranges of SoC need.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-06 Thread Rongjun Ying


> -Original Message-
> From: Shawn Guo [mailto:shawn@linaro.org]
> Sent: Thursday, November 07, 2013 10:27 AM
> To: Rongjun Ying
> Cc: Viresh Kumar; rjying; Rafael J. Wysocki; cpuf...@vger.kernel.org;
> linux...@vger.kernel.org; Linux Kernel Mailing List; Barry Song
> Subject: Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage
> instead of voltage-tolerance
> 
> On Thu, Nov 07, 2013 at 01:55:21AM +, Rongjun Ying wrote:
> > > For given board, what voltages could be provided is known.  So you
> > > can just define OPP table in .dts and specify the voltage as
> > > the value that the regulator IC can supply, e.g. 1.200V in above
> example.
> > >
> > > This is not nice, as OPP table is CPU/SoC specific and should be
> > > ideally defined in .dtsi.  But still it's a way out for you to
> > > use
> > > cpufreq-cpu0 driver as it is.
> > >
> > > In any case, you can not just change voltage-tolerance to
> > > voltage-max with no care about the existing users.
> > >
> > > Shawn
> > >
> > I don't think so. The voltage/freq pairs are attribute of the CPU.
> > Any boards can choose regulator IC base the cost and other reasons.
> > If the opp table defined in .dts, we can set exact
> voltage/freq
> > pairs, and not need use the voltage-tolerance to set tolerance.
> 
> If you read my comment above, you should see that I agree OPP is
> CPU/SoC specific and should be defined in .dtsi.  But property
> operating-points can reasonably be overwritten by particular
> .dts for some reason like some voltages cannot be supplied on
> that board.
> 
> Again, this is just a way for you to use generic cpufreq-cpu0 driver as
> it is, but not necessarily the best one.
> 
> Shawn
> 

I think my patch is better.
All soc have a max work voltage. If regulator IC can't supply min voltage, 
It can supply max voltage to soc.
As my patch, not need overwrite OPP in .dts.
As your comment above, almost all board need overwrite OPP, unless the 
regulator 
IC can supply all voltage ranges of SoC need.

Thanks
-RongJun Ying
> 
> 
>  To report this email as spam click
> https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==
> aM23S6+s5uWr7qEkawiSK+0AUqjCk0gm6KMeRLY+cWrx9g== .


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at 
http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-06 Thread Shawn Guo
On Thu, Nov 07, 2013 at 01:55:21AM +, Rongjun Ying wrote:
> > For given board, what voltages could be provided is known.  So you can
> > just define OPP table in .dts and specify the voltage as the
> > value that the regulator IC can supply, e.g. 1.200V in above example.
> > 
> > This is not nice, as OPP table is CPU/SoC specific and should be
> > ideally defined in .dtsi.  But still it's a way out for you to use
> > cpufreq-cpu0 driver as it is.
> > 
> > In any case, you can not just change voltage-tolerance to voltage-max
> > with no care about the existing users.
> > 
> > Shawn
> > 
> I don't think so. The voltage/freq pairs are attribute of the CPU.
> Any boards can choose regulator IC base the cost and other reasons.
> If the opp table defined in .dts, we can set exact voltage/freq pairs,
> and not need use the voltage-tolerance to set tolerance.

If you read my comment above, you should see that I agree OPP is
CPU/SoC specific and should be defined in .dtsi.  But property
operating-points can reasonably be overwritten by particular .dts
for some reason like some voltages cannot be supplied on that board.

Again, this is just a way for you to use generic cpufreq-cpu0 driver as
it is, but not necessarily the best one.

Shawn

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-06 Thread Rongjun Ying


> -Original Message-
> From: Shawn Guo [mailto:shawn@linaro.org]
> Sent: Wednesday, November 06, 2013 11:28 AM
> To: Rongjun Ying
> Cc: Viresh Kumar; rjying; Rafael J. Wysocki; cpuf...@vger.kernel.org;
> linux...@vger.kernel.org; Linux Kernel Mailing List;
> rongjun.y...@gcsr.com
> Subject: Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage
> instead of voltage-tolerance
> 
> On Wed, Nov 06, 2013 at 02:15:07AM +, Rongjun Ying wrote:
> > If omit voltage-tolerance, sometimes also can't get appropriate
> voltages.
> > For example:
> > If the regulator IC only can supply min voltage is 1.000V and max
> voltage is 1.200V, and cpu work max voltage is 1.200V.
> > But the cpu just need 1.100V when cpu run under a freq.
> > So regulator_set_voltage_tol will return failed.
> > Because the regulator_set_voltage will invoke with min-uV is 110
> and max-uV is 110 parameters.
> > Regulator can't supply it.
> > As this case, the regulator just need supply 1.200V.
> 
> For given board, what voltages could be provided is known.  So you can
> just define OPP table in .dts and specify the voltage as the
> value that the regulator IC can supply, e.g. 1.200V in above example.
> 
> This is not nice, as OPP table is CPU/SoC specific and should be
> ideally defined in .dtsi.  But still it's a way out for you to use
> cpufreq-cpu0 driver as it is.
> 
> In any case, you can not just change voltage-tolerance to voltage-max
> with no care about the existing users.
> 
> Shawn
> 
I don't think so. The voltage/freq pairs are attribute of the CPU.
Any boards can choose regulator IC base the cost and other reasons.
If the opp table defined in .dts, we can set exact voltage/freq pairs,
and not need use the voltage-tolerance to set tolerance.

Thanks
-RongJun Ying
> 
> 
>  To report this email as spam click
> https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==
> ch0RRg48Kxe8iwle4qrOOz8w5o+DwGNVtWag1M3YVHc55g== .


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at 
http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-06 Thread Rongjun Ying


 -Original Message-
 From: Shawn Guo [mailto:shawn@linaro.org]
 Sent: Wednesday, November 06, 2013 11:28 AM
 To: Rongjun Ying
 Cc: Viresh Kumar; rjying; Rafael J. Wysocki; cpuf...@vger.kernel.org;
 linux...@vger.kernel.org; Linux Kernel Mailing List;
 rongjun.y...@gcsr.com
 Subject: Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage
 instead of voltage-tolerance
 
 On Wed, Nov 06, 2013 at 02:15:07AM +, Rongjun Ying wrote:
  If omit voltage-tolerance, sometimes also can't get appropriate
 voltages.
  For example:
  If the regulator IC only can supply min voltage is 1.000V and max
 voltage is 1.200V, and cpu work max voltage is 1.200V.
  But the cpu just need 1.100V when cpu run under a freq.
  So regulator_set_voltage_tol will return failed.
  Because the regulator_set_voltage will invoke with min-uV is 110
 and max-uV is 110 parameters.
  Regulator can't supply it.
  As this case, the regulator just need supply 1.200V.
 
 For given board, what voltages could be provided is known.  So you can
 just define OPP table in board.dts and specify the voltage as the
 value that the regulator IC can supply, e.g. 1.200V in above example.
 
 This is not nice, as OPP table is CPU/SoC specific and should be
 ideally defined in soc.dtsi.  But still it's a way out for you to use
 cpufreq-cpu0 driver as it is.
 
 In any case, you can not just change voltage-tolerance to voltage-max
 with no care about the existing users.
 
 Shawn
 
I don't think so. The voltage/freq pairs are attribute of the CPU.
Any boards can choose regulator IC base the cost and other reasons.
If the opp table defined in board.dts, we can set exact voltage/freq pairs,
and not need use the voltage-tolerance to set tolerance.

Thanks
-RongJun Ying
 
 
  To report this email as spam click
 https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==
 ch0RRg48Kxe8iwle4qrOOz8w5o+DwGNVtWag1M3YVHc55g== .


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at 
http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-06 Thread Shawn Guo
On Thu, Nov 07, 2013 at 01:55:21AM +, Rongjun Ying wrote:
  For given board, what voltages could be provided is known.  So you can
  just define OPP table in board.dts and specify the voltage as the
  value that the regulator IC can supply, e.g. 1.200V in above example.
  
  This is not nice, as OPP table is CPU/SoC specific and should be
  ideally defined in soc.dtsi.  But still it's a way out for you to use
  cpufreq-cpu0 driver as it is.
  
  In any case, you can not just change voltage-tolerance to voltage-max
  with no care about the existing users.
  
  Shawn
  
 I don't think so. The voltage/freq pairs are attribute of the CPU.
 Any boards can choose regulator IC base the cost and other reasons.
 If the opp table defined in board.dts, we can set exact voltage/freq pairs,
 and not need use the voltage-tolerance to set tolerance.

If you read my comment above, you should see that I agree OPP is
CPU/SoC specific and should be defined in soc.dtsi.  But property
operating-points can reasonably be overwritten by particular board.dts
for some reason like some voltages cannot be supplied on that board.

Again, this is just a way for you to use generic cpufreq-cpu0 driver as
it is, but not necessarily the best one.

Shawn

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-06 Thread Rongjun Ying


 -Original Message-
 From: Shawn Guo [mailto:shawn@linaro.org]
 Sent: Thursday, November 07, 2013 10:27 AM
 To: Rongjun Ying
 Cc: Viresh Kumar; rjying; Rafael J. Wysocki; cpuf...@vger.kernel.org;
 linux...@vger.kernel.org; Linux Kernel Mailing List; Barry Song
 Subject: Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage
 instead of voltage-tolerance
 
 On Thu, Nov 07, 2013 at 01:55:21AM +, Rongjun Ying wrote:
   For given board, what voltages could be provided is known.  So you
   can just define OPP table in board.dts and specify the voltage as
   the value that the regulator IC can supply, e.g. 1.200V in above
 example.
  
   This is not nice, as OPP table is CPU/SoC specific and should be
   ideally defined in soc.dtsi.  But still it's a way out for you to
   use
   cpufreq-cpu0 driver as it is.
  
   In any case, you can not just change voltage-tolerance to
   voltage-max with no care about the existing users.
  
   Shawn
  
  I don't think so. The voltage/freq pairs are attribute of the CPU.
  Any boards can choose regulator IC base the cost and other reasons.
  If the opp table defined in board.dts, we can set exact
 voltage/freq
  pairs, and not need use the voltage-tolerance to set tolerance.
 
 If you read my comment above, you should see that I agree OPP is
 CPU/SoC specific and should be defined in soc.dtsi.  But property
 operating-points can reasonably be overwritten by particular
 board.dts for some reason like some voltages cannot be supplied on
 that board.
 
 Again, this is just a way for you to use generic cpufreq-cpu0 driver as
 it is, but not necessarily the best one.
 
 Shawn
 

I think my patch is better.
All soc have a max work voltage. If regulator IC can't supply min voltage, 
It can supply max voltage to soc.
As my patch, not need overwrite OPP in board.dts.
As your comment above, almost all board need overwrite OPP, unless the 
regulator 
IC can supply all voltage ranges of SoC need.

Thanks
-RongJun Ying
 
 
  To report this email as spam click
 https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==
 aM23S6+s5uWr7qEkawiSK+0AUqjCk0gm6KMeRLY+cWrx9g== .


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at 
http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-06 Thread Shawn Guo
On Thu, Nov 07, 2013 at 03:32:09AM +, Rongjun Ying wrote:
 I think my patch is better.

Well, unfortunately your patch is plainly wrong, because there are
in-tree users of voltage-tolerance right now.  How can you simply remove
it from driver with ignoring these users?

$ git grep voltage-tolerance arch/arm/boot/dts
arch/arm/boot/dts/am33xx.dtsi:  voltage-tolerance = 2; /* 2 
percentage */
arch/arm/boot/dts/imx27.dtsi:   voltage-tolerance = 5;
arch/arm/boot/dts/r8a73a4-ape6evm-reference.dts:voltage-tolerance = 
1; /* 1% */
arch/arm/boot/dts/r8a73a4-ape6evm.dts:  voltage-tolerance = 1; /* 1% */
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts:   
voltage-tolerance = 1; /* 1% */

Shawn

 All soc have a max work voltage. If regulator IC can't supply min voltage, 
 It can supply max voltage to soc.
 As my patch, not need overwrite OPP in board.dts.
 As your comment above, almost all board need overwrite OPP, unless the 
 regulator 
 IC can supply all voltage ranges of SoC need.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-05 Thread Shawn Guo
On Wed, Nov 06, 2013 at 02:15:07AM +, Rongjun Ying wrote:
> If omit voltage-tolerance, sometimes also can't get appropriate voltages.
> For example:
> If the regulator IC only can supply min voltage is 1.000V and max voltage is 
> 1.200V, and cpu work max voltage is 1.200V.
> But the cpu just need 1.100V when cpu run under a freq.
> So regulator_set_voltage_tol will return failed. 
> Because the regulator_set_voltage will invoke with min-uV is 110 and 
> max-uV is 110 parameters.
> Regulator can't supply it.
> As this case, the regulator just need supply 1.200V.

For given board, what voltages could be provided is known.  So you can
just define OPP table in .dts and specify the voltage as the
value that the regulator IC can supply, e.g. 1.200V in above example.

This is not nice, as OPP table is CPU/SoC specific and should be ideally
defined in .dtsi.  But still it's a way out for you to use
cpufreq-cpu0 driver as it is.

In any case, you can not just change voltage-tolerance to voltage-max
with no care about the existing users.

Shawn

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-05 Thread Rongjun Ying


> -Original Message-
> From: Shawn Guo [mailto:shawn@linaro.org]
> Sent: Tuesday, November 05, 2013 7:53 PM
> To: Viresh Kumar
> Cc: rjying; Rafael J. Wysocki; cpuf...@vger.kernel.org; linux-
> p...@vger.kernel.org; Linux Kernel Mailing List; rongjun.y...@gcsr.com;
> Rongjun Ying
> Subject: Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage
> instead of voltage-tolerance
> 
> On Tue, Nov 05, 2013 at 10:08:06AM +0530, Viresh Kumar wrote:
> > Adding shawn in cc list..
> >
> > On 5 November 2013 08:40, rjying  wrote:
> > > From: Rongjun Ying 
> > >
> > > Sometime the regulator can't supply appropriate voltages for
> requestion of cpu.
> > > All voltage tolerance value can't figure out a good voltage.
> 
> The voltage-tolerance is an optional device tree property.  You can
> omit it if you do not have a value for it.
> 
> Shawn

It bounced for some reason, trying to send again.

If omit voltage-tolerance, sometimes also can't get appropriate voltages.
For example:
If the regulator IC only can supply min voltage is 1.000V and max voltage is 
1.200V, and cpu work max voltage is 1.200V.
But the cpu just need 1.100V when cpu run under a freq.
So regulator_set_voltage_tol will return failed. 
Because the regulator_set_voltage will invoke with min-uV is 110 and max-uV 
is 110 parameters.
Regulator can't supply it.
As this case, the regulator just need supply 1.200V.

RongJun Ying
> 
> > >
> > > Signed-off-by: Rongjun Ying 
> > > ---
> > >  drivers/cpufreq/cpufreq-cpu0.c |   17 ++---
> > >  1 files changed, 10 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/drivers/cpufreq/cpufreq-cpu0.c
> > > b/drivers/cpufreq/cpufreq-cpu0.c index c522a95..0c9e6b9 100644
> > > --- a/drivers/cpufreq/cpufreq-cpu0.c
> > > +++ b/drivers/cpufreq/cpufreq-cpu0.c
> > > @@ -23,7 +23,7 @@
> > >  #include 
> > >
> > >  static unsigned int transition_latency; -static unsigned int
> > > voltage_tolerance; /* in percentage */
> > > +static unsigned int voltage_max;
> > >
> > >  static struct device *cpu_dev;
> > >  static struct clk *cpu_clk;
> > > @@ -45,7 +45,7 @@ static int cpu0_set_target(struct cpufreq_policy
> > > *policy,  {
> > > struct cpufreq_freqs freqs;
> > > struct opp *opp;
> > > -   unsigned long volt = 0, volt_old = 0, tol = 0;
> > > +   unsigned long volt = 0, volt_old = 0;
> > > long freq_Hz, freq_exact;
> > > unsigned int index;
> > > int ret;
> > > @@ -82,7 +82,6 @@ static int cpu0_set_target(struct cpufreq_policy
> *policy,
> > > }
> > > volt = opp_get_voltage(opp);
> > > rcu_read_unlock();
> > > -   tol = volt * voltage_tolerance / 100;
> > > volt_old = regulator_get_voltage(cpu_reg);
> > > }
> > >
> > > @@ -92,7 +91,7 @@ static int cpu0_set_target(struct cpufreq_policy
> > > *policy,
> > >
> > > /* scaling up?  scale voltage before frequency */
> > > if (!IS_ERR(cpu_reg) && freqs.new > freqs.old) {
> > > -   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
> > > +   ret = regulator_set_voltage(cpu_reg, volt,
> > > + voltage_max);
> > > if (ret) {
> > > pr_err("failed to scale voltage up: %d\n",
> ret);
> > > freqs.new = freqs.old; @@ -104,14 +103,14
> @@
> > > static int cpu0_set_target(struct cpufreq_policy *policy,
> > > if (ret) {
> > > pr_err("failed to set clock rate: %d\n", ret);
> > > if (!IS_ERR(cpu_reg))
> > > -   regulator_set_voltage_tol(cpu_reg, volt_old,
> tol);
> > > +   regulator_set_voltage(cpu_reg, volt_old,
> > > + voltage_max);
> > > freqs.new = freqs.old;
> > > goto post_notify;
> > > }
> > >
> > > /* scaling down?  scale voltage after frequency */
> > > if (!IS_ERR(cpu_reg) && freqs.new < freqs.old) {
> > > -   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
> > > +   ret = regulator_set_voltage(cpu_reg, volt,
> > > + voltage_max);
> > > if (ret) {
> > > pr_err("failed to scale vo

Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-05 Thread Shawn Guo
On Tue, Nov 05, 2013 at 10:08:06AM +0530, Viresh Kumar wrote:
> Adding shawn in cc list..
> 
> On 5 November 2013 08:40, rjying  wrote:
> > From: Rongjun Ying 
> >
> > Sometime the regulator can't supply appropriate voltages for requestion of 
> > cpu.
> > All voltage tolerance value can't figure out a good voltage.

The voltage-tolerance is an optional device tree property.  You can omit
it if you do not have a value for it.

Shawn

> >
> > Signed-off-by: Rongjun Ying 
> > ---
> >  drivers/cpufreq/cpufreq-cpu0.c |   17 ++---
> >  1 files changed, 10 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
> > index c522a95..0c9e6b9 100644
> > --- a/drivers/cpufreq/cpufreq-cpu0.c
> > +++ b/drivers/cpufreq/cpufreq-cpu0.c
> > @@ -23,7 +23,7 @@
> >  #include 
> >
> >  static unsigned int transition_latency;
> > -static unsigned int voltage_tolerance; /* in percentage */
> > +static unsigned int voltage_max;
> >
> >  static struct device *cpu_dev;
> >  static struct clk *cpu_clk;
> > @@ -45,7 +45,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
> >  {
> > struct cpufreq_freqs freqs;
> > struct opp *opp;
> > -   unsigned long volt = 0, volt_old = 0, tol = 0;
> > +   unsigned long volt = 0, volt_old = 0;
> > long freq_Hz, freq_exact;
> > unsigned int index;
> > int ret;
> > @@ -82,7 +82,6 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
> > }
> > volt = opp_get_voltage(opp);
> > rcu_read_unlock();
> > -   tol = volt * voltage_tolerance / 100;
> > volt_old = regulator_get_voltage(cpu_reg);
> > }
> >
> > @@ -92,7 +91,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
> >
> > /* scaling up?  scale voltage before frequency */
> > if (!IS_ERR(cpu_reg) && freqs.new > freqs.old) {
> > -   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
> > +   ret = regulator_set_voltage(cpu_reg, volt, voltage_max);
> > if (ret) {
> > pr_err("failed to scale voltage up: %d\n", ret);
> > freqs.new = freqs.old;
> > @@ -104,14 +103,14 @@ static int cpu0_set_target(struct cpufreq_policy 
> > *policy,
> > if (ret) {
> > pr_err("failed to set clock rate: %d\n", ret);
> > if (!IS_ERR(cpu_reg))
> > -   regulator_set_voltage_tol(cpu_reg, volt_old, tol);
> > +   regulator_set_voltage(cpu_reg, volt_old, 
> > voltage_max);
> > freqs.new = freqs.old;
> > goto post_notify;
> > }
> >
> > /* scaling down?  scale voltage after frequency */
> > if (!IS_ERR(cpu_reg) && freqs.new < freqs.old) {
> > -   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
> > +   ret = regulator_set_voltage(cpu_reg, volt, voltage_max);
> > if (ret) {
> > pr_err("failed to scale voltage down: %d\n", ret);
> > clk_set_rate(cpu_clk, freqs.old * 1000);
> > @@ -224,7 +223,11 @@ static int cpu0_cpufreq_probe(struct platform_device 
> > *pdev)
> > goto out_put_node;
> > }
> >
> > -   of_property_read_u32(np, "voltage-tolerance", _tolerance);
> > +   ret = of_property_read_u32(np, "voltage-max", _max);
> > +   if (ret) {
> > +   pr_err("failed to get max voltage: %d\n", ret);
> > +   goto out_put_node;
> > +   }
> >
> > if (of_property_read_u32(np, "clock-latency", _latency))
> > transition_latency = CPUFREQ_ETERNAL;
> > --
> > 1.7.5.4
> >

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-05 Thread Shawn Guo
On Tue, Nov 05, 2013 at 10:08:06AM +0530, Viresh Kumar wrote:
 Adding shawn in cc list..
 
 On 5 November 2013 08:40, rjying rjy...@gmail.com wrote:
  From: Rongjun Ying rongjun.y...@csr.com
 
  Sometime the regulator can't supply appropriate voltages for requestion of 
  cpu.
  All voltage tolerance value can't figure out a good voltage.

The voltage-tolerance is an optional device tree property.  You can omit
it if you do not have a value for it.

Shawn

 
  Signed-off-by: Rongjun Ying rongjun.y...@csr.com
  ---
   drivers/cpufreq/cpufreq-cpu0.c |   17 ++---
   1 files changed, 10 insertions(+), 7 deletions(-)
 
  diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
  index c522a95..0c9e6b9 100644
  --- a/drivers/cpufreq/cpufreq-cpu0.c
  +++ b/drivers/cpufreq/cpufreq-cpu0.c
  @@ -23,7 +23,7 @@
   #include linux/slab.h
 
   static unsigned int transition_latency;
  -static unsigned int voltage_tolerance; /* in percentage */
  +static unsigned int voltage_max;
 
   static struct device *cpu_dev;
   static struct clk *cpu_clk;
  @@ -45,7 +45,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
   {
  struct cpufreq_freqs freqs;
  struct opp *opp;
  -   unsigned long volt = 0, volt_old = 0, tol = 0;
  +   unsigned long volt = 0, volt_old = 0;
  long freq_Hz, freq_exact;
  unsigned int index;
  int ret;
  @@ -82,7 +82,6 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
  }
  volt = opp_get_voltage(opp);
  rcu_read_unlock();
  -   tol = volt * voltage_tolerance / 100;
  volt_old = regulator_get_voltage(cpu_reg);
  }
 
  @@ -92,7 +91,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
 
  /* scaling up?  scale voltage before frequency */
  if (!IS_ERR(cpu_reg)  freqs.new  freqs.old) {
  -   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
  +   ret = regulator_set_voltage(cpu_reg, volt, voltage_max);
  if (ret) {
  pr_err(failed to scale voltage up: %d\n, ret);
  freqs.new = freqs.old;
  @@ -104,14 +103,14 @@ static int cpu0_set_target(struct cpufreq_policy 
  *policy,
  if (ret) {
  pr_err(failed to set clock rate: %d\n, ret);
  if (!IS_ERR(cpu_reg))
  -   regulator_set_voltage_tol(cpu_reg, volt_old, tol);
  +   regulator_set_voltage(cpu_reg, volt_old, 
  voltage_max);
  freqs.new = freqs.old;
  goto post_notify;
  }
 
  /* scaling down?  scale voltage after frequency */
  if (!IS_ERR(cpu_reg)  freqs.new  freqs.old) {
  -   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
  +   ret = regulator_set_voltage(cpu_reg, volt, voltage_max);
  if (ret) {
  pr_err(failed to scale voltage down: %d\n, ret);
  clk_set_rate(cpu_clk, freqs.old * 1000);
  @@ -224,7 +223,11 @@ static int cpu0_cpufreq_probe(struct platform_device 
  *pdev)
  goto out_put_node;
  }
 
  -   of_property_read_u32(np, voltage-tolerance, voltage_tolerance);
  +   ret = of_property_read_u32(np, voltage-max, voltage_max);
  +   if (ret) {
  +   pr_err(failed to get max voltage: %d\n, ret);
  +   goto out_put_node;
  +   }
 
  if (of_property_read_u32(np, clock-latency, transition_latency))
  transition_latency = CPUFREQ_ETERNAL;
  --
  1.7.5.4
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-05 Thread Rongjun Ying


 -Original Message-
 From: Shawn Guo [mailto:shawn@linaro.org]
 Sent: Tuesday, November 05, 2013 7:53 PM
 To: Viresh Kumar
 Cc: rjying; Rafael J. Wysocki; cpuf...@vger.kernel.org; linux-
 p...@vger.kernel.org; Linux Kernel Mailing List; rongjun.y...@gcsr.com;
 Rongjun Ying
 Subject: Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage
 instead of voltage-tolerance
 
 On Tue, Nov 05, 2013 at 10:08:06AM +0530, Viresh Kumar wrote:
  Adding shawn in cc list..
 
  On 5 November 2013 08:40, rjying rjy...@gmail.com wrote:
   From: Rongjun Ying rongjun.y...@csr.com
  
   Sometime the regulator can't supply appropriate voltages for
 requestion of cpu.
   All voltage tolerance value can't figure out a good voltage.
 
 The voltage-tolerance is an optional device tree property.  You can
 omit it if you do not have a value for it.
 
 Shawn

It bounced for some reason, trying to send again.

If omit voltage-tolerance, sometimes also can't get appropriate voltages.
For example:
If the regulator IC only can supply min voltage is 1.000V and max voltage is 
1.200V, and cpu work max voltage is 1.200V.
But the cpu just need 1.100V when cpu run under a freq.
So regulator_set_voltage_tol will return failed. 
Because the regulator_set_voltage will invoke with min-uV is 110 and max-uV 
is 110 parameters.
Regulator can't supply it.
As this case, the regulator just need supply 1.200V.

RongJun Ying
 
  
   Signed-off-by: Rongjun Ying rongjun.y...@csr.com
   ---
drivers/cpufreq/cpufreq-cpu0.c |   17 ++---
1 files changed, 10 insertions(+), 7 deletions(-)
  
   diff --git a/drivers/cpufreq/cpufreq-cpu0.c
   b/drivers/cpufreq/cpufreq-cpu0.c index c522a95..0c9e6b9 100644
   --- a/drivers/cpufreq/cpufreq-cpu0.c
   +++ b/drivers/cpufreq/cpufreq-cpu0.c
   @@ -23,7 +23,7 @@
#include linux/slab.h
  
static unsigned int transition_latency; -static unsigned int
   voltage_tolerance; /* in percentage */
   +static unsigned int voltage_max;
  
static struct device *cpu_dev;
static struct clk *cpu_clk;
   @@ -45,7 +45,7 @@ static int cpu0_set_target(struct cpufreq_policy
   *policy,  {
   struct cpufreq_freqs freqs;
   struct opp *opp;
   -   unsigned long volt = 0, volt_old = 0, tol = 0;
   +   unsigned long volt = 0, volt_old = 0;
   long freq_Hz, freq_exact;
   unsigned int index;
   int ret;
   @@ -82,7 +82,6 @@ static int cpu0_set_target(struct cpufreq_policy
 *policy,
   }
   volt = opp_get_voltage(opp);
   rcu_read_unlock();
   -   tol = volt * voltage_tolerance / 100;
   volt_old = regulator_get_voltage(cpu_reg);
   }
  
   @@ -92,7 +91,7 @@ static int cpu0_set_target(struct cpufreq_policy
   *policy,
  
   /* scaling up?  scale voltage before frequency */
   if (!IS_ERR(cpu_reg)  freqs.new  freqs.old) {
   -   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
   +   ret = regulator_set_voltage(cpu_reg, volt,
   + voltage_max);
   if (ret) {
   pr_err(failed to scale voltage up: %d\n,
 ret);
   freqs.new = freqs.old; @@ -104,14 +103,14
 @@
   static int cpu0_set_target(struct cpufreq_policy *policy,
   if (ret) {
   pr_err(failed to set clock rate: %d\n, ret);
   if (!IS_ERR(cpu_reg))
   -   regulator_set_voltage_tol(cpu_reg, volt_old,
 tol);
   +   regulator_set_voltage(cpu_reg, volt_old,
   + voltage_max);
   freqs.new = freqs.old;
   goto post_notify;
   }
  
   /* scaling down?  scale voltage after frequency */
   if (!IS_ERR(cpu_reg)  freqs.new  freqs.old) {
   -   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
   +   ret = regulator_set_voltage(cpu_reg, volt,
   + voltage_max);
   if (ret) {
   pr_err(failed to scale voltage down: %d\n,
 ret);
   clk_set_rate(cpu_clk, freqs.old * 1000); @@
   -224,7 +223,11 @@ static int cpu0_cpufreq_probe(struct
 platform_device *pdev)
   goto out_put_node;
   }
  
   -   of_property_read_u32(np, voltage-tolerance,
 voltage_tolerance);
   +   ret = of_property_read_u32(np, voltage-max, voltage_max);
   +   if (ret) {
   +   pr_err(failed to get max voltage: %d\n, ret);
   +   goto out_put_node;
   +   }
  
   if (of_property_read_u32(np, clock-latency,
 transition_latency))
   transition_latency = CPUFREQ_ETERNAL;
   --
   1.7.5.4
  
 
 
 
  To report this email as spam click
 https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==
 X88IR7qi8t8XvyHQDjR!61qPoTyr8GNFXkv3KeH4!zzvzA== .


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number

Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-05 Thread Shawn Guo
On Wed, Nov 06, 2013 at 02:15:07AM +, Rongjun Ying wrote:
 If omit voltage-tolerance, sometimes also can't get appropriate voltages.
 For example:
 If the regulator IC only can supply min voltage is 1.000V and max voltage is 
 1.200V, and cpu work max voltage is 1.200V.
 But the cpu just need 1.100V when cpu run under a freq.
 So regulator_set_voltage_tol will return failed. 
 Because the regulator_set_voltage will invoke with min-uV is 110 and 
 max-uV is 110 parameters.
 Regulator can't supply it.
 As this case, the regulator just need supply 1.200V.

For given board, what voltages could be provided is known.  So you can
just define OPP table in board.dts and specify the voltage as the
value that the regulator IC can supply, e.g. 1.200V in above example.

This is not nice, as OPP table is CPU/SoC specific and should be ideally
defined in soc.dtsi.  But still it's a way out for you to use
cpufreq-cpu0 driver as it is.

In any case, you can not just change voltage-tolerance to voltage-max
with no care about the existing users.

Shawn

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-04 Thread Viresh Kumar
Adding shawn in cc list..

On 5 November 2013 08:40, rjying  wrote:
> From: Rongjun Ying 
>
> Sometime the regulator can't supply appropriate voltages for requestion of 
> cpu.
> All voltage tolerance value can't figure out a good voltage.
>
> Signed-off-by: Rongjun Ying 
> ---
>  drivers/cpufreq/cpufreq-cpu0.c |   17 ++---
>  1 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
> index c522a95..0c9e6b9 100644
> --- a/drivers/cpufreq/cpufreq-cpu0.c
> +++ b/drivers/cpufreq/cpufreq-cpu0.c
> @@ -23,7 +23,7 @@
>  #include 
>
>  static unsigned int transition_latency;
> -static unsigned int voltage_tolerance; /* in percentage */
> +static unsigned int voltage_max;
>
>  static struct device *cpu_dev;
>  static struct clk *cpu_clk;
> @@ -45,7 +45,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
>  {
> struct cpufreq_freqs freqs;
> struct opp *opp;
> -   unsigned long volt = 0, volt_old = 0, tol = 0;
> +   unsigned long volt = 0, volt_old = 0;
> long freq_Hz, freq_exact;
> unsigned int index;
> int ret;
> @@ -82,7 +82,6 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
> }
> volt = opp_get_voltage(opp);
> rcu_read_unlock();
> -   tol = volt * voltage_tolerance / 100;
> volt_old = regulator_get_voltage(cpu_reg);
> }
>
> @@ -92,7 +91,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
>
> /* scaling up?  scale voltage before frequency */
> if (!IS_ERR(cpu_reg) && freqs.new > freqs.old) {
> -   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
> +   ret = regulator_set_voltage(cpu_reg, volt, voltage_max);
> if (ret) {
> pr_err("failed to scale voltage up: %d\n", ret);
> freqs.new = freqs.old;
> @@ -104,14 +103,14 @@ static int cpu0_set_target(struct cpufreq_policy 
> *policy,
> if (ret) {
> pr_err("failed to set clock rate: %d\n", ret);
> if (!IS_ERR(cpu_reg))
> -   regulator_set_voltage_tol(cpu_reg, volt_old, tol);
> +   regulator_set_voltage(cpu_reg, volt_old, voltage_max);
> freqs.new = freqs.old;
> goto post_notify;
> }
>
> /* scaling down?  scale voltage after frequency */
> if (!IS_ERR(cpu_reg) && freqs.new < freqs.old) {
> -   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
> +   ret = regulator_set_voltage(cpu_reg, volt, voltage_max);
> if (ret) {
> pr_err("failed to scale voltage down: %d\n", ret);
> clk_set_rate(cpu_clk, freqs.old * 1000);
> @@ -224,7 +223,11 @@ static int cpu0_cpufreq_probe(struct platform_device 
> *pdev)
> goto out_put_node;
> }
>
> -   of_property_read_u32(np, "voltage-tolerance", _tolerance);
> +   ret = of_property_read_u32(np, "voltage-max", _max);
> +   if (ret) {
> +   pr_err("failed to get max voltage: %d\n", ret);
> +   goto out_put_node;
> +   }
>
> if (of_property_read_u32(np, "clock-latency", _latency))
> transition_latency = CPUFREQ_ETERNAL;
> --
> 1.7.5.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-04 Thread rjying
From: Rongjun Ying 

Sometime the regulator can't supply appropriate voltages for requestion of cpu.
All voltage tolerance value can't figure out a good voltage.

Signed-off-by: Rongjun Ying 
---
 drivers/cpufreq/cpufreq-cpu0.c |   17 ++---
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index c522a95..0c9e6b9 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -23,7 +23,7 @@
 #include 
 
 static unsigned int transition_latency;
-static unsigned int voltage_tolerance; /* in percentage */
+static unsigned int voltage_max;
 
 static struct device *cpu_dev;
 static struct clk *cpu_clk;
@@ -45,7 +45,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
 {
struct cpufreq_freqs freqs;
struct opp *opp;
-   unsigned long volt = 0, volt_old = 0, tol = 0;
+   unsigned long volt = 0, volt_old = 0;
long freq_Hz, freq_exact;
unsigned int index;
int ret;
@@ -82,7 +82,6 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
}
volt = opp_get_voltage(opp);
rcu_read_unlock();
-   tol = volt * voltage_tolerance / 100;
volt_old = regulator_get_voltage(cpu_reg);
}
 
@@ -92,7 +91,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
 
/* scaling up?  scale voltage before frequency */
if (!IS_ERR(cpu_reg) && freqs.new > freqs.old) {
-   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
+   ret = regulator_set_voltage(cpu_reg, volt, voltage_max);
if (ret) {
pr_err("failed to scale voltage up: %d\n", ret);
freqs.new = freqs.old;
@@ -104,14 +103,14 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
if (ret) {
pr_err("failed to set clock rate: %d\n", ret);
if (!IS_ERR(cpu_reg))
-   regulator_set_voltage_tol(cpu_reg, volt_old, tol);
+   regulator_set_voltage(cpu_reg, volt_old, voltage_max);
freqs.new = freqs.old;
goto post_notify;
}
 
/* scaling down?  scale voltage after frequency */
if (!IS_ERR(cpu_reg) && freqs.new < freqs.old) {
-   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
+   ret = regulator_set_voltage(cpu_reg, volt, voltage_max);
if (ret) {
pr_err("failed to scale voltage down: %d\n", ret);
clk_set_rate(cpu_clk, freqs.old * 1000);
@@ -224,7 +223,11 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
goto out_put_node;
}
 
-   of_property_read_u32(np, "voltage-tolerance", _tolerance);
+   ret = of_property_read_u32(np, "voltage-max", _max);
+   if (ret) {
+   pr_err("failed to get max voltage: %d\n", ret);
+   goto out_put_node;
+   }
 
if (of_property_read_u32(np, "clock-latency", _latency))
transition_latency = CPUFREQ_ETERNAL;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-04 Thread rjying
From: Rongjun Ying rongjun.y...@csr.com

Sometime the regulator can't supply appropriate voltages for requestion of cpu.
All voltage tolerance value can't figure out a good voltage.

Signed-off-by: Rongjun Ying rongjun.y...@csr.com
---
 drivers/cpufreq/cpufreq-cpu0.c |   17 ++---
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index c522a95..0c9e6b9 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -23,7 +23,7 @@
 #include linux/slab.h
 
 static unsigned int transition_latency;
-static unsigned int voltage_tolerance; /* in percentage */
+static unsigned int voltage_max;
 
 static struct device *cpu_dev;
 static struct clk *cpu_clk;
@@ -45,7 +45,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
 {
struct cpufreq_freqs freqs;
struct opp *opp;
-   unsigned long volt = 0, volt_old = 0, tol = 0;
+   unsigned long volt = 0, volt_old = 0;
long freq_Hz, freq_exact;
unsigned int index;
int ret;
@@ -82,7 +82,6 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
}
volt = opp_get_voltage(opp);
rcu_read_unlock();
-   tol = volt * voltage_tolerance / 100;
volt_old = regulator_get_voltage(cpu_reg);
}
 
@@ -92,7 +91,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
 
/* scaling up?  scale voltage before frequency */
if (!IS_ERR(cpu_reg)  freqs.new  freqs.old) {
-   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
+   ret = regulator_set_voltage(cpu_reg, volt, voltage_max);
if (ret) {
pr_err(failed to scale voltage up: %d\n, ret);
freqs.new = freqs.old;
@@ -104,14 +103,14 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
if (ret) {
pr_err(failed to set clock rate: %d\n, ret);
if (!IS_ERR(cpu_reg))
-   regulator_set_voltage_tol(cpu_reg, volt_old, tol);
+   regulator_set_voltage(cpu_reg, volt_old, voltage_max);
freqs.new = freqs.old;
goto post_notify;
}
 
/* scaling down?  scale voltage after frequency */
if (!IS_ERR(cpu_reg)  freqs.new  freqs.old) {
-   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
+   ret = regulator_set_voltage(cpu_reg, volt, voltage_max);
if (ret) {
pr_err(failed to scale voltage down: %d\n, ret);
clk_set_rate(cpu_clk, freqs.old * 1000);
@@ -224,7 +223,11 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
goto out_put_node;
}
 
-   of_property_read_u32(np, voltage-tolerance, voltage_tolerance);
+   ret = of_property_read_u32(np, voltage-max, voltage_max);
+   if (ret) {
+   pr_err(failed to get max voltage: %d\n, ret);
+   goto out_put_node;
+   }
 
if (of_property_read_u32(np, clock-latency, transition_latency))
transition_latency = CPUFREQ_ETERNAL;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance

2013-11-04 Thread Viresh Kumar
Adding shawn in cc list..

On 5 November 2013 08:40, rjying rjy...@gmail.com wrote:
 From: Rongjun Ying rongjun.y...@csr.com

 Sometime the regulator can't supply appropriate voltages for requestion of 
 cpu.
 All voltage tolerance value can't figure out a good voltage.

 Signed-off-by: Rongjun Ying rongjun.y...@csr.com
 ---
  drivers/cpufreq/cpufreq-cpu0.c |   17 ++---
  1 files changed, 10 insertions(+), 7 deletions(-)

 diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
 index c522a95..0c9e6b9 100644
 --- a/drivers/cpufreq/cpufreq-cpu0.c
 +++ b/drivers/cpufreq/cpufreq-cpu0.c
 @@ -23,7 +23,7 @@
  #include linux/slab.h

  static unsigned int transition_latency;
 -static unsigned int voltage_tolerance; /* in percentage */
 +static unsigned int voltage_max;

  static struct device *cpu_dev;
  static struct clk *cpu_clk;
 @@ -45,7 +45,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
  {
 struct cpufreq_freqs freqs;
 struct opp *opp;
 -   unsigned long volt = 0, volt_old = 0, tol = 0;
 +   unsigned long volt = 0, volt_old = 0;
 long freq_Hz, freq_exact;
 unsigned int index;
 int ret;
 @@ -82,7 +82,6 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
 }
 volt = opp_get_voltage(opp);
 rcu_read_unlock();
 -   tol = volt * voltage_tolerance / 100;
 volt_old = regulator_get_voltage(cpu_reg);
 }

 @@ -92,7 +91,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,

 /* scaling up?  scale voltage before frequency */
 if (!IS_ERR(cpu_reg)  freqs.new  freqs.old) {
 -   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
 +   ret = regulator_set_voltage(cpu_reg, volt, voltage_max);
 if (ret) {
 pr_err(failed to scale voltage up: %d\n, ret);
 freqs.new = freqs.old;
 @@ -104,14 +103,14 @@ static int cpu0_set_target(struct cpufreq_policy 
 *policy,
 if (ret) {
 pr_err(failed to set clock rate: %d\n, ret);
 if (!IS_ERR(cpu_reg))
 -   regulator_set_voltage_tol(cpu_reg, volt_old, tol);
 +   regulator_set_voltage(cpu_reg, volt_old, voltage_max);
 freqs.new = freqs.old;
 goto post_notify;
 }

 /* scaling down?  scale voltage after frequency */
 if (!IS_ERR(cpu_reg)  freqs.new  freqs.old) {
 -   ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
 +   ret = regulator_set_voltage(cpu_reg, volt, voltage_max);
 if (ret) {
 pr_err(failed to scale voltage down: %d\n, ret);
 clk_set_rate(cpu_clk, freqs.old * 1000);
 @@ -224,7 +223,11 @@ static int cpu0_cpufreq_probe(struct platform_device 
 *pdev)
 goto out_put_node;
 }

 -   of_property_read_u32(np, voltage-tolerance, voltage_tolerance);
 +   ret = of_property_read_u32(np, voltage-max, voltage_max);
 +   if (ret) {
 +   pr_err(failed to get max voltage: %d\n, ret);
 +   goto out_put_node;
 +   }

 if (of_property_read_u32(np, clock-latency, transition_latency))
 transition_latency = CPUFREQ_ETERNAL;
 --
 1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/