diff options
| author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2007-11-12 16:55:12 -0500 |
|---|---|---|
| committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-01-26 09:40:57 -0500 |
| commit | d142b6e77d394a4fcc0a42381b03852bd9c4e263 (patch) | |
| tree | f3d2be80d681dd16abcd9bfea0895149bc867877 | |
| parent | 9b73e76f3cf63379dcf45fcd4f112f5812418d0a (diff) | |
[ARM] sa1100: add clock source support
Add generic clock source support for SA11x0 platforms.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
| -rw-r--r-- | arch/arm/Kconfig | 1 | ||||
| -rw-r--r-- | arch/arm/mach-sa1100/time.c | 38 |
2 files changed, 21 insertions, 18 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index a04f507e7f2c..742527957048 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
| @@ -366,6 +366,7 @@ config ARCH_SA1100 | |||
| 366 | select ARCH_DISCONTIGMEM_ENABLE | 366 | select ARCH_DISCONTIGMEM_ENABLE |
| 367 | select ARCH_MTD_XIP | 367 | select ARCH_MTD_XIP |
| 368 | select GENERIC_GPIO | 368 | select GENERIC_GPIO |
| 369 | select GENERIC_TIME | ||
| 369 | help | 370 | help |
| 370 | Support for StrongARM 11x0 based boards. | 371 | Support for StrongARM 11x0 based boards. |
| 371 | 372 | ||
diff --git a/arch/arm/mach-sa1100/time.c b/arch/arm/mach-sa1100/time.c index fdf7b016e7ad..72984354a247 100644 --- a/arch/arm/mach-sa1100/time.c +++ b/arch/arm/mach-sa1100/time.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <linux/irq.h> | 14 | #include <linux/irq.h> |
| 15 | #include <linux/timex.h> | 15 | #include <linux/timex.h> |
| 16 | #include <linux/signal.h> | 16 | #include <linux/signal.h> |
| 17 | #include <linux/clocksource.h> | ||
| 17 | 18 | ||
| 18 | #include <asm/mach/time.h> | 19 | #include <asm/mach/time.h> |
| 19 | #include <asm/hardware.h> | 20 | #include <asm/hardware.h> |
| @@ -35,23 +36,6 @@ static int sa1100_set_rtc(void) | |||
| 35 | return 0; | 36 | return 0; |
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | /* IRQs are disabled before entering here from do_gettimeofday() */ | ||
| 39 | static unsigned long sa1100_gettimeoffset (void) | ||
| 40 | { | ||
| 41 | unsigned long ticks_to_match, elapsed, usec; | ||
| 42 | |||
| 43 | /* Get ticks before next timer match */ | ||
| 44 | ticks_to_match = OSMR0 - OSCR; | ||
| 45 | |||
| 46 | /* We need elapsed ticks since last match */ | ||
| 47 | elapsed = LATCH - ticks_to_match; | ||
| 48 | |||
| 49 | /* Now convert them to usec */ | ||
| 50 | usec = (unsigned long)(elapsed * (tick_nsec / 1000))/LATCH; | ||
| 51 | |||
| 52 | return usec; | ||
| 53 | } | ||
| 54 | |||
| 55 | #ifdef CONFIG_NO_IDLE_HZ | 39 | #ifdef CONFIG_NO_IDLE_HZ |
| 56 | static unsigned long initial_match; | 40 | static unsigned long initial_match; |
| 57 | static int match_posponed; | 41 | static int match_posponed; |
| @@ -96,6 +80,20 @@ static struct irqaction sa1100_timer_irq = { | |||
| 96 | .handler = sa1100_timer_interrupt, | 80 | .handler = sa1100_timer_interrupt, |
| 97 | }; | 81 | }; |
| 98 | 82 | ||
| 83 | static cycle_t sa1100_read_oscr(void) | ||
| 84 | { | ||
| 85 | return OSCR; | ||
| 86 | } | ||
| 87 | |||
| 88 | static struct clocksource cksrc_sa1100_oscr = { | ||
| 89 | .name = "oscr", | ||
| 90 | .rating = 200, | ||
| 91 | .read = sa1100_read_oscr, | ||
| 92 | .mask = CLOCKSOURCE_MASK(32), | ||
| 93 | .shift = 20, | ||
| 94 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
| 95 | }; | ||
| 96 | |||
| 99 | static void __init sa1100_timer_init(void) | 97 | static void __init sa1100_timer_init(void) |
| 100 | { | 98 | { |
| 101 | unsigned long flags; | 99 | unsigned long flags; |
| @@ -109,6 +107,11 @@ static void __init sa1100_timer_init(void) | |||
| 109 | OIER = OIER_E0; /* enable match on timer 0 to cause interrupts */ | 107 | OIER = OIER_E0; /* enable match on timer 0 to cause interrupts */ |
| 110 | OSMR0 = OSCR + LATCH; /* set initial match */ | 108 | OSMR0 = OSCR + LATCH; /* set initial match */ |
| 111 | local_irq_restore(flags); | 109 | local_irq_restore(flags); |
| 110 | |||
| 111 | cksrc_sa1100_oscr.mult = | ||
| 112 | clocksource_hz2mult(CLOCK_TICK_RATE, cksrc_sa1100_oscr.shift); | ||
| 113 | |||
| 114 | clocksource_register(&cksrc_sa1100_oscr); | ||
| 112 | } | 115 | } |
| 113 | 116 | ||
| 114 | #ifdef CONFIG_NO_IDLE_HZ | 117 | #ifdef CONFIG_NO_IDLE_HZ |
| @@ -182,7 +185,6 @@ struct sys_timer sa1100_timer = { | |||
| 182 | .init = sa1100_timer_init, | 185 | .init = sa1100_timer_init, |
| 183 | .suspend = sa1100_timer_suspend, | 186 | .suspend = sa1100_timer_suspend, |
| 184 | .resume = sa1100_timer_resume, | 187 | .resume = sa1100_timer_resume, |
| 185 | .offset = sa1100_gettimeoffset, | ||
| 186 | #ifdef CONFIG_NO_IDLE_HZ | 188 | #ifdef CONFIG_NO_IDLE_HZ |
| 187 | .dyn_tick = &sa1100_dyn_tick, | 189 | .dyn_tick = &sa1100_dyn_tick, |
| 188 | #endif | 190 | #endif |
