| 154 | } |
| 155 | |
| 156 | static int |
| 157 | mv_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 | |
| 182 | static uint32_t |
| 183 | mv_rtc_reg_read(struct mv_rtc_softc *sc, bus_size_t off) |
nothing calls this directly
no test coverage detected