| 86 | } |
| 87 | |
| 88 | static int |
| 89 | dotg_fdt_attach(device_t dev) |
| 90 | { |
| 91 | struct dwc_otg_softc *sc = device_get_softc(dev); |
| 92 | int err, rid; |
| 93 | |
| 94 | /* setup controller interface softc */ |
| 95 | |
| 96 | /* initialise some bus fields */ |
| 97 | sc->sc_mode = DWC_MODE_HOST; |
| 98 | sc->sc_bus.parent = dev; |
| 99 | |
| 100 | rid = 0; |
| 101 | sc->sc_io_res = |
| 102 | bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); |
| 103 | if (!(sc->sc_io_res)) { |
| 104 | printf("Can`t alloc MEM\n"); |
| 105 | goto error; |
| 106 | } |
| 107 | |
| 108 | rid = 0; |
| 109 | sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, |
| 110 | &rid, RF_ACTIVE); |
| 111 | if (!(sc->sc_irq_res)) { |
| 112 | printf("Can`t alloc IRQ\n"); |
| 113 | goto error; |
| 114 | } |
| 115 | |
| 116 | sc->sc_bus.bdev = device_add_child(dev, "usbus", -1); |
| 117 | if (!(sc->sc_bus.bdev)) { |
| 118 | printf("Can`t add usbus\n"); |
| 119 | goto error; |
| 120 | } |
| 121 | device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); |
| 122 | |
| 123 | err = dwc_otg_init(sc); |
| 124 | if (err) printf("dotg_init fail\n"); |
| 125 | if (!err) { |
| 126 | err = device_probe_and_attach(sc->sc_bus.bdev); |
| 127 | if (err) printf("device_probe_and_attach fail %d\n", err); |
| 128 | } |
| 129 | if (err) { |
| 130 | goto error; |
| 131 | } |
| 132 | return (0); |
| 133 | |
| 134 | error: |
| 135 | dotg_fdt_detach(dev); |
| 136 | return (ENXIO); |
| 137 | } |
| 138 | |
| 139 | static int |
| 140 | dotg_fdt_detach(device_t dev) |
nothing calls this directly
no test coverage detected