usb.c revision 1.7 1 1.7 augustss /* $NetBSD: usb.c,v 1.7 1998/12/26 12:53:03 augustss Exp $ */
2 1.1 augustss
3 1.1 augustss /*
4 1.1 augustss * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 1.1 augustss * All rights reserved.
6 1.1 augustss *
7 1.5 augustss * This code is derived from software contributed to The NetBSD Foundation
8 1.5 augustss * by Lennart Augustsson (augustss (at) carlstedt.se) at
9 1.5 augustss * Carlstedt Research & Technology.
10 1.1 augustss *
11 1.1 augustss * Redistribution and use in source and binary forms, with or without
12 1.1 augustss * modification, are permitted provided that the following conditions
13 1.1 augustss * are met:
14 1.1 augustss * 1. Redistributions of source code must retain the above copyright
15 1.1 augustss * notice, this list of conditions and the following disclaimer.
16 1.1 augustss * 2. Redistributions in binary form must reproduce the above copyright
17 1.1 augustss * notice, this list of conditions and the following disclaimer in the
18 1.1 augustss * documentation and/or other materials provided with the distribution.
19 1.1 augustss * 3. All advertising materials mentioning features or use of this software
20 1.1 augustss * must display the following acknowledgement:
21 1.1 augustss * This product includes software developed by the NetBSD
22 1.1 augustss * Foundation, Inc. and its contributors.
23 1.1 augustss * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.1 augustss * contributors may be used to endorse or promote products derived
25 1.1 augustss * from this software without specific prior written permission.
26 1.1 augustss *
27 1.1 augustss * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.1 augustss * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.1 augustss * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.1 augustss * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.1 augustss * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.1 augustss * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.1 augustss * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.1 augustss * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.1 augustss * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.1 augustss * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.1 augustss * POSSIBILITY OF SUCH DAMAGE.
38 1.1 augustss */
39 1.1 augustss
40 1.1 augustss /*
41 1.1 augustss * USB spec: http://www.teleport.com/cgi-bin/mailmerge.cgi/~usb/cgiform.tpl
42 1.1 augustss * More USB specs at http://www.usb.org/developers/index.shtml
43 1.1 augustss */
44 1.1 augustss
45 1.1 augustss #include <sys/param.h>
46 1.1 augustss #include <sys/systm.h>
47 1.1 augustss #include <sys/kernel.h>
48 1.1 augustss #include <sys/malloc.h>
49 1.7 augustss #if defined(__NetBSD__)
50 1.1 augustss #include <sys/device.h>
51 1.7 augustss #elif defined(__FreeBSD__)
52 1.7 augustss #include <sys/module.h>
53 1.7 augustss #include <sys/bus.h>
54 1.7 augustss #include <sys/ioccom.h>
55 1.7 augustss #include <sys/uio.h>
56 1.7 augustss #include <sys/conf.h>
57 1.7 augustss #endif
58 1.1 augustss #include <sys/poll.h>
59 1.1 augustss #include <sys/proc.h>
60 1.1 augustss #include <sys/select.h>
61 1.1 augustss
62 1.1 augustss #include <dev/usb/usb.h>
63 1.1 augustss
64 1.7 augustss #if defined(__FreeBSD__)
65 1.7 augustss MALLOC_DEFINE(M_USB, "USB", "USB");
66 1.7 augustss MALLOC_DEFINE(M_USBDEV, "USBdev", "USB device");
67 1.7 augustss
68 1.7 augustss #include "usb_if.h"
69 1.7 augustss #endif /* defined(__FreeBSD__) */
70 1.7 augustss
71 1.1 augustss #include <dev/usb/usbdi.h>
72 1.1 augustss #include <dev/usb/usbdivar.h>
73 1.1 augustss #include <dev/usb/usb_quirks.h>
74 1.1 augustss
75 1.1 augustss #ifdef USB_DEBUG
76 1.1 augustss #define DPRINTF(x) if (usbdebug) printf x
77 1.1 augustss #define DPRINTFN(n,x) if (usbdebug>(n)) printf x
78 1.1 augustss int usbdebug = 0;
79 1.1 augustss int uhcidebug;
80 1.1 augustss int ohcidebug;
81 1.1 augustss #else
82 1.1 augustss #define DPRINTF(x)
83 1.1 augustss #define DPRINTFN(n,x)
84 1.1 augustss #endif
85 1.1 augustss
86 1.1 augustss #define USBUNIT(dev) (minor(dev))
87 1.1 augustss
88 1.1 augustss struct usb_softc {
89 1.7 augustss bdevice sc_dev; /* base device */
90 1.1 augustss usbd_bus_handle sc_bus; /* USB controller */
91 1.1 augustss struct usbd_port sc_port; /* dummy port for root hub */
92 1.1 augustss char sc_running;
93 1.1 augustss char sc_exploring;
94 1.1 augustss struct selinfo sc_consel; /* waiting for connect change */
95 1.1 augustss };
96 1.1 augustss
97 1.7 augustss #if defined(__NetBSD__)
98 1.1 augustss int usbopen __P((dev_t, int, int, struct proc *));
99 1.1 augustss int usbclose __P((dev_t, int, int, struct proc *));
100 1.1 augustss int usbioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
101 1.1 augustss int usbpoll __P((dev_t, int, struct proc *));
102 1.1 augustss
103 1.7 augustss #elif defined(__FreeBSD__)
104 1.7 augustss static device_probe_t usb_match;
105 1.7 augustss static device_attach_t usb_attach;
106 1.7 augustss static bus_print_child_t usb_print_child;
107 1.7 augustss
108 1.7 augustss d_open_t usbopen;
109 1.7 augustss d_close_t usbclose;
110 1.7 augustss d_ioctl_t usbioctl;
111 1.7 augustss int usbpoll __P((dev_t, int, struct proc *));
112 1.7 augustss
113 1.7 augustss struct cdevsw usb_cdevsw = {
114 1.7 augustss usbopen, usbclose, noread, nowrite,
115 1.7 augustss usbioctl, nullstop, nullreset, nodevtotty,
116 1.7 augustss usbpoll, nommap, nostrat,
117 1.7 augustss "usb", NULL, -1
118 1.7 augustss };
119 1.7 augustss #endif
120 1.7 augustss
121 1.1 augustss usbd_status usb_discover __P((struct usb_softc *));
122 1.1 augustss
123 1.7 augustss USB_DECLARE_DRIVER_INIT(usb, DEVMETHOD(bus_print_child, usb_print_child));
124 1.1 augustss
125 1.7 augustss USB_MATCH(usb)
126 1.1 augustss {
127 1.1 augustss DPRINTF(("usbd_match\n"));
128 1.7 augustss return (UMATCH_GENERIC);
129 1.1 augustss }
130 1.1 augustss
131 1.7 augustss USB_ATTACH(usb)
132 1.1 augustss {
133 1.7 augustss #if defined(__NetBSD__)
134 1.1 augustss struct usb_softc *sc = (struct usb_softc *)self;
135 1.7 augustss #elif defined(__FreeBSD__)
136 1.7 augustss struct usb_softc *sc = device_get_softc(device);
137 1.7 augustss void *aux = device_get_ivars(device);
138 1.7 augustss #endif
139 1.1 augustss usbd_device_handle dev;
140 1.1 augustss usbd_status r;
141 1.1 augustss
142 1.7 augustss #if defined(__NetBSD__)
143 1.4 augustss printf("\n");
144 1.7 augustss #elif defined(__FreeBSD__)
145 1.7 augustss sc->sc_dev = device;
146 1.7 augustss #endif
147 1.4 augustss
148 1.1 augustss DPRINTF(("usbd_attach\n"));
149 1.4 augustss usbd_init();
150 1.1 augustss sc->sc_bus = aux;
151 1.1 augustss sc->sc_bus->usbctl = sc;
152 1.1 augustss sc->sc_running = 1;
153 1.3 augustss sc->sc_bus->use_polling = 1;
154 1.1 augustss sc->sc_port.power = USB_MAX_POWER;
155 1.1 augustss r = usbd_new_device(&sc->sc_dev, sc->sc_bus, 0, 0, 0, &sc->sc_port);
156 1.7 augustss
157 1.1 augustss if (r == USBD_NORMAL_COMPLETION) {
158 1.1 augustss dev = sc->sc_port.device;
159 1.1 augustss if (!dev->hub) {
160 1.1 augustss sc->sc_running = 0;
161 1.7 augustss printf("%s: root device is not a hub\n",
162 1.7 augustss USBDEVNAME(sc->sc_dev));
163 1.7 augustss USB_ATTACH_ERROR_RETURN;
164 1.1 augustss }
165 1.1 augustss sc->sc_bus->root_hub = dev;
166 1.7 augustss dev->hub->explore(sc->sc_bus->root_hub);
167 1.1 augustss } else {
168 1.1 augustss printf("%s: root hub problem, error=%d\n",
169 1.7 augustss USBDEVNAME(sc->sc_dev), r);
170 1.1 augustss sc->sc_running = 0;
171 1.1 augustss }
172 1.3 augustss sc->sc_bus->use_polling = 0;
173 1.7 augustss
174 1.7 augustss USB_ATTACH_SUCCESS_RETURN;
175 1.1 augustss }
176 1.1 augustss
177 1.7 augustss #if defined(__NetBSD__)
178 1.1 augustss int
179 1.1 augustss usbctlprint(aux, pnp)
180 1.1 augustss void *aux;
181 1.1 augustss const char *pnp;
182 1.1 augustss {
183 1.1 augustss /* only "usb"es can attach to host controllers */
184 1.1 augustss if (pnp)
185 1.1 augustss printf("usb at %s", pnp);
186 1.1 augustss
187 1.1 augustss return (UNCONF);
188 1.1 augustss }
189 1.1 augustss
190 1.7 augustss #elif defined(__FreeBSD__)
191 1.7 augustss static void
192 1.7 augustss usb_print_child(device_t parent, device_t child)
193 1.7 augustss {
194 1.7 augustss struct usb_softc *sc = device_get_softc(child);
195 1.7 augustss
196 1.7 augustss printf(" at %s%d", device_get_name(parent), device_get_unit(parent));
197 1.7 augustss
198 1.7 augustss /* How do we get to the usbd_device_handle???
199 1.7 augustss usbd_device_handle dev = invalidadosch;
200 1.7 augustss
201 1.7 augustss printf(" addr %d", dev->addr);
202 1.7 augustss
203 1.7 augustss if (bootverbose) {
204 1.7 augustss if (dev->lowspeed)
205 1.7 augustss printf(", lowspeed");
206 1.7 augustss if (dev->self_powered)
207 1.7 augustss printf(", self powered");
208 1.7 augustss else
209 1.7 augustss printf(", %dmA", dev->power);
210 1.7 augustss printf(", config %d", dev->config);
211 1.7 augustss }
212 1.7 augustss */
213 1.7 augustss }
214 1.7 augustss
215 1.7 augustss /* Reconfigure all the USB busses in the system. */
216 1.7 augustss int
217 1.7 augustss usb_driver_load(module_t mod, int what, void *arg)
218 1.7 augustss {
219 1.7 augustss /* subroutine is there but inactive at the moment
220 1.7 augustss * the reconfiguration process has not been thought through yet.
221 1.7 augustss */
222 1.7 augustss devclass_t ugen_devclass = devclass_find("ugen");
223 1.7 augustss device_t *devlist;
224 1.7 augustss int devcount;
225 1.7 augustss int error;
226 1.7 augustss
227 1.7 augustss switch (what) {
228 1.7 augustss case MOD_LOAD:
229 1.7 augustss case MOD_UNLOAD:
230 1.7 augustss if (!usb_devclass)
231 1.7 augustss return 0; /* just ignore call */
232 1.7 augustss
233 1.7 augustss if (ugen_devclass) {
234 1.7 augustss /* detach devices from generic driver if possible
235 1.7 augustss */
236 1.7 augustss error = devclass_get_devices(ugen_devclass, &devlist,
237 1.7 augustss &devcount);
238 1.7 augustss if (!error)
239 1.7 augustss for (devcount--; devcount >= 0; devcount--)
240 1.7 augustss (void)DEVICE_DETACH(devlist[devcount]);
241 1.7 augustss }
242 1.7 augustss
243 1.7 augustss error = devclass_get_devices(usb_devclass, &devlist, &devcount);
244 1.7 augustss if (error)
245 1.7 augustss return 0; /* XXX maybe transient, or error? */
246 1.7 augustss
247 1.7 augustss for (devcount--; devcount >= 0; devcount--)
248 1.7 augustss USB_RECONFIGURE(devlist[devcount]);
249 1.7 augustss
250 1.7 augustss free(devlist, M_TEMP);
251 1.7 augustss return 0;
252 1.7 augustss }
253 1.7 augustss
254 1.7 augustss return 0; /* nothing to do by us */
255 1.7 augustss }
256 1.7 augustss
257 1.7 augustss /* Set the description of the device including a malloc and copy. */
258 1.7 augustss void
259 1.7 augustss usb_device_set_desc(device_t device, char *devinfo)
260 1.7 augustss {
261 1.7 augustss size_t l;
262 1.7 augustss char *desc;
263 1.7 augustss
264 1.7 augustss if ( devinfo ) {
265 1.7 augustss l = strlen(devinfo);
266 1.7 augustss desc = malloc(l+1, M_USB, M_NOWAIT);
267 1.7 augustss if (desc)
268 1.7 augustss memcpy(desc, devinfo, l+1);
269 1.7 augustss } else
270 1.7 augustss desc = NULL;
271 1.7 augustss
272 1.7 augustss device_set_desc(device, desc);
273 1.7 augustss }
274 1.7 augustss
275 1.7 augustss /*
276 1.7 augustss * A static buffer is a loss if this routine is used from an interrupt,
277 1.7 augustss * but it's not fatal.
278 1.7 augustss */
279 1.7 augustss char *
280 1.7 augustss usb_devname(struct device *bdev)
281 1.7 augustss {
282 1.7 augustss static char buf[20];
283 1.7 augustss
284 1.7 augustss sprintf(buf, "%s%d", device_get_name(*bdev), device_get_unit(*bdev));
285 1.7 augustss return (buf);
286 1.7 augustss }
287 1.7 augustss
288 1.7 augustss #endif
289 1.7 augustss
290 1.1 augustss int
291 1.1 augustss usbopen(dev, flag, mode, p)
292 1.1 augustss dev_t dev;
293 1.1 augustss int flag, mode;
294 1.1 augustss struct proc *p;
295 1.1 augustss {
296 1.7 augustss USB_GET_SC_OPEN(usb, USBUNIT(dev), sc);
297 1.1 augustss
298 1.1 augustss if (sc == 0 || !sc->sc_running)
299 1.1 augustss return (ENXIO);
300 1.1 augustss
301 1.1 augustss return (0);
302 1.1 augustss }
303 1.1 augustss
304 1.1 augustss int
305 1.1 augustss usbclose(dev, flag, mode, p)
306 1.1 augustss dev_t dev;
307 1.1 augustss int flag, mode;
308 1.1 augustss struct proc *p;
309 1.1 augustss {
310 1.1 augustss return (0);
311 1.1 augustss }
312 1.1 augustss
313 1.1 augustss int
314 1.1 augustss usbioctl(dev, cmd, data, flag, p)
315 1.1 augustss dev_t dev;
316 1.1 augustss u_long cmd;
317 1.1 augustss caddr_t data;
318 1.1 augustss int flag;
319 1.1 augustss struct proc *p;
320 1.1 augustss {
321 1.7 augustss USB_GET_SC(usb, USBUNIT(dev), sc);
322 1.1 augustss
323 1.1 augustss if (sc == 0 || !sc->sc_running)
324 1.1 augustss return (ENXIO);
325 1.1 augustss switch (cmd) {
326 1.1 augustss #ifdef USB_DEBUG
327 1.1 augustss case USB_SETDEBUG:
328 1.1 augustss usbdebug = uhcidebug = ohcidebug = *(int *)data;
329 1.1 augustss break;
330 1.1 augustss #endif
331 1.1 augustss case USB_DISCOVER:
332 1.1 augustss usb_discover(sc);
333 1.1 augustss break;
334 1.1 augustss case USB_REQUEST:
335 1.1 augustss {
336 1.1 augustss struct usb_ctl_request *ur = (void *)data;
337 1.1 augustss int len = UGETW(ur->request.wLength);
338 1.1 augustss struct iovec iov;
339 1.1 augustss struct uio uio;
340 1.1 augustss void *ptr = 0;
341 1.1 augustss int addr = ur->addr;
342 1.1 augustss usbd_status r;
343 1.1 augustss int error = 0;
344 1.1 augustss
345 1.1 augustss if (len < 0 || len > 32768)
346 1.1 augustss return EINVAL;
347 1.1 augustss if (addr < 0 || addr >= USB_MAX_DEVICES ||
348 1.1 augustss sc->sc_bus->devices[addr] == 0)
349 1.1 augustss return EINVAL;
350 1.1 augustss if (len != 0) {
351 1.1 augustss iov.iov_base = (caddr_t)ur->data;
352 1.1 augustss iov.iov_len = len;
353 1.1 augustss uio.uio_iov = &iov;
354 1.1 augustss uio.uio_iovcnt = 1;
355 1.1 augustss uio.uio_resid = len;
356 1.1 augustss uio.uio_offset = 0;
357 1.1 augustss uio.uio_segflg = UIO_USERSPACE;
358 1.1 augustss uio.uio_rw =
359 1.1 augustss ur->request.bmRequestType & UT_READ ?
360 1.1 augustss UIO_READ : UIO_WRITE;
361 1.1 augustss uio.uio_procp = p;
362 1.1 augustss ptr = malloc(len, M_TEMP, M_WAITOK);
363 1.1 augustss if (uio.uio_rw == UIO_WRITE) {
364 1.1 augustss error = uiomove(ptr, len, &uio);
365 1.1 augustss if (error)
366 1.1 augustss goto ret;
367 1.1 augustss }
368 1.1 augustss }
369 1.1 augustss r = usbd_do_request(sc->sc_bus->devices[addr],
370 1.1 augustss &ur->request, ptr);
371 1.1 augustss if (r) {
372 1.1 augustss error = EIO;
373 1.1 augustss goto ret;
374 1.1 augustss }
375 1.1 augustss if (len != 0) {
376 1.1 augustss if (uio.uio_rw == UIO_READ) {
377 1.1 augustss error = uiomove(ptr, len, &uio);
378 1.1 augustss if (error)
379 1.1 augustss goto ret;
380 1.1 augustss }
381 1.1 augustss }
382 1.1 augustss ret:
383 1.1 augustss if (ptr)
384 1.1 augustss free(ptr, M_TEMP);
385 1.1 augustss return (error);
386 1.1 augustss }
387 1.1 augustss
388 1.1 augustss case USB_DEVICEINFO:
389 1.1 augustss {
390 1.1 augustss struct usb_device_info *di = (void *)data;
391 1.1 augustss int addr = di->addr;
392 1.1 augustss usbd_device_handle dev;
393 1.1 augustss
394 1.1 augustss if (addr < 1 || addr >= USB_MAX_DEVICES)
395 1.1 augustss return (EINVAL);
396 1.1 augustss dev = sc->sc_bus->devices[addr];
397 1.1 augustss if (dev == 0)
398 1.1 augustss return (ENXIO);
399 1.6 augustss usbd_fill_deviceinfo(dev, di);
400 1.1 augustss break;
401 1.1 augustss }
402 1.2 augustss
403 1.2 augustss case USB_DEVICESTATS:
404 1.2 augustss *(struct usb_device_stats *)data = sc->sc_bus->stats;
405 1.2 augustss break;
406 1.1 augustss
407 1.1 augustss default:
408 1.1 augustss return (ENXIO);
409 1.1 augustss }
410 1.1 augustss return (0);
411 1.1 augustss }
412 1.1 augustss
413 1.1 augustss int
414 1.1 augustss usbpoll(dev, events, p)
415 1.1 augustss dev_t dev;
416 1.1 augustss int events;
417 1.1 augustss struct proc *p;
418 1.1 augustss {
419 1.1 augustss int revents, s;
420 1.7 augustss USB_GET_SC(usb, USBUNIT(dev), sc);
421 1.1 augustss
422 1.1 augustss DPRINTFN(2, ("usbpoll: sc=%p events=0x%x\n", sc, events));
423 1.1 augustss s = splusb();
424 1.1 augustss revents = 0;
425 1.1 augustss if (events & (POLLOUT | POLLWRNORM))
426 1.1 augustss if (sc->sc_bus->needs_explore)
427 1.1 augustss revents |= events & (POLLOUT | POLLWRNORM);
428 1.1 augustss DPRINTFN(2, ("usbpoll: revents=0x%x\n", revents));
429 1.1 augustss if (revents == 0) {
430 1.1 augustss if (events & (POLLOUT | POLLWRNORM)) {
431 1.1 augustss DPRINTFN(2, ("usbpoll: selrecord\n"));
432 1.1 augustss selrecord(p, &sc->sc_consel);
433 1.1 augustss }
434 1.1 augustss }
435 1.1 augustss splx(s);
436 1.1 augustss return (revents);
437 1.1 augustss }
438 1.1 augustss
439 1.1 augustss int
440 1.1 augustss usb_bus_count()
441 1.1 augustss {
442 1.1 augustss int i, n;
443 1.1 augustss
444 1.1 augustss for (i = n = 0; i < usb_cd.cd_ndevs; i++)
445 1.1 augustss if (usb_cd.cd_devs[i])
446 1.1 augustss n++;
447 1.1 augustss return (n);
448 1.1 augustss }
449 1.1 augustss
450 1.1 augustss usbd_status
451 1.1 augustss usb_get_bus_handle(n, h)
452 1.1 augustss int n;
453 1.1 augustss usbd_bus_handle *h;
454 1.1 augustss {
455 1.1 augustss int i;
456 1.1 augustss
457 1.1 augustss for (i = 0; i < usb_cd.cd_ndevs; i++)
458 1.1 augustss if (usb_cd.cd_devs[i] && n-- == 0) {
459 1.1 augustss *h = usb_cd.cd_devs[i];
460 1.1 augustss return (USBD_NORMAL_COMPLETION);
461 1.1 augustss }
462 1.1 augustss return (USBD_INVAL);
463 1.1 augustss }
464 1.1 augustss
465 1.1 augustss usbd_status
466 1.1 augustss usb_discover(sc)
467 1.1 augustss struct usb_softc *sc;
468 1.1 augustss {
469 1.1 augustss int s;
470 1.1 augustss
471 1.1 augustss /* Explore device tree from the root */
472 1.1 augustss /* We need mutual exclusion while traversing the device tree. */
473 1.1 augustss s = splusb();
474 1.1 augustss while (sc->sc_exploring)
475 1.1 augustss tsleep(&sc->sc_exploring, PRIBIO, "usbdis", 0);
476 1.1 augustss sc->sc_exploring = 1;
477 1.1 augustss sc->sc_bus->needs_explore = 0;
478 1.1 augustss splx(s);
479 1.1 augustss
480 1.7 augustss sc->sc_bus->root_hub->hub->explore(sc->sc_bus->root_hub);
481 1.1 augustss
482 1.1 augustss s = splusb();
483 1.1 augustss sc->sc_exploring = 0;
484 1.1 augustss wakeup(&sc->sc_exploring);
485 1.1 augustss splx(s);
486 1.1 augustss /* XXX should we start over if sc_needsexplore is set again? */
487 1.1 augustss return (0);
488 1.1 augustss }
489 1.1 augustss
490 1.1 augustss void
491 1.1 augustss usb_needs_explore(bus)
492 1.1 augustss usbd_bus_handle bus;
493 1.1 augustss {
494 1.1 augustss bus->needs_explore = 1;
495 1.1 augustss selwakeup(&bus->usbctl->sc_consel);
496 1.1 augustss }
497 1.7 augustss
498 1.7 augustss #if defined(__FreeBSD__)
499 1.7 augustss int
500 1.7 augustss usb_detach(device_t self)
501 1.7 augustss {
502 1.7 augustss struct usb_softc *sc = device_get_softc(self);
503 1.7 augustss char *devinfo = (char *) device_get_desc(self);
504 1.7 augustss
505 1.7 augustss if (devinfo) {
506 1.7 augustss device_set_desc(self, NULL);
507 1.7 augustss free(devinfo, M_USB);
508 1.7 augustss }
509 1.7 augustss
510 1.7 augustss return (0);
511 1.7 augustss }
512 1.7 augustss
513 1.7 augustss DRIVER_MODULE(usb, root, usb_driver, usb_devclass, 0, 0);
514 1.7 augustss #endif
515