Lines Matching +full:0 +full:- +full:mon
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
52 #define DA9063_RTC_LOCK(sc) mtx_lock(&(sc)->mtx)
53 #define DA9063_RTC_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
54 #define DA9063_RTC_ASSERT_LOCKED(sc) mtx_assert(&(sc)->mtx, MA_OWNED);
55 #define DA9063_RTC_ASSERT_UNLOCKED(sc) mtx_assert(&(sc)->mtx, MA_NOTOWNED);
58 { "dlg,da9063-rtc", 1 },
59 { NULL, 0 }
65 uint8_t sec, min, hour, day, mon, year; in da9063_rtc_read_ct() local
70 error = DA9063_READ(sc->parent, DA9063_COUNT_S, &sec); in da9063_rtc_read_ct()
71 if (error != 0) in da9063_rtc_read_ct()
73 if ((sec & DA9063_COUNT_S_RTC_READ) == 0) in da9063_rtc_read_ct()
76 error = DA9063_READ(sc->parent, DA9063_COUNT_MI, &min); in da9063_rtc_read_ct()
77 if (error != 0) in da9063_rtc_read_ct()
80 error = DA9063_READ(sc->parent, DA9063_COUNT_H, &hour); in da9063_rtc_read_ct()
81 if (error != 0) in da9063_rtc_read_ct()
84 error = DA9063_READ(sc->parent, DA9063_COUNT_D, &day); in da9063_rtc_read_ct()
85 if (error != 0) in da9063_rtc_read_ct()
88 error = DA9063_READ(sc->parent, DA9063_COUNT_MO, &mon); in da9063_rtc_read_ct()
89 if (error != 0) in da9063_rtc_read_ct()
92 error = DA9063_READ(sc->parent, DA9063_COUNT_Y, &year); in da9063_rtc_read_ct()
93 if (error != 0) in da9063_rtc_read_ct()
96 ct->nsec = 0; in da9063_rtc_read_ct()
97 ct->dow = -1; in da9063_rtc_read_ct()
98 ct->sec = sec & DA9063_COUNT_S_COUNT_SEC_MASK; in da9063_rtc_read_ct()
99 ct->min = min & DA9063_COUNT_MI_COUNT_MIN_MASK; in da9063_rtc_read_ct()
100 ct->hour = hour & DA9063_COUNT_H_COUNT_HOUR_MASK; in da9063_rtc_read_ct()
101 ct->day = day & DA9063_COUNT_D_COUNT_DAY_MASK; in da9063_rtc_read_ct()
102 ct->mon = mon & DA9063_COUNT_MO_COUNT_MONTH_MASK; in da9063_rtc_read_ct()
103 ct->year = (year & DA9063_COUNT_Y_COUNT_YEAR_MASK) + in da9063_rtc_read_ct()
106 return (0); in da9063_rtc_read_ct()
116 error = DA9063_WRITE(sc->parent, DA9063_COUNT_S, ct->sec); in da9063_rtc_write_ct()
117 if (error != 0) in da9063_rtc_write_ct()
120 error = DA9063_WRITE(sc->parent, DA9063_COUNT_MI, ct->min); in da9063_rtc_write_ct()
121 if (error != 0) in da9063_rtc_write_ct()
124 error = DA9063_WRITE(sc->parent, DA9063_COUNT_H, ct->hour); in da9063_rtc_write_ct()
125 if (error != 0) in da9063_rtc_write_ct()
128 error = DA9063_WRITE(sc->parent, DA9063_COUNT_D, ct->day); in da9063_rtc_write_ct()
129 if (error != 0) in da9063_rtc_write_ct()
132 error = DA9063_WRITE(sc->parent, DA9063_COUNT_MO, ct->mon); in da9063_rtc_write_ct()
133 if (error != 0) in da9063_rtc_write_ct()
136 error = DA9063_WRITE(sc->parent, DA9063_COUNT_Y, in da9063_rtc_write_ct()
137 (ct->year - DA9063_RTC_BASE_YEAR) & in da9063_rtc_write_ct()
139 if (error != 0) in da9063_rtc_write_ct()
142 return (0); in da9063_rtc_write_ct()
157 if (error != 0) in da9063_rtc_gettime()
163 * be, so re-read to get a consistent set of values. in da9063_rtc_gettime()
168 if (error != 0) in da9063_rtc_gettime()
171 ct.day != oldct.day || ct.mon != oldct.mon || in da9063_rtc_gettime()
177 if (error != 0) in da9063_rtc_gettime()
180 return (0); in da9063_rtc_gettime()
197 * We request a timespec with no resolution-adjustment. That also in da9063_rtc_settime()
200 ts->tv_sec -= utc_offset(); in da9063_rtc_settime()
216 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) in da9063_rtc_probe()
232 sc->dev = dev; in da9063_rtc_attach()
233 sc->parent = device_get_parent(dev); in da9063_rtc_attach()
236 error = DA9063_MODIFY(sc->parent, DA9063_CONTROL_E, 0, in da9063_rtc_attach()
238 if (error != 0) in da9063_rtc_attach()
242 error = DA9063_MODIFY(sc->parent, DA9063_EN_32K, 0, in da9063_rtc_attach()
244 if (error != 0) in da9063_rtc_attach()
248 error = DA9063_MODIFY(sc->parent, DA9063_ALARM_Y, in da9063_rtc_attach()
249 DA9063_ALARM_Y_ALARM_ON | DA9063_ALARM_Y_TICK_ON, 0); in da9063_rtc_attach()
250 if (error != 0) in da9063_rtc_attach()
253 mtx_init(&sc->mtx, device_get_nameunit(sc->dev), NULL, MTX_DEF); in da9063_rtc_attach()
261 return (0); in da9063_rtc_attach()
272 mtx_destroy(&sc->mtx); in da9063_rtc_detach()
274 return (0); in da9063_rtc_detach()