diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-01-15 13:10:33 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-04-29 13:04:15 -0400 |
commit | b9cedda230793cbf58eb012ddadedd490cc8e129 (patch) | |
tree | 5c1e21e04206d68d9089299e6b9f61347c3f8070 /arch/arm | |
parent | ba02a21544b41a65e58506f1d79353203d94b8b6 (diff) |
ARM: Integrator: convert to generic time support
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/Kconfig | 1 | ||||
-rw-r--r-- | arch/arm/mach-integrator/common.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-integrator/core.c | 62 | ||||
-rw-r--r-- | arch/arm/mach-integrator/integrator_ap.c | 1 | ||||
-rw-r--r-- | arch/arm/mach-integrator/integrator_cp.c | 1 |
5 files changed, 31 insertions, 35 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index c5408bf1bf43..7698d8705a8f 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -241,6 +241,7 @@ config ARCH_INTEGRATOR | |||
241 | select HAVE_CLK | 241 | select HAVE_CLK |
242 | select COMMON_CLKDEV | 242 | select COMMON_CLKDEV |
243 | select ICST525 | 243 | select ICST525 |
244 | select GENERIC_TIME | ||
244 | help | 245 | help |
245 | Support for ARM's Integrator platform. | 246 | Support for ARM's Integrator platform. |
246 | 247 | ||
diff --git a/arch/arm/mach-integrator/common.h b/arch/arm/mach-integrator/common.h index 609c49de3d47..7dc24bb9bdc1 100644 --- a/arch/arm/mach-integrator/common.h +++ b/arch/arm/mach-integrator/common.h | |||
@@ -1,2 +1 @@ | |||
1 | extern void integrator_time_init(unsigned long, unsigned int); | extern void integrator_time_init(unsigned long, unsigned int); | |
2 | extern unsigned long integrator_gettimeoffset(void); | ||
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c index 096f899625f8..87c6f980944d 100644 --- a/arch/arm/mach-integrator/core.c +++ b/arch/arm/mach-integrator/core.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/termios.h> | 19 | #include <linux/termios.h> |
20 | #include <linux/amba/bus.h> | 20 | #include <linux/amba/bus.h> |
21 | #include <linux/amba/serial.h> | 21 | #include <linux/amba/serial.h> |
22 | #include <linux/clocksource.h> | ||
22 | #include <linux/io.h> | 23 | #include <linux/io.h> |
23 | 24 | ||
24 | #include <asm/clkdev.h> | 25 | #include <asm/clkdev.h> |
@@ -225,7 +226,6 @@ EXPORT_SYMBOL(cm_control); | |||
225 | #define TIMER0_VA_BASE (IO_ADDRESS(INTEGRATOR_CT_BASE)+0x00000000) | 226 | #define TIMER0_VA_BASE (IO_ADDRESS(INTEGRATOR_CT_BASE)+0x00000000) |
226 | #define TIMER1_VA_BASE (IO_ADDRESS(INTEGRATOR_CT_BASE)+0x00000100) | 227 | #define TIMER1_VA_BASE (IO_ADDRESS(INTEGRATOR_CT_BASE)+0x00000100) |
227 | #define TIMER2_VA_BASE (IO_ADDRESS(INTEGRATOR_CT_BASE)+0x00000200) | 228 | #define TIMER2_VA_BASE (IO_ADDRESS(INTEGRATOR_CT_BASE)+0x00000200) |
228 | #define VA_IC_BASE IO_ADDRESS(INTEGRATOR_IC_BASE) | ||
229 | 229 | ||
230 | /* | 230 | /* |
231 | * How long is the timer interval? | 231 | * How long is the timer interval? |
@@ -241,42 +241,38 @@ EXPORT_SYMBOL(cm_control); | |||
241 | 241 | ||
242 | static unsigned long timer_reload; | 242 | static unsigned long timer_reload; |
243 | 243 | ||
244 | /* | 244 | static void __iomem * const clksrc_base = (void __iomem *)TIMER2_VA_BASE; |
245 | * Returns number of ms since last clock interrupt. Note that interrupts | 245 | |
246 | * will have been disabled by do_gettimeoffset() | 246 | static cycle_t timersp_read(struct clocksource *cs) |
247 | */ | ||
248 | unsigned long integrator_gettimeoffset(void) | ||
249 | { | 247 | { |
250 | unsigned long ticks1, ticks2, status; | 248 | return ~(readl(clksrc_base + TIMER_VALUE) & 0xffff); |
249 | } | ||
251 | 250 | ||
252 | /* | 251 | static struct clocksource clocksource_timersp = { |
253 | * Get the current number of ticks. Note that there is a race | 252 | .name = "timer2", |
254 | * condition between us reading the timer and checking for | 253 | .rating = 200, |
255 | * an interrupt. We get around this by ensuring that the | 254 | .read = timersp_read, |
256 | * counter has not reloaded between our two reads. | 255 | .mask = CLOCKSOURCE_MASK(16), |
257 | */ | 256 | .shift = 16, |
258 | ticks2 = readl(TIMER1_VA_BASE + TIMER_VALUE) & 0xffff; | 257 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
259 | do { | 258 | }; |
260 | ticks1 = ticks2; | ||
261 | status = __raw_readl(VA_IC_BASE + IRQ_RAW_STATUS); | ||
262 | ticks2 = readl(TIMER1_VA_BASE + TIMER_VALUE) & 0xffff; | ||
263 | } while (ticks2 > ticks1); | ||
264 | 259 | ||
265 | /* | 260 | static void integrator_clocksource_init(u32 khz) |
266 | * Number of ticks since last interrupt. | 261 | { |
267 | */ | 262 | struct clocksource *cs = &clocksource_timersp; |
268 | ticks1 = timer_reload - ticks2; | 263 | void __iomem *base = clksrc_base; |
264 | u32 ctrl = TIMER_CTRL_ENABLE; | ||
269 | 265 | ||
270 | /* | 266 | if (khz >= 1500) { |
271 | * Interrupt pending? If so, we've reloaded once already. | 267 | khz /= 16; |
272 | */ | 268 | ctrl = TIMER_CTRL_DIV16; |
273 | if (status & (1 << IRQ_TIMERINT1)) | 269 | } |
274 | ticks1 += timer_reload; | ||
275 | 270 | ||
276 | /* | 271 | writel(ctrl, base + TIMER_CTRL); |
277 | * Convert the ticks to usecs | 272 | writel(0xffff, base + TIMER_LOAD); |
278 | */ | 273 | |
279 | return TICKS2USECS(ticks1); | 274 | cs->mult = clocksource_khz2mult(khz, cs->shift); |
275 | clocksource_register(cs); | ||
280 | } | 276 | } |
281 | 277 | ||
282 | /* | 278 | /* |
@@ -308,6 +304,8 @@ void __init integrator_time_init(unsigned long reload, unsigned int ctrl) | |||
308 | { | 304 | { |
309 | unsigned int timer_ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC; | 305 | unsigned int timer_ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC; |
310 | 306 | ||
307 | integrator_clocksource_init(reload * HZ / 1000); | ||
308 | |||
311 | timer_reload = reload; | 309 | timer_reload = reload; |
312 | timer_ctrl |= ctrl; | 310 | timer_ctrl |= ctrl; |
313 | 311 | ||
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c index 018c32da4c86..cfb718fe31a8 100644 --- a/arch/arm/mach-integrator/integrator_ap.c +++ b/arch/arm/mach-integrator/integrator_ap.c | |||
@@ -342,7 +342,6 @@ static void __init ap_init_timer(void) | |||
342 | 342 | ||
343 | static struct sys_timer ap_timer = { | 343 | static struct sys_timer ap_timer = { |
344 | .init = ap_init_timer, | 344 | .init = ap_init_timer, |
345 | .offset = integrator_gettimeoffset, | ||
346 | }; | 345 | }; |
347 | 346 | ||
348 | MACHINE_START(INTEGRATOR, "ARM-Integrator") | 347 | MACHINE_START(INTEGRATOR, "ARM-Integrator") |
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c index c66e8fa0e622..3e84732163ea 100644 --- a/arch/arm/mach-integrator/integrator_cp.c +++ b/arch/arm/mach-integrator/integrator_cp.c | |||
@@ -577,7 +577,6 @@ static void __init intcp_timer_init(void) | |||
577 | 577 | ||
578 | static struct sys_timer cp_timer = { | 578 | static struct sys_timer cp_timer = { |
579 | .init = intcp_timer_init, | 579 | .init = intcp_timer_init, |
580 | .offset = integrator_gettimeoffset, | ||
581 | }; | 580 | }; |
582 | 581 | ||
583 | MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP") | 582 | MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP") |