Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iicbus/pmic/rockchip/rk8xx_rtc.c
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | rk8xx_settime(device_t dev, struct timespec *ts) | ||||
struct rk8xx_softc *sc; | struct rk8xx_softc *sc; | ||||
struct bcd_clocktime bct; | struct bcd_clocktime bct; | ||||
uint8_t data[7]; | uint8_t data[7]; | ||||
int error; | int error; | ||||
uint8_t ctrl; | uint8_t ctrl; | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
clock_ts_to_bcd(ts, &bct, false); | error = clock_ts_to_bcd(ts, &bct, false); | ||||
if (error) | |||||
return (error); | |||||
/* 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) { | if (sc->type == RK809 || sc->type == RK817) { | ||||
/* valid for 2000-2099 only */ | /* valid for 2000-2099 only */ | ||||
if ((bct.year & 0xff00) != 0x2000) { | if ((bct.year & 0xff00) != 0x2000) { | ||||
device_printf(dev, "year out of range\n"); | device_printf(dev, "year out of range\n"); | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
Show All 29 Lines |