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

Function mv_timer_attach

freebsd/arm/mv/timer.c:182–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182static int
183mv_timer_attach(device_t dev)
184{
185 int error;
186 void *ihl;
187 struct mv_timer_softc *sc;
188 uint32_t irq_cause, irq_mask;
189
190 if (timer_softc != NULL)
191 return (ENXIO);
192
193 sc = (struct mv_timer_softc *)device_get_softc(dev);
194 timer_softc = sc;
195
196 sc->config = (struct mv_timer_config*)
197 ofw_bus_search_compatible(dev, mv_timer_soc_config)->ocd_data;
198
199 if (sc->config->clock_src == 0)
200 sc->config->clock_src = get_tclk();
201
202 error = bus_alloc_resources(dev, mv_timer_spec, sc->timer_res);
203 if (error) {
204 device_printf(dev, "could not allocate resources\n");
205 return (ENXIO);
206 }
207
208 sc->timer_bst = rman_get_bustag(sc->timer_res[0]);
209 sc->timer_bsh = rman_get_bushandle(sc->timer_res[0]);
210
211 sc->has_wdt = ofw_bus_has_prop(dev, "mrvl,has-wdt");
212
213 mtx_init(&timer_softc->timer_mtx, "watchdog", NULL, MTX_DEF);
214
215 if (sc->has_wdt) {
216 if (sc->config->watchdog_disable)
217 sc->config->watchdog_disable();
218 EVENTHANDLER_REGISTER(watchdog_list, mv_watchdog_event, sc, 0);
219 }
220
221 if (ofw_bus_search_compatible(dev, mv_timer_compat)->ocd_data
222 == MV_WDT) {
223 /* Don't set timers for wdt-only entry. */
224 device_printf(dev, "only watchdog attached\n");
225 return (0);
226 } else if (sc->timer_res[1] == NULL) {
227 device_printf(dev, "no interrupt resource\n");
228 bus_release_resources(dev, mv_timer_spec, sc->timer_res);
229 return (ENXIO);
230 }
231
232 if (bus_setup_intr(dev, sc->timer_res[1], INTR_TYPE_CLK,
233 mv_hardclock, NULL, sc, &ihl) != 0) {
234 bus_release_resources(dev, mv_timer_spec, sc->timer_res);
235 device_printf(dev, "Could not setup interrupt.\n");
236 return (ENXIO);
237 }
238
239 mv_setup_timers();

Callers

nothing calls this directly

Calls 15

device_get_softcFunction · 0.85
get_tclkFunction · 0.85
bus_alloc_resourcesFunction · 0.85
device_printfFunction · 0.85
rman_get_bustagFunction · 0.85
rman_get_bushandleFunction · 0.85
mtx_initFunction · 0.85
bus_release_resourcesFunction · 0.85
bus_setup_intrFunction · 0.85
mv_setup_timersFunction · 0.85
read_cpu_ctrlFunction · 0.85
write_cpu_ctrlFunction · 0.85

Tested by

no test coverage detected