Commit 639622dd authored by Dave Jiang's avatar Dave Jiang Committed by Russell King

[ARM PATCH] 2222/1: iop3xx timer routine cleanup

Patch from Dave Jiang

Clean up iop3xx timer routines and move to xtime_lock/timer_tick schemes
dependent on patch 2216/1

Signed-off-by: Dave Jiang
Signed-off-by: Russell King
parent 2c503674
......@@ -29,11 +29,9 @@
#define IOP321_TIME_SYNC 0
static unsigned long iop321_latch;
static inline unsigned long get_elapsed(void)
{
return iop321_latch - *IOP321_TU_TCR0;
return LATCH - *IOP321_TU_TCR0;
}
static unsigned long iop321_gettimeoffset(void)
......@@ -55,14 +53,14 @@ static unsigned long iop321_gettimeoffset(void)
asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr2));
if(tisr1 & 1)
elapsed += iop321_latch;
elapsed += LATCH;
else if (tisr2 & 1)
elapsed = iop321_latch + get_elapsed();
elapsed = LATCH + get_elapsed();
/*
* Now convert them to usec.
*/
usec = (unsigned long)(elapsed * (tick_nsec / 1000)) / iop321_latch;
usec = (unsigned long)(elapsed * (tick_nsec / 1000)) / LATCH;
return usec;
}
......@@ -71,38 +69,16 @@ static irqreturn_t
iop321_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
u32 tisr;
#ifdef IOP321_TIME_SYNC
u32 passed;
#define TM_THRESH (iop321_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 IOP321_TIME_SYNC
passed = 0xffffffff - *IOP321_TU_TCR1;
do
{
do_timer(regs);
if(passed < TM_THRESH)
break;
if(passed > iop321_latch)
passed -= iop321_latch;
else
passed = 0;
} while(1);
asm volatile("mcr p6, 0, %0, c3, c1, 0" : : "r" (0xffffffff));
#else
do_timer(regs);
#ifndef CONFIG_SMP
update_process_times(user_mode(regs));
#endif
#endif
timer_tick(regs);
write_sequnlock(&xtime_lock);
return IRQ_HANDLED;
}
......@@ -117,25 +93,14 @@ static void __init iop321_timer_init(void)
{
u32 timer_ctl;
iop321_latch = (CLOCK_TICK_RATE + HZ / 2) / HZ;
setup_irq(IRQ_IOP321_TIMER0, &iop321_timer_irq);
timer_ctl = IOP321_TMR_EN | IOP321_TMR_PRIVILEGED | IOP321_TMR_RELOAD |
IOP321_TMR_RATIO_1_1;
asm volatile("mcr p6, 0, %0, c4, c1, 0" : : "r" (iop321_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 IOP321_TIME_SYNC
/* Setup second timer */
/* setup counter */
timer_ctl = IOP321_TMR_EN | IOP321_TMR_PRIVILEGED |
IOP321_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 iop321_timer = {
......
......@@ -27,13 +27,9 @@
#include <asm/mach/irq.h>
#include <asm/mach/time.h>
#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 +51,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 * (tick_nsec / 1000)) / LATCH;
return usec;
}
......@@ -71,39 +67,16 @@ 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);
#ifndef CONFIG_SMP
update_process_times(user_mode(regs));
#endif
#endif
timer_tick(regs);
write_sequnlock(&xtime_lock);
return IRQ_HANDLED;
}
......@@ -117,25 +90,15 @@ static void __init iop331_timer_init(void)
{
u32 timer_ctl;
iop331_latch = (CLOCK_TICK_RATE + HZ / 2) / HZ;
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 = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment