ARM i.MX timer: request correct clock
authorSascha Hauer <s.hauer@pengutronix.de>
Fri, 9 Mar 2012 08:29:27 +0000 (09:29 +0100)
committerSascha Hauer <s.hauer@pengutronix.de>
Wed, 25 Apr 2012 15:03:45 +0000 (17:03 +0200)
We used to pass the timer clock directly to mxc_timer_init. We
should instead request the correct clock. This is an intermediate
step: For now we request the clock in the timer code when NULL
is passed as clock.
Also, the gpt on some i.MX have an additional ipg clock which can
be gated. Request and enable this.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
arch/arm/plat-mxc/time.c

index 7daf7c9a413bf62eb9a7ad86f659a0eadf016d44..99f958ca6cb8c34ac650896418d1dc8e1a4cd247 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/irq.h>
 #include <linux/clockchips.h>
 #include <linux/clk.h>
+#include <linux/err.h>
 
 #include <mach/hardware.h>
 #include <asm/sched_clock.h>
@@ -282,6 +283,19 @@ static int __init mxc_clockevent_init(struct clk *timer_clk)
 void __init mxc_timer_init(struct clk *timer_clk, void __iomem *base, int irq)
 {
        uint32_t tctl_val;
+       struct clk *timer_ipg_clk;
+
+       if (!timer_clk) {
+               timer_clk = clk_get_sys("imx-gpt.0", "per");
+               if (IS_ERR(timer_clk)) {
+                       pr_err("i.MX timer: unable to get clk\n");
+                       return;
+               }
+
+               timer_ipg_clk = clk_get_sys("imx-gpt.0", "ipg");
+               if (!IS_ERR(timer_ipg_clk))
+                       clk_prepare_enable(timer_ipg_clk);
+       }
 
        clk_prepare_enable(timer_clk);