| 128 | } |
| 129 | |
| 130 | static int |
| 131 | mv_rtc_gettime(device_t dev, struct timespec *ts) |
| 132 | { |
| 133 | struct clocktime ct; |
| 134 | struct mv_rtc_softc *sc; |
| 135 | uint32_t val; |
| 136 | |
| 137 | sc = device_get_softc(dev); |
| 138 | |
| 139 | val = mv_rtc_reg_read(sc, MV_RTC_TIME_REG); |
| 140 | |
| 141 | ct.nsec = 0; |
| 142 | ct.sec = FROMBCD(val & 0x7f); |
| 143 | ct.min = FROMBCD((val & 0x7f00) >> 8); |
| 144 | ct.hour = FROMBCD((val & 0x3f0000) >> 16); |
| 145 | ct.dow = FROMBCD((val & 0x7000000) >> 24) - 1; |
| 146 | |
| 147 | val = mv_rtc_reg_read(sc, MV_RTC_DATE_REG); |
| 148 | |
| 149 | ct.day = FROMBCD(val & 0x7f); |
| 150 | ct.mon = FROMBCD((val & 0x1f00) >> 8); |
| 151 | ct.year = YEAR_BASE + FROMBCD((val & 0xff0000) >> 16); |
| 152 | |
| 153 | return (clock_ct_to_ts(&ct, ts)); |
| 154 | } |
| 155 | |
| 156 | static int |
| 157 | mv_rtc_settime(device_t dev, struct timespec *ts) |
nothing calls this directly
no test coverage detected