linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] ARM: imx31/of: clk: init clock controller with CLK_OF_DECLARE
@ 2016-09-19  2:42 Vladimir Zapolskiy
  2016-09-19  2:42 ` [PATCH 1/2] ARM: imx31: remove mx31_clocks_init_dt() function calls Vladimir Zapolskiy
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Vladimir Zapolskiy @ 2016-09-19  2:42 UTC (permalink / raw)
  To: linux-arm-kernel

The change is based on v4.8.0-rc1 and plus it depends on this fixup:

  ARM: dts: imx31: fix clock control module interrupts description

The change is tested on qemu kzm target and mx31lite board, while both
targets don't have DTS in upstream, I had to write simple DTS files for
them, because the proposed change is for i.MX31 targets with OF support.

The second change in the series compilation time dependent on the first
one, while the first change apparently should break runtime execution
of i.MX31 boards with OF support, if both changes are applied everything
should be fine, regression testing on the same legacy targets does not
show any problems. Moreover i.MX31/OF/clock initialization seems to be
broken currently, if the change is not applied I can not get a working
clock source during early boot stage, jiffies are not incremented, but
because I didn't check the problem thoroughly (can it be caused by
missing CLK_OF_DECLARE? Or caused by something fixed by the change
http://www.spinics.net/lists/linux-clk/msg12235.html ?) and because
the change was tested against code which is not found in upstream,
I won't call this change as a fix, however its application is apparently
wanted to get better OF support for i.MX31 targets.

Vladimir Zapolskiy (2):
  ARM: imx31: remove mx31_clocks_init_dt() function calls
  clk: imx31: properly init clocks for machines with DT

 arch/arm/mach-imx/common.h   |  1 -
 arch/arm/mach-imx/imx31-dt.c |  6 ------
 drivers/clk/imx/clk-imx31.c  | 49 ++++++++++++++++++++++----------------------
 3 files changed, 25 insertions(+), 31 deletions(-)

-- 
2.8.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] ARM: imx31: remove mx31_clocks_init_dt() function calls
  2016-09-19  2:42 [PATCH 0/2] ARM: imx31/of: clk: init clock controller with CLK_OF_DECLARE Vladimir Zapolskiy
@ 2016-09-19  2:42 ` Vladimir Zapolskiy
  2016-09-19  2:42 ` [PATCH 2/2] clk: imx31: properly init clocks for machines with DT Vladimir Zapolskiy
  2016-09-19  5:58 ` [PATCH 0/2] ARM: imx31/of: clk: init clock controller with CLK_OF_DECLARE Uwe Kleine-König
  2 siblings, 0 replies; 6+ messages in thread
From: Vladimir Zapolskiy @ 2016-09-19  2:42 UTC (permalink / raw)
  To: linux-arm-kernel

Clock initialization for i.MX31 powered machines with DT support
should be done by a call of an init function registered with
CLK_OF_DECLARE() in common clock framework.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
---
 arch/arm/mach-imx/common.h   | 1 -
 arch/arm/mach-imx/imx31-dt.c | 6 ------
 2 files changed, 7 deletions(-)

diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
index a8f4693..e97d8cb 100644
--- a/arch/arm/mach-imx/common.h
+++ b/arch/arm/mach-imx/common.h
@@ -48,7 +48,6 @@ int mx21_clocks_init(unsigned long lref, unsigned long fref);
 int mx27_clocks_init(unsigned long fref);
 int mx31_clocks_init(unsigned long fref);
 int mx35_clocks_init(void);
-int mx31_clocks_init_dt(void);
 struct platform_device *mxc_register_gpio(char *name, int id,
 	resource_size_t iobase, resource_size_t iosize, int irq, int irq_high);
 void mxc_set_cpu_type(unsigned int type);
diff --git a/arch/arm/mach-imx/imx31-dt.c b/arch/arm/mach-imx/imx31-dt.c
index 62e6b4f..668d74b 100644
--- a/arch/arm/mach-imx/imx31-dt.c
+++ b/arch/arm/mach-imx/imx31-dt.c
@@ -23,11 +23,6 @@ static const char * const imx31_dt_board_compat[] __initconst = {
 	NULL
 };
 
-static void __init imx31_dt_timer_init(void)
-{
-	mx31_clocks_init_dt();
-}
-
 /* FIXME: replace with DT binding */
 static const struct resource imx31_rnga_res[] __initconst = {
 	DEFINE_RES_MEM(MX31_RNGA_BASE_ADDR, SZ_16K),
@@ -43,7 +38,6 @@ DT_MACHINE_START(IMX31_DT, "Freescale i.MX31 (Device Tree Support)")
 	.map_io		= mx31_map_io,
 	.init_early	= imx31_init_early,
 	.init_irq	= mx31_init_irq,
-	.init_time	= imx31_dt_timer_init,
 	.init_machine	= imx31_dt_mach_init,
 	.dt_compat	= imx31_dt_board_compat,
 MACHINE_END
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] clk: imx31: properly init clocks for machines with DT
  2016-09-19  2:42 [PATCH 0/2] ARM: imx31/of: clk: init clock controller with CLK_OF_DECLARE Vladimir Zapolskiy
  2016-09-19  2:42 ` [PATCH 1/2] ARM: imx31: remove mx31_clocks_init_dt() function calls Vladimir Zapolskiy
@ 2016-09-19  2:42 ` Vladimir Zapolskiy
  2016-09-20 17:36   ` Stephen Boyd
  2016-09-19  5:58 ` [PATCH 0/2] ARM: imx31/of: clk: init clock controller with CLK_OF_DECLARE Uwe Kleine-König
  2 siblings, 1 reply; 6+ messages in thread
From: Vladimir Zapolskiy @ 2016-09-19  2:42 UTC (permalink / raw)
  To: linux-arm-kernel

The change converts exported mx31_clocks_init_dt() into a static
initialization function registered by CLK_OF_DECLARE().

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
---
 drivers/clk/imx/clk-imx31.c | 50 +++++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 24 deletions(-)

diff --git a/drivers/clk/imx/clk-imx31.c b/drivers/clk/imx/clk-imx31.c
index 6a49ba2..cbce308 100644
--- a/drivers/clk/imx/clk-imx31.c
+++ b/drivers/clk/imx/clk-imx31.c
@@ -21,6 +21,7 @@
 #include <linux/io.h>
 #include <linux/err.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <soc/imx/revision.h>
 #include <soc/imx/timer.h>
 #include <asm/irq.h>
@@ -72,14 +73,8 @@ static struct clk ** const uart_clks[] __initconst = {
 	NULL
 };
 
-static void __init _mx31_clocks_init(unsigned long fref)
+static void __init _mx31_clocks_init(void __iomem *base, unsigned long fref)
 {
-	void __iomem *base;
-	struct device_node *np;
-
-	base = ioremap(MX31_CCM_BASE_ADDR, SZ_4K);
-	BUG_ON(!base);
-
 	clk[dummy] = imx_clk_fixed("dummy", 0);
 	clk[ckih] = imx_clk_fixed("ckih", fref);
 	clk[ckil] = imx_clk_fixed("ckil", 32768);
@@ -147,19 +142,17 @@ static void __init _mx31_clocks_init(unsigned long fref)
 	clk_prepare_enable(clk[iim_gate]);
 	mx31_revision();
 	clk_disable_unprepare(clk[iim_gate]);
-
-	np = of_find_compatible_node(NULL, NULL, "fsl,imx31-ccm");
-
-	if (np) {
-		clk_data.clks = clk;
-		clk_data.clk_num = ARRAY_SIZE(clk);
-		of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
-	}
 }
 
 int __init mx31_clocks_init(unsigned long fref)
 {
-	_mx31_clocks_init(fref);
+	void __iomem *base;
+
+	base = ioremap(MX31_CCM_BASE_ADDR, SZ_4K);
+	if (!base)
+		panic("%s: failed to map registers\n", __func__);
+
+	_mx31_clocks_init(base, fref);
 
 	clk_register_clkdev(clk[gpt_gate], "per", "imx-gpt.0");
 	clk_register_clkdev(clk[ipg], "ipg", "imx-gpt.0");
@@ -222,22 +215,31 @@ int __init mx31_clocks_init(unsigned long fref)
 	return 0;
 }
 
-int __init mx31_clocks_init_dt(void)
+static void __init mx31_clocks_init_dt(struct device_node *np)
 {
-	struct device_node *np;
+	struct device_node *osc_np;
 	u32 fref = 26000000; /* default */
+	void __iomem *ccm;
 
-	for_each_compatible_node(np, NULL, "fixed-clock") {
-		if (!of_device_is_compatible(np, "fsl,imx-osc26m"))
+	for_each_compatible_node(osc_np, NULL, "fixed-clock") {
+		if (!of_device_is_compatible(osc_np, "fsl,imx-osc26m"))
 			continue;
 
-		if (!of_property_read_u32(np, "clock-frequency", &fref)) {
-			of_node_put(np);
+		if (!of_property_read_u32(osc_np, "clock-frequency", &fref)) {
+			of_node_put(osc_np);
 			break;
 		}
 	}
 
-	_mx31_clocks_init(fref);
+	ccm = of_iomap(np, 0);
+	if (!ccm)
+		panic("%s: failed to map registers\n", __func__);
 
-	return 0;
+	_mx31_clocks_init(ccm, fref);
+
+	clk_data.clks = clk;
+	clk_data.clk_num = ARRAY_SIZE(clk);
+	of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
 }
+
+CLK_OF_DECLARE(imx31_ccm, "fsl,imx31-ccm", mx31_clocks_init_dt);
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 0/2] ARM: imx31/of: clk: init clock controller with CLK_OF_DECLARE
  2016-09-19  2:42 [PATCH 0/2] ARM: imx31/of: clk: init clock controller with CLK_OF_DECLARE Vladimir Zapolskiy
  2016-09-19  2:42 ` [PATCH 1/2] ARM: imx31: remove mx31_clocks_init_dt() function calls Vladimir Zapolskiy
  2016-09-19  2:42 ` [PATCH 2/2] clk: imx31: properly init clocks for machines with DT Vladimir Zapolskiy
@ 2016-09-19  5:58 ` Uwe Kleine-König
  2016-09-20 17:32   ` Stephen Boyd
  2 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2016-09-19  5:58 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On Mon, Sep 19, 2016 at 05:42:17AM +0300, Vladimir Zapolskiy wrote:
> The change is based on v4.8.0-rc1 and plus it depends on this fixup:
> 
>   ARM: dts: imx31: fix clock control module interrupts description
> 
> The change is tested on qemu kzm target and mx31lite board, while both
> targets don't have DTS in upstream, I had to write simple DTS files for
> them, because the proposed change is for i.MX31 targets with OF support.
> 
> The second change in the series compilation time dependent on the first
> one, while the first change apparently should break runtime execution
> of i.MX31 boards with OF support, if both changes are applied everything
> should be fine, regression testing on the same legacy targets does not

that means this should be done in a single patch.

> show any problems. Moreover i.MX31/OF/clock initialization seems to be
> broken currently, if the change is not applied I can not get a working
> clock source during early boot stage, jiffies are not incremented, but
> because I didn't check the problem thoroughly (can it be caused by
> missing CLK_OF_DECLARE? Or caused by something fixed by the change
> http://www.spinics.net/lists/linux-clk/msg12235.html ?) and because
> the change was tested against code which is not found in upstream,
> I won't call this change as a fix, however its application is apparently
> wanted to get better OF support for i.MX31 targets.

Very appreciated!

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 0/2] ARM: imx31/of: clk: init clock controller with CLK_OF_DECLARE
  2016-09-19  5:58 ` [PATCH 0/2] ARM: imx31/of: clk: init clock controller with CLK_OF_DECLARE Uwe Kleine-König
@ 2016-09-20 17:32   ` Stephen Boyd
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Boyd @ 2016-09-20 17:32 UTC (permalink / raw)
  To: linux-arm-kernel

On 09/19, Uwe Kleine-K?nig wrote:
> Hello,
> 
> On Mon, Sep 19, 2016 at 05:42:17AM +0300, Vladimir Zapolskiy wrote:
> > The change is based on v4.8.0-rc1 and plus it depends on this fixup:
> > 
> >   ARM: dts: imx31: fix clock control module interrupts description
> > 
> > The change is tested on qemu kzm target and mx31lite board, while both
> > targets don't have DTS in upstream, I had to write simple DTS files for
> > them, because the proposed change is for i.MX31 targets with OF support.
> > 
> > The second change in the series compilation time dependent on the first
> > one, while the first change apparently should break runtime execution
> > of i.MX31 boards with OF support, if both changes are applied everything
> > should be fine, regression testing on the same legacy targets does not
> 
> that means this should be done in a single patch.

Yes, please combine the patches. I can ack it then so it can be
routed through arm-soc.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] clk: imx31: properly init clocks for machines with DT
  2016-09-19  2:42 ` [PATCH 2/2] clk: imx31: properly init clocks for machines with DT Vladimir Zapolskiy
@ 2016-09-20 17:36   ` Stephen Boyd
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Boyd @ 2016-09-20 17:36 UTC (permalink / raw)
  To: linux-arm-kernel

On 09/19, Vladimir Zapolskiy wrote:
> @@ -222,22 +215,31 @@ int __init mx31_clocks_init(unsigned long fref)
>  	return 0;
>  }
>  
> -int __init mx31_clocks_init_dt(void)
> +static void __init mx31_clocks_init_dt(struct device_node *np)

Alternatively we can leave mx31_clocks_init_dt() around as an
exported API, but make it return 0 immediately in the same patch
to the clk driver here. Then after rc1 we can delete the "unused"
function in the clk tree assuming the last caller has been
deleted through arm-soc.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-09-20 17:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-19  2:42 [PATCH 0/2] ARM: imx31/of: clk: init clock controller with CLK_OF_DECLARE Vladimir Zapolskiy
2016-09-19  2:42 ` [PATCH 1/2] ARM: imx31: remove mx31_clocks_init_dt() function calls Vladimir Zapolskiy
2016-09-19  2:42 ` [PATCH 2/2] clk: imx31: properly init clocks for machines with DT Vladimir Zapolskiy
2016-09-20 17:36   ` Stephen Boyd
2016-09-19  5:58 ` [PATCH 0/2] ARM: imx31/of: clk: init clock controller with CLK_OF_DECLARE Uwe Kleine-König
2016-09-20 17:32   ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).