From: Peter Keilty Initial sparc64 conversion to generic clocksource/timekeeping code. Signed-off-by: Peter Keilty Signed-off-by: John Stultz Kconfig | 2 +- defconfig | 2 +- kernel/time.c | 34 +++++++++++++++++++++++----------- 3 files changed, 25 insertions(+), 13 deletions(-) linux-2.6.18-rc6_timeofday-arch-sparc64_C6.patch ============================================ diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig index 8a36ba8..d8e15d3 100644 --- a/arch/sparc64/Kconfig +++ b/arch/sparc64/Kconfig @@ -26,7 +26,7 @@ config MMU bool default y -config TIME_INTERPOLATION +config GENERIC_TIME bool default y diff --git a/arch/sparc64/defconfig b/arch/sparc64/defconfig index 43d9229..10d4bd6 100644 --- a/arch/sparc64/defconfig +++ b/arch/sparc64/defconfig @@ -7,7 +7,7 @@ CONFIG_SPARC=y CONFIG_SPARC64=y CONFIG_64BIT=y CONFIG_MMU=y -CONFIG_TIME_INTERPOLATION=y +CONFIG_GENERIC_TIME=y CONFIG_ARCH_MAY_HAVE_PC_FDC=y CONFIG_SPARC64_PAGE_SIZE_8KB=y # CONFIG_SPARC64_PAGE_SIZE_64KB is not set diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index 094d3e3..ec92d5a 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -621,7 +622,7 @@ static void __init set_system_time(void) if (!mregs && !dregs) { prom_printf("Something wrong, clock regs not mapped yet.\n"); prom_halt(); - } + } if (mregs) { spin_lock_irq(&mostek_lock); @@ -821,7 +822,7 @@ static int __devinit clock_probe(struct } set_system_time(); - + local_irq_restore(flags); return 0; @@ -976,22 +977,33 @@ static struct notifier_block sparc64_cpu #endif /* CONFIG_CPU_FREQ */ -static struct time_interpolator sparc64_cpu_interpolator = { - .source = TIME_SOURCE_CPU, - .shift = 16, - .mask = 0xffffffffffffffffLL +static cycle_t read_itc(void) +{ + return (cycle_t)get_cycles()); +} + +static struct clocksource clocksource_sparc64_itc = { + .name = "sparc64_itc", + .rating = 300, + .read = read_itc, + .mask = 0xffffffffffffffffLL, + .mult = 0, /*to be caluclated*/ + .shift = 16, + .is_continuous = 1, }; + /* The quotient formula is taken from the IA64 port. */ #define SPARC64_NSEC_PER_CYC_SHIFT 30UL void __init time_init(void) { unsigned long clock = sparc64_init_timers(); - sparc64_cpu_interpolator.frequency = clock; - register_time_interpolator(&sparc64_cpu_interpolator); + clocksource_sparc64_itc.mult = clocksource_hz2mult(clock, + clocksource_sparc64_itc.shift); + clocksource_register(&clocksource_sparc64_itc); - /* Now that the interpolator is registered, it is + /* Now that the clocksource is registered, it is * safe to start the timer ticking. */ sparc64_start_timers(); @@ -1026,11 +1038,11 @@ static int set_rtc_mmss(unsigned long no unsigned long flags; u8 tmp; - /* + /* * Not having a register set can lead to trouble. * Also starfire doesn't have a tod clock. */ - if (!mregs && !dregs) + if (!mregs && !dregs) return -1; if (mregs) {