Catch up with improvements in RTC handling... It's no longer necessary to
ignore the timestamp passed in to settime() due to inaccuracy, the core routines now pass in a nanosecond-accurate time freshly-obtained before calling each driver's settime() method. Also, add calls to the new debugging output helpers.
This commit is contained in:
parent
da485b59a5
commit
1e1fb9a665
@ -137,36 +137,34 @@ snvs_gettime(device_t dev, struct timespec *ts)
|
||||
|
||||
*ts = sbttots(counter1);
|
||||
|
||||
clock_dbgprint_ts(sc->dev, CLOCK_DBG_READ, ts);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
snvs_settime(device_t dev, struct timespec *unused)
|
||||
snvs_settime(device_t dev, struct timespec *ts)
|
||||
{
|
||||
struct snvs_softc *sc;
|
||||
struct bintime bt;
|
||||
sbintime_t sbt;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
/*
|
||||
* Ignore the inaccurate time passed in from the common clock code and
|
||||
* obtain a time worthy of our 30us accuracy.
|
||||
*/
|
||||
bintime(&bt);
|
||||
bt.sec -= utc_offset();
|
||||
sbt = bttosbt(bt);
|
||||
|
||||
/*
|
||||
* It takes two clock cycles for the counter to start after setting the
|
||||
* enable bit, so add two SBT_LSBs to what we're about to set.
|
||||
* The hardware format is the same as sbt (with fewer fractional bits),
|
||||
* so first convert the time to sbt. It takes two clock cycles for the
|
||||
* counter to start after setting the enable bit, so add two SBT_LSBs to
|
||||
* what we're about to set.
|
||||
*/
|
||||
sbt = tstosbt(*ts);
|
||||
sbt += 2 << SBT_LSB;
|
||||
snvs_rtc_enable(sc, false);
|
||||
WR4(sc, SNVS_LPSRTCMR, (uint32_t)(sbt >> (SBT_LSB + 32)));
|
||||
WR4(sc, SNVS_LPSRTCLR, (uint32_t)(sbt >> (SBT_LSB)));
|
||||
snvs_rtc_enable(sc, true);
|
||||
|
||||
clock_dbgprint_ts(sc->dev, CLOCK_DBG_WRITE, ts);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user