diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /arch/arm/mach-omap2/timer-gp.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'arch/arm/mach-omap2/timer-gp.c')
-rw-r--r-- | arch/arm/mach-omap2/timer-gp.c | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c index 74fbed8491f2..3b9cf85f4bb9 100644 --- a/arch/arm/mach-omap2/timer-gp.c +++ b/arch/arm/mach-omap2/timer-gp.c | |||
@@ -39,6 +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> | ||
43 | #include <plat/common.h> | ||
44 | #include <plat/omap_hwmod.h> | ||
45 | |||
46 | #include "timer-gp.h" | ||
47 | |||
42 | 48 | ||
43 | /* MAX_GPTIMER_ID: number of GPTIMERs on the chip */ | 49 | /* MAX_GPTIMER_ID: number of GPTIMERs on the chip */ |
44 | #define MAX_GPTIMER_ID 12 | 50 | #define MAX_GPTIMER_ID 12 |
@@ -128,9 +134,13 @@ static void __init omap2_gp_clockevent_init(void) | |||
128 | { | 134 | { |
129 | u32 tick_rate; | 135 | u32 tick_rate; |
130 | int src; | 136 | int src; |
137 | char clockevent_hwmod_name[8]; /* 8 = sizeof("timerXX0") */ | ||
131 | 138 | ||
132 | inited = 1; | 139 | inited = 1; |
133 | 140 | ||
141 | sprintf(clockevent_hwmod_name, "timer%d", gptimer_id); | ||
142 | omap_hwmod_setup_one(clockevent_hwmod_name); | ||
143 | |||
134 | gptimer = omap_dm_timer_request_specific(gptimer_id); | 144 | gptimer = omap_dm_timer_request_specific(gptimer_id); |
135 | BUG_ON(gptimer == NULL); | 145 | BUG_ON(gptimer == NULL); |
136 | gptimer_wakeup = gptimer; | 146 | gptimer_wakeup = gptimer; |
@@ -174,14 +184,19 @@ static void __init omap2_gp_clockevent_init(void) | |||
174 | /* | 184 | /* |
175 | * When 32k-timer is enabled, don't use GPTimer for clocksource | 185 | * When 32k-timer is enabled, don't use GPTimer for clocksource |
176 | * instead, just leave default clocksource which uses the 32k | 186 | * instead, just leave default clocksource which uses the 32k |
177 | * sync counter. See clocksource setup in see plat-omap/common.c. | 187 | * sync counter. See clocksource setup in plat-omap/counter_32k.c |
178 | */ | 188 | */ |
179 | 189 | ||
180 | static inline void __init omap2_gp_clocksource_init(void) {} | 190 | static void __init omap2_gp_clocksource_init(void) |
191 | { | ||
192 | omap_init_clocksource_32k(); | ||
193 | } | ||
194 | |||
181 | #else | 195 | #else |
182 | /* | 196 | /* |
183 | * clocksource | 197 | * clocksource |
184 | */ | 198 | */ |
199 | static DEFINE_CLOCK_DATA(cd); | ||
185 | static struct omap_dm_timer *gpt_clocksource; | 200 | static struct omap_dm_timer *gpt_clocksource; |
186 | static cycle_t clocksource_read_cycles(struct clocksource *cs) | 201 | static cycle_t clocksource_read_cycles(struct clocksource *cs) |
187 | { | 202 | { |
@@ -193,15 +208,23 @@ static struct clocksource clocksource_gpt = { | |||
193 | .rating = 300, | 208 | .rating = 300, |
194 | .read = clocksource_read_cycles, | 209 | .read = clocksource_read_cycles, |
195 | .mask = CLOCKSOURCE_MASK(32), | 210 | .mask = CLOCKSOURCE_MASK(32), |
196 | .shift = 24, | ||
197 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | 211 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
198 | }; | 212 | }; |
199 | 213 | ||
214 | static void notrace dmtimer_update_sched_clock(void) | ||
215 | { | ||
216 | u32 cyc; | ||
217 | |||
218 | cyc = omap_dm_timer_read_counter(gpt_clocksource); | ||
219 | |||
220 | update_sched_clock(&cd, cyc, (u32)~0); | ||
221 | } | ||
222 | |||
200 | /* Setup free-running counter for clocksource */ | 223 | /* Setup free-running counter for clocksource */ |
201 | static void __init omap2_gp_clocksource_init(void) | 224 | static void __init omap2_gp_clocksource_init(void) |
202 | { | 225 | { |
203 | static struct omap_dm_timer *gpt; | 226 | static struct omap_dm_timer *gpt; |
204 | u32 tick_rate, tick_period; | 227 | u32 tick_rate; |
205 | static char err1[] __initdata = KERN_ERR | 228 | static char err1[] __initdata = KERN_ERR |
206 | "%s: failed to request dm-timer\n"; | 229 | "%s: failed to request dm-timer\n"; |
207 | static char err2[] __initdata = KERN_ERR | 230 | static char err2[] __initdata = KERN_ERR |
@@ -214,13 +237,12 @@ static void __init omap2_gp_clocksource_init(void) | |||
214 | 237 | ||
215 | omap_dm_timer_set_source(gpt, OMAP_TIMER_SRC_SYS_CLK); | 238 | omap_dm_timer_set_source(gpt, OMAP_TIMER_SRC_SYS_CLK); |
216 | tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gpt)); | 239 | tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gpt)); |
217 | tick_period = (tick_rate / HZ) - 1; | ||
218 | 240 | ||
219 | omap_dm_timer_set_load_start(gpt, 1, 0); | 241 | omap_dm_timer_set_load_start(gpt, 1, 0); |
220 | 242 | ||
221 | clocksource_gpt.mult = | 243 | init_sched_clock(&cd, dmtimer_update_sched_clock, 32, tick_rate); |
222 | clocksource_khz2mult(tick_rate/1000, clocksource_gpt.shift); | 244 | |
223 | if (clocksource_register(&clocksource_gpt)) | 245 | if (clocksource_register_hz(&clocksource_gpt, tick_rate)) |
224 | printk(err2, clocksource_gpt.name); | 246 | printk(err2, clocksource_gpt.name); |
225 | } | 247 | } |
226 | #endif | 248 | #endif |
@@ -228,8 +250,10 @@ static void __init omap2_gp_clocksource_init(void) | |||
228 | static void __init omap2_gp_timer_init(void) | 250 | static void __init omap2_gp_timer_init(void) |
229 | { | 251 | { |
230 | #ifdef CONFIG_LOCAL_TIMERS | 252 | #ifdef CONFIG_LOCAL_TIMERS |
231 | twd_base = ioremap(OMAP44XX_LOCAL_TWD_BASE, SZ_256); | 253 | if (cpu_is_omap44xx()) { |
232 | BUG_ON(!twd_base); | 254 | twd_base = ioremap(OMAP44XX_LOCAL_TWD_BASE, SZ_256); |
255 | BUG_ON(!twd_base); | ||
256 | } | ||
233 | #endif | 257 | #endif |
234 | omap_dm_timer_init(); | 258 | omap_dm_timer_init(); |
235 | 259 | ||