aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/timer-gp.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/timer-gp.c')
-rw-r--r--arch/arm/mach-omap2/timer-gp.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c
index 4e48e786bec7..0fc550e7e482 100644
--- a/arch/arm/mach-omap2/timer-gp.c
+++ b/arch/arm/mach-omap2/timer-gp.c
@@ -39,9 +39,12 @@
39#include <asm/mach/time.h> 39#include <asm/mach/time.h>
40#include <plat/dmtimer.h> 40#include <plat/dmtimer.h>
41#include <asm/localtimer.h> 41#include <asm/localtimer.h>
42#include <asm/sched_clock.h>
42 43
43#include "timer-gp.h" 44#include "timer-gp.h"
44 45
46#include <plat/common.h>
47
45/* MAX_GPTIMER_ID: number of GPTIMERs on the chip */ 48/* MAX_GPTIMER_ID: number of GPTIMERs on the chip */
46#define MAX_GPTIMER_ID 12 49#define MAX_GPTIMER_ID 12
47 50
@@ -176,14 +179,19 @@ static void __init omap2_gp_clockevent_init(void)
176/* 179/*
177 * When 32k-timer is enabled, don't use GPTimer for clocksource 180 * When 32k-timer is enabled, don't use GPTimer for clocksource
178 * instead, just leave default clocksource which uses the 32k 181 * instead, just leave default clocksource which uses the 32k
179 * sync counter. See clocksource setup in see plat-omap/common.c. 182 * sync counter. See clocksource setup in plat-omap/counter_32k.c
180 */ 183 */
181 184
182static inline void __init omap2_gp_clocksource_init(void) {} 185static void __init omap2_gp_clocksource_init(void)
186{
187 omap_init_clocksource_32k();
188}
189
183#else 190#else
184/* 191/*
185 * clocksource 192 * clocksource
186 */ 193 */
194static DEFINE_CLOCK_DATA(cd);
187static struct omap_dm_timer *gpt_clocksource; 195static struct omap_dm_timer *gpt_clocksource;
188static cycle_t clocksource_read_cycles(struct clocksource *cs) 196static cycle_t clocksource_read_cycles(struct clocksource *cs)
189{ 197{
@@ -198,6 +206,15 @@ static struct clocksource clocksource_gpt = {
198 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 206 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
199}; 207};
200 208
209static void notrace dmtimer_update_sched_clock(void)
210{
211 u32 cyc;
212
213 cyc = omap_dm_timer_read_counter(gpt_clocksource);
214
215 update_sched_clock(&cd, cyc, (u32)~0);
216}
217
201/* Setup free-running counter for clocksource */ 218/* Setup free-running counter for clocksource */
202static void __init omap2_gp_clocksource_init(void) 219static void __init omap2_gp_clocksource_init(void)
203{ 220{
@@ -218,6 +235,8 @@ static void __init omap2_gp_clocksource_init(void)
218 235
219 omap_dm_timer_set_load_start(gpt, 1, 0); 236 omap_dm_timer_set_load_start(gpt, 1, 0);
220 237
238 init_sched_clock(&cd, dmtimer_update_sched_clock, 32, tick_rate);
239
221 if (clocksource_register_hz(&clocksource_gpt, tick_rate)) 240 if (clocksource_register_hz(&clocksource_gpt, tick_rate))
222 printk(err2, clocksource_gpt.name); 241 printk(err2, clocksource_gpt.name);
223} 242}