2 * $NetBSD: usb.c,v 1.68 2002/02/20 20:30:12 christos Exp $
3 * $FreeBSD: src/sys/dev/usb/usb.c,v 1.106 2005/03/27 15:31:23 iedowse Exp $
4 * $DragonFly: src/sys/bus/usb/usb.c,v 1.50 2008/09/26 08:21:22 hasso Exp $
7 /* Also already merged from NetBSD:
8 * $NetBSD: usb.c,v 1.70 2002/05/09 21:54:32 augustss Exp $
9 * $NetBSD: usb.c,v 1.71 2002/06/01 23:51:04 lukem Exp $
10 * $NetBSD: usb.c,v 1.73 2002/09/23 05:51:19 simonb Exp $
11 * $NetBSD: usb.c,v 1.80 2003/11/07 17:03:25 wiz Exp $
15 * Copyright (c) 1998 The NetBSD Foundation, Inc.
16 * All rights reserved.
18 * This code is derived from software contributed to The NetBSD Foundation
19 * by Lennart Augustsson (lennart@augustsson.net) at
20 * Carlstedt Research & Technology.
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
25 * 1. Redistributions of source code must retain the above copyright
26 * notice, this list of conditions and the following disclaimer.
27 * 2. Redistributions in binary form must reproduce the above copyright
28 * notice, this list of conditions and the following disclaimer in the
29 * documentation and/or other materials provided with the distribution.
30 * 3. All advertising materials mentioning features or use of this software
31 * must display the following acknowledgement:
32 * This product includes software developed by the NetBSD
33 * Foundation, Inc. and its contributors.
34 * 4. Neither the name of The NetBSD Foundation nor the names of its
35 * contributors may be used to endorse or promote products derived
36 * from this software without specific prior written permission.
38 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
39 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
40 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
42 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
43 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
44 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
45 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
46 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48 * POSSIBILITY OF SUCH DAMAGE.
52 * USB specifications and other documentation can be found at
53 * http://www.usb.org/developers/docs/ and
54 * http://www.usb.org/developers/devclass_docs/
57 #include <sys/param.h>
58 #include <sys/systm.h>
59 #include <sys/kernel.h>
61 #include <sys/malloc.h>
62 #include <sys/unistd.h>
63 #include <sys/module.h>
65 #include <sys/fcntl.h>
66 #include <sys/filio.h>
68 #include <sys/kthread.h>
71 #include <sys/device.h>
72 #include <sys/event.h>
73 #include <sys/vnode.h>
74 #include <sys/signalvar.h>
75 #include <sys/sysctl.h>
76 #include <sys/thread2.h>
78 #include <bus/usb/usb.h>
79 #include <bus/usb/usbdi.h>
80 #include <bus/usb/usbdi_util.h>
82 #define USBUNIT(d) (minor(d)) /* usb_discover device nodes, kthread */
83 #define USB_DEV_MINOR 255 /* event queue device */
85 MALLOC_DEFINE(M_USB, "USB", "USB");
86 MALLOC_DEFINE(M_USBDEV, "USBdev", "USB device");
87 MALLOC_DEFINE(M_USBHC, "USBHC", "USB host controller");
91 #include <bus/usb/usbdivar.h>
92 #include <bus/usb/usb_quirks.h>
94 /* Define this unconditionally in case a kernel module is loaded that
95 * has been compiled with debugging options.
97 SYSCTL_NODE(_hw, OID_AUTO, usb, CTLFLAG_RW, 0, "USB debugging");
100 * XXX: This is a hack! If your USB keyboard doesn't work
101 * early at boot, try setting this tunable to 0 from
104 * set hw.usb.hack_defer_exploration=0
106 static int hack_defer_exploration = 1;
109 #define DPRINTF(x) if (usbdebug) kprintf x
110 #define DPRINTFN(n,x) if (usbdebug>(n)) kprintf x
112 SYSCTL_INT(_hw_usb, OID_AUTO, debug, CTLFLAG_RW,
113 &usbdebug, 0, "usb debug level");
116 * 0 - do usual exploration
117 * 1 - do not use timeout exploration
118 * >1 - do no exploration
120 int usb_noexplore = 0;
123 #define DPRINTFN(n,x)
128 TAILQ_ENTRY(usb_softc) sc_coldexplist; /* cold needs-explore list */
129 usbd_bus_handle sc_bus; /* USB controller */
130 struct usbd_port sc_port; /* dummy port for root hub */
132 struct thread *sc_event_thread;
138 TAILQ_HEAD(, usb_task) tasks;
139 struct thread *task_thread_proc;
141 int taskcreated; /* task thread exists. */
143 static struct usb_taskq usb_taskq[USB_NUM_TASKQS];
149 d_kqfilter_t usbkqfilter;
151 static void usbfilt_detach(struct knote *);
152 static int usbfilt(struct knote *, long);
154 struct dev_ops usb_ops = {
155 { "usb", USB_CDEV_MAJOR, 0 },
160 .d_kqfilter = usbkqfilter
163 static void usb_discover(device_t);
164 static bus_child_detached_t usb_child_detached;
165 static void usb_create_event_thread(device_t);
166 static void usb_event_thread(void *);
167 static void usb_task_thread(void *);
169 static cdev_t usb_dev; /* The /dev/usb device. */
170 static int usb_ndevs; /* Number of /dev/usbN devices. */
171 /* Busses to explore at the end of boot-time device configuration */
172 static TAILQ_HEAD(, usb_softc) usb_coldexplist =
173 TAILQ_HEAD_INITIALIZER(usb_coldexplist);
175 #define USB_MAX_EVENTS 100
178 TAILQ_ENTRY(usb_event_q) next;
180 static TAILQ_HEAD(, usb_event_q) usb_events =
181 TAILQ_HEAD_INITIALIZER(usb_events);
182 static int usb_nevents = 0;
183 static struct kqinfo usb_kqevent;
184 static struct proc *usb_async_proc; /* process that wants USB SIGIO */
185 static int usb_dev_open = 0;
186 static void usb_add_event(int, struct usb_event *);
188 static int usb_get_next_event(struct usb_event *);
190 static const char *usbrev_str[] = USBREV_STR;
192 static device_probe_t usb_match;
193 static device_attach_t usb_attach;
194 static device_detach_t usb_detach;
196 static devclass_t usb_devclass;
198 static kobj_method_t usb_methods[] = {
199 DEVMETHOD(device_probe, usb_match),
200 DEVMETHOD(device_attach, usb_attach),
201 DEVMETHOD(device_detach, usb_detach),
202 DEVMETHOD(bus_child_detached, usb_child_detached),
203 DEVMETHOD(device_suspend, bus_generic_suspend),
204 DEVMETHOD(device_resume, bus_generic_resume),
205 DEVMETHOD(device_shutdown, bus_generic_shutdown),
209 static driver_t usb_driver = {
212 sizeof(struct usb_softc)
215 MODULE_DEPEND(usb, usb, 1, 1, 1);
216 MODULE_VERSION(usb, 1);
219 usb_match(device_t self)
221 DPRINTF(("usb_match\n"));
222 return (UMATCH_GENERIC);
226 usb_attach(device_t self)
228 struct usb_softc *sc = device_get_softc(self);
229 void *aux = device_get_ivars(self);
231 usbd_device_handle dev;
237 TUNABLE_INT_FETCH("hw.usb.hack_defer_exploration",
238 &hack_defer_exploration);
240 DPRINTF(("usb_attach\n"));
244 sc->sc_bus->usbctl = sc;
245 sc->sc_port.power = USB_MAX_POWER;
247 usbrev = sc->sc_bus->usbrev;
248 device_printf(self, "USB revision %s", usbrev_str[usbrev]);
252 speed = USB_SPEED_FULL;
255 speed = USB_SPEED_HIGH;
258 kprintf(", not supported\n");
264 /* Make sure not to use tsleep() if we are cold booting. */
265 if (hack_defer_exploration && cold)
266 sc->sc_bus->use_polling++;
268 ue.u.ue_ctrlr.ue_bus = device_get_unit(self);
269 usb_add_event(USB_EVENT_CTRLR_ATTACH, &ue);
271 #ifdef USB_USE_SOFTINTR
272 callout_init(&sc->sc_bus->softi);
275 err = usbd_new_device(self, sc->sc_bus, 0, speed, 0, &sc->sc_port);
277 dev = sc->sc_port.device;
278 if (dev->hub == NULL) {
281 "root device is not a hub\n");
284 sc->sc_bus->root_hub = dev;
287 * Turning this code off will delay attachment of USB devices
288 * until the USB event thread is running, which means that
289 * the keyboard will not work until after cold boot.
292 if (hack_defer_exploration) {
293 /* Explore high-speed busses before others. */
294 if (speed == USB_SPEED_HIGH)
295 dev->hub->explore(sc->sc_bus->root_hub);
297 TAILQ_INSERT_TAIL(&usb_coldexplist, sc,
301 * XXX Exploring high speed devices here will
304 if (speed != USB_SPEED_HIGH)
305 dev->hub->explore(sc->sc_bus->root_hub);
311 "root hub problem, error=%d\n", err);
314 if (hack_defer_exploration && cold)
315 sc->sc_bus->use_polling--;
317 usb_create_event_thread(self);
320 * The per controller devices (used for usb_discover)
321 * XXX This is redundant now, but old usbd's will want it
323 tmp_dev = make_dev(&usb_ops, device_get_unit(self),
324 UID_ROOT, GID_OPERATOR, 0660,
325 "usb%d", device_get_unit(self));
326 sc->sc_usbdev = reference_dev(tmp_dev);
327 if (usb_ndevs++ == 0) {
328 /* The device spitting out events */
329 tmp_dev = make_dev(&usb_ops, USB_DEV_MINOR,
330 UID_ROOT, GID_OPERATOR, 0660, "usb");
331 usb_dev = reference_dev(tmp_dev);
337 static const char *taskq_names[] = USB_TASKQ_NAMES;
340 usb_create_event_thread(device_t self)
342 struct usb_softc *sc = device_get_softc(self);
345 if (kthread_create(usb_event_thread, self, &sc->sc_event_thread,
346 "%s", device_get_nameunit(self))) {
348 "unable to create event thread for\n");
349 panic("usb_create_event_thread");
352 for (i = 0; i < USB_NUM_TASKQS; i++) {
353 struct usb_taskq *taskq = &usb_taskq[i];
355 if (taskq->taskcreated == 0) {
356 taskq->taskcreated = 1;
357 taskq->name = taskq_names[i];
358 TAILQ_INIT(&taskq->tasks);
359 if (kthread_create(usb_task_thread, taskq,
360 &taskq->task_thread_proc, taskq->name)) {
361 kprintf("unable to create task thread\n");
362 panic("usb_create_event_thread task");
369 * Add a task to be performed by the task thread. This function can be
370 * called from any context and the task will be executed in a process
374 usb_add_task(usbd_device_handle dev, struct usb_task *task, int queue)
376 struct usb_taskq *taskq;
380 taskq = &usb_taskq[queue];
381 if (task->queue == -1) {
382 DPRINTFN(2,("usb_add_task: task=%p\n", task));
383 TAILQ_INSERT_TAIL(&taskq->tasks, task, next);
386 DPRINTFN(3,("usb_add_task: task=%p on q\n", task));
388 wakeup(&taskq->tasks);
394 usb_do_task(usbd_device_handle dev, struct usb_task *task, int queue,
397 struct usb_taskq *taskq;
401 taskq = &usb_taskq[queue];
402 if (task->queue == -1) {
403 DPRINTFN(2,("usb_add_task: task=%p\n", task));
404 TAILQ_INSERT_TAIL(&taskq->tasks, task, next);
407 DPRINTFN(3,("usb_add_task: task=%p on q\n", task));
409 wakeup(&taskq->tasks);
411 /* Wait until task is finished */
412 tsleep((&taskq->tasks + 1), 0, "usbdotsk", time_out);
418 usb_rem_task(usbd_device_handle dev, struct usb_task *task)
421 if (task->queue != -1) {
422 TAILQ_REMOVE(&usb_taskq[task->queue].tasks, task, next);
429 usb_event_thread(void *arg)
432 struct usb_softc *sc = device_get_softc(self);
434 DPRINTF(("usb_event_thread: start\n"));
437 * In case this controller is a companion controller to an
438 * EHCI controller we need to wait until the EHCI controller
439 * has grabbed the port.
440 * XXX It would be nicer to do this with a tsleep(), but I don't
441 * know how to synchronize the creation of the threads so it
444 usb_delay_ms(sc->sc_bus, 500);
448 /* Make sure first discover does something. */
449 sc->sc_bus->needs_explore = 1;
452 while (!sc->sc_dying) {
454 if (usb_noexplore < 2)
458 tsleep(&sc->sc_bus->needs_explore, 0, "usbevt",
459 usb_noexplore ? 0 : hz * 60);
461 tsleep(&sc->sc_bus->needs_explore, 0, "usbevt", hz * 60);
463 DPRINTFN(2,("usb_event_thread: woke up\n"));
465 sc->sc_event_thread = NULL;
469 /* In case parent is waiting for us to exit. */
472 DPRINTF(("usb_event_thread: exit\n"));
477 usb_task_thread(void *arg)
479 struct usb_task *task;
480 struct usb_taskq *taskq;
485 DPRINTF(("usb_task_thread: start taskq %s\n", taskq->name));
487 while (usb_ndevs > 0) {
488 task = TAILQ_FIRST(&taskq->tasks);
490 tsleep(&taskq->tasks, 0, "usbtsk", 0);
491 task = TAILQ_FIRST(&taskq->tasks);
493 DPRINTFN(2,("usb_task_thread: woke up task=%p\n", task));
495 TAILQ_REMOVE(&taskq->tasks, task, next);
498 task->fun(task->arg);
500 wakeup((&taskq->tasks + 1));
506 taskq->taskcreated = 0;
507 wakeup(&taskq->taskcreated);
509 DPRINTF(("usb_event_thread: exit\n"));
513 usbopen(struct dev_open_args *ap)
515 cdev_t dev = ap->a_head.a_dev;
516 int unit = USBUNIT(dev);
517 struct usb_softc *sc;
519 if (unit == USB_DEV_MINOR) {
523 usb_async_proc = NULL;
527 sc = devclass_get_softc(usb_devclass, unit);
538 usbread(struct dev_read_args *ap)
540 cdev_t dev = ap->a_head.a_dev;
541 struct uio *uio = ap->a_uio;
543 int unit = USBUNIT(dev);
546 if (unit != USB_DEV_MINOR)
549 if (uio->uio_resid != sizeof(struct usb_event))
555 n = usb_get_next_event(&ue);
558 if (ap->a_ioflag & IO_NDELAY) {
562 error = tsleep(&usb_events, PCATCH, "usbrea", 0);
568 error = uiomove((void *)&ue, uio->uio_resid, uio);
574 usbclose(struct dev_close_args *ap)
576 cdev_t dev = ap->a_head.a_dev;
577 int unit = USBUNIT(dev);
579 if (unit == USB_DEV_MINOR) {
580 usb_async_proc = NULL;
588 usbioctl(struct dev_ioctl_args *ap)
590 cdev_t devt = ap->a_head.a_dev;
591 struct usb_softc *sc;
592 int unit = USBUNIT(devt);
594 if (unit == USB_DEV_MINOR) {
597 if (*(int *)ap->a_data)
598 usb_async_proc = curproc;
600 usb_async_proc = NULL;
608 sc = devclass_get_softc(usb_devclass, unit);
614 /* This part should be deleted */
619 struct usb_ctl_request *ur = (void *)ap->a_data;
620 size_t len = UGETW(ur->ucr_request.wLength);
624 int addr = ur->ucr_addr;
628 DPRINTF(("usbioctl: USB_REQUEST addr=%d len=%zu\n", addr, len));
631 if (addr < 0 || addr >= USB_MAX_DEVICES ||
632 sc->sc_bus->devices[addr] == 0)
635 iov.iov_base = (caddr_t)ur->ucr_data;
641 uio.uio_segflg = UIO_USERSPACE;
643 ur->ucr_request.bmRequestType & UT_READ ?
644 UIO_READ : UIO_WRITE;
645 uio.uio_td = curthread;
646 ptr = kmalloc(len, M_TEMP, M_WAITOK);
647 if (uio.uio_rw == UIO_WRITE) {
648 error = uiomove(ptr, len, &uio);
653 err = usbd_do_request_flags(sc->sc_bus->devices[addr],
654 &ur->ucr_request, ptr, ur->ucr_flags, &ur->ucr_actlen,
655 USBD_DEFAULT_TIMEOUT);
661 if (uio.uio_rw == UIO_READ) {
662 error = uiomove(ptr, len, &uio);
675 struct usb_device_info *di = (void *)ap->a_data;
676 int addr = di->udi_addr;
677 usbd_device_handle dev;
679 if (addr < 1 || addr >= USB_MAX_DEVICES)
681 dev = sc->sc_bus->devices[addr];
684 usbd_fill_deviceinfo(dev, di, 1);
688 case USB_DEVICESTATS:
689 *(struct usb_device_stats *)ap->a_data = sc->sc_bus->stats;
698 static struct filterops usbfiltops =
699 { FILTEROP_ISFD, NULL, usbfilt_detach, usbfilt };
702 usbkqfilter(struct dev_kqfilter_args *ap)
704 cdev_t dev = ap->a_head.a_dev;
705 struct knote *kn = ap->a_kn;
710 switch (kn->kn_filter) {
712 kn->kn_fop = &usbfiltops;
713 kn->kn_hook = (caddr_t)dev;
716 ap->a_result = EOPNOTSUPP;
720 klist = &usb_kqevent.ki_note;
721 knote_insert(klist, kn);
727 usbfilt_detach(struct knote *kn)
731 klist = &usb_kqevent.ki_note;
732 knote_remove(klist, kn);
736 usbfilt(struct knote *kn, long hint)
738 cdev_t dev = (cdev_t)kn->kn_hook;
739 int unit = USBUNIT(dev);
742 if (unit == USB_DEV_MINOR) {
752 /* Explore device tree from the root. */
754 usb_discover(device_t self)
756 struct usb_softc *sc = device_get_softc(self);
758 DPRINTFN(2,("usb_discover\n"));
760 if (usb_noexplore > 1)
765 * We need mutual exclusion while traversing the device tree,
766 * but this is guaranteed since this function is only called
767 * from the event thread for the controller.
770 while (sc->sc_bus->needs_explore && !sc->sc_dying) {
771 sc->sc_bus->needs_explore = 0;
774 sc->sc_bus->root_hub->hub->explore(sc->sc_bus->root_hub);
782 usb_needs_explore(usbd_device_handle dev)
784 DPRINTFN(2,("usb_needs_explore\n"));
785 dev->bus->needs_explore = 1;
786 wakeup(&dev->bus->needs_explore);
789 /* Called from a critical section */
791 usb_get_next_event(struct usb_event *ue)
793 struct usb_event_q *ueq;
795 if (usb_nevents <= 0)
797 ueq = TAILQ_FIRST(&usb_events);
800 kprintf("usb: usb_nevents got out of sync! %d\n", usb_nevents);
807 TAILQ_REMOVE(&usb_events, ueq, next);
808 kfree(ueq, M_USBDEV);
814 usbd_add_dev_event(int type, usbd_device_handle udev)
818 usbd_fill_deviceinfo(udev, &ue.u.ue_device, USB_EVENT_IS_ATTACH(type));
819 usb_add_event(type, &ue);
823 usbd_add_drv_event(int type, usbd_device_handle udev, device_t dev)
827 ue.u.ue_driver.ue_cookie = udev->cookie;
828 strncpy(ue.u.ue_driver.ue_devname, device_get_nameunit(dev),
829 sizeof ue.u.ue_driver.ue_devname);
830 usb_add_event(type, &ue);
834 usb_add_event(int type, struct usb_event *uep)
836 struct usb_event_q *ueq;
837 struct timeval thetime;
839 ueq = kmalloc(sizeof *ueq, M_USBDEV, M_INTWAIT);
841 ueq->ue.ue_type = type;
843 TIMEVAL_TO_TIMESPEC(&thetime, &ueq->ue.ue_time);
846 if (USB_EVENT_IS_DETACH(type)) {
847 struct usb_event_q *ueqi, *ueqi_next;
849 for (ueqi = TAILQ_FIRST(&usb_events); ueqi; ueqi = ueqi_next) {
850 ueqi_next = TAILQ_NEXT(ueqi, next);
851 if (ueqi->ue.u.ue_driver.ue_cookie.cookie ==
852 uep->u.ue_device.udi_cookie.cookie) {
853 TAILQ_REMOVE(&usb_events, ueqi, next);
854 kfree(ueqi, M_USBDEV);
856 ueqi_next = TAILQ_FIRST(&usb_events);
860 if (usb_nevents >= USB_MAX_EVENTS) {
861 /* Too many queued events, drop an old one. */
862 DPRINTF(("usb: event dropped\n"));
863 usb_get_next_event(NULL);
865 TAILQ_INSERT_TAIL(&usb_events, ueq, next);
868 KNOTE(&usb_kqevent.ki_note, 0);
869 if (usb_async_proc != NULL) {
870 ksignal(usb_async_proc, SIGIO);
876 usb_schedsoftintr(usbd_bus_handle bus)
878 DPRINTFN(10,("usb_schedsoftintr: polling=%d\n", bus->use_polling));
879 #ifdef USB_USE_SOFTINTR
880 if (bus->use_polling) {
881 bus->methods->soft_intr(bus);
883 if (!callout_pending(&bus->softi))
884 callout_reset(&bus->softi, 0, bus->methods->soft_intr,
888 bus->methods->soft_intr(bus);
889 #endif /* USB_USE_SOFTINTR */
893 usb_detach(device_t self)
895 struct usb_softc *sc = device_get_softc(self);
898 DPRINTF(("usb_detach: start\n"));
902 /* Make all devices disconnect. */
903 if (sc->sc_port.device != NULL)
904 usb_disconnect_port(&sc->sc_port, self);
906 /* Kill off event thread. */
907 if (sc->sc_event_thread != NULL) {
908 wakeup(&sc->sc_bus->needs_explore);
909 if (tsleep(sc, 0, "usbdet", hz * 60))
911 "event thread didn't die\n");
912 DPRINTF(("usb_detach: event thread dead\n"));
915 release_dev(sc->sc_usbdev);
917 if (--usb_ndevs == 0) {
920 release_dev(usb_dev);
921 dev_ops_remove_minor(&usb_ops, USB_DEV_MINOR);
924 for (i = 0; i < USB_NUM_TASKQS; i++) {
925 struct usb_taskq *taskq = &usb_taskq[i];
926 wakeup(&taskq->tasks);
927 if (tsleep(&taskq->taskcreated, 0, "usbtdt",
929 kprintf("usb task thread %s didn't die\n",
937 #ifdef USB_USE_SOFTINTR
938 callout_stop(&sc->sc_bus->softi);
941 ue.u.ue_ctrlr.ue_bus = device_get_unit(self);
942 usb_add_event(USB_EVENT_CTRLR_DETACH, &ue);
948 usb_child_detached(device_t self, device_t child)
950 struct usb_softc *sc = device_get_softc(self);
952 /* XXX, should check it is the right device. */
953 sc->sc_port.device = NULL;
956 /* Explore USB busses at the end of device configuration */
958 usb_cold_explore(void *arg)
960 struct usb_softc *sc;
962 TUNABLE_INT_FETCH("hw.usb.hack_defer_exploration",
963 &hack_defer_exploration);
965 if (!hack_defer_exploration)
968 KASSERT(cold || TAILQ_EMPTY(&usb_coldexplist),
969 ("usb_cold_explore: busses to explore when !cold"));
970 while (!TAILQ_EMPTY(&usb_coldexplist)) {
971 sc = TAILQ_FIRST(&usb_coldexplist);
972 TAILQ_REMOVE(&usb_coldexplist, sc, sc_coldexplist);
974 sc->sc_bus->use_polling++;
975 sc->sc_port.device->hub->explore(sc->sc_bus->root_hub);
976 sc->sc_bus->use_polling--;
981 usb_getbushandle(struct usb_softc *sc)
987 SYSINIT(usb_cold_explore, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE,
988 usb_cold_explore, NULL);
990 DRIVER_MODULE(usb, ohci, usb_driver, usb_devclass, 0, 0);
991 DRIVER_MODULE(usb, uhci, usb_driver, usb_devclass, 0, 0);
992 DRIVER_MODULE(usb, ehci, usb_driver, usb_devclass, 0, 0);