[v2,3/6] dt: add new member 'clk' into device_node

Message ID 1300472672-13392-4-git-send-email-shawn.guo@linaro.org
State New
Headers show

Commit Message

Shawn Guo March 18, 2011, 6:24 p.m.
This pointer to 'struct clk' is added to save the reference to 'clk'
which is dynamically created per dt clock node, so that clkdev API
like clk_get can work with dt based device driver.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 include/linux/of.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Comments

Grant Likely March 31, 2011, 7:59 p.m. | #1
On Sat, Mar 19, 2011 at 02:24:29AM +0800, Shawn Guo wrote:
> This pointer to 'struct clk' is added to save the reference to 'clk'
> which is dynamically created per dt clock node, so that clkdev API
> like clk_get can work with dt based device driver.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  include/linux/of.h |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/of.h b/include/linux/of.h
> index d9dd664..e621295 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -54,6 +54,7 @@ struct device_node {
>  	struct	device_node *allnext;	/* next in list of all nodes */
>  	struct	proc_dir_entry *pde;	/* this node's proc directory */
>  	struct	kref kref;
> +	struct	clk *clk;

The dt clock support code can already translate from dt node to a
clock provider, and each clock provider should provide a .get() hook
to return the correct struct clk.  of_clk_add_provider() inserts a
mapping into the of_clk_providers() list, and clk_get() calls
of_clk_get() which will process a devicenode->clk provider mapping.

Adding a struct clk pointer to the device node isn't sufficient since
a single clock provider node can provide multiple clock outputs.

g.

Patch

diff --git a/include/linux/of.h b/include/linux/of.h
index d9dd664..e621295 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -54,6 +54,7 @@  struct device_node {
 	struct	device_node *allnext;	/* next in list of all nodes */
 	struct	proc_dir_entry *pde;	/* this node's proc directory */
 	struct	kref kref;
+	struct	clk *clk;
 	unsigned long _flags;
 	void	*data;
 #if defined(CONFIG_SPARC)