Patchwork [RFC,v2,08/16] ARM: mxs: remove custom .init_time hook

login
register
mail settings
Submitter Sebastian Hesselbarth
Date Aug. 27, 2013, 9:28 p.m.
Message ID <1377638890-371-9-git-send-email-sebastian.hesselbarth@gmail.com>
Download mbox | patch
Permalink /patch/270276/
State New
Headers show

Comments

Sebastian Hesselbarth - Aug. 27, 2013, 9:28 p.m.
This patch converts clk-imx2[38] clocksource_of_init compatible init
associated with fsl,imx2[38]-clkctrl. With arch/arm calling
of_clk_init(NULL) from time_init(), we can now also remove custom
.init_time hooks.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 arch/arm/mach-mxs/mach-mxs.c |   13 -------------
 drivers/clk/mxs/clk-imx23.c  |   16 +++++++---------
 drivers/clk/mxs/clk-imx28.c  |   16 +++++++---------
 include/linux/clk/mxs.h      |    2 --
 4 files changed, 14 insertions(+), 33 deletions(-)
Mike Turquette - Aug. 27, 2013, 11:16 p.m.
Quoting Sebastian Hesselbarth (2013-08-27 14:28:02)
> This patch converts clk-imx2[38] clocksource_of_init compatible init
> associated with fsl,imx2[38]-clkctrl. With arch/arm calling
> of_clk_init(NULL) from time_init(), we can now also remove custom
> .init_time hooks.
> 
> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>

Acked-by: Mike Turquette <mturquette@linaro.org>

Need Shawn's Ack for this as well.

