From: Greg Ungerer Date: Fri, 1 Feb 2008 07:40:17 +0000 (+1000) Subject: m68knommu: switch 68328 timer to use GENERIC_TIME X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=36a90f26aa24c58e5279786340beb9f5bea39361;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git m68knommu: switch 68328 timer to use GENERIC_TIME Switch the 68328 CPU timer code to using GENERIC_TIME. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds --- diff --git a/arch/m68knommu/platform/68328/timers.c b/arch/m68knommu/platform/68328/timers.c index 04cbc661d4bd..9159fd05c9ac 100644 --- a/arch/m68knommu/platform/68328/timers.c +++ b/arch/m68knommu/platform/68328/timers.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,19 @@ #define TICKS_PER_JIFFY 10 #endif +static u32 m68328_tick_cnt; + +/***************************************************************************/ + +static irqreturn_t hw_tick(int irq, void *dummy) +{ + /* Reset Timer1 */ + TSTAT &= 0; + + m68328_tick_cnt += TICKS_PER_JIFFY; + return arch_timer_interrupt(irq, dummy); +} + /***************************************************************************/ static irqreturn_t hw_tick(int irq, void *dummy) @@ -69,6 +83,33 @@ static struct irqaction m68328_timer_irq = { .handler = hw_tick, }; +/***************************************************************************/ + +static cycle_t m68328_read_clk(void) +{ + unsigned long flags; + u32 cycles; + + local_irq_save(flags); + cycles = m68328_tick_cnt + TCN; + local_irq_restore(flags); + + return cycles; +} + +/***************************************************************************/ + +static struct clocksource m68328_clk = { + .name = "timer", + .rating = 250, + .read = m68328_read_clk, + .shift = 20, + .mask = CLOCKSOURCE_MASK(32), + .flags = CLOCK_SOURCE_IS_CONTINUOUS, +}; + +/***************************************************************************/ + void hw_timer_init(void) { /* disable timer 1 */ @@ -84,19 +125,8 @@ void hw_timer_init(void) /* Enable timer 1 */ TCTL |= TCTL_TEN; -} - -/***************************************************************************/ - -unsigned long hw_timer_offset(void) -{ - unsigned long ticks = TCN, offset = 0; - - /* check for pending interrupt */ - if (ticks < (TICKS_PER_JIFFY >> 1) && (ISR & (1 << TMR_IRQ_NUM))) - offset = 1000000 / HZ; - ticks = (ticks * 1000000 / HZ) / TICKS_PER_JIFFY; - return ticks + offset; + m68328_clk.mult = clocksource_hz2mult(TICKS_PER_JIFFY*HZ, m68328_clk.shift); + clocksource_register(&m68328_clk); } /***************************************************************************/