Commit 31d49a63 authored by Russell King's avatar Russell King

[ARM] Update timekeeping functions to use tick_nsec/1000

This updates the ARM time keeping functions to use tick_nsec/1000
instead of tick.
parent eac00de1
......@@ -25,44 +25,37 @@ extern unsigned long (*gettimeoffset)(void);
static unsigned long ioctime_gettimeoffset(void)
{
unsigned int count1, count2, status1, status2;
unsigned long offset = 0;
unsigned int count1, count2, status;
long offset;
status1 = ioc_readb(IOC_IRQREQA);
barrier ();
ioc_writeb (0, IOC_T0LATCH);
barrier ();
count1 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
barrier ();
status2 = ioc_readb(IOC_IRQREQA);
status = ioc_readb(IOC_IRQREQA);
barrier ();
ioc_writeb (0, IOC_T0LATCH);
barrier ();
count2 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
offset = count2;
if (count2 < count1) {
/*
* This means that we haven't just had an interrupt
* while reading into status2.
* We have not had an interrupt between reading count1
* and count2.
*/
if (status2 & (1 << 5))
offset = tick;
count1 = count2;
if (status & (1 << 5))
offset -= LATCH;
} else if (count2 > count1) {
/*
* We have just had another interrupt while reading
* status2.
* We have just had another interrupt between reading
* count1 and count2.
*/
offset += tick;
count1 = count2;
offset -= LATCH;
}
count1 = LATCH - count1;
/*
* count1 = number of clock ticks since last interrupt
*/
offset += count1 * tick / LATCH;
return offset;
offset = (LATCH - offset) * (tick_nsec / 1000);
return (offset + LATCH/2) / LATCH;
}
void __init ioctime_init(void)
......
......@@ -115,8 +115,8 @@ static inline void do_set_rtc(void)
time_before(xtime.tv_sec, next_rtc_update))
return;
if (xtime.tv_usec < 50000 - (tick >> 1) &&
xtime.tv_usec >= 50000 + (tick >> 1))
if (xtime.tv_nsec < 500000000 - ((unsigned) tick_nsec >> 1) &&
xtime.tv_nsec >= 500000000 + ((unsigned) tick_nsec >> 1))
return;
if (set_rtc())
......@@ -166,7 +166,7 @@ void do_gettimeofday(struct timeval *tv)
usec += lost * USECS_PER_JIFFY;
sec = xtime.tv_sec;
usec += xtime.tv_usec;
usec += xtime.tv_nsec / 1000;
read_unlock_irqrestore(&xtime_lock, flags);
/* usec may have gone up a lot: be safe */
......@@ -196,7 +196,8 @@ void do_settimeofday(struct timeval *tv)
tv->tv_sec--;
}
xtime = *tv;
xtime.tv_sec = tv->tv_sec;
xtime.tv_nsec = tv->tv_usec * 1000;
time_adjust = 0; /* stop active adjtime() */
time_status |= STA_UNSYNC;
time_maxerror = NTP_PHASE_LIMIT;
......
......@@ -85,7 +85,7 @@ static unsigned long iq80310_gettimeoffset (void)
/*
* Now convert them to usec.
*/
usec = (unsigned long)(elapsed*tick)/LATCH;
usec = (unsigned long)(elapsed * (tick_nsec / 1000))/LATCH;
return usec;
}
......
......@@ -62,7 +62,7 @@ static unsigned long isa_gettimeoffset(void)
count_p = count;
count = (((mSEC_10_from_14/6)-1) - count) * tick;
count = (((mSEC_10_from_14/6)-1) - count) * (tick_nsec / 1000);
count = (count + (mSEC_10_from_14/6)/2) / (mSEC_10_from_14/6);
return count;
......@@ -182,7 +182,7 @@ static unsigned long timer1_gettimeoffset (void)
{
unsigned long value = LATCH - *CSR_TIMER1_VALUE;
return (tick * value) / LATCH;
return ((tick_nsec / 1000) * value) / LATCH;
}
static void timer1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
......
......@@ -58,7 +58,7 @@ static unsigned long sa1100_gettimeoffset (void)
elapsed = LATCH - ticks_to_match;
/* Now convert them to usec */
usec = (unsigned long)(elapsed*tick)/LATCH;
usec = (unsigned long)(elapsed * (tick_nsec / 1000))/LATCH;
return usec;
}
......
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