diff mbox

clk: ti: change clock init to use generic of_clk_init

Message ID 1408628959-32442-1-git-send-email-t-kristo@ti.com
State New
Headers show

Commit Message

Tero Kristo Aug. 21, 2014, 1:49 p.m. UTC
Previously, the TI clock driver initialized all the clocks hierarchically
under each separate clock provider node. Now, each clock that requires
IO access will instead check their parent node to find out which IO range
to use.

This patch allows the TI clock driver to use a few new features provided
by the generic of_clk_init, and also allows registration of clock nodes
outside the clock hierarchy (for example, any external clocks.)

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Stefan Assmann <sassmann@kpanic.de>
---
 arch/arm/mach-omap2/io.c         |   10 ++++++++--
 arch/arm/mach-omap2/prm_common.c |    2 --
 drivers/clk/ti/clk.c             |   31 ++++++++++++++++---------------
 3 files changed, 24 insertions(+), 19 deletions(-)

Comments

Jyri Sarha Aug. 27, 2014, 3:15 p.m. UTC | #1
On 08/21/2014 04:49 PM, Tero Kristo wrote:
> Previously, the TI clock driver initialized all the clocks hierarchically
> under each separate clock provider node. Now, each clock that requires
> IO access will instead check their parent node to find out which IO range
> to use.
>
> This patch allows the TI clock driver to use a few new features provided
> by the generic of_clk_init, and also allows registration of clock nodes
> outside the clock hierarchy (for example, any external clocks.)
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
> Cc: Mike Turquette <mturquette@linaro.org>
> Cc: Paul Walmsley <paul@pwsan.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Stefan Assmann <sassmann@kpanic.de>

Tested-by: Jyri Sarha <jsarha@ti.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tony Lindgren Sept. 18, 2014, 5:17 p.m. UTC | #2
* Tero Kristo <t-kristo@ti.com> [140821 06:52]:
> Previously, the TI clock driver initialized all the clocks hierarchically
> under each separate clock provider node. Now, each clock that requires
> IO access will instead check their parent node to find out which IO range
> to use.
> 
> This patch allows the TI clock driver to use a few new features provided
> by the generic of_clk_init, and also allows registration of clock nodes
> outside the clock hierarchy (for example, any external clocks.)

Paul, any comments on this one?

Regards,