> ---
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Cc: Mike Turquette <mturquette@linaro.org>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  arch/arm/mach-mxs/mach-mxs.c |   13 -------------
>  drivers/clk/mxs/clk-imx23.c  |   16 +++++++---------
>  drivers/clk/mxs/clk-imx28.c  |   16 +++++++---------
>  include/linux/clk/mxs.h      |    2 --
>  4 files changed, 14 insertions(+), 33 deletions(-)
> 
> diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
> index 98f6e2a..cc511a4 100644
> --- a/arch/arm/mach-mxs/mach-mxs.c
> +++ b/arch/arm/mach-mxs/mach-mxs.c
> @@ -13,8 +13,6 @@
>  #include <linux/clk.h>
>  #include <linux/clk/mxs.h>
>  #include <linux/clkdev.h>
> -#include <linux/clocksource.h>
> -#include <linux/clk-provider.h>
>  #include <linux/delay.h>
>  #include <linux/err.h>
>  #include <linux/gpio.h>
> @@ -490,16 +488,6 @@ static void mxs_restart(enum reboot_mode mode, const char *cmd)
>         soft_restart(0);
>  }
>  
> -static void __init mxs_timer_init(void)
> -{
> -       if (of_machine_is_compatible("fsl,imx23"))
> -               mx23_clocks_init();
> -       else
> -               mx28_clocks_init();
> -       of_clk_init(NULL);
> -       clocksource_of_init();
> -}
> -
>  static const char *mxs_dt_compat[] __initdata = {
>         "fsl,imx28",
>         "fsl,imx23",
> @@ -508,7 +496,6 @@ static const char *mxs_dt_compat[] __initdata = {
>  
>  DT_MACHINE_START(MXS, "Freescale MXS (Device Tree)")
>         .handle_irq     = icoll_handle_irq,
> -       .init_time      = mxs_timer_init,
>         .init_machine   = mxs_machine_init,
>         .init_late      = mxs_pm_init,
>         .dt_compat      = mxs_dt_compat,
> diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c
> index c396fe3..7eb1d1a 100644
> --- a/drivers/clk/mxs/clk-imx23.c
> +++ b/drivers/clk/mxs/clk-imx23.c
> @@ -12,6 +12,7 @@
>  #include <linux/clk.h>
>  #include <linux/clk/mxs.h>
>  #include <linux/clkdev.h>
> +#include <linux/clk-provider.h>
>  #include <linux/err.h>
>  #include <linux/init.h>
>  #include <linux/io.h>
> @@ -100,19 +101,17 @@ static enum imx23_clk clks_init_on[] __initdata = {
>         cpu, hbus, xbus, emi, uart,
>  };
>  
> -int __init mx23_clocks_init(void)
> +static void __init mx23_clocks_init(struct device_node *np)
>  {
> -       struct device_node *np;
>         u32 i;
>  
> +       clkctrl = of_iomap(np, 0);
> +       WARN_ON(!clkctrl);
> +
>         np = of_find_compatible_node(NULL, NULL, "fsl,imx23-digctl");
>         digctrl = of_iomap(np, 0);
>         WARN_ON(!digctrl);
>  
> -       np = of_find_compatible_node(NULL, NULL, "fsl,imx23-clkctrl");
> -       clkctrl = of_iomap(np, 0);
> -       WARN_ON(!clkctrl);
> -
>         clk_misc_init();
>  
>         clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
> @@ -162,7 +161,7 @@ int __init mx23_clocks_init(void)
>                 if (IS_ERR(clks[i])) {
>                         pr_err("i.MX23 clk %d: register failed with %ld\n",
>                                 i, PTR_ERR(clks[i]));
> -                       return PTR_ERR(clks[i]);
> +                       return;
>                 }
>  
>         clk_data.clks = clks;
> @@ -171,6 +170,5 @@ int __init mx23_clocks_init(void)
>  
>         for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
>                 clk_prepare_enable(clks[clks_init_on[i]]);
> -
> -       return 0;
>  }
> +CLK_OF_DECLARE(imx23_clkctrl, "fsl,imx23-clkctrl", mx23_clocks_init);
> diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
> index 4faf0af..12d3f3d 100644
> --- a/drivers/clk/mxs/clk-imx28.c
> +++ b/drivers/clk/mxs/clk-imx28.c
> @@ -12,6 +12,7 @@
>  #include <linux/clk.h>
>  #include <linux/clk/mxs.h>
>  #include <linux/clkdev.h>
> +#include <linux/clk-provider.h>
>  #include <linux/err.h>
>  #include <linux/init.h>
>  #include <linux/io.h>
> @@ -154,19 +155,17 @@ static enum imx28_clk clks_init_on[] __initdata = {
>         cpu, hbus, xbus, emi, uart,
>  };
>  
> -int __init mx28_clocks_init(void)
> +static void __init mx28_clocks_init(struct device_node *np)
>  {
> -       struct device_node *np;
>         u32 i;
>  
> +       clkctrl = of_iomap(np, 0);
> +       WARN_ON(!clkctrl);
> +
>         np = of_find_compatible_node(NULL, NULL, "fsl,imx28-digctl");
>         digctrl = of_iomap(np, 0);
>         WARN_ON(!digctrl);
>  
> -       np = of_find_compatible_node(NULL, NULL, "fsl,imx28-clkctrl");
> -       clkctrl = of_iomap(np, 0);
> -       WARN_ON(!clkctrl);
> -
>         clk_misc_init();
>  
>         clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
> @@ -239,7 +238,7 @@ int __init mx28_clocks_init(void)
>                 if (IS_ERR(clks[i])) {
>                         pr_err("i.MX28 clk %d: register failed with %ld\n",
>                                 i, PTR_ERR(clks[i]));
> -                       return PTR_ERR(clks[i]);
> +                       return;
>                 }
>  
>         clk_data.clks = clks;
> @@ -250,6 +249,5 @@ int __init mx28_clocks_init(void)
>  
>         for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
>                 clk_prepare_enable(clks[clks_init_on[i]]);
> -
> -       return 0;
>  }
> +CLK_OF_DECLARE(imx28_clkctrl, "fsl,imx28-clkctrl", mx28_clocks_init);
> diff --git a/include/linux/clk/mxs.h b/include/linux/clk/mxs.h
> index 90c30dc..5138a90 100644
> --- a/include/linux/clk/mxs.h
> +++ b/include/linux/clk/mxs.h
> @@ -9,8 +9,6 @@
>  #ifndef __LINUX_CLK_MXS_H
>  #define __LINUX_CLK_MXS_H
>  
> -int mx23_clocks_init(void);
> -int mx28_clocks_init(void);
>  int mxs_saif_clkmux_select(unsigned int clkmux);
>  
>  #endif
> -- 
> 1.7.2.5
Shawn Guo - Aug. 29, 2013, 11:08 a.m.
On Tue, Aug 27, 2013 at 11:28:02PM +0200, Sebastian Hesselbarth wrote:
> @@ -100,19 +101,17 @@ static enum imx23_clk clks_init_on[] __initdata = {
>  	cpu, hbus, xbus, emi, uart,
>  };
>  
> -int __init mx23_clocks_init(void)
> +static void __init mx23_clocks_init(struct device_node *np)
>  {
> -	struct device_node *np;
>  	u32 i;
>  
> +	clkctrl = of_iomap(np, 0);
> +	WARN_ON(!clkctrl);
> +
>  	np = of_find_compatible_node(NULL, NULL, "fsl,imx23-digctl");
>  	digctrl = of_iomap(np, 0);
>  	WARN_ON(!digctrl);
>  
> -	np = of_find_compatible_node(NULL, NULL, "fsl,imx23-clkctrl");
> -	clkctrl = of_iomap(np, 0);
> -	WARN_ON(!clkctrl);
> -

With the changes, 'np' becomes a pointer to digctl node instead of
clkctrl as the original.  This will cause problem for
of_clk_add_provider(np, ...) later in this function.

Same problem with mx28_clocks_init() changes.

Shawn

>  	clk_misc_init();
>  
>  	clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
> @@ -162,7 +161,7 @@ int __init mx23_clocks_init(void)
>  		if (IS_ERR(clks[i])) {
>  			pr_err("i.MX23 clk %d: register failed with %ld\n",
>  				i, PTR_ERR(clks[i]));
> -			return PTR_ERR(clks[i]);
> +			return;
>  		}
>  
>  	clk_data.clks = clks;
> @@ -171,6 +170,5 @@ int __init mx23_clocks_init(void)
>  
>  	for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
>  		clk_prepare_enable(clks[clks_init_on[i]]);
> -
> -	return 0;
>  }
> +CLK_OF_DECLARE(imx23_clkctrl, "fsl,imx23-clkctrl", mx23_clocks_init);
> diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
> index 4faf0af..12d3f3d 100644
> --- a/drivers/clk/mxs/clk-imx28.c
> +++ b/drivers/clk/mxs/clk-imx28.c
> @@ -12,6 +12,7 @@
>  #include <linux/clk.h>
>  #include <linux/clk/mxs.h>
>  #include <linux/clkdev.h>
> +#include <linux/clk-provider.h>
>  #include <linux/err.h>
>  #include <linux/init.h>
>  #include <linux/io.h>
> @@ -154,19 +155,17 @@ static enum imx28_clk clks_init_on[] __initdata = {
>  	cpu, hbus, xbus, emi, uart,
>  };
>  
> -int __init mx28_clocks_init(void)
> +static void __init mx28_clocks_init(struct device_node *np)
>  {
> -	struct device_node *np;
>  	u32 i;
>  
> +	clkctrl = of_iomap(np, 0);
> +	WARN_ON(!clkctrl);
> +
>  	np = of_find_compatible_node(NULL, NULL, "fsl,imx28-digctl");
>  	digctrl = of_iomap(np, 0);
>  	WARN_ON(!digctrl);
>  
> -	np = of_find_compatible_node(NULL, NULL, "fsl,imx28-clkctrl");
> -	clkctrl = of_iomap(np, 0);
> -	WARN_ON(!clkctrl);
> -
>  	clk_misc_init();
>  
>  	clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
> @@ -239,7 +238,7 @@ int __init mx28_clocks_init(void)
>  		if (IS_ERR(clks[i])) {
>  			pr_err("i.MX28 clk %d: register failed with %ld\n",
>  				i, PTR_ERR(clks[i]));
> -			return PTR_ERR(clks[i]);
> +			return;
>  		}
>  
>  	clk_data.clks = clks;
> @@ -250,6 +249,5 @@ int __init mx28_clocks_init(void)
>  
>  	for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
>  		clk_prepare_enable(clks[clks_init_on[i]]);
> -
> -	return 0;
>  }
> +CLK_OF_DECLARE(imx28_clkctrl, "fsl,imx28-clkctrl", mx28_clocks_init);
> diff --git a/include/linux/clk/mxs.h b/include/linux/clk/mxs.h
> index 90c30dc..5138a90 100644
> --- a/include/linux/clk/mxs.h
> +++ b/include/linux/clk/mxs.h
> @@ -9,8 +9,6 @@
>  #ifndef __LINUX_CLK_MXS_H
>  #define __LINUX_CLK_MXS_H
>  
> -int mx23_clocks_init(void);
> -int mx28_clocks_init(void);
>  int mxs_saif_clkmux_select(unsigned int clkmux);
>  
>  #endif
> -- 
> 1.7.2.5
>
Sebastian Hesselbarth - Aug. 29, 2013, 11:32 a.m.
On 08/29/13 13:08, Shawn Guo wrote:
> On Tue, Aug 27, 2013 at 11:28:02PM +0200, Sebastian Hesselbarth wrote:
>> @@ -100,19 +101,17 @@ static enum imx23_clk clks_init_on[] __initdata = {
>>   	cpu, hbus, xbus, emi, uart,
>>   };
>>
>> -int __init mx23_clocks_init(void)
>> +static void __init mx23_clocks_init(struct device_node *np)
>>   {
>> -	struct device_node *np;
>>   	u32 i;
>>
>> +	clkctrl = of_iomap(np, 0);
>> +	WARN_ON(!clkctrl);
>> +
>>   	np = of_find_compatible_node(NULL, NULL, "fsl,imx23-digctl");
>>   	digctrl = of_iomap(np, 0);
>>   	WARN_ON(!digctrl);
>>
>> -	np = of_find_compatible_node(NULL, NULL, "fsl,imx23-clkctrl");
>> -	clkctrl = of_iomap(np, 0);
>> -	WARN_ON(!clkctrl);
>> -
>
> With the changes, 'np' becomes a pointer to digctl node instead of
> clkctrl as the original.  This will cause problem for
> of_clk_add_provider(np, ...) later in this function.
>
> Same problem with mx28_clocks_init() changes.

Ok, will take care of it. I assume you are fine with having an extra
struct device_node pointer for the sake of readability instead of
reusing the same pointer.

Sebastian
Shawn Guo - Aug. 29, 2013, 12:58 p.m.
On Thu, Aug 29, 2013 at 01:32:33PM +0200, Sebastian Hesselbarth wrote:
> Ok, will take care of it. I assume you are fine with having an extra
> struct device_node pointer for the sake of readability instead of
> reusing the same pointer.

Yeah, something like np_digctl for digctl node.

Thanks for your work.

Shawn

Patch

diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
index 98f6e2a..cc511a4 100644
--- a/arch/arm/mach-mxs/mach-mxs.c
+++ b/arch/arm/mach-mxs/mach-mxs.c
@@ -13,8 +13,6 @@ 
 #include <linux/clk.h>
 #include <linux/clk/mxs.h>
 #include <linux/clkdev.h>
-#include <linux/clocksource.h>
-#include <linux/clk-provider.h>
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/gpio.h>
@@ -490,16 +488,6 @@  static void mxs_restart(enum reboot_mode mode, const char *cmd)
 	soft_restart(0);
 }
 
-static void __init mxs_timer_init(void)
-{
-	if (of_machine_is_compatible("fsl,imx23"))
-		mx23_clocks_init();
-	else
-		mx28_clocks_init();
-	of_clk_init(NULL);
-	clocksource_of_init();
-}
-
 static const char *mxs_dt_compat[] __initdata = {
 	"fsl,imx28",
 	"fsl,imx23",
@@ -508,7 +496,6 @@  static const char *mxs_dt_compat[] __initdata = {
 
 DT_MACHINE_START(MXS, "Freescale MXS (Device Tree)")
 	.handle_irq	= icoll_handle_irq,
-	.init_time	= mxs_timer_init,
 	.init_machine	= mxs_machine_init,
 	.init_late      = mxs_pm_init,
 	.dt_compat	= mxs_dt_compat,
diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c
index c396fe3..7eb1d1a 100644
--- a/drivers/clk/mxs/clk-imx23.c
+++ b/drivers/clk/mxs/clk-imx23.c
@@ -12,6 +12,7 @@ 
 #include <linux/clk.h>
 #include <linux/clk/mxs.h>
 #include <linux/clkdev.h>
+#include <linux/clk-provider.h>
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/io.h>
@@ -100,19 +101,17 @@  static enum imx23_clk clks_init_on[] __initdata = {
 	cpu, hbus, xbus, emi, uart,
 };
 
-int __init mx23_clocks_init(void)
+static void __init mx23_clocks_init(struct device_node *np)
 {
-	struct device_node *np;
 	u32 i;
 
+	clkctrl = of_iomap(np, 0);
+	WARN_ON(!clkctrl);
+
 	np = of_find_compatible_node(NULL, NULL, "fsl,imx23-digctl");
 	digctrl = of_iomap(np, 0);
 	WARN_ON(!digctrl);
 
-	np = of_find_compatible_node(NULL, NULL, "fsl,imx23-clkctrl");
-	clkctrl = of_iomap(np, 0);
-	WARN_ON(!clkctrl);
-
 	clk_misc_init();
 
 	clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
@@ -162,7 +161,7 @@  int __init mx23_clocks_init(void)
 		if (IS_ERR(clks[i])) {
 			pr_err("i.MX23 clk %d: register failed with %ld\n",
 				i, PTR_ERR(clks[i]));
-			return PTR_ERR(clks[i]);
+			return;
 		}
 
 	clk_data.clks = clks;
@@ -171,6 +170,5 @@  int __init mx23_clocks_init(void)
 
 	for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
 		clk_prepare_enable(clks[clks_init_on[i]]);
-
-	return 0;
 }
+CLK_OF_DECLARE(imx23_clkctrl, "fsl,imx23-clkctrl", mx23_clocks_init);
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
index 4faf0af..12d3f3d 100644
--- a/drivers/clk/mxs/clk-imx28.c
+++ b/drivers/clk/mxs/clk-imx28.c
@@ -12,6 +12,7 @@ 
 #include <linux/clk.h>
 #include <linux/clk/mxs.h>
 #include <linux/clkdev.h>
+#include <linux/clk-provider.h>
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/io.h>
@@ -154,19 +155,17 @@  static enum imx28_clk clks_init_on[] __initdata = {
 	cpu, hbus, xbus, emi, uart,
 };
 
-int __init mx28_clocks_init(void)
+static void __init mx28_clocks_init(struct device_node *np)
 {
-	struct device_node *np;
 	u32 i;
 
+	clkctrl = of_iomap(np, 0);
+	WARN_ON(!clkctrl);
+
 	np = of_find_compatible_node(NULL, NULL, "fsl,imx28-digctl");
 	digctrl = of_iomap(np, 0);
 	WARN_ON(!digctrl);
 
-	np = of_find_compatible_node(NULL, NULL, "fsl,imx28-clkctrl");
-	clkctrl = of_iomap(np, 0);
-	WARN_ON(!clkctrl);
-
 	clk_misc_init();
 
 	clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
@@ -239,7 +238,7 @@  int __init mx28_clocks_init(void)
 		if (IS_ERR(clks[i])) {
 			pr_err("i.MX28 clk %d: register failed with %ld\n",
 				i, PTR_ERR(clks[i]));
-			return PTR_ERR(clks[i]);
+			return;
 		}
 
 	clk_data.clks = clks;
@@ -250,6 +249,5 @@  int __init mx28_clocks_init(void)
 
 	for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
 		clk_prepare_enable(clks[clks_init_on[i]]);
-
-	return 0;
 }
+CLK_OF_DECLARE(imx28_clkctrl, "fsl,imx28-clkctrl", mx28_clocks_init);
diff --git a/include/linux/clk/mxs.h b/include/linux/clk/mxs.h
index 90c30dc..5138a90 100644
--- a/include/linux/clk/mxs.h
+++ b/include/linux/clk/mxs.h
@@ -9,8 +9,6 @@ 
 #ifndef __LINUX_CLK_MXS_H
 #define __LINUX_CLK_MXS_H
 
-int mx23_clocks_init(void);
-int mx28_clocks_init(void);
 int mxs_saif_clkmux_select(unsigned int clkmux);
 
 #endif