Lines Matching +full:armada +full:- +full:380 +full:- +full:rtc
1 /*-
69 #define MV_RTC_LOCK(sc) mtx_lock_spin(&(sc)->mutex)
70 #define MV_RTC_UNLOCK(sc) mtx_unlock_spin(&(sc)->mutex)
98 { -1, 0 }
134 "rtc",
143 {"marvell,armada-380-rtc", RTC_A38X},
144 {"marvell,armada-8k-rtc", RTC_A8K},
194 if (!ofw_bus_search_compatible(dev, mv_rtc_compat)->ocd_data) in mv_rtc_probe()
197 device_set_desc(dev, "Marvell Integrated RTC"); in mv_rtc_probe()
209 sc->dev = dev; in mv_rtc_attach()
210 sc->rtc_type = ofw_bus_search_compatible(dev, mv_rtc_compat)->ocd_data; in mv_rtc_attach()
212 mtx_init(&sc->mutex, device_get_nameunit(dev), NULL, MTX_SPIN); in mv_rtc_attach()
214 ret = bus_alloc_resources(dev, res_spec, sc->res); in mv_rtc_attach()
217 mtx_destroy(&sc->mutex); in mv_rtc_attach()
221 switch (sc->rtc_type) { in mv_rtc_attach()
229 panic("Unknown RTC type: %d", sc->rtc_type); in mv_rtc_attach()
243 mtx_destroy(&sc->mutex); in mv_rtc_detach()
245 bus_release_resources(dev, res_spec, sc->res); in mv_rtc_detach()
268 } while ((val_check - val) > 1); in mv_rtc_gettime()
272 ts->tv_sec = val_check; in mv_rtc_gettime()
273 /* RTC resolution is 1 sec */ in mv_rtc_gettime()
274 ts->tv_nsec = 0; in mv_rtc_gettime()
286 /* RTC resolution is 1 sec */ in mv_rtc_settime()
287 if (ts->tv_nsec >= HALF_OF_SEC_NS) in mv_rtc_settime()
288 ts->tv_sec++; in mv_rtc_settime()
289 ts->tv_nsec = 0; in mv_rtc_settime()
295 /* RTC was not resetted yet */ in mv_rtc_settime()
300 * According to errata FE-3124064, Write to RTC TIME register in mv_rtc_settime()
301 * may fail. As a workaround, before writing to RTC TIME register, in mv_rtc_settime()
302 * issue a dummy write of 0x0 twice to RTC Status register. in mv_rtc_settime()
306 mv_rtc_reg_write(sc, RTC_TIME, ts->tv_sec); in mv_rtc_settime()
316 return (bus_read_4(sc->res[RTC_RES], off)); in mv_rtc_reg_read()
321 * register write to the RTC hard macro so that the required update
328 bus_write_4(sc->res[RTC_RES], off, val); in mv_rtc_reg_write()
339 val = bus_read_4(sc->res[RTC_SOC_RES], A38X_RTC_BRIDGE_TIMING_CTRL); in mv_rtc_configure_bus_a38x()
343 bus_write_4(sc->res[RTC_SOC_RES], A38X_RTC_BRIDGE_TIMING_CTRL, val); in mv_rtc_configure_bus_a38x()
351 val = bus_read_4(sc->res[RTC_SOC_RES], A8K_RTC_BRIDGE_TIMING_CTRL0); in mv_rtc_configure_bus_a8k()
355 bus_write_4(sc->res[RTC_SOC_RES], A8K_RTC_BRIDGE_TIMING_CTRL1, val); in mv_rtc_configure_bus_a8k()
357 val = bus_read_4(sc->res[RTC_SOC_RES], A8K_RTC_BRIDGE_TIMING_CTRL0); in mv_rtc_configure_bus_a8k()
360 bus_write_4(sc->res[RTC_SOC_RES], A8K_RTC_BRIDGE_TIMING_CTRL1, val); in mv_rtc_configure_bus_a8k()