Patchwork [2/6] ARM: mxs: look up timrot clock from device tree

login
register
mail settings
Submitter Shawn Guo
Date March 25, 2013, 3:17 p.m.
Message ID <1364224652-28332-3-git-send-email-shawn.guo@linaro.org>
Download mbox | patch
Permalink /patch/230740/
State New
Headers show

Comments

Shawn Guo - March 25, 2013, 3:17 p.m.
Change call clk_get_sys() to of_clk_get() to look up timrot clock from
device tree, so that the clk_register_clkdev() call for timrot can be
saved in clock driver.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/boot/dts/imx23.dtsi |    1 +
 arch/arm/boot/dts/imx28.dtsi |    1 +
 arch/arm/mach-mxs/timer.c    |    2 +-
 drivers/clk/mxs/clk-imx23.c  |    2 --
 drivers/clk/mxs/clk-imx28.c  |    1 -
 5 files changed, 3 insertions(+), 4 deletions(-)
Uwe Kleine-König - July 11, 2013, 10:56 a.m.
Hello Shawn,

On Mon, Mar 25, 2013 at 11:17:28PM +0800, Shawn Guo wrote:
> Change call clk_get_sys() to of_clk_get() to look up timrot clock from
> device tree, so that the clk_register_clkdev() call for timrot can be
> saved in clock driver.

I'm currently using an i.MX28 with 3.8-rt13 and patched the clocksource
and clockevent to use the 24 MHz clock source
(BV_TIMROTv2_TIMCTRLn_SELECT__ALWAYS instead of
BV_TIMROTv2_TIMCTRLn_SELECT__32KHZ_XTAL). Currently my patch is a hack
because I hard code the 24 MHz. I wonder how to do it properly?

Add another item to the "clocks = <...>" entry and use the first entry
for enable and the 2nd for clk_get_rate?

Something like:

	always_clk = of_clk_get(np, 1);
	if (always_clk)
		register timers using always clk (24 MHz, SELECT__ALWAYS)
	else
		fall back to timer_clk (32 kHz, 32KHZ_XTAL)

and then

	timrot@80068000 {
		compatible = "fsl,imx28-timrot", "fsl,timrot";
		reg = <0x80068000 0x2000>;
		interrupts = <48 49 50 51>;
		clocks = <&clks 26 &clks 0>;
	};

If you like it, too, I can prepare a patch.

Best regards
Uwe
Shawn Guo - July 11, 2013, 1:57 p.m.
Hi Uwe,

On Thu, Jul 11, 2013 at 12:56:26PM +0200, Uwe Kleine-König wrote:
> I'm currently using an i.MX28 with 3.8-rt13 and patched the clocksource
> and clockevent to use the 24 MHz clock source
> (BV_TIMROTv2_TIMCTRLn_SELECT__ALWAYS instead of
> BV_TIMROTv2_TIMCTRLn_SELECT__32KHZ_XTAL). Currently my patch is a hack
> because I hard code the 24 MHz. I wonder how to do it properly?
> 

You may want to take a look at commit 2fb318f (ARM: mxs: use apbx bus
clock to drive the timers on timrotv2), which hit mainline in v3.9.

Shawn

> Add another item to the "clocks = <...>" entry and use the first entry
> for enable and the 2nd for clk_get_rate?
> 
> Something like:
> 
> 	always_clk = of_clk_get(np, 1);
> 	if (always_clk)
> 		register timers using always clk (24 MHz, SELECT__ALWAYS)
> 	else
> 		fall back to timer_clk (32 kHz, 32KHZ_XTAL)
> 
> and then
> 
> 	timrot@80068000 {
> 		compatible = "fsl,imx28-timrot", "fsl,timrot";
> 		reg = <0x80068000 0x2000>;
> 		interrupts = <48 49 50 51>;
> 		clocks = <&clks 26 &clks 0>;
> 	};
> 
> If you like it, too, I can prepare a patch.
> 
> Best regards
> Uwe
> 
> -- 
> Pengutronix e.K.                           | Uwe Kleine-König            |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |

Patch

diff --git a/arch/arm/boot/dts/imx23.dtsi b/arch/arm/boot/dts/imx23.dtsi
index 56afcf4..27ce807 100644
--- a/arch/arm/boot/dts/imx23.dtsi
+++ b/arch/arm/boot/dts/imx23.dtsi
@@ -426,6 +426,7 @@ 
 				compatible = "fsl,imx23-timrot", "fsl,timrot";
 				reg = <0x80068000 0x2000>;
 				interrupts = <28 29 30 31>;
+				clocks = <&clks 28>;
 			};
 
 			auart0: serial@8006c000 {
diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index 7ba4966..c2f10d3 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -838,6 +838,7 @@ 
 				compatible = "fsl,imx28-timrot", "fsl,timrot";
 				reg = <0x80068000 0x2000>;
 				interrupts = <48 49 50 51>;
+				clocks = <&clks 26>;
 			};
 
 			auart0: serial@8006a000 {
diff --git a/arch/arm/mach-mxs/timer.c b/arch/arm/mach-mxs/timer.c
index fe2903d..f5142aa 100644
--- a/arch/arm/mach-mxs/timer.c
+++ b/arch/arm/mach-mxs/timer.c
@@ -247,7 +247,7 @@  static void __init mxs_timer_init(struct device_node *np)
 	struct clk *timer_clk;
 	int irq;
 
-	timer_clk = clk_get_sys("timrot", NULL);
+	timer_clk = of_clk_get(np, 0);
 	if (IS_ERR(timer_clk)) {
 		pr_err("%s: failed to get clk\n", __func__);
 		return;
diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c
index 52e0365..f65b19c 100644
--- a/drivers/clk/mxs/clk-imx23.c
+++ b/drivers/clk/mxs/clk-imx23.c
@@ -160,8 +160,6 @@  int __init mx23_clocks_init(void)
 		of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
 	}
 
-	clk_register_clkdev(clks[clk32k], NULL, "timrot");
-
 	for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
 		clk_prepare_enable(clks[clks_init_on[i]]);
 
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
index 03918e1..3cc82ea 100644
--- a/drivers/clk/mxs/clk-imx28.c
+++ b/drivers/clk/mxs/clk-imx28.c
@@ -238,7 +238,6 @@  int __init mx28_clocks_init(void)
 		of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
 	}
 
-	clk_register_clkdev(clks[xbus], NULL, "timrot");
 	clk_register_clkdev(clks[enet_out], NULL, "enet_out");
 
 	for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)