Tony
 
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
> Cc: Mike Turquette <mturquette@linaro.org>
> Cc: Paul Walmsley <paul@pwsan.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Stefan Assmann <sassmann@kpanic.de>
> ---
>  arch/arm/mach-omap2/io.c         |   10 ++++++++--
>  arch/arm/mach-omap2/prm_common.c |    2 --
>  drivers/clk/ti/clk.c             |   31 ++++++++++++++++---------------
>  3 files changed, 24 insertions(+), 19 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
> index 5d0667c..3325df6 100644
> --- a/arch/arm/mach-omap2/io.c
> +++ b/arch/arm/mach-omap2/io.c
> @@ -734,8 +734,14 @@ int __init omap_clk_init(void)
>  	ti_clk_init_features();
>  
>  	ret = of_prcm_init();
> -	if (!ret)
> -		ret = omap_clk_soc_init();
> +	if (ret)
> +		return ret;
> +
> +	of_clk_init(NULL);
> +
> +	ti_dt_clockdomains_setup();
> +
> +	ret = omap_clk_soc_init();
>  
>  	return ret;
>  }
> diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
> index 76ca320..3b89080 100644
> --- a/arch/arm/mach-omap2/prm_common.c
> +++ b/arch/arm/mach-omap2/prm_common.c
> @@ -525,8 +525,6 @@ int __init of_prcm_init(void)
>  		memmap_index++;
>  	}
>  
> -	ti_dt_clockdomains_setup();
> -
>  	return 0;
>  }
>  
> diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
> index b1a6f71..f7201d0 100644
> --- a/drivers/clk/ti/clk.c
> +++ b/drivers/clk/ti/clk.c
> @@ -25,8 +25,8 @@
>  #undef pr_fmt
>  #define pr_fmt(fmt) "%s: " fmt, __func__
>  
> -static int ti_dt_clk_memmap_index;
>  struct ti_clk_ll_ops *ti_clk_ll_ops;
> +static struct device_node *clocks_node_ptr[CLK_MAX_MEMMAPS];
>  
>  /**
>   * ti_dt_clocks_register - register DT alias clocks during boot
> @@ -108,9 +108,21 @@ void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index)
>  	struct clk_omap_reg *reg;
>  	u32 val;
>  	u32 tmp;
> +	int i;
>  
>  	reg = (struct clk_omap_reg *)&tmp;
> -	reg->index = ti_dt_clk_memmap_index;
> +
> +	for (i = 0; i < CLK_MAX_MEMMAPS; i++) {
> +		if (clocks_node_ptr[i] == node->parent)
> +			break;
> +	}
> +
> +	if (i == CLK_MAX_MEMMAPS) {
> +		pr_err("clk-provider not found for %s!\n", node->name);
> +		return NULL;
> +	}
> +
> +	reg->index = i;
>  
>  	if (of_property_read_u32_index(node, "reg", index, &val)) {
>  		pr_err("%s must have reg[%d]!\n", node->name, index);
> @@ -133,15 +145,10 @@ void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index)
>   */
>  void ti_dt_clk_init_provider(struct device_node *parent, int index)
>  {
> -	const struct of_device_id *match;
> -	struct device_node *np;
>  	struct device_node *clocks;
> -	of_clk_init_cb_t clk_init_cb;
>  	struct clk_init_item *retry;
>  	struct clk_init_item *tmp;
>  
> -	ti_dt_clk_memmap_index = index;
> -
>  	/* get clocks for this parent */
>  	clocks = of_get_child_by_name(parent, "clocks");
>  	if (!clocks) {
> @@ -149,14 +156,8 @@ void ti_dt_clk_init_provider(struct device_node *parent, int index)
>  		return;
>  	}
>  
> -	for_each_child_of_node(clocks, np) {
> -		match = of_match_node(&__clk_of_table, np);
> -		if (!match)
> -			continue;
> -		clk_init_cb = (of_clk_init_cb_t)match->data;
> -		pr_debug("%s: initializing: %s\n", __func__, np->name);
> -		clk_init_cb(np);
> -	}
> +	/* add clocks node info */
> +	clocks_node_ptr[index] = clocks;
>  
>  	list_for_each_entry_safe(retry, tmp, &retry_list, link) {
>  		pr_debug("retry-init: %s\n", retry->node->name);
> -- 
> 1.7.9.5
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paul Walmsley Sept. 19, 2014, 4:33 p.m. UTC | #3
On Thu, 18 Sep 2014, Tony Lindgren wrote:

> * Tero Kristo <t-kristo@ti.com> [140821 06:52]:
> > Previously, the TI clock driver initialized all the clocks hierarchically
> > under each separate clock provider node. Now, each clock that requires
> > IO access will instead check their parent node to find out which IO range
> > to use.
> > 
> > This patch allows the TI clock driver to use a few new features provided
> > by the generic of_clk_init, and also allows registration of clock nodes
> > outside the clock hierarchy (for example, any external clocks.)
> 
> Paul, any comments on this one?

Not at this point.


- Paul
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tero Kristo Sept. 22, 2014, 6:52 a.m. UTC | #4
On 09/19/2014 07:33 PM, Paul Walmsley wrote:
> On Thu, 18 Sep 2014, Tony Lindgren wrote:
>
>> * Tero Kristo <t-kristo@ti.com> [140821 06:52]:
>>> Previously, the TI clock driver initialized all the clocks hierarchically
>>> under each separate clock provider node. Now, each clock that requires
>>> IO access will instead check their parent node to find out which IO range
>>> to use.
>>>
>>> This patch allows the TI clock driver to use a few new features provided
>>> by the generic of_clk_init, and also allows registration of clock nodes
>>> outside the clock hierarchy (for example, any external clocks.)
>>
>> Paul, any comments on this one?
>
> Not at this point.

Tony, ok to merge this through clock tree?

-Tero

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tero Kristo Sept. 22, 2014, 7:55 a.m. UTC | #5
On 09/22/2014 09:52 AM, Tero Kristo wrote:
> On 09/19/2014 07:33 PM, Paul Walmsley wrote:
>> On Thu, 18 Sep 2014, Tony Lindgren wrote:
>>
>>> * Tero Kristo <t-kristo@ti.com> [140821 06:52]:
>>>> Previously, the TI clock driver initialized all the clocks
>>>> hierarchically
>>>> under each separate clock provider node. Now, each clock that requires
>>>> IO access will instead check their parent node to find out which IO
>>>> range
>>>> to use.
>>>>
>>>> This patch allows the TI clock driver to use a few new features
>>>> provided
>>>> by the generic of_clk_init, and also allows registration of clock nodes
>>>> outside the clock hierarchy (for example, any external clocks.)
>>>
>>> Paul, any comments on this one?
>>
>> Not at this point.
>
> Tony, ok to merge this through clock tree?

Oh btw, this is v1, I posted v2 a week back here:

http://article.gmane.org/gmane.linux.ports.arm.omap/118551

v2 has the retry init logic fixed in it (mainly for DPLLs which can have 
two separate parents which of both must be available during init.)

-Tero
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tony Lindgren Sept. 23, 2014, 3:49 p.m. UTC | #6
* Tero Kristo <t-kristo@ti.com> [140922 00:55]:
> On 09/22/2014 09:52 AM, Tero Kristo wrote:
> >On 09/19/2014 07:33 PM, Paul Walmsley wrote:
> >>On Thu, 18 Sep 2014, Tony Lindgren wrote:
> >>
> >>>* Tero Kristo <t-kristo@ti.com> [140821 06:52]:
> >>>>Previously, the TI clock driver initialized all the clocks
> >>>>hierarchically
> >>>>under each separate clock provider node. Now, each clock that requires
> >>>>IO access will instead check their parent node to find out which IO
> >>>>range
> >>>>to use.
> >>>>
> >>>>This patch allows the TI clock driver to use a few new features
> >>>>provided
> >>>>by the generic of_clk_init, and also allows registration of clock nodes
> >>>>outside the clock hierarchy (for example, any external clocks.)
> >>>
> >>>Paul, any comments on this one?
> >>
> >>Not at this point.
> >
> >Tony, ok to merge this through clock tree?
> 
> Oh btw, this is v1, I posted v2 a week back here:
> 
> http://article.gmane.org/gmane.linux.ports.arm.omap/118551
> 
> v2 has the retry init logic fixed in it (mainly for DPLLs which can have two
> separate parents which of both must be available during init.)

Oh OK. I acked that one so please feel free to merge it via the
clock tree. It does not seem to confilict with anything I have
queued up.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" 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/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 5d0667c..3325df6 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -734,8 +734,14 @@  int __init omap_clk_init(void)
 	ti_clk_init_features();
 
 	ret = of_prcm_init();
-	if (!ret)
-		ret = omap_clk_soc_init();
+	if (ret)
+		return ret;
+
+	of_clk_init(NULL);
+
+	ti_dt_clockdomains_setup();
+
+	ret = omap_clk_soc_init();
 
 	return ret;
 }
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index 76ca320..3b89080 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -525,8 +525,6 @@  int __init of_prcm_init(void)
 		memmap_index++;
 	}
 
