Skip to contentSkip to conversation

clk: add clock-indices support

PATCH In review Ben Dooks 4 participants 10 messages Feb 13, 2014 – Mar 6, 2014

Subsystems (3)
lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

PATCH 1/3 clk: add clock-indices support

Add a property called clock-indices to allow clock-output-names to be used where the index used to lookup a clock is not a 1:1 mapping to the array position in the clock-output-names

---
 .../devicetree/bindings/clock/clock-bindings.txt     | 17 +++++++++++++++++
 drivers/clk/clk.c                                    | 20 +++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/clock/clock-bindings.txt +17 -0
index 7c52c29..700e7aa 100644
@@ -44,6 +44,23 @@ For example:
   clocks by index. The names should reflect the clock output signal
   names for the device.
 
+clock-indices:	   If the identifyng number for the clocks in the node
+		   is not linear from zero, then the this mapping allows
+		   the mapping of identifiers into the clock-output-names
+		   array.
+
+For example, if we have two clocks <&oscillator 1> and <&oscillator 3>:
+
+	oscillator {
+		compatible = "myclocktype";
+		#clock-cells = <1>;
+		clock-indices = <1>, <3>;
+		clock-output-names = "clka", "clkb";
+	}
+
+	This ensures we do not have any empty nodes in clock-output-names
+
+
 =Clock consumers=
 
 Required properties:
drivers/clk/clk.c +19 -1
index 5517944..18633c9 100644
@@ -2505,8 +2505,12 @@ EXPORT_SYMBOL_GPL(of_clk_get_parent_count);
 const char *of_clk_get_parent_name(struct device_node *np, int index)
 {
 	struct of_phandle_args clkspec;
+	struct property *prop;
 	const char *clk_name;
+	const __be32 *vp;
+	u32 pv;
 	int rc;
+	int count;
 
 	if (index < 0)
 		return NULL;
@@ -2516,8 +2520,22 @@ const char *of_clk_get_parent_name(struct device_node *np, int index)
 	if (rc)
 		return NULL;
 
+	index = clkspec.args_count ? clkspec.args[0] : 0;
+	count = 0;
+
+	/* if there is an indices property, use it to transfer the index
+	 * specified into an array offset for the clock-output-names property.
+	 */
+	of_property_for_each_u32(clkspec.np, "clock-indices", prop, vp, pv) {
+		if (index = pv) {
+			index = count;
+			break;
+		}
+		count++;
+	}
+
 	if (of_property_read_string_index(clkspec.np, "clock-output-names",
-					  clkspec.args_count ? clkspec.args[0] : 0,
+					  index,
 					  &clk_name) < 0)
 		clk_name = clkspec.np->name;
 
Signature · 1 line
1.8.5.3
#1 lore raw

Hello.

Quoted 23 lines · Ben Dooks

Add a property called clock-indices to allow clock-output-names to be used where the index used to lookup a clock is not a 1:1 mapping to the array position in the clock-output-names

---
  .../devicetree/bindings/clock/clock-bindings.txt     | 17 +++++++++++++++++
  drivers/clk/clk.c                                    | 20 +++++++++++++++++++-
  2 files changed, 36 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/clock/clock-bindings.txt +5 -0
index 7c52c29..700e7aa 100644
@@ -44,6 +44,23 @@ For example:
    clocks by index. The names should reflect the clock output signal
    names for the device.
 
+clock-indices:	   If the identifyng number for the clocks in the node
+		   is not linear from zero, then the this mapping allows
+		   the mapping of identifiers into the clock-output-names
+		   array.
+

Documentation/devicetree/bindings/clock/clock-bindings.txt For example: · line 61

Quoted 10 lines
Documentation/devicetree/bindings/clock/clock-bindings.txt +10 -0
+For example, if we have two clocks <&oscillator 1> and <&oscillator 3>:
+
+	oscillator {
+		compatible = "myclocktype";
+		#clock-cells = <1>;
+		clock-indices = <1>, <3>;
+		clock-output-names = "clka", "clkb";
+	}
+
+	This ensures we do not have any empty nodes in clock-output-names

You mean empty strings?

WBR, Sergei

author
#2 lore raw
In reply to Ben Dooks
Quoted 35 lines · Sergei Shtylyov

Hello.

Quoted 31 lines · Ben Dooks

Add a property called clock-indices to allow clock-output-names to be used where the index used to lookup a clock is not a 1:1 mapping to the array position in the clock-output-names

---
  .../devicetree/bindings/clock/clock-bindings.txt     | 17
+++++++++++++++++
  drivers/clk/clk.c                                    | 20
+++++++++++++++++++-
  2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/clock/clock-bindings.txt b/Documentation/devicetree/bindings/clock/clock-bindings.txt index 7c52c29..700e7aa 100644

Documentation/devicetree/bindings/clock/clock-bindings.txt +9 -0
@@ -44,6 +44,23 @@ For example:
    clocks by index. The names should reflect the clock output signal
    names for the device.
 
+clock-indices:       If the identifyng number for the clocks in the node
+           is not linear from zero, then the this mapping allows
+           the mapping of identifiers into the clock-output-names
+           array.
+
+For example, if we have two clocks <&oscillator 1> and <&oscillator 3>:
+
+    oscillator {
+        compatible = "myclocktype";
Quoted 8 lines

Documentation/devicetree/bindings/clock/clock-bindings.txt For example: · line 61

Quoted 6 lines
Documentation/devicetree/bindings/clock/clock-bindings.txt +6 -0
+        #clock-cells = <1>;
+        clock-indices = <1>, <3>;
+        clock-output-names = "clka", "clkb";
+    }
+
+    This ensures we do not have any empty nodes in clock-output-names

You mean empty strings?

Yes, thanks. Empty strings.

Signature · 2 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius
#3 lore raw
In reply to Ben Dooks

Quoting Ben Dooks (2014-02-13 10:02:49)

Quoted 5 lines

Add a property called clock-indices to allow clock-output-names to be used where the index used to lookup a clock is not a 1:1 mapping to the array position in the clock-output-names

Ben & Laurent,

The clock-indices stuff looks sane to me. I've taken Ben's patch #1 into clk-next. It seems patch #3 might be dropped and patch #2 didn't apply cleanly for me.

Can Laurent's patches and Ben's #2 be rebased and sent together as a PR? I'll leave it up to you guys to figure out the backwards compatibility issue with Ben's patch #3.

Regards,
Mike

Quoted 77 lines
---
 .../devicetree/bindings/clock/clock-bindings.txt     | 17 +++++++++++++++++
 drivers/clk/clk.c                                    | 20 +++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/clock/clock-bindings.txt +17 -0
index 7c52c29..700e7aa 100644
@@ -44,6 +44,23 @@ For example:
   clocks by index. The names should reflect the clock output signal
   names for the device.
 
+clock-indices:    If the identifyng number for the clocks in the node
+                  is not linear from zero, then the this mapping allows
+                  the mapping of identifiers into the clock-output-names
+                  array.
+
+For example, if we have two clocks <&oscillator 1> and <&oscillator 3>:
+
+       oscillator {
+               compatible = "myclocktype";
+               #clock-cells = <1>;
+               clock-indices = <1>, <3>;
+               clock-output-names = "clka", "clkb";
+       }
+
+       This ensures we do not have any empty nodes in clock-output-names
+
+
 =Clock consumers=
 
 Required properties:
drivers/clk/clk.c +19 -1
index 5517944..18633c9 100644
@@ -2505,8 +2505,12 @@ EXPORT_SYMBOL_GPL(of_clk_get_parent_count);
 const char *of_clk_get_parent_name(struct device_node *np, int index)
 {
        struct of_phandle_args clkspec;
+       struct property *prop;
        const char *clk_name;
+       const __be32 *vp;
+       u32 pv;
        int rc;
+       int count;
 
        if (index < 0)
                return NULL;
@@ -2516,8 +2520,22 @@ const char *of_clk_get_parent_name(struct device_node *np, int index)
        if (rc)
                return NULL;
 
+       index = clkspec.args_count ? clkspec.args[0] : 0;
+       count = 0;
+
+       /* if there is an indices property, use it to transfer the index
+        * specified into an array offset for the clock-output-names property.
+        */
+       of_property_for_each_u32(clkspec.np, "clock-indices", prop, vp, pv) {
+               if (index = pv) {
+                       index = count;
+                       break;
+               }
+               count++;
+       }
+
        if (of_property_read_string_index(clkspec.np, "clock-output-names",
-                                         clkspec.args_count ? clkspec.args[0] : 0,
+                                         index,
                                          &clk_name) < 0)
                clk_name = clkspec.np->name;
 
Signature · 1 line
1.8.5.3
#4 lore raw
In reply to Ben Dooks

Hi Mike,

Quoted 8 lines · On Sunday 23 February 2014 13:00:24 Mike Turquette wrote:

Quoting Ben Dooks (2014-02-13 10:02:49)

Quoted 5 lines

Add a property called clock-indices to allow clock-output-names to be used where the index used to lookup a clock is not a 1:1 mapping to the array position in the clock-output-names

Quoted 7 lines

Ben & Laurent,

The clock-indices stuff looks sane to me. I've taken Ben's patch #1 into clk-next. It seems patch #3 might be dropped and patch #2 didn't apply cleanly for me.

Can Laurent's patches and Ben's #2 be rebased and sent together as a PR?

Sure. I've pushed my pending patches to

git://linuxtv.org/pinchartl/fbdev.git clocks/next/drivers

Ben, could you please rebase your patch on top of it and repost ? I'll then send a pull request to Mike.

Quoted 2 lines

I'll leave it up to you guys to figure out the backwards compatibility issue with Ben's patch #3.

Signature · 3 lines
Regards,

Laurent Pinchart
#5 lore raw
In reply to Ben Dooks
Quoted 20 lines · On Sunday 23 February 2014 15:46:04 Mike Turquette wrote:

Quoting Laurent Pinchart (2014-02-23 14:40:46)

Quoted 19 lines · On Sunday 23 February 2014 13:00:24 Mike Turquette wrote:
Quoted 8 lines

Quoting Ben Dooks (2014-02-13 10:02:49)

Quoted 5 lines

Add a property called clock-indices to allow clock-output-names to be used where the index used to lookup a clock is not a 1:1 mapping to the array position in the clock-output-names

Quoted 7 lines

Ben & Laurent,

The clock-indices stuff looks sane to me. I've taken Ben's patch #1 into clk-next. It seems patch #3 might be dropped and patch #2 didn't apply cleanly for me.

Can Laurent's patches and Ben's #2 be rebased and sent together as a PR?

Sure. I've pushed my pending patches to

Quoted 8 lines
Quoted 4 lines

git://linuxtv.org/pinchartl/fbdev.git clocks/next/drivers

Ben, could you please rebase your patch on top of it and repost ? I'll then send a pull request to Mike.

FYI, I've just pushed a new clk-next branch based on -rc3 out to my linaro remote. You don't need to rebase but it's there if you want to put your stuff on top of the latest.

Thanks. Rebased and pushed.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I'll leave it up to you guys to figure out the backwards compatibility issue with Ben's patch #3.

Signature · 3 lines
Regards,

Laurent Pinchart
author
#6 lore raw
In reply to Ben Dooks
Quoted 9 lines · Mike Turquette

Quoting Ben Dooks (2014-02-13 10:02:49)

Quoted 5 lines

Add a property called clock-indices to allow clock-output-names to be used where the index used to lookup a clock is not a 1:1 mapping to the array position in the clock-output-names

Ben & Laurent,

Quoted 7 lines

The clock-indices stuff looks sane to me. I've taken Ben's patch #1 into clk-next. It seems patch #3 might be dropped and patch #2 didn't apply cleanly for me.

Can Laurent's patches and Ben's #2 be rebased and sent together as a PR? I'll leave it up to you guys to figure out the backwards compatibility issue with Ben's patch #3.

Thanks, I've only just found this in my mailbox.
Is there still any actions I need to take?

Signature · 2 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius
#7 lore raw
In reply to Ben Dooks

Hi Ben,

Quoted 15 lines · On Sunday 02 March 2014 22:28:09 Ben Dooks wrote:
Quoted 14 lines · Mike Turquette

Quoting Ben Dooks (2014-02-13 10:02:49)

Quoted 5 lines

Add a property called clock-indices to allow clock-output-names to be used where the index used to lookup a clock is not a 1:1 mapping to the array position in the clock-output-names

Ben & Laurent,

The clock-indices stuff looks sane to me. I've taken Ben's patch #1 into clk-next. It seems patch #3 might be dropped and patch #2 didn't apply cleanly for me.

Quoted 6 lines
Quoted 3 lines

Can Laurent's patches and Ben's #2 be rebased and sent together as a PR? I'll leave it up to you guys to figure out the backwards compatibility issue with Ben's patch #3.

Thanks, I've only just found this in my mailbox.
Is there still any actions I need to take?

I've sent a pull request for my patches only. Could you please rebase yours ?

Signature · 3 lines
Regards,

Laurent Pinchart
author
#8 lore raw
In reply to Ben Dooks
Quoted 18 lines · Laurent Pinchart

Hi Ben,

Quoted 15 lines · On Sunday 02 March 2014 22:28:09 Ben Dooks wrote:
Quoted 14 lines · Mike Turquette

Quoting Ben Dooks (2014-02-13 10:02:49)

Quoted 5 lines

Add a property called clock-indices to allow clock-output-names to be used where the index used to lookup a clock is not a 1:1 mapping to the array position in the clock-output-names

Ben & Laurent,

The clock-indices stuff looks sane to me. I've taken Ben's patch #1 into clk-next. It seems patch #3 might be dropped and patch #2 didn't apply cleanly for me.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Can Laurent's patches and Ben's #2 be rebased and sent together as a PR? I'll leave it up to you guys to figure out the backwards compatibility issue with Ben's patch #3.

Thanks, I've only just found this in my mailbox.
Is there still any actions I need to take?

I've sent a pull request for my patches only. Could you please rebase yours ?

Ok, will go and see if I can find it.

Signature · 2 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius
author
#9 lore raw
In reply to Ben Dooks
Quoted 22 lines · Mike Turquette

Quoting Laurent Pinchart (2014-02-23 14:40:46)

Quoted 21 lines

Hi Mike,

Quoted 8 lines · On Sunday 23 February 2014 13:00:24 Mike Turquette wrote:

Quoting Ben Dooks (2014-02-13 10:02:49)

Quoted 5 lines

Add a property called clock-indices to allow clock-output-names to be used where the index used to lookup a clock is not a 1:1 mapping to the array position in the clock-output-names

Quoted 7 lines

Ben & Laurent,

The clock-indices stuff looks sane to me. I've taken Ben's patch #1 into clk-next. It seems patch #3 might be dropped and patch #2 didn't apply cleanly for me.

Can Laurent's patches and Ben's #2 be rebased and sent together as a PR?

Sure. I've pushed my pending patches to

Quoted 8 lines
Quoted 4 lines

git://linuxtv.org/pinchartl/fbdev.git clocks/next/drivers

Ben, could you please rebase your patch on top of it and repost ? I'll then send a pull request to Mike.

FYI, I've just pushed a new clk-next branch based on -rc3 out to my linaro remote. You don't need to rebase but it's there if you want to put your stuff on top of the latest.

Thanks. Will look at re-doing the reneasas clock driver as soon as we can get some discussion on the best way to deal with the merging.

Signature · 2 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius