| 68 | } |
| 69 | |
| 70 | int |
| 71 | as3722_rtc_settime(device_t dev, struct timespec *ts) |
| 72 | { |
| 73 | struct as3722_softc *sc; |
| 74 | struct clocktime ct; |
| 75 | uint8_t buf[6]; |
| 76 | int rv; |
| 77 | |
| 78 | sc = device_get_softc(dev); |
| 79 | clock_ts_to_ct(ts, &ct); |
| 80 | |
| 81 | if (ct.year < AS3722_RTC_START_YEAR) |
| 82 | return (EINVAL); |
| 83 | |
| 84 | buf[0] = bin2bcd(ct.sec); |
| 85 | buf[1] = bin2bcd(ct.min); |
| 86 | buf[2] = bin2bcd(ct.hour); |
| 87 | buf[3] = bin2bcd(ct.day); |
| 88 | buf[4] = bin2bcd(ct.mon); |
| 89 | buf[5] = bin2bcd(ct.year - AS3722_RTC_START_YEAR); |
| 90 | |
| 91 | rv = as3722_write_buf(sc, AS3722_RTC_SECOND, buf, 6); |
| 92 | if (rv != 0) { |
| 93 | device_printf(sc->dev, "Failed to write RTC data\n"); |
| 94 | return (rv); |
| 95 | } |
| 96 | return (0); |
| 97 | } |
| 98 | |
| 99 | int |
| 100 | as3722_rtc_attach(struct as3722_softc *sc, phandle_t node) |
nothing calls this directly
no test coverage detected