* [PATCH V3 1/2] ARM: imx: add vddsoc/pu setpoint info into dts
@ 2013-12-18 21:26 Anson Huang
2013-12-18 11:08 ` Fabio Estevam
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Anson Huang @ 2013-12-18 21:26 UTC (permalink / raw)
To: shawn.guo, rjw, viresh.kumar
Cc: cpufreq, linux-pm, linux-arm-kernel, devicetree
i.MX6Q needs to update vddarm, vddsoc/pu regulators when cpu freq
is changed, each setpoint has different voltage, so we need to
pass vddarm, vddsoc/pu's freq-voltage info from dts together.
Signed-off-by: Anson Huang <b20788@freescale.com>
---
.../devicetree/bindings/cpufreq/cpufreq-imx6.txt | 56 ++++++++++++++++++++
arch/arm/boot/dts/imx6q.dtsi | 7 +++
2 files changed, 63 insertions(+)
create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-imx6.txt
diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-imx6.txt b/Documentation/devicetree/bindings/cpufreq/cpufreq-imx6.txt
new file mode 100644
index 0000000..cf1c5f7
--- /dev/null
+++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-imx6.txt
@@ -0,0 +1,56 @@
+i.MX6 cpufreq driver
+-------------------
+
+i.MX6 SoC cpufreq driver for CPU frequency scaling.
+
+This binding doc defines properties that must be put in the /cpus/cpu@0 node,
+please refer to Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt
+for detail.
+
+Required properties:
+- operating-points: Refer to Documentation/devicetree/bindings/power/opp.txt
+ for details.
+- clocks: Specify clocks that need to be used when cpu frequency is scaled,
+ refer to Documentation/devicetree/bindings/clock/clock-bindings.txt for
+ details.
+- clock-names: List of clock input name strings sorted in the same order as the
+ clocks property, refer to Documentation/devicetree/bindings/clock/clock-bindings.txt
+ for details.
+- xxx-supply: Input voltage supply regulator, refer to
+ Documentation/devicetree/bindings/regulator/regulator.txt for details.
+ arm-supply: vddarm input.
+ pu-supply: vddpu input.
+ soc-supply: vddsoc input.
+
+Optional properties:
+- fsl,soc-operating-points: Specify vddsoc/pu voltage settings that must
+ go with cpu0's operating-points.
+- clock-latency: Specify the possible maximum transition latency for clock,
+ in unit of nanoseconds.
+
+Examples:
+
+ cpu@0 {
+ operating-points = <
+ /* kHz uV */
+ 1200000 1275000
+ 996000 1250000
+ 792000 1150000
+ 396000 975000
+ >;
+ fsl,soc-operating-points = <
+ /* ARM kHz SOC-PU uV */
+ 1200000 1275000
+ 996000 1250000
+ 792000 1175000
+ 396000 1175000
+ >;
+ clock-latency = <61036>; /* two CLK32 periods */
+ clocks = <&clks 104>, <&clks 6>, <&clks 16>,
+ <&clks 17>, <&clks 170>;
+ clock-names = "arm", "pll2_pfd2_396m", "step",
+ "pll1_sw", "pll1_sys";
+ arm-supply = <®_arm>;
+ pu-supply = <®_pu>;
+ soc-supply = <®_soc>;
+ };
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index e7e8332..021e0cb 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -30,6 +30,13 @@
792000 1150000
396000 975000
>;
+ fsl,soc-operating-points = <
+ /* ARM kHz SOC-PU uV */
+ 1200000 1275000
+ 996000 1250000
+ 792000 1175000
+ 396000 1175000
+ >;
clock-latency = <61036>; /* two CLK32 periods */
clocks = <&clks 104>, <&clks 6>, <&clks 16>,
<&clks 17>, <&clks 170>;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH V3 1/2] ARM: imx: add vddsoc/pu setpoint info into dts 2013-12-18 21:26 [PATCH V3 1/2] ARM: imx: add vddsoc/pu setpoint info into dts Anson Huang @ 2013-12-18 11:08 ` Fabio Estevam 2013-12-18 12:01 ` Anson.Huang 2013-12-18 14:21 ` Shawn Guo 2013-12-18 21:26 ` [PATCH V3 2/2] cpufreq: imx6q: correct VDDSOC/PU voltage scaling when cpufreq is changed Anson Huang 2 siblings, 1 reply; 10+ messages in thread From: Fabio Estevam @ 2013-12-18 11:08 UTC (permalink / raw) To: Anson Huang Cc: Shawn Guo, rjw, Viresh Kumar, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, cpufreq, linux-pm Hi Anson, On Wed, Dec 18, 2013 at 7:26 PM, Anson Huang <b20788@freescale.com> wrote: > + Documentation/devicetree/bindings/regulator/regulator.txt for details. > + arm-supply: vddarm input. > + pu-supply: vddpu input. > + soc-supply: vddsoc input. I found these messages confusing, as someone may think that you are referring to the VDD_ARM_IN/VDD_ARM23_IN and VDD_SOC_IN, which are really inputs. What about doing this instead? arm-supply: VDDARM LDO output pu-supply: VDDPU LDO output soc-supply: VDDSOC LDO output Regards, Fabio Estevam ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V3 1/2] ARM: imx: add vddsoc/pu setpoint info into dts 2013-12-18 11:08 ` Fabio Estevam @ 2013-12-18 12:01 ` Anson.Huang 2013-12-19 2:13 ` Anson.Huang 0 siblings, 1 reply; 10+ messages in thread From: Anson.Huang @ 2013-12-18 12:01 UTC (permalink / raw) To: Fabio Estevam Cc: Anson.Huang@freescale.com, Shawn Guo, rjw@rjwysocki.net, Viresh Kumar, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org Sent from Anson's iPhone > 在 2013年12月18日,19:08,"Fabio Estevam" <festevam@gmail.com> 写道: > > Hi Anson, > >> On Wed, Dec 18, 2013 at 7:26 PM, Anson Huang <b20788@freescale.com> wrote: >> >> + Documentation/devicetree/bindings/regulator/regulator.txt for details. >> + arm-supply: vddarm input. >> + pu-supply: vddpu input. >> + soc-supply: vddsoc input. > > I found these messages confusing, as someone may think that you are > referring to the VDD_ARM_IN/VDD_ARM23_IN and VDD_SOC_IN, which are > really inputs. > > What about doing this instead? > > arm-supply: VDDARM LDO output > pu-supply: VDDPU LDO output > soc-supply: VDDSOC LDO output I think they should know these regulators mean the arm, soc/pu's real working voltage, as you know, our i.MX6 also support LDO bypass mode, then these regulators can be VDDXXX_IN. that is why I use vddxxx input, not vddxxx LDO input.Thanks! > > Regards, > > Fabio Estevam > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH V3 1/2] ARM: imx: add vddsoc/pu setpoint info into dts 2013-12-18 12:01 ` Anson.Huang @ 2013-12-19 2:13 ` Anson.Huang 2013-12-19 2:30 ` Fabio Estevam 0 siblings, 1 reply; 10+ messages in thread From: Anson.Huang @ 2013-12-19 2:13 UTC (permalink / raw) To: Fabio Estevam Cc: Shawn Guo, rjw@rjwysocki.net, Viresh Kumar, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org Best Regards. Anson huang 黄勇才 Freescale Semiconductor Shanghai 上海浦东新区亮景路192号A座2楼 201203 Tel:021-28937058 >-----Original Message----- >From: Huang Yongcai-B20788 >Sent: Wednesday, December 18, 2013 8:01 PM >To: Fabio Estevam >Cc: Huang Yongcai-B20788; Shawn Guo; rjw@rjwysocki.net; Viresh Kumar; >devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org; >cpufreq@vger.kernel.org; linux-pm@vger.kernel.org >Subject: Re: [PATCH V3 1/2] ARM: imx: add vddsoc/pu setpoint info into dts > > > >Sent from Anson's iPhone > >> 在 2013年12月18日,19:08,"Fabio Estevam" <festevam@gmail.com> 写道: >> >> Hi Anson, >> >>> On Wed, Dec 18, 2013 at 7:26 PM, Anson Huang <b20788@freescale.com> wrote: >>> >>> + Documentation/devicetree/bindings/regulator/regulator.txt for details. >>> + arm-supply: vddarm input. >>> + pu-supply: vddpu input. >>> + soc-supply: vddsoc input. >> >> I found these messages confusing, as someone may think that you are >> referring to the VDD_ARM_IN/VDD_ARM23_IN and VDD_SOC_IN, which are >> really inputs. >> >> What about doing this instead? >> >> arm-supply: VDDARM LDO output >> pu-supply: VDDPU LDO output >> soc-supply: VDDSOC LDO output > >I think they should know these regulators mean the arm, soc/pu's real working >voltage, as you know, our i.MX6 also support LDO bypass mode, then these >regulators can be VDDXXX_IN. that is why I use vddxxx input, not vddxxx LDO >input.Thanks! After re-consideration, I think below should be better: arm-supply: regulator node supplying arm. pu-supply: regulator node supplying pu. soc-supply: regulator node supplying soc. Anson >> >> Regards, >> >> Fabio Estevam >> >> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V3 1/2] ARM: imx: add vddsoc/pu setpoint info into dts 2013-12-19 2:13 ` Anson.Huang @ 2013-12-19 2:30 ` Fabio Estevam 0 siblings, 0 replies; 10+ messages in thread From: Fabio Estevam @ 2013-12-19 2:30 UTC (permalink / raw) To: Anson.Huang@freescale.com Cc: Shawn Guo, rjw@rjwysocki.net, Viresh Kumar, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org On Thu, Dec 19, 2013 at 12:13 AM, Anson.Huang@freescale.com <Anson.Huang@freescale.com> wrote: > After re-consideration, I think below should be better: > arm-supply: regulator node supplying arm. > pu-supply: regulator node supplying pu. > soc-supply: regulator node supplying soc. Yes, this looks better. Regards, Fabio Estevam ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V3 1/2] ARM: imx: add vddsoc/pu setpoint info into dts 2013-12-18 21:26 [PATCH V3 1/2] ARM: imx: add vddsoc/pu setpoint info into dts Anson Huang 2013-12-18 11:08 ` Fabio Estevam @ 2013-12-18 14:21 ` Shawn Guo 2013-12-18 23:31 ` Anson.Huang 2013-12-18 21:26 ` [PATCH V3 2/2] cpufreq: imx6q: correct VDDSOC/PU voltage scaling when cpufreq is changed Anson Huang 2 siblings, 1 reply; 10+ messages in thread From: Shawn Guo @ 2013-12-18 14:21 UTC (permalink / raw) To: Anson Huang Cc: rjw, viresh.kumar, cpufreq, linux-pm, linux-arm-kernel, devicetree On Wed, Dec 18, 2013 at 04:26:49PM -0500, Anson Huang wrote: > i.MX6Q needs to update vddarm, vddsoc/pu regulators when cpu freq > is changed, each setpoint has different voltage, so we need to > pass vddarm, vddsoc/pu's freq-voltage info from dts together. > > Signed-off-by: Anson Huang <b20788@freescale.com> > --- > .../devicetree/bindings/cpufreq/cpufreq-imx6.txt | 56 ++++++++++++++++++++ As I said in V2 review, the device tree binding doc change should be part of driver patch (patch #2 in this case) or a separate patch, but never be in the same patch as DTS change. Shawn > arch/arm/boot/dts/imx6q.dtsi | 7 +++ > 2 files changed, 63 insertions(+) > create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-imx6.txt > > diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-imx6.txt b/Documentation/devicetree/bindings/cpufreq/cpufreq-imx6.txt > new file mode 100644 > index 0000000..cf1c5f7 > --- /dev/null > +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-imx6.txt > @@ -0,0 +1,56 @@ > +i.MX6 cpufreq driver > +------------------- > + > +i.MX6 SoC cpufreq driver for CPU frequency scaling. > + > +This binding doc defines properties that must be put in the /cpus/cpu@0 node, > +please refer to Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt > +for detail. > + > +Required properties: > +- operating-points: Refer to Documentation/devicetree/bindings/power/opp.txt > + for details. > +- clocks: Specify clocks that need to be used when cpu frequency is scaled, > + refer to Documentation/devicetree/bindings/clock/clock-bindings.txt for > + details. > +- clock-names: List of clock input name strings sorted in the same order as the > + clocks property, refer to Documentation/devicetree/bindings/clock/clock-bindings.txt > + for details. > +- xxx-supply: Input voltage supply regulator, refer to > + Documentation/devicetree/bindings/regulator/regulator.txt for details. > + arm-supply: vddarm input. > + pu-supply: vddpu input. > + soc-supply: vddsoc input. > + > +Optional properties: > +- fsl,soc-operating-points: Specify vddsoc/pu voltage settings that must > + go with cpu0's operating-points. > +- clock-latency: Specify the possible maximum transition latency for clock, > + in unit of nanoseconds. > + > +Examples: > + > + cpu@0 { > + operating-points = < > + /* kHz uV */ > + 1200000 1275000 > + 996000 1250000 > + 792000 1150000 > + 396000 975000 > + >; > + fsl,soc-operating-points = < > + /* ARM kHz SOC-PU uV */ > + 1200000 1275000 > + 996000 1250000 > + 792000 1175000 > + 396000 1175000 > + >; > + clock-latency = <61036>; /* two CLK32 periods */ > + clocks = <&clks 104>, <&clks 6>, <&clks 16>, > + <&clks 17>, <&clks 170>; > + clock-names = "arm", "pll2_pfd2_396m", "step", > + "pll1_sw", "pll1_sys"; > + arm-supply = <®_arm>; > + pu-supply = <®_pu>; > + soc-supply = <®_soc>; > + }; > diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi > index e7e8332..021e0cb 100644 > --- a/arch/arm/boot/dts/imx6q.dtsi > +++ b/arch/arm/boot/dts/imx6q.dtsi > @@ -30,6 +30,13 @@ > 792000 1150000 > 396000 975000 > >; > + fsl,soc-operating-points = < > + /* ARM kHz SOC-PU uV */ > + 1200000 1275000 > + 996000 1250000 > + 792000 1175000 > + 396000 1175000 > + >; > clock-latency = <61036>; /* two CLK32 periods */ > clocks = <&clks 104>, <&clks 6>, <&clks 16>, > <&clks 17>, <&clks 170>; > -- > 1.7.9.5 > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V3 1/2] ARM: imx: add vddsoc/pu setpoint info into dts 2013-12-18 14:21 ` Shawn Guo @ 2013-12-18 23:31 ` Anson.Huang 0 siblings, 0 replies; 10+ messages in thread From: Anson.Huang @ 2013-12-18 23:31 UTC (permalink / raw) To: Shawn Guo Cc: devicetree@vger.kernel.org, linux-pm@vger.kernel.org, viresh.kumar@linaro.org, Anson.Huang@freescale.com, rjw@rjwysocki.net, cpufreq@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sent from Anson's iPhone > 在 2013年12月18日,22:21,"Shawn Guo" <shawn.guo@linaro.org> 写道: > >> On Wed, Dec 18, 2013 at 04:26:49PM -0500, Anson Huang wrote: >> i.MX6Q needs to update vddarm, vddsoc/pu regulators when cpu freq >> is changed, each setpoint has different voltage, so we need to >> pass vddarm, vddsoc/pu's freq-voltage info from dts together. >> >> Signed-off-by: Anson Huang <b20788@freescale.com> >> --- >> .../devicetree/bindings/cpufreq/cpufreq-imx6.txt | 56 ++++++++++++++++++++ > > As I said in V2 review, the device tree binding doc change should be > part of driver patch (patch #2 in this case) or a separate patch, but > never be in the same patch as DTS change. I missed that one, sorry for that, then I will send out a V4 patch set. > > Shawn > >> arch/arm/boot/dts/imx6q.dtsi | 7 +++ >> 2 files changed, 63 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-imx6.txt >> >> diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-imx6.txt b/Documentation/devicetree/bindings/cpufreq/cpufreq-imx6.txt >> new file mode 100644 >> index 0000000..cf1c5f7 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-imx6.txt >> @@ -0,0 +1,56 @@ >> +i.MX6 cpufreq driver >> +------------------- >> + >> +i.MX6 SoC cpufreq driver for CPU frequency scaling. >> + >> +This binding doc defines properties that must be put in the /cpus/cpu@0 node, >> +please refer to Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt >> +for detail. >> + >> +Required properties: >> +- operating-points: Refer to Documentation/devicetree/bindings/power/opp.txt >> + for details. >> +- clocks: Specify clocks that need to be used when cpu frequency is scaled, >> + refer to Documentation/devicetree/bindings/clock/clock-bindings.txt for >> + details. >> +- clock-names: List of clock input name strings sorted in the same order as the >> + clocks property, refer to Documentation/devicetree/bindings/clock/clock-bindings.txt >> + for details. >> +- xxx-supply: Input voltage supply regulator, refer to >> + Documentation/devicetree/bindings/regulator/regulator.txt for details. >> + arm-supply: vddarm input. >> + pu-supply: vddpu input. >> + soc-supply: vddsoc input. >> + >> +Optional properties: >> +- fsl,soc-operating-points: Specify vddsoc/pu voltage settings that must >> + go with cpu0's operating-points. >> +- clock-latency: Specify the possible maximum transition latency for clock, >> + in unit of nanoseconds. >> + >> +Examples: >> + >> + cpu@0 { >> + operating-points = < >> + /* kHz uV */ >> + 1200000 1275000 >> + 996000 1250000 >> + 792000 1150000 >> + 396000 975000 >> + >; >> + fsl,soc-operating-points = < >> + /* ARM kHz SOC-PU uV */ >> + 1200000 1275000 >> + 996000 1250000 >> + 792000 1175000 >> + 396000 1175000 >> + >; >> + clock-latency = <61036>; /* two CLK32 periods */ >> + clocks = <&clks 104>, <&clks 6>, <&clks 16>, >> + <&clks 17>, <&clks 170>; >> + clock-names = "arm", "pll2_pfd2_396m", "step", >> + "pll1_sw", "pll1_sys"; >> + arm-supply = <®_arm>; >> + pu-supply = <®_pu>; >> + soc-supply = <®_soc>; >> + }; >> diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi >> index e7e8332..021e0cb 100644 >> --- a/arch/arm/boot/dts/imx6q.dtsi >> +++ b/arch/arm/boot/dts/imx6q.dtsi >> @@ -30,6 +30,13 @@ >> 792000 1150000 >> 396000 975000 >> >; >> + fsl,soc-operating-points = < >> + /* ARM kHz SOC-PU uV */ >> + 1200000 1275000 >> + 996000 1250000 >> + 792000 1175000 >> + 396000 1175000 >> + >; >> clock-latency = <61036>; /* two CLK32 periods */ >> clocks = <&clks 104>, <&clks 6>, <&clks 16>, >> <&clks 17>, <&clks 170>; >> -- >> 1.7.9.5 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH V3 2/2] cpufreq: imx6q: correct VDDSOC/PU voltage scaling when cpufreq is changed 2013-12-18 21:26 [PATCH V3 1/2] ARM: imx: add vddsoc/pu setpoint info into dts Anson Huang 2013-12-18 11:08 ` Fabio Estevam 2013-12-18 14:21 ` Shawn Guo @ 2013-12-18 21:26 ` Anson Huang 2013-12-18 14:25 ` Shawn Guo 2 siblings, 1 reply; 10+ messages in thread From: Anson Huang @ 2013-12-18 21:26 UTC (permalink / raw) To: shawn.guo, rjw, viresh.kumar Cc: cpufreq, linux-pm, linux-arm-kernel, devicetree on i.MX6Q, cpu freq change need to follow below flows: 1. each setpoint has different VDDARM, VDDSOC/PU voltage, get the setpoint table from dts; 2. when cpu freq is scaling up, need to increase VDDSOC/PU voltage before VDDARM, if VDDPU is off, no need to change it; 3. when cpu freq is scaling down, need to decrease VDDARM voltage before VDDSOC/PU, if VDDPU is off, no need to change it; normally dts will pass vddsoc/pu freq/volt info to kernel, if not, will use fixed value for vddsoc/pu voltage setting. Signed-off-by: Anson Huang <b20788@freescale.com> --- drivers/cpufreq/imx6q-cpufreq.c | 106 ++++++++++++++++++++++++++++----------- 1 file changed, 77 insertions(+), 29 deletions(-) diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 4b3f18e..c29198f 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -35,6 +35,9 @@ static struct device *cpu_dev; static struct cpufreq_frequency_table *freq_table; static unsigned int transition_latency; +static u32 *imx6_soc_volt; +static u32 soc_opp_count; + static unsigned int imx6q_get_speed(unsigned int cpu) { return clk_get_rate(arm_clk) / 1000; @@ -69,23 +72,22 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) /* scaling up? scale voltage before frequency */ if (new_freq > old_freq) { + ret = regulator_set_voltage_tol(pu_reg, imx6_soc_volt[index], 0); + if (ret) { + dev_err(cpu_dev, "failed to scale vddpu up: %d\n", ret); + return ret; + } + ret = regulator_set_voltage_tol(soc_reg, imx6_soc_volt[index], 0); + if (ret) { + dev_err(cpu_dev, "failed to scale vddsoc up: %d\n", ret); + return ret; + } ret = regulator_set_voltage_tol(arm_reg, volt, 0); if (ret) { dev_err(cpu_dev, "failed to scale vddarm up: %d\n", ret); return ret; } - - /* - * Need to increase vddpu and vddsoc for safety - * if we are about to run at 1.2 GHz. - */ - if (new_freq == FREQ_1P2_GHZ / 1000) { - regulator_set_voltage_tol(pu_reg, - PU_SOC_VOLTAGE_HIGH, 0); - regulator_set_voltage_tol(soc_reg, - PU_SOC_VOLTAGE_HIGH, 0); - } } /* @@ -120,12 +122,15 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) "failed to scale vddarm down: %d\n", ret); ret = 0; } - - if (old_freq == FREQ_1P2_GHZ / 1000) { - regulator_set_voltage_tol(pu_reg, - PU_SOC_VOLTAGE_NORMAL, 0); - regulator_set_voltage_tol(soc_reg, - PU_SOC_VOLTAGE_NORMAL, 0); + ret = regulator_set_voltage_tol(soc_reg, imx6_soc_volt[index], 0); + if (ret) { + dev_warn(cpu_dev, "failed to scale vddsoc down: %d\n", ret); + ret = 0; + } + ret = regulator_set_voltage_tol(pu_reg, imx6_soc_volt[index], 0); + if (ret) { + dev_warn(cpu_dev, "failed to scale vddpu down: %d\n", ret); + ret = 0; } } @@ -153,6 +158,9 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) struct dev_pm_opp *opp; unsigned long min_volt, max_volt; int num, ret; + const struct property *prop; + const __be32 *val; + u32 nr, i, j; cpu_dev = get_cpu_device(0); if (!cpu_dev) { @@ -201,10 +209,62 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) goto put_node; } + /* Make imx6_soc_volt array's size same as arm opp number */ + imx6_soc_volt = devm_kzalloc(cpu_dev, sizeof(*imx6_soc_volt) * num, GFP_KERNEL); + if (imx6_soc_volt == NULL) { + ret = -ENOMEM; + goto free_freq_table; + } + + prop = of_find_property(np, "fsl,soc-operating-points", NULL); + if (!prop || !prop->value) + goto soc_opp_out; + + /* + * Each OPP is a set of tuples consisting of frequency and + * voltage like <freq-kHz vol-uV>. + */ + nr = prop->length / sizeof(u32); + if (nr % 2 || (nr / 2) < num) + goto soc_opp_out; + + for (j = 0; j < num; j++) { + val = prop->value; + for (i = 0; i < nr / 2; i++) { + unsigned long freq = be32_to_cpup(val++); + unsigned long volt = be32_to_cpup(val++); + if (freq_table[j].frequency == freq) { + imx6_soc_volt[soc_opp_count++] = volt; + break; + } + } + } + +soc_opp_out: + /* use fixed soc opp volt if no valid soc opp info found in dtb */ + if (soc_opp_count != num) { + dev_warn(cpu_dev, "can NOT find valid fsl,soc-operating-points property in dtb, use default value!\n"); + for (j = 0; j < num; j++) + imx6_soc_volt[j] = PU_SOC_VOLTAGE_NORMAL; + if (freq_table[num - 1].frequency * 1000 == FREQ_1P2_GHZ) + imx6_soc_volt[num - 1] = PU_SOC_VOLTAGE_HIGH; + } + if (of_property_read_u32(np, "clock-latency", &transition_latency)) transition_latency = CPUFREQ_ETERNAL; /* + * Calculate the ramp time for max voltage change in the + * VDDSOC and VDDPU regulators. + */ + ret = regulator_set_voltage_time(soc_reg, imx6_soc_volt[0], imx6_soc_volt[num - 1]); + if (ret > 0) + transition_latency += ret * 1000; + ret = regulator_set_voltage_time(pu_reg, imx6_soc_volt[0], imx6_soc_volt[num - 1]); + if (ret > 0) + transition_latency += ret * 1000; + + /* * OPP is maintained in order of increasing frequency, and * freq_table initialised from OPP is therefore sorted in the * same order. @@ -221,18 +281,6 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) if (ret > 0) transition_latency += ret * 1000; - /* Count vddpu and vddsoc latency in for 1.2 GHz support */ - if (freq_table[num].frequency == FREQ_1P2_GHZ / 1000) { - ret = regulator_set_voltage_time(pu_reg, PU_SOC_VOLTAGE_NORMAL, - PU_SOC_VOLTAGE_HIGH); - if (ret > 0) - transition_latency += ret * 1000; - ret = regulator_set_voltage_time(soc_reg, PU_SOC_VOLTAGE_NORMAL, - PU_SOC_VOLTAGE_HIGH); - if (ret > 0) - transition_latency += ret * 1000; - } - ret = cpufreq_register_driver(&imx6q_cpufreq_driver); if (ret) { dev_err(cpu_dev, "failed register driver: %d\n", ret); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH V3 2/2] cpufreq: imx6q: correct VDDSOC/PU voltage scaling when cpufreq is changed 2013-12-18 21:26 ` [PATCH V3 2/2] cpufreq: imx6q: correct VDDSOC/PU voltage scaling when cpufreq is changed Anson Huang @ 2013-12-18 14:25 ` Shawn Guo 2014-01-03 9:52 ` Anson.Huang 0 siblings, 1 reply; 10+ messages in thread From: Shawn Guo @ 2013-12-18 14:25 UTC (permalink / raw) To: Anson Huang Cc: rjw, viresh.kumar, cpufreq, linux-pm, linux-arm-kernel, devicetree On Wed, Dec 18, 2013 at 04:26:50PM -0500, Anson Huang wrote: > on i.MX6Q, cpu freq change need to follow below flows: > > 1. each setpoint has different VDDARM, VDDSOC/PU voltage, get the setpoint > table from dts; > 2. when cpu freq is scaling up, need to increase VDDSOC/PU voltage before > VDDARM, if VDDPU is off, no need to change it; > 3. when cpu freq is scaling down, need to decrease VDDARM voltage before > VDDSOC/PU, if VDDPU is off, no need to change it; > > normally dts will pass vddsoc/pu freq/volt info to kernel, if not, will > use fixed value for vddsoc/pu voltage setting. > > Signed-off-by: Anson Huang <b20788@freescale.com> Acked-by: Shawn Guo <shawn.guo@linaro.org> ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH V3 2/2] cpufreq: imx6q: correct VDDSOC/PU voltage scaling when cpufreq is changed 2013-12-18 14:25 ` Shawn Guo @ 2014-01-03 9:52 ` Anson.Huang 0 siblings, 0 replies; 10+ messages in thread From: Anson.Huang @ 2014-01-03 9:52 UTC (permalink / raw) To: Shawn Guo, rjw@rjwysocki.net, viresh.kumar@linaro.org Cc: cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Ping... Best Regards. Anson huang 黄勇才 Freescale Semiconductor Shanghai 上海浦东新区亮景路192号A座2楼 201203 Tel:021-28937058 >-----Original Message----- >From: Shawn Guo [mailto:shawn.guo@linaro.org] >Sent: Wednesday, December 18, 2013 10:26 PM >To: Huang Yongcai-B20788 >Cc: rjw@rjwysocki.net; viresh.kumar@linaro.org; cpufreq@vger.kernel.org; >linux-pm@vger.kernel.org; linux-arm-kernel@lists.infradead.org; >devicetree@vger.kernel.org >Subject: Re: [PATCH V3 2/2] cpufreq: imx6q: correct VDDSOC/PU voltage scaling >when cpufreq is changed > >On Wed, Dec 18, 2013 at 04:26:50PM -0500, Anson Huang wrote: >> on i.MX6Q, cpu freq change need to follow below flows: >> >> 1. each setpoint has different VDDARM, VDDSOC/PU voltage, get the setpoint >> table from dts; >> 2. when cpu freq is scaling up, need to increase VDDSOC/PU voltage before >> VDDARM, if VDDPU is off, no need to change it; 3. when cpu freq is >> scaling down, need to decrease VDDARM voltage before >> VDDSOC/PU, if VDDPU is off, no need to change it; >> >> normally dts will pass vddsoc/pu freq/volt info to kernel, if not, >> will use fixed value for vddsoc/pu voltage setting. >> >> Signed-off-by: Anson Huang <b20788@freescale.com> > >Acked-by: Shawn Guo <shawn.guo@linaro.org> ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-01-03 9:52 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-12-18 21:26 [PATCH V3 1/2] ARM: imx: add vddsoc/pu setpoint info into dts Anson Huang 2013-12-18 11:08 ` Fabio Estevam 2013-12-18 12:01 ` Anson.Huang 2013-12-19 2:13 ` Anson.Huang 2013-12-19 2:30 ` Fabio Estevam 2013-12-18 14:21 ` Shawn Guo 2013-12-18 23:31 ` Anson.Huang 2013-12-18 21:26 ` [PATCH V3 2/2] cpufreq: imx6q: correct VDDSOC/PU voltage scaling when cpufreq is changed Anson Huang 2013-12-18 14:25 ` Shawn Guo 2014-01-03 9:52 ` Anson.Huang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).