diff mbox

[v2,5/5] ARM: shmobile: lager: (DEVEL) add CPUFreq support

Message ID 1380216060-14506-6-git-send-email-g.liakhovetski@gmx.de (mailing list archive)
State Changes Requested
Headers show

Commit Message

Guennadi Liakhovetski Sept. 26, 2013, 5:21 p.m. UTC
The Lager board uses a DA9210 voltage regulator to supply DVFS power to the
CA15 cores on the r8a7790 SoC. This patch adds CPUFreq support for that
board using the cpufreq-cpu0 driver.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
---

v2: added 'status = "okay";' to the i2c bus

 arch/arm/boot/dts/r8a7790-lager-reference.dts  |   33 ++++++++++++++++++++++++
 arch/arm/mach-shmobile/board-lager-reference.c |    4 ++-
 2 files changed, 36 insertions(+), 1 deletions(-)

Comments

Sergei Shtylyov Sept. 26, 2013, 6:23 p.m. UTC | #1
Hello.

On 09/26/2013 09:21 PM, Guennadi Liakhovetski wrote:

> The Lager board uses a DA9210 voltage regulator to supply DVFS power to the
> CA15 cores on the r8a7790 SoC. This patch adds CPUFreq support for that
> board using the cpufreq-cpu0 driver.

> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
> ---

> v2: added 'status = "okay";' to the i2c bus

>   arch/arm/boot/dts/r8a7790-lager-reference.dts  |   33 ++++++++++++++++++++++++
>   arch/arm/mach-shmobile/board-lager-reference.c |    4 ++-
>   2 files changed, 36 insertions(+), 1 deletions(-)

> diff --git a/arch/arm/boot/dts/r8a7790-lager-reference.dts b/arch/arm/boot/dts/r8a7790-lager-reference.dts
> index c462ef1..1ce0a97 100644
> --- a/arch/arm/boot/dts/r8a7790-lager-reference.dts
> +++ b/arch/arm/boot/dts/r8a7790-lager-reference.dts
> @@ -43,3 +43,36 @@
>   		};
>   	};
>   };
> +
> +&i2c3 {
> +	status = "okay";
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&i2c3_pins>;
> +
> +	vdd_dvfs: da9210@68 {

   ePAPR spec [1] says: "The name of a node should be somewhat generic, 
reflecting the function of the device and not its precise programming model."
So I suggest "regulator" instead of "da9210".

> +		compatible = "diasemi,da9210";
> +		reg = <0x68>;
> +
> +		regulator-min-microvolt = <900000>;
> +		regulator-max-microvolt = <1000000>;
> +		regulator-boot-on;
> +		regulator-always-on;
> +	};
> +};
[...]
> diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c
> index 1a1a4a8..2bc8bae 100644
> --- a/arch/arm/mach-shmobile/board-lager-reference.c
> +++ b/arch/arm/mach-shmobile/board-lager-reference.c
[...]
> @@ -29,7 +30,8 @@ static void __init lager_add_standard_devices(void)
>   	r8a7790_clock_init();
>
>   	r8a7790_add_dt_devices();
> -        of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);

    Hm, "drove-by" cleanup?

> +	platform_device_register_simple("cpufreq-cpu0", -1, NULL, 0);
>   }
>
>   static const char *lager_boards_compat_dt[] __initdata = {

    Shouldn't the patch be split into .dts and .c parts, I wonder?

[1] http://www.power.org/resources/downloads/Power_ePAPR_APPROVED_v1.0.pdf

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Laurent Pinchart Sept. 26, 2013, 11:59 p.m. UTC | #2
Hi Guennadi,

Thank you for the patch.

On Thursday 26 September 2013 19:21:00 Guennadi Liakhovetski wrote:
> The Lager board uses a DA9210 voltage regulator to supply DVFS power to the
> CA15 cores on the r8a7790 SoC. This patch adds CPUFreq support for that
> board using the cpufreq-cpu0 driver.
> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
> ---
> 
> v2: added 'status = "okay";' to the i2c bus
> 
>  arch/arm/boot/dts/r8a7790-lager-reference.dts  |   33 +++++++++++++++++++++
>  arch/arm/mach-shmobile/board-lager-reference.c |    4 ++-
>  2 files changed, 36 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/r8a7790-lager-reference.dts
> b/arch/arm/boot/dts/r8a7790-lager-reference.dts index c462ef1..1ce0a97
> 100644
> --- a/arch/arm/boot/dts/r8a7790-lager-reference.dts
> +++ b/arch/arm/boot/dts/r8a7790-lager-reference.dts
> @@ -43,3 +43,36 @@
>  		};
>  	};
>  };
> +
> +&i2c3 {
> +	status = "okay";
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&i2c3_pins>;
> +
> +	vdd_dvfs: da9210@68 {
> +		compatible = "diasemi,da9210";
> +		reg = <0x68>;
> +
> +		regulator-min-microvolt = <900000>;
> +		regulator-max-microvolt = <1000000>;
> +		regulator-boot-on;
> +		regulator-always-on;
> +	};
> +};
> +
> +&cpu0 {
> +	cpu0-supply = <&vdd_dvfs>;
> +	operating-points = <
> +		/* kHz  uV - OPs unknown yet */
> +		1300000 1000000
> +		1000000  900000
> +	>;
> +	voltage-tolerance = <1>; /* 1% */
> +};
> +
> +&pfc {
> +	i2c3_pins: i2c3 {
> +		renesas,groups = "i2c3";
> +		renesas,function = "i2c3";
> +	};
> +};
> diff --git a/arch/arm/mach-shmobile/board-lager-reference.c
> b/arch/arm/mach-shmobile/board-lager-reference.c index 1a1a4a8..2bc8bae
> 100644
> --- a/arch/arm/mach-shmobile/board-lager-reference.c
> +++ b/arch/arm/mach-shmobile/board-lager-reference.c
> @@ -20,6 +20,7 @@
> 
>  #include <linux/init.h>
>  #include <linux/of_platform.h>
> +#include <linux/platform_device.h>
>  #include <mach/r8a7790.h>
>  #include <asm/mach/arch.h>
> 
> @@ -29,7 +30,8 @@ static void __init lager_add_standard_devices(void)
>  	r8a7790_clock_init();
> 
>  	r8a7790_add_dt_devices();
> -        of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> +	platform_device_register_simple("cpufreq-cpu0", -1, NULL, 0);

Out of curiosity, could you explain how this cpufreq-cpu0 platform device gets 
associated with the cpu0 DT node ? The cpufreq-cpu0 driver requires a DT node 
(its probe function returns -ENOENT if pdev->dev.of_node is NULL), and I don't 
see how the of_node gets set as the platform device is registered through 
board code. I might of course be missing something obvious :-)

>  }
> 
>  static const char *lager_boards_compat_dt[] __initdata = {
Guennadi Liakhovetski Sept. 27, 2013, 6:32 a.m. UTC | #3
Hi Laurent

On Fri, 27 Sep 2013, Laurent Pinchart wrote:

> Hi Guennadi,
> 
> Thank you for the patch.
> 
> On Thursday 26 September 2013 19:21:00 Guennadi Liakhovetski wrote:
> > The Lager board uses a DA9210 voltage regulator to supply DVFS power to the
> > CA15 cores on the r8a7790 SoC. This patch adds CPUFreq support for that
> > board using the cpufreq-cpu0 driver.
> > 
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
> > ---
> > 
> > v2: added 'status = "okay";' to the i2c bus
> > 
> >  arch/arm/boot/dts/r8a7790-lager-reference.dts  |   33 +++++++++++++++++++++
> >  arch/arm/mach-shmobile/board-lager-reference.c |    4 ++-
> >  2 files changed, 36 insertions(+), 1 deletions(-)
> > 
> > diff --git a/arch/arm/boot/dts/r8a7790-lager-reference.dts
> > b/arch/arm/boot/dts/r8a7790-lager-reference.dts index c462ef1..1ce0a97
> > 100644
> > --- a/arch/arm/boot/dts/r8a7790-lager-reference.dts
> > +++ b/arch/arm/boot/dts/r8a7790-lager-reference.dts
> > @@ -43,3 +43,36 @@
> >  		};
> >  	};
> >  };
> > +
> > +&i2c3 {
> > +	status = "okay";
> > +	pinctrl-names = "default";
> > +	pinctrl-0 = <&i2c3_pins>;
> > +
> > +	vdd_dvfs: da9210@68 {
> > +		compatible = "diasemi,da9210";
> > +		reg = <0x68>;
> > +
> > +		regulator-min-microvolt = <900000>;
> > +		regulator-max-microvolt = <1000000>;
> > +		regulator-boot-on;
> > +		regulator-always-on;
> > +	};
> > +};
> > +
> > +&cpu0 {
> > +	cpu0-supply = <&vdd_dvfs>;
> > +	operating-points = <
> > +		/* kHz  uV - OPs unknown yet */
> > +		1300000 1000000
> > +		1000000  900000
> > +	>;
> > +	voltage-tolerance = <1>; /* 1% */
> > +};
> > +
> > +&pfc {
> > +	i2c3_pins: i2c3 {
> > +		renesas,groups = "i2c3";
> > +		renesas,function = "i2c3";
> > +	};
> > +};
> > diff --git a/arch/arm/mach-shmobile/board-lager-reference.c
> > b/arch/arm/mach-shmobile/board-lager-reference.c index 1a1a4a8..2bc8bae
> > 100644
> > --- a/arch/arm/mach-shmobile/board-lager-reference.c
> > +++ b/arch/arm/mach-shmobile/board-lager-reference.c
> > @@ -20,6 +20,7 @@
> > 
> >  #include <linux/init.h>
> >  #include <linux/of_platform.h>
> > +#include <linux/platform_device.h>
> >  #include <mach/r8a7790.h>
> >  #include <asm/mach/arch.h>
> > 
> > @@ -29,7 +30,8 @@ static void __init lager_add_standard_devices(void)
> >  	r8a7790_clock_init();
> > 
> >  	r8a7790_add_dt_devices();
> > -        of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> > +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> > +	platform_device_register_simple("cpufreq-cpu0", -1, NULL, 0);
> 
> Out of curiosity, could you explain how this cpufreq-cpu0 platform device gets 
> associated with the cpu0 DT node ?

I can try, yes.

> The cpufreq-cpu0 driver requires a DT node 
> (its probe function returns -ENOENT if pdev->dev.of_node is NULL), and I don't 
> see how the of_node gets set as the platform device is registered through 
> board code. I might of course be missing something obvious :-)

I think you can just follow this threads:

http://thread.gmane.org/gmane.linux.kernel.cpufreq/11427/focus=1547510
http://thread.gmane.org/gmane.linux.kernel.cpufreq/12408

and there's also a comment in another my patch from yesterday from the 
same thread:

http://marc.info/?l=linux-sh&m=138021613314913&w=2

So, in short, you seem to be looking at a buggy driver state, yes. A fix 
is on its way.

Thanks
Guennadi

> >  }
> > 
> >  static const char *lager_boards_compat_dt[] __initdata = {
> -- 
> Regards,
> 
> Laurent Pinchart

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Guennadi Liakhovetski Sept. 27, 2013, 8:37 a.m. UTC | #4
Hi Sergei

On Thu, 26 Sep 2013, Sergei Shtylyov wrote:

> Hello.
> 
> On 09/26/2013 09:21 PM, Guennadi Liakhovetski wrote:
> 
> > The Lager board uses a DA9210 voltage regulator to supply DVFS power to the
> > CA15 cores on the r8a7790 SoC. This patch adds CPUFreq support for that
> > board using the cpufreq-cpu0 driver.
> 
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
> > ---
> 
> > v2: added 'status = "okay";' to the i2c bus
> 
> >   arch/arm/boot/dts/r8a7790-lager-reference.dts  |   33
> > ++++++++++++++++++++++++
> >   arch/arm/mach-shmobile/board-lager-reference.c |    4 ++-
> >   2 files changed, 36 insertions(+), 1 deletions(-)
> 
> > diff --git a/arch/arm/boot/dts/r8a7790-lager-reference.dts
> > b/arch/arm/boot/dts/r8a7790-lager-reference.dts
> > index c462ef1..1ce0a97 100644
> > --- a/arch/arm/boot/dts/r8a7790-lager-reference.dts
> > +++ b/arch/arm/boot/dts/r8a7790-lager-reference.dts
> > @@ -43,3 +43,36 @@
> >   		};
> >   	};
> >   };
> > +
> > +&i2c3 {
> > +	status = "okay";
> > +	pinctrl-names = "default";
> > +	pinctrl-0 = <&i2c3_pins>;
> > +
> > +	vdd_dvfs: da9210@68 {
> 
>   ePAPR spec [1] says: "The name of a node should be somewhat generic,
> reflecting the function of the device and not its precise programming model."

Sure, but I think it is common in Linux .dts files for I2C devices to use 
"<model>@<i2c addr>" as a name.

> So I suggest "regulator" instead of "da9210".
> 
> > +		compatible = "diasemi,da9210";
> > +		reg = <0x68>;
> > +
> > +		regulator-min-microvolt = <900000>;
> > +		regulator-max-microvolt = <1000000>;
> > +		regulator-boot-on;
> > +		regulator-always-on;
> > +	};
> > +};
> [...]
> > diff --git a/arch/arm/mach-shmobile/board-lager-reference.c
> > b/arch/arm/mach-shmobile/board-lager-reference.c
> > index 1a1a4a8..2bc8bae 100644
> > --- a/arch/arm/mach-shmobile/board-lager-reference.c
> > +++ b/arch/arm/mach-shmobile/board-lager-reference.c
> [...]
> > @@ -29,7 +30,8 @@ static void __init lager_add_standard_devices(void)
> >   	r8a7790_clock_init();
> > 
> >   	r8a7790_add_dt_devices();
> > -        of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> > +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> 
>    Hm, "drove-by" cleanup?

This should be avoided in general, but this kind of stuff really doesn't 
deserve neither a separate patch nor a mention. Don't waste your precious 
brain cycles.

> > +	platform_device_register_simple("cpufreq-cpu0", -1, NULL, 0);
> >   }
> > 
> >   static const char *lager_boards_compat_dt[] __initdata = {
> 
>    Shouldn't the patch be split into .dts and .c parts, I wonder?

Simon didn't complain, but perhaps it should, yes. I think I'll resubmit 
this as 2 patches with no changes.

Thanks
Guennadi

> [1] http://www.power.org/resources/downloads/Power_ePAPR_APPROVED_v1.0.pdf
> 
> WBR, Sergei

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/boot/dts/r8a7790-lager-reference.dts b/arch/arm/boot/dts/r8a7790-lager-reference.dts
index c462ef1..1ce0a97 100644
--- a/arch/arm/boot/dts/r8a7790-lager-reference.dts
+++ b/arch/arm/boot/dts/r8a7790-lager-reference.dts
@@ -43,3 +43,36 @@ 
 		};
 	};
 };
+
+&i2c3 {
+	status = "okay";
+	pinctrl-names = "default";
+	pinctrl-0 = <&i2c3_pins>;
+
+	vdd_dvfs: da9210@68 {
+		compatible = "diasemi,da9210";
+		reg = <0x68>;
+
+		regulator-min-microvolt = <900000>;
+		regulator-max-microvolt = <1000000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+};
+
+&cpu0 {
+	cpu0-supply = <&vdd_dvfs>;
+	operating-points = <
+		/* kHz  uV - OPs unknown yet */
+		1300000 1000000
+		1000000  900000
+	>;
+	voltage-tolerance = <1>; /* 1% */
+};
+
+&pfc {
+	i2c3_pins: i2c3 {
+		renesas,groups = "i2c3";
+		renesas,function = "i2c3";
+	};
+};
diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c
index 1a1a4a8..2bc8bae 100644
--- a/arch/arm/mach-shmobile/board-lager-reference.c
+++ b/arch/arm/mach-shmobile/board-lager-reference.c
@@ -20,6 +20,7 @@ 
 
 #include <linux/init.h>
 #include <linux/of_platform.h>
+#include <linux/platform_device.h>
 #include <mach/r8a7790.h>
 #include <asm/mach/arch.h>
 
@@ -29,7 +30,8 @@  static void __init lager_add_standard_devices(void)
 	r8a7790_clock_init();
 
 	r8a7790_add_dt_devices();
-        of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+	platform_device_register_simple("cpufreq-cpu0", -1, NULL, 0);
 }
 
 static const char *lager_boards_compat_dt[] __initdata = {