| 177 | } |
| 178 | |
| 179 | static int |
| 180 | pdma_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 | |
| 221 | static int |
| 222 | pdma_detach(device_t dev) |
nothing calls this directly
no test coverage detected