Add nanosecond slewing to Linux driver

For offset adjustments below 10 microseconds use kernel PLL with
locked frequency and 1s time constant.
This commit is contained in:
Miroslav Lichvar
2010-08-05 19:15:45 +02:00
parent 7994b31de4
commit cb28aeeacc
4 changed files with 155 additions and 12 deletions

View File

@@ -74,8 +74,6 @@ TMX_SetFrequency(double *freq, long tick)
txc.freq = (long)(*freq * (double)(1 << SHIFT_USEC));
*freq = txc.freq / (double)(1 << SHIFT_USEC);
txc.tick = tick;
/* Prevent any of the FLL/PLL stuff coming up */
txc.status = status;
if (!(status & STA_UNSYNC)) {
@@ -201,5 +199,46 @@ int TMX_SetSync(int sync)
return adjtimex(&txc);
}
int
TMX_EnableNanoPLL(void)
{
struct timex txc;
int result;
txc.modes = ADJ_STATUS | ADJ_OFFSET | ADJ_TIMECONST | ADJ_NANO;
txc.status = STA_PLL | STA_FREQHOLD;
txc.offset = 0;
txc.constant = 0;
result = adjtimex(&txc);
if (result < 0 || !(txc.status & STA_NANO) || txc.offset || txc.constant)
return -1;
status |= STA_PLL | STA_FREQHOLD;
return result;
}
int
TMX_ApplyPLLOffset(long offset)
{
struct timex txc;
txc.modes = ADJ_OFFSET | ADJ_TIMECONST | ADJ_NANO;
txc.offset = offset;
txc.constant = 0;
return adjtimex(&txc);
}
int
TMX_GetPLLOffsetLeft(long *offset)
{
struct timex txc;
int result;
txc.modes = 0;
result = adjtimex(&txc);
*offset = txc.offset;
return result;
}
#endif