summaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/nomadik-mtu.c
diff options
context:
space:
mode:
authorRabin Vincent <rabin.vincent@stericsson.com>2013-04-03 07:28:26 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-05-12 15:49:56 -0400
commitc7785ea0d279322bf92107d9a4fee195f5148c08 (patch)
treec06e8a66706e814d920a0cf3c510be84d8dc1096 /drivers/clocksource/nomadik-mtu.c
parentf722406faae2d073cc1d01063d1123c35425939e (diff)
clocksource: nomadik-mtu: support of probe
Support device tree probe of the nomadik-mtu clocksource. Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Diffstat (limited to 'drivers/clocksource/nomadik-mtu.c')
-rw-r--r--drivers/clocksource/nomadik-mtu.c70
1 files changed, 58 insertions, 12 deletions
diff --git a/drivers/clocksource/nomadik-mtu.c b/drivers/clocksource/nomadik-mtu.c
index e405531e1cc5..7982cb0f25f2 100644
--- a/drivers/clocksource/nomadik-mtu.c
+++ b/drivers/clocksource/nomadik-mtu.c
@@ -13,6 +13,9 @@
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/clockchips.h> 14#include <linux/clockchips.h>
15#include <linux/clocksource.h> 15#include <linux/clocksource.h>
16#include <linux/of_address.h>
17#include <linux/of_irq.h>
18#include <linux/of_platform.h>
16#include <linux/clk.h> 19#include <linux/clk.h>
17#include <linux/jiffies.h> 20#include <linux/jiffies.h>
18#include <linux/delay.h> 21#include <linux/delay.h>
@@ -188,22 +191,15 @@ static struct irqaction nmdk_timer_irq = {
188 .dev_id = &nmdk_clkevt, 191 .dev_id = &nmdk_clkevt,
189}; 192};
190 193
191void __init nmdk_timer_init(void __iomem *base, int irq) 194static void __init __nmdk_timer_init(void __iomem *base, int irq,
195 struct clk *pclk, struct clk *clk)
192{ 196{
193 unsigned long rate; 197 unsigned long rate;
194 struct clk *clk0, *pclk0;
195 198
196 mtu_base = base; 199 mtu_base = base;
197 200
198 pclk0 = clk_get_sys("mtu0", "apb_pclk"); 201 BUG_ON(clk_prepare_enable(pclk));
199 BUG_ON(IS_ERR(pclk0)); 202 BUG_ON(clk_prepare_enable(clk));
200 BUG_ON(clk_prepare(pclk0) < 0);
201 BUG_ON(clk_enable(pclk0) < 0);
202
203 clk0 = clk_get_sys("mtu0", NULL);
204 BUG_ON(IS_ERR(clk0));
205 BUG_ON(clk_prepare(clk0) < 0);
206 BUG_ON(clk_enable(clk0) < 0);
207 203
208 /* 204 /*
209 * Tick rate is 2.4MHz for Nomadik and 2.4Mhz, 100MHz or 133 MHz 205 * Tick rate is 2.4MHz for Nomadik and 2.4Mhz, 100MHz or 133 MHz
@@ -213,7 +209,7 @@ void __init nmdk_timer_init(void __iomem *base, int irq)
213 * to wake-up at a max 127s a head in time. Dividing a 2.4 MHz timer 209 * to wake-up at a max 127s a head in time. Dividing a 2.4 MHz timer
214 * with 16 gives too low timer resolution. 210 * with 16 gives too low timer resolution.
215 */ 211 */
216 rate = clk_get_rate(clk0); 212 rate = clk_get_rate(clk);
217 if (rate > 32000000) { 213 if (rate > 32000000) {
218 rate /= 16; 214 rate /= 16;
219 clk_prescale = MTU_CRn_PRESCALE_16; 215 clk_prescale = MTU_CRn_PRESCALE_16;
@@ -247,3 +243,53 @@ void __init nmdk_timer_init(void __iomem *base, int irq)
247 mtu_delay_timer.freq = rate; 243 mtu_delay_timer.freq = rate;
248 register_current_timer_delay(&mtu_delay_timer); 244 register_current_timer_delay(&mtu_delay_timer);
249} 245}
246
247void __init nmdk_timer_init(void __iomem *base, int irq)
248{
249 struct clk *clk0, *pclk0;
250
251 pclk0 = clk_get_sys("mtu0", "apb_pclk");
252 BUG_ON(IS_ERR(pclk0));
253 clk0 = clk_get_sys("mtu0", NULL);
254 BUG_ON(IS_ERR(clk0));
255
256 __nmdk_timer_init(base, irq, pclk0, clk0);
257}
258
259static struct of_device_id nmdk_timer_match[] __initconst = {
260 { .compatible = "st,nomadik-mtu" },
261 {}
262};
263
264static void __init nmdk_timer_of_init(void)
265{
266 struct device_node *node;
267 struct clk *pclk;
268 struct clk *clk;
269 void __iomem *base;
270 int irq;
271
272 node = of_find_matching_node(NULL, nmdk_timer_match);
273 if (!node)
274 panic("No timer node");
275
276 base = of_iomap(node, 0);
277 if (!base)
278 panic("Can't remap registers");
279
280 pclk = of_clk_get_by_name(node, "apb_pclk");
281 if (IS_ERR(pclk))
282 panic("could not get apb_pclk");
283
284 clk = of_clk_get_by_name(node, "timclk");
285 if (IS_ERR(clk))
286 panic("could not get timclk");
287
288 irq = irq_of_parse_and_map(node, 0);
289 if (irq <= 0)
290 panic("Can't parse IRQ");
291
292 __nmdk_timer_init(base, irq, pclk, clk);
293}
294CLOCKSOURCE_OF_DECLARE(nomadik_mtu, "st,nomadik-mtu",
295 nmdk_timer_of_init);