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

Function versatile_sic_attach

freebsd/arm/versatile/versatile_sic.c:217–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217static int
218versatile_sic_attach(device_t dev)
219{
220 struct versatile_sic_softc *sc = device_get_softc(dev);
221 int rid, error;
222 uint32_t irq;
223 const char *name;
224 struct versatile_sic_irqsrc *isrcs;
225
226 sc->dev = dev;
227 mtx_init(&sc->mtx, device_get_nameunit(dev), "sic",
228 MTX_SPIN);
229
230 /* Request memory resources */
231 rid = 0;
232 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
233 RF_ACTIVE);
234 if (sc->mem_res == NULL) {
235 device_printf(dev, "Error: could not allocate memory resources\n");
236 return (ENXIO);
237 }
238
239 /* Request memory resources */
240 rid = 0;
241 sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
242 RF_ACTIVE);
243 if (sc->irq_res == NULL) {
244 device_printf(dev, "could not allocate IRQ resources\n");
245 versatile_sic_detach(dev);
246 return (ENXIO);
247 }
248
249 if ((bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC,
250 versatile_sic_filter, NULL, sc, &sc->intrh))) {
251 device_printf(dev,
252 "unable to register interrupt handler\n");
253 versatile_sic_detach(dev);
254 return (ENXIO);
255 }
256
257 /* Disable all interrupts on SIC */
258 SIC_WRITE_4(sc, SIC_ENCLR, 0xffffffff);
259
260 /* PIC attachment */
261 isrcs = sc->isrcs;
262 name = device_get_nameunit(sc->dev);
263 for (irq = 0; irq < SIC_NIRQS; irq++) {
264 isrcs[irq].irq = irq;
265 error = intr_isrc_register(&isrcs[irq].isrc, sc->dev,
266 0, "%s,%u", name, irq);
267 if (error != 0)
268 return (error);
269 }
270
271 intr_pic_register(dev, OF_xref_from_node(ofw_bus_get_node(dev)));
272
273 return (0);
274}

Callers

nothing calls this directly

Calls 9

device_get_softcFunction · 0.85
mtx_initFunction · 0.85
device_get_nameunitFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
device_printfFunction · 0.85
versatile_sic_detachFunction · 0.85
bus_setup_intrFunction · 0.85
intr_isrc_registerFunction · 0.85
intr_pic_registerFunction · 0.85

Tested by

no test coverage detected