Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iicbus/pmic/rockchip/rk8xx_rtc.c
Context not available. | |||||
error = rk8xx_write(dev, sc->rtc_regs.ctrl, &ctrl, 1); | error = rk8xx_write(dev, sc->rtc_regs.ctrl, &ctrl, 1); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
if (sc->type == RK809 || sc->type == RK817) { | |||||
/* wait one 32khz cycle for clock shadow registers to latch */ | |||||
DELAY(1000000 / 32000); | |||||
} | |||||
ctrl &= ~sc->rtc_regs.ctrl_gettime_mask; | ctrl &= ~sc->rtc_regs.ctrl_gettime_mask; | ||||
error = rk8xx_write(dev, sc->rtc_regs.ctrl, &ctrl, 1); | error = rk8xx_write(dev, sc->rtc_regs.ctrl, &ctrl, 1); | ||||
if (error != 0) | if (error != 0) | ||||
Context not available. | |||||
if (bct.dow == 7) | if (bct.dow == 7) | ||||
bct.dow = 0; | bct.dow = 0; | ||||
bct.ispm = 0; | bct.ispm = 0; | ||||
if (sc->type == RK809 || sc->type == RK817) | |||||
bct.year += 0x2000; /* valid for 2000-2099 only */ | |||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(dev, "Read RTC: %02x-%02x-%02x %02x:%02x:%02x\n", | device_printf(dev, "Read RTC: %02x-%02x-%02x %02x:%02x:%02x\n", | ||||
Context not available. | |||||
clock_ts_to_bcd(ts, &bct, false); | clock_ts_to_bcd(ts, &bct, false); | ||||
/* This works as long as RK805_RTC_SECS = 0 */ | /* This works as long as RK805_RTC_SECS = 0 */ | ||||
if (sc->type == RK809 || sc->type == RK817) { | |||||
/* valid for 2000-2099 only */ | |||||
if ((bct.year & 0xff00) != 0x2000) { | |||||
device_printf(dev, "year out of range\n"); | |||||
return (EINVAL); | |||||
} | |||||
bct.year &= 0x00ff; | |||||
} | |||||
data[sc->rtc_regs.years] = bct.year; | data[sc->rtc_regs.years] = bct.year; | ||||
data[sc->rtc_regs.months] = bct.mon; | data[sc->rtc_regs.months] = bct.mon; | ||||
data[sc->rtc_regs.days] = bct.day; | data[sc->rtc_regs.days] = bct.day; | ||||
Context not available. |