X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Farm%2Fmach-iop3xx%2Fiop331-time.c;h=3c1f0ebbd636e42e8160fddae779bf81d90c9e9c;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=c90a0c9bd3dd2e19bf89f05ff2aa8eb3c9639c44;hpb=a2c21200f1c81b08cb55e417b68150bba439b646;p=linux-2.6.git diff --git a/arch/arm/mach-iop3xx/iop331-time.c b/arch/arm/mach-iop3xx/iop331-time.c index c90a0c9bd..3c1f0ebbd 100644 --- a/arch/arm/mach-iop3xx/iop331-time.c +++ b/arch/arm/mach-iop3xx/iop331-time.c @@ -23,17 +23,12 @@ #include #include #include -#include #include #include -#undef IOP331_TIME_SYNC - -static unsigned long iop331_latch; - static inline unsigned long get_elapsed(void) { - return iop331_latch - *IOP331_TU_TCR0; + return LATCH - *IOP331_TU_TCR0; } static unsigned long iop331_gettimeoffset(void) @@ -55,14 +50,14 @@ static unsigned long iop331_gettimeoffset(void) asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr2)); if(tisr1 & 1) - elapsed += iop331_latch; + elapsed += LATCH; else if (tisr2 & 1) - elapsed = iop331_latch + get_elapsed(); + elapsed = LATCH + get_elapsed(); /* * Now convert them to usec. */ - usec = (unsigned long)(elapsed * (tick_nsec / 1000)) / iop331_latch; + usec = (unsigned long)(elapsed / (CLOCK_TICK_RATE/1000000)); return usec; } @@ -71,71 +66,41 @@ static irqreturn_t iop331_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) { u32 tisr; -#ifdef IOP331_TIME_SYNC - u32 passed; -#define TM_THRESH (iop331_latch*2) -#endif - asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr)); + write_seqlock(&xtime_lock); + asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr)); tisr |= 1; - asm volatile("mcr p6, 0, %0, c6, c1, 0" : : "r" (tisr)); -#ifdef IOP331_TIME_SYNC - passed = 0xffffffff - *IOP331_TU_TCR1; - - do - { - do_timer(regs); - if(passed < TM_THRESH) - break; - if(passed > iop331_latch) - passed -= iop331_latch; - else - passed = 0; - } while(1); - - asm volatile("mcr p6, 0, %0, c3, c1, 0" : : "r" (0xffffffff)); -#else - do_timer(regs); -#endif + timer_tick(regs); + write_sequnlock(&xtime_lock); return IRQ_HANDLED; } static struct irqaction iop331_timer_irq = { .name = "IOP331 Timer Tick", .handler = iop331_timer_interrupt, - .flags = SA_INTERRUPT + .flags = SA_INTERRUPT | SA_TIMER, }; -extern int setup_arm_irq(int, struct irqaction*); - -void __init iop331_init_time(void) +static void __init iop331_timer_init(void) { u32 timer_ctl; - iop331_latch = (CLOCK_TICK_RATE + HZ / 2) / HZ; - gettimeoffset = iop331_gettimeoffset; setup_irq(IRQ_IOP331_TIMER0, &iop331_timer_irq); timer_ctl = IOP331_TMR_EN | IOP331_TMR_PRIVILEGED | IOP331_TMR_RELOAD | IOP331_TMR_RATIO_1_1; - asm volatile("mcr p6, 0, %0, c4, c1, 0" : : "r" (iop331_latch)); + asm volatile("mcr p6, 0, %0, c4, c1, 0" : : "r" (LATCH)); asm volatile("mcr p6, 0, %0, c0, c1, 0" : : "r" (timer_ctl)); -#ifdef IOP331_TIME_SYNC - /* Setup second timer */ - /* setup counter */ - timer_ctl = IOP331_TMR_EN | IOP331_TMR_PRIVILEGED | - IOP331_TMR_RATIO_1_1; - asm volatile("mcr p6, 0, %0, c3, c1, 0" : : "r" (0xffffffff)); - /* setup control */ - asm volatile("mcr p6, 0, %0, c1, c1, 0" : : "r" (timer_ctl)); -#endif } - +struct sys_timer iop331_timer = { + .init = iop331_timer_init, + .offset = iop331_gettimeoffset, +};