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

Function dotg_fdt_attach

freebsd/mips/mediatek/mtk_dotg.c:88–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88static int
89dotg_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
134error:
135 dotg_fdt_detach(dev);
136 return (ENXIO);
137}
138
139static int
140dotg_fdt_detach(device_t dev)

Callers

nothing calls this directly

Calls 7

device_get_softcFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
device_add_childFunction · 0.85
device_set_ivarsFunction · 0.85
device_probe_and_attachFunction · 0.85
dotg_fdt_detachFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected