aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/nomadik-mtu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/clocksource/nomadik-mtu.c')
-rw-r--r--drivers/clocksource/nomadik-mtu.c60
1 files changed, 48 insertions, 12 deletions
diff --git a/drivers/clocksource/nomadik-mtu.c b/drivers/clocksource/nomadik-mtu.c
index e405531e1cc5..b9415b622f55 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,43 @@ 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 void __init nmdk_timer_of_init(struct device_node *node)
260{
261 struct clk *pclk;
262 struct clk *clk;
263 void __iomem *base;
264 int irq;
265
266 base = of_iomap(node, 0);
267 if (!base)
268 panic("Can't remap registers");
269
270 pclk = of_clk_get_by_name(node, "apb_pclk");
271 if (IS_ERR(pclk))
272 panic("could not get apb_pclk");
273
274 clk = of_clk_get_by_name(node, "timclk");
275 if (IS_ERR(clk))
276 panic("could not get timclk");
277
278 irq = irq_of_parse_and_map(node, 0);
279 if (irq <= 0)
280 panic("Can't parse IRQ");
281
282 __nmdk_timer_init(base, irq, pclk, clk);
283}
284CLOCKSOURCE_OF_DECLARE(nomadik_mtu, "st,nomadik-mtu",
285 nmdk_timer_of_init);