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

Function pdma_attach

freebsd/mips/ingenic/jz4780_pdma.c:179–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179static int
180pdma_attach(device_t dev)
181{
182 struct pdma_softc *sc;
183 phandle_t xref, node;
184 int err;
185 int reg;
186
187 sc = device_get_softc(dev);
188 sc->dev = dev;
189
190 if (bus_alloc_resources(dev, pdma_spec, sc->res)) {
191 device_printf(dev, "could not allocate resources for device\n");
192 return (ENXIO);
193 }
194
195 /* Memory interface */
196 sc->bst = rman_get_bustag(sc->res[0]);
197 sc->bsh = rman_get_bushandle(sc->res[0]);
198
199 /* Setup interrupt handler */
200 err = bus_setup_intr(dev, sc->res[1], INTR_TYPE_MISC | INTR_MPSAFE,
201 NULL, pdma_intr, sc, &sc->ih);
202 if (err) {
203 device_printf(dev, "Unable to alloc interrupt resource.\n");
204 return (ENXIO);
205 }
206
207 node = ofw_bus_get_node(dev);
208 xref = OF_xref_from_node(node);
209 OF_device_register_xref(xref, dev);
210
211 reg = READ4(sc, PDMA_DMAC);
212 reg &= ~(DMAC_HLT | DMAC_AR);
213 reg |= (DMAC_DMAE);
214 WRITE4(sc, PDMA_DMAC, reg);
215
216 WRITE4(sc, PDMA_DMACP, 0);
217
218 return (0);
219}
220
221static int
222pdma_detach(device_t dev)

Callers

nothing calls this directly

Calls 6

device_get_softcFunction · 0.85
bus_alloc_resourcesFunction · 0.85
device_printfFunction · 0.85
rman_get_bustagFunction · 0.85
rman_get_bushandleFunction · 0.85
bus_setup_intrFunction · 0.85

Tested by

no test coverage detected