MCPcopy Create free account
hub / github.com/F-Stack/f-stack / aw_rtc_attach

Function aw_rtc_attach

freebsd/arm/allwinner/aw_rtc.c:207–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207static int
208aw_rtc_attach(device_t dev)
209{
210 struct aw_rtc_softc *sc = device_get_softc(dev);
211 uint32_t val;
212 int rid = 0;
213
214 sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
215 if (!sc->res) {
216 device_printf(dev, "could not allocate resources\n");
217 return (ENXIO);
218 }
219
220 sc->conf = (struct aw_rtc_conf *)ofw_bus_search_compatible(dev, compat_data)->ocd_data;
221 val = RTC_READ(sc, LOSC_CTRL_REG);
222 val |= LOSC_AUTO_SW_EN;
223 val |= LOSC_MAGIC | LOSC_GSM | LOSC_OSC_SRC;
224 RTC_WRITE(sc, LOSC_CTRL_REG, val);
225
226 DELAY(100);
227
228 if (bootverbose) {
229 val = RTC_READ(sc, sc->conf->rtc_losc_sta);
230 if ((val & LOSC_OSC_SRC) == 0)
231 device_printf(dev, "Using internal oscillator\n");
232 else
233 device_printf(dev, "Using external oscillator\n");
234 }
235
236 aw_rtc_install_clocks(sc, dev);
237
238 clock_register(dev, RTC_RES_US);
239
240 return (0);
241}
242
243static int
244aw_rtc_detach(device_t dev)

Callers

nothing calls this directly

Calls 6

device_get_softcFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
device_printfFunction · 0.85
aw_rtc_install_clocksFunction · 0.85
clock_registerFunction · 0.85
DELAYFunction · 0.50

Tested by

no test coverage detected