-	ti_dt_clockdomains_setup();
-
 	return 0;
 }
 
diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
index b1a6f71..f7201d0 100644
--- a/drivers/clk/ti/clk.c
+++ b/drivers/clk/ti/clk.c
@@ -25,8 +25,8 @@ 
 #undef pr_fmt
 #define pr_fmt(fmt) "%s: " fmt, __func__
 
-static int ti_dt_clk_memmap_index;
 struct ti_clk_ll_ops *ti_clk_ll_ops;
+static struct device_node *clocks_node_ptr[CLK_MAX_MEMMAPS];
 
 /**
  * ti_dt_clocks_register - register DT alias clocks during boot
@@ -108,9 +108,21 @@  void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index)
 	struct clk_omap_reg *reg;
 	u32 val;
 	u32 tmp;
+	int i;
 
 	reg = (struct clk_omap_reg *)&tmp;
-	reg->index = ti_dt_clk_memmap_index;
+
+	for (i = 0; i < CLK_MAX_MEMMAPS; i++) {
+		if (clocks_node_ptr[i] == node->parent)
+			break;
+	}
+
+	if (i == CLK_MAX_MEMMAPS) {
+		pr_err("clk-provider not found for %s!\n", node->name);
+		return NULL;
+	}
+
+	reg->index = i;
 
 	if (of_property_read_u32_index(node, "reg", index, &val)) {
 		pr_err("%s must have reg[%d]!\n", node->name, index);
@@ -133,15 +145,10 @@  void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index)
  */
 void ti_dt_clk_init_provider(struct device_node *parent, int index)
 {
-	const struct of_device_id *match;
-	struct device_node *np;
 	struct device_node *clocks;
-	of_clk_init_cb_t clk_init_cb;
 	struct clk_init_item *retry;
 	struct clk_init_item *tmp;
 
-	ti_dt_clk_memmap_index = index;
-
 	/* get clocks for this parent */
 	clocks = of_get_child_by_name(parent, "clocks");
 	if (!clocks) {
@@ -149,14 +156,8 @@  void ti_dt_clk_init_provider(struct device_node *parent, int index)
 		return;
 	}
 
-	for_each_child_of_node(clocks, np) {
-		match = of_match_node(&__clk_of_table, np);
-		if (!match)
-			continue;
-		clk_init_cb = (of_clk_init_cb_t)match->data;
-		pr_debug("%s: initializing: %s\n", __func__, np->name);
-		clk_init_cb(np);
-	}
+	/* add clocks node info */
+	clocks_node_ptr[index] = clocks;
 
 	list_for_each_entry_safe(retry, tmp, &retry_list, link) {
 		pr_debug("retry-init: %s\n", retry->node->name);