Source
62
62
#define MTU_PCELL1 0xff4
63
63
#define MTU_PCELL2 0xff8
64
64
#define MTU_PCELL3 0xffC
65
65
66
66
static void __iomem *mtu_base;
67
67
static bool clkevt_periodic;
68
68
static u32 clk_prescale;
69
69
static u32 nmdk_cycle; /* write-once */
70
70
static struct delay_timer mtu_delay_timer;
71
71
72
-
#ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK
73
72
/*
74
73
* Override the global weak sched_clock symbol with this
75
74
* local implementation which uses the clocksource to get some
76
75
* better resolution when scheduling the kernel.
77
76
*/
78
77
static u64 notrace nomadik_read_sched_clock(void)
79
78
{
80
79
if (unlikely(!mtu_base))
81
80
return 0;
82
81
83
82
return -readl(mtu_base + MTU_VAL(0));
84
83
}
85
-
#endif
86
84
87
85
static unsigned long nmdk_timer_read_current_timer(void)
88
86
{
89
87
return ~readl_relaxed(mtu_base + MTU_VAL(0));
90
88
}
91
89
92
90
/* Clockevent device: use one-shot mode */
93
91
static int nmdk_clkevt_next(unsigned long evt, struct clock_event_device *ev)
94
92
{
95
93
writel(1 << 1, mtu_base + MTU_IMSC);
227
225
/* Timer 0 is the free running clocksource */
228
226
nmdk_clksrc_reset();
229
227
230
228
ret = clocksource_mmio_init(mtu_base + MTU_VAL(0), "mtu_0",
231
229
rate, 200, 32, clocksource_mmio_readl_down);
232
230
if (ret) {
233
231
pr_err("timer: failed to initialize clock source %s\n", "mtu_0");
234
232
return ret;
235
233
}
236
234
237
-
#ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK
238
235
sched_clock_register(nomadik_read_sched_clock, 32, rate);
239
-
#endif
240
236
241
237
/* Timer 1 is used for events, register irq and clockevents */
242
238
setup_irq(irq, &nmdk_timer_irq);
243
239
nmdk_clkevt.cpumask = cpumask_of(0);
244
240
nmdk_clkevt.irq = irq;
245
241
clockevents_config_and_register(&nmdk_clkevt, rate, 2, 0xffffffffU);
246
242
247
243
mtu_delay_timer.read_current_timer = &nmdk_timer_read_current_timer;
248
244
mtu_delay_timer.freq = rate;
249
245
register_current_timer_delay(&mtu_delay_timer);