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

Function mv_rtc_settime

freebsd/arm/mv/rtc.c:156–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156static int
157mv_rtc_settime(device_t dev, struct timespec *ts)
158{
159 struct clocktime ct;
160 struct mv_rtc_softc *sc;
161 uint32_t val;
162
163 sc = device_get_softc(dev);
164
165 /* Resolution: 1 sec */
166 if (ts->tv_nsec >= 500000000)
167 ts->tv_sec++;
168 ts->tv_nsec = 0;
169 clock_ts_to_ct(ts, &ct);
170
171 val = TOBCD(ct.sec) | (TOBCD(ct.min) << 8) |
172 (TOBCD(ct.hour) << 16) | (TOBCD( ct.dow + 1) << 24);
173 mv_rtc_reg_write(sc, MV_RTC_TIME_REG, val);
174
175 val = TOBCD(ct.day) | (TOBCD(ct.mon) << 8) |
176 (TOBCD(ct.year - YEAR_BASE) << 16);
177 mv_rtc_reg_write(sc, MV_RTC_DATE_REG, val);
178
179 return (0);
180}
181
182static uint32_t
183mv_rtc_reg_read(struct mv_rtc_softc *sc, bus_size_t off)

Callers

nothing calls this directly

Calls 3

device_get_softcFunction · 0.85
clock_ts_to_ctFunction · 0.85
mv_rtc_reg_writeFunction · 0.70

Tested by

no test coverage detected