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