diff mbox

[1/2] cpufreq: cpufreq-cpu0: support for clock which are not in DT yet.

Message ID 1363043130-30270-2-git-send-email-nm@ti.com (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Nishanth Menon March 11, 2013, 11:05 p.m. UTC
On certain SoCs like variants of OMAP, the clock conversion to DT
is not complete. In short, the ability to:
cpus {
    cpu@0 {
	clocks = <&cpuclk 0>;
    };
 };
is not possible. However, the clock node is registered.
Allow for clk names to be provided as string so as to be used when needed.
Example (for OMAP3630):
cpus {
    cpu@0 {
	clock-name = "cpufreq_ck";
    };
 };

Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: linux-kernel@vger.kernel.org
Cc: cpufreq@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Cc: linux-omap@vger.kernel.org

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 .../devicetree/bindings/cpufreq/cpufreq-cpu0.txt   |    3 +++
 drivers/cpufreq/cpufreq-cpu0.c                     |    6 +++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

Comments

Santosh Shilimkar March 12, 2013, 5:03 a.m. UTC | #1
On Tuesday 12 March 2013 04:35 AM, Nishanth Menon wrote:
> On certain SoCs like variants of OMAP, the clock conversion to DT
> is not complete. In short, the ability to:
> cpus {
>     cpu@0 {
> 	clocks = <&cpuclk 0>;
>     };
>  };
> is not possible. However, the clock node is registered.
> Allow for clk names to be provided as string so as to be used when needed.
> Example (for OMAP3630):
> cpus {
>     cpu@0 {
> 	clock-name = "cpufreq_ck";
>     };
>  };
> 
> Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Cc: linux-kernel@vger.kernel.org
> Cc: cpufreq@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-omap@vger.kernel.org
> 
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
Seems a reasonable to me.
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>


--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Shawn Guo March 12, 2013, 7:36 a.m. UTC | #2
On Mon, Mar 11, 2013 at 06:05:29PM -0500, Nishanth Menon wrote:
> On certain SoCs like variants of OMAP, the clock conversion to DT
> is not complete. In short, the ability to:
> cpus {
>     cpu@0 {
> 	clocks = <&cpuclk 0>;
>     };
>  };
> is not possible. However, the clock node is registered.
> Allow for clk names to be provided as string so as to be used when needed.
> Example (for OMAP3630):
> cpus {
>     cpu@0 {
> 	clock-name = "cpufreq_ck";
>     };
>  };
> 
I'm not sure why the patch is needed at all.  For platform that is
unable to look up clock from device tree yet, something like the
following in kernel will just help cpufreq-cpu0 find the clock, if
you instantiate cpufreq-cpu0 driver in the same way that
highbank-cpufreq does.

  clk_register_clkdev(cpuclk, NULL, "cpufreq-cpu0.0");

Shawn

> Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Cc: linux-kernel@vger.kernel.org
> Cc: cpufreq@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-omap@vger.kernel.org
> 
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
>  .../devicetree/bindings/cpufreq/cpufreq-cpu0.txt   |    3 +++
>  drivers/cpufreq/cpufreq-cpu0.c                     |    6 +++++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt b/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt
> index 4416ccc..f180963 100644
> --- a/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt
> +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt
> @@ -12,6 +12,9 @@ Required properties:
>    for details
>  
>  Optional properties:
> +- clock-name: If the clock is not converted to device tree, then describe
> +  the clock name as a string. This may also be replaced with clocks=<&cpuclk>
> +  cpu clocks has already been converted to device tree.
>  - clock-latency: Specify the possible maximum transition latency for clock,
>    in unit of nanoseconds.
>  - voltage-tolerance: Specify the CPU voltage tolerance in percentage.
> diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
> index 4e5b7fb..28223c9 100644
> --- a/drivers/cpufreq/cpufreq-cpu0.c
> +++ b/drivers/cpufreq/cpufreq-cpu0.c
> @@ -180,6 +180,7 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
>  {
>  	struct device_node *np;
>  	int ret;
> +	const char *clk_name = NULL;
>  
>  	for_each_child_of_node(of_find_node_by_path("/cpus"), np) {
>  		if (of_get_property(np, "operating-points", NULL))
> @@ -194,7 +195,10 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
>  	cpu_dev = &pdev->dev;
>  	cpu_dev->of_node = np;
>  
> -	cpu_clk = devm_clk_get(cpu_dev, NULL);
> +	/* If clocks are not in DT yet, allow to define it part of CPU node */
> +	of_property_read_string(np, "clock-name", &clk_name);
> +
> +	cpu_clk = devm_clk_get(cpu_dev, clk_name);
>  	if (IS_ERR(cpu_clk)) {
>  		ret = PTR_ERR(cpu_clk);
>  		pr_err("failed to get cpu0 clock: %d\n", ret);
> -- 
> 1.7.9.5
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Benoit Cousson March 12, 2013, 2:24 p.m. UTC | #3
Hi Guys,

On 03/12/2013 06:03 AM, Santosh Shilimkar wrote:
> On Tuesday 12 March 2013 04:35 AM, Nishanth Menon wrote:
>> On certain SoCs like variants of OMAP, the clock conversion to DT
>> is not complete. In short, the ability to:
>> cpus {
>>     cpu@0 {
>> 	clocks = <&cpuclk 0>;
>>     };
>>  };
>> is not possible. However, the clock node is registered.
>> Allow for clk names to be provided as string so as to be used when needed.
>> Example (for OMAP3630):
>> cpus {
>>     cpu@0 {
>> 	clock-name = "cpufreq_ck";
>>     };
>>  };
>>
>> Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
>> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
>> Cc: Shawn Guo <shawn.guo@linaro.org>
>> Cc: linux-kernel@vger.kernel.org
>> Cc: cpufreq@vger.kernel.org
>> Cc: linux-pm@vger.kernel.org
>> Cc: linux-omap@vger.kernel.org
>>
>> Signed-off-by: Nishanth Menon <nm@ti.com>
>> ---
> Seems a reasonable to me.

No, it is not...

You cannot add a temp binding just because the OMAP support is not
there, since the real binding already exist.

You need to register properly a clock provider to be able to reference
it.
If you do need a hacky temp code you could do it in OMAP code but not in
the binding.


Regards,
Benoit
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" 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/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt b/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt
index 4416ccc..f180963 100644
--- a/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt
+++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt
@@ -12,6 +12,9 @@  Required properties:
   for details
 
 Optional properties:
+- clock-name: If the clock is not converted to device tree, then describe
+  the clock name as a string. This may also be replaced with clocks=<&cpuclk>
+  cpu clocks has already been converted to device tree.
 - clock-latency: Specify the possible maximum transition latency for clock,
   in unit of nanoseconds.
 - voltage-tolerance: Specify the CPU voltage tolerance in percentage.
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index 4e5b7fb..28223c9 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -180,6 +180,7 @@  static int cpu0_cpufreq_probe(struct platform_device *pdev)
 {
 	struct device_node *np;
 	int ret;
+	const char *clk_name = NULL;
 
 	for_each_child_of_node(of_find_node_by_path("/cpus"), np) {
 		if (of_get_property(np, "operating-points", NULL))
@@ -194,7 +195,10 @@  static int cpu0_cpufreq_probe(struct platform_device *pdev)
 	cpu_dev = &pdev->dev;
 	cpu_dev->of_node = np;
 
-	cpu_clk = devm_clk_get(cpu_dev, NULL);
+	/* If clocks are not in DT yet, allow to define it part of CPU node */
+	of_property_read_string(np, "clock-name", &clk_name);
+
+	cpu_clk = devm_clk_get(cpu_dev, clk_name);
 	if (IS_ERR(cpu_clk)) {
 		ret = PTR_ERR(cpu_clk);
 		pr_err("failed to get cpu0 clock: %d\n", ret);