No subject
Fri Oct 22 17:57:35 EDT 2010
clock_gettime( CLOCK_MONOTONIC, &now );
leads me to believe that kernel function ks8695_gettimeoffset() is not worth anything.
I suspect that there really is no "count down" read support on the KS8695 timer register.
The time delta (when it jumps) that I see from clock_gettime() corresponds to the 2 msec system
interrupt HZ tick that I compiled into the kernel.
I think this is a hardware limitation, but wanted another opinion, kernel code for said function has
not changed in years, shown below.
Thank you,
Dick
/*
* Returns number of ms since last clock interrupt. Note that interrupts
* will have been disabled by do_gettimeoffset()
*/
static unsigned long ks8695_gettimeoffset (void)
{
unsigned long elapsed, tick2, intpending;
/*
* Get the current number of ticks. Note that there is a race
* condition between us reading the timer and checking for an
* interrupt. We solve this by ensuring that the counter has not
* reloaded between our two reads.
*/
elapsed = __raw_readl(KS8695_TMR_VA + KS8695_T1TC) + __raw_readl(KS8695_TMR_VA + KS8695_T1PD);
do {
tick2 = elapsed;
intpending = __raw_readl(KS8695_IRQ_VA + KS8695_INTST) & (1 << KS8695_IRQ_TIMER1);
elapsed = __raw_readl(KS8695_TMR_VA + KS8695_T1TC) + __raw_readl(KS8695_TMR_VA + KS8695_T1PD);
} while (elapsed > tick2);
/* Convert to number of ticks expired (not remaining) */
elapsed = (CLOCK_TICK_RATE / HZ) - elapsed;
/* Is interrupt pending? If so, then timer has been reloaded already. */
if (intpending)
elapsed += (CLOCK_TICK_RATE / HZ);
/* Convert ticks to usecs */
return (unsigned long)(elapsed * (tick_nsec / 1000)) / LATCH;
}
More information about the linux-arm-kernel
mailing list