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

Function ohci_fdt_attach

freebsd/mips/mediatek/mtk_ohci.c:89–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89static int
90ohci_fdt_attach(device_t self)
91{
92 ohci_softc_t *sc = device_get_softc(self);
93 int err;
94 int rid;
95
96 /* initialise some bus fields */
97 sc->sc_bus.parent = self;
98 sc->sc_bus.devices = sc->sc_devices;
99 sc->sc_bus.devices_max = OHCI_MAX_DEVICES;
100 sc->sc_bus.dma_bits = 32;
101
102 /* get all DMA memory */
103 if (usb_bus_mem_alloc_all(&sc->sc_bus,
104 USB_GET_DMA_TAG(self), &ohci_iterate_hw_softc)) {
105 printf("No mem\n");
106 return (ENOMEM);
107 }
108
109 rid = 0;
110 sc->sc_io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid,
111 RF_ACTIVE);
112 if (!sc->sc_io_res) {
113 device_printf(self, "Could not map memory\n");
114 goto error;
115 }
116 sc->sc_io_tag = rman_get_bustag(sc->sc_io_res);
117 sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res);
118 sc->sc_io_size = rman_get_size(sc->sc_io_res);
119
120 rid = 0;
121 sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid,
122 RF_SHAREABLE | RF_ACTIVE);
123 if (sc->sc_irq_res == NULL) {
124 device_printf(self, "Could not allocate irq\n");
125 goto error;
126 }
127
128 sc->sc_bus.bdev = device_add_child(self, "usbus", -1);
129 if (!(sc->sc_bus.bdev)) {
130 device_printf(self, "Could not add USB device\n");
131 goto error;
132 }
133 device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
134 device_set_desc(sc->sc_bus.bdev, OHCI_HC_DEVSTR);
135
136 sprintf(sc->sc_vendor, "MediaTek");
137
138 err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
139 NULL, (driver_intr_t *)ohci_interrupt, sc, &sc->sc_intr_hdl);
140 if (err) {
141 device_printf(self, "Could not setup irq, %d\n", err);
142 sc->sc_intr_hdl = NULL;
143 goto error;
144 }
145
146 err = ohci_init(sc);

Callers

nothing calls this directly

Calls 14

device_get_softcFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
device_printfFunction · 0.85
rman_get_bustagFunction · 0.85
rman_get_bushandleFunction · 0.85
rman_get_sizeFunction · 0.85
device_add_childFunction · 0.85
device_set_ivarsFunction · 0.85
device_set_descFunction · 0.85
sprintfFunction · 0.85
bus_setup_intrFunction · 0.85
device_probe_and_attachFunction · 0.85

Tested by

no test coverage detected