MCPcopy Create free account
hub / github.com/F-Stack/f-stack / aw_rtc_gettime

Function aw_rtc_gettime

freebsd/arm/allwinner/aw_rtc.c:285–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283}
284
285static int
286aw_rtc_gettime(device_t dev, struct timespec *ts)
287{
288 struct aw_rtc_softc *sc = device_get_softc(dev);
289 struct clocktime ct;
290 uint32_t rdate, rtime;
291
292 rdate = RTC_READ(sc, sc->conf->rtc_date);
293 rtime = RTC_READ(sc, sc->conf->rtc_time);
294
295 if ((rtime & TIME_MASK) == 0)
296 rdate = RTC_READ(sc, sc->conf->rtc_date);
297
298 ct.sec = GET_SEC_VALUE(rtime);
299 ct.min = GET_MIN_VALUE(rtime);
300 ct.hour = GET_HOUR_VALUE(rtime);
301 ct.day = GET_DAY_VALUE(rdate);
302 ct.mon = GET_MON_VALUE(rdate);
303 ct.year = GET_YEAR_VALUE(rdate) + YEAR_OFFSET;
304 ct.dow = -1;
305 /* RTC resolution is 1 sec */
306 ct.nsec = 0;
307
308 return (clock_ct_to_ts(&ct, ts));
309}
310
311static int
312aw_rtc_settime(device_t dev, struct timespec *ts)

Callers

nothing calls this directly

Calls 2

device_get_softcFunction · 0.85
clock_ct_to_tsFunction · 0.85

Tested by

no test coverage detected