Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iicbus/rtc8583.c
Show First 20 Lines • Show All 250 Lines • ▼ Show 20 Lines | rtc8583_settime(device_t dev, struct timespec *ts) | ||||
struct rtc8583_softc *sc; | struct rtc8583_softc *sc; | ||||
struct bcd_clocktime bct; | struct bcd_clocktime bct; | ||||
struct time_regs tregs; | struct time_regs tregs; | ||||
uint8_t sreg; | uint8_t sreg; | ||||
int err; | int err; | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
ts->tv_sec -= utc_offset(); | ts->tv_sec -= utc_offset(); | ||||
clock_ts_to_bcd(ts, &bct, false); | err = clock_ts_to_bcd(ts, &bct, false); | ||||
if (err) | |||||
return (err); | |||||
clock_dbgprint_bcd(sc->dev, CLOCK_DBG_WRITE, &bct); | clock_dbgprint_bcd(sc->dev, CLOCK_DBG_WRITE, &bct); | ||||
/* The 'msec' reg is actually 1/100ths, in bcd. */ | /* The 'msec' reg is actually 1/100ths, in bcd. */ | ||||
tregs.msec = bin2bcd(ts->tv_nsec / (10 * 1000 * 1000)); | tregs.msec = bin2bcd(ts->tv_nsec / (10 * 1000 * 1000)); | ||||
tregs.sec = bct.sec; | tregs.sec = bct.sec; | ||||
tregs.min = bct.min; | tregs.min = bct.min; | ||||
tregs.hour = bct.hour; | tregs.hour = bct.hour; | ||||
tregs.day = bct.day | (bct.year & 0x03 << 6); | tregs.day = bct.day | (bct.year & 0x03 << 6); | ||||
Show All 37 Lines |