ehci_pci.c revision 220303
117683Spst/*-
217683Spst * Copyright (c) 1998 The NetBSD Foundation, Inc.
317683Spst * All rights reserved.
417683Spst *
517683Spst * This code is derived from software contributed to The NetBSD Foundation
617683Spst * by Lennart Augustsson (augustss@carlstedt.se) at
717683Spst * Carlstedt Research & Technology.
817683Spst *
917683Spst * Redistribution and use in source and binary forms, with or without
1017683Spst * modification, are permitted provided that the following conditions
1117683Spst * are met:
1217683Spst * 1. Redistributions of source code must retain the above copyright
1317683Spst *    notice, this list of conditions and the following disclaimer.
1417683Spst * 2. Redistributions in binary form must reproduce the above copyright
1517683Spst *    notice, this list of conditions and the following disclaimer in the
1617683Spst *    documentation and/or other materials provided with the distribution.
1717683Spst *
1817683Spst * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1917683Spst * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2017683Spst * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2117683Spst * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2217683Spst * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2317683Spst * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2417683Spst * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2517683Spst * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2617683Spst * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2717683Spst * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2817683Spst * POSSIBILITY OF SUCH DAMAGE.
2917683Spst */
3017683Spst
3117683Spst#include <sys/cdefs.h>
3217683Spst__FBSDID("$FreeBSD: head/sys/dev/usb/controller/ehci_pci.c 220303 2011-04-03 20:17:49Z hselasky $");
3317683Spst
3417683Spst/*
3517683Spst * USB Enhanced Host Controller Driver, a.k.a. USB 2.0 controller.
3617683Spst *
3717683Spst * The EHCI 1.0 spec can be found at
3817683Spst * http://developer.intel.com/technology/usb/download/ehci-r10.pdf
3917683Spst * and the USB 2.0 spec at
4017683Spst * http://www.usb.org/developers/docs/usb_20.zip
4117683Spst */
4217683Spst
4317683Spst/* The low level controller code for EHCI has been split into
4417683Spst * PCI probes and EHCI specific code. This was done to facilitate the
4517683Spst * sharing of code between *BSD's
4617683Spst */
4717683Spst
4817683Spst#include <sys/stdint.h>
4917683Spst#include <sys/stddef.h>
5017683Spst#include <sys/param.h>
5117683Spst#include <sys/queue.h>
5217683Spst#include <sys/types.h>
5317683Spst#include <sys/systm.h>
5417683Spst#include <sys/kernel.h>
5517683Spst#include <sys/bus.h>
5617683Spst#include <sys/module.h>
5717683Spst#include <sys/lock.h>
5817683Spst#include <sys/mutex.h>
5917683Spst#include <sys/condvar.h>
6017683Spst#include <sys/sysctl.h>
6117683Spst#include <sys/sx.h>
6217683Spst#include <sys/unistd.h>
6317683Spst#include <sys/callout.h>
6417683Spst#include <sys/malloc.h>
6517683Spst#include <sys/priv.h>
6617683Spst
6717683Spst#include <dev/usb/usb.h>
6817683Spst#include <dev/usb/usbdi.h>
6917683Spst
7017683Spst#include <dev/usb/usb_core.h>
7117683Spst#include <dev/usb/usb_busdma.h>
7217683Spst#include <dev/usb/usb_process.h>
7317683Spst#include <dev/usb/usb_util.h>
7417683Spst
7517683Spst#include <dev/usb/usb_controller.h>
7617683Spst#include <dev/usb/usb_bus.h>
7717683Spst#include <dev/usb/usb_pci.h>
7817683Spst#include <dev/usb/controller/ehci.h>
7917683Spst#include <dev/usb/controller/ehcireg.h>
8017683Spst
8117683Spst#define	PCI_EHCI_VENDORID_ACERLABS	0x10b9
8217683Spst#define	PCI_EHCI_VENDORID_AMD		0x1022
8317683Spst#define	PCI_EHCI_VENDORID_APPLE		0x106b
8417683Spst#define	PCI_EHCI_VENDORID_ATI		0x1002
8517683Spst#define	PCI_EHCI_VENDORID_CMDTECH	0x1095
8617683Spst#define	PCI_EHCI_VENDORID_INTEL		0x8086
8717683Spst#define	PCI_EHCI_VENDORID_NEC		0x1033
8817683Spst#define	PCI_EHCI_VENDORID_OPTI		0x1045
8917683Spst#define	PCI_EHCI_VENDORID_PHILIPS	0x1131
9017683Spst#define	PCI_EHCI_VENDORID_SIS		0x1039
9117683Spst#define	PCI_EHCI_VENDORID_NVIDIA	0x12D2
9217683Spst#define	PCI_EHCI_VENDORID_NVIDIA2	0x10DE
9317683Spst#define	PCI_EHCI_VENDORID_VIA		0x1106
9417683Spst
9517683Spststatic void ehci_pci_takecontroller(device_t self);
9617683Spst
9717683Spststatic device_probe_t ehci_pci_probe;
9817683Spststatic device_attach_t ehci_pci_attach;
9917683Spststatic device_detach_t ehci_pci_detach;
10017683Spststatic device_suspend_t ehci_pci_suspend;
10117683Spststatic device_resume_t ehci_pci_resume;
10217683Spststatic device_shutdown_t ehci_pci_shutdown;
10317683Spst
10417683Spststatic int
10517683Spstehci_pci_suspend(device_t self)
10617683Spst{
10717683Spst	ehci_softc_t *sc = device_get_softc(self);
10817683Spst	int err;
10917683Spst
11017683Spst	err = bus_generic_suspend(self);
11117683Spst	if (err)
11217683Spst		return (err);
11317683Spst	ehci_suspend(sc);
11417683Spst	return (0);
11517683Spst}
11617683Spst
11717683Spststatic int
11817683Spstehci_pci_resume(device_t self)
11917683Spst{
12017683Spst	ehci_softc_t *sc = device_get_softc(self);
12117683Spst
12217683Spst	ehci_pci_takecontroller(self);
12317683Spst	ehci_resume(sc);
12417683Spst
12517683Spst	bus_generic_resume(self);
12617683Spst
12717683Spst	return (0);
12817683Spst}
12917683Spst
13017683Spststatic int
13117683Spstehci_pci_shutdown(device_t self)
13217683Spst{
13317683Spst	ehci_softc_t *sc = device_get_softc(self);
13417683Spst	int err;
13517683Spst
13617683Spst	err = bus_generic_shutdown(self);
13717683Spst	if (err)
13817683Spst		return (err);
13917683Spst	ehci_shutdown(sc);
14017683Spst
14117683Spst	return (0);
14217683Spst}
14317683Spst
14417683Spststatic const char *
14517683Spstehci_pci_match(device_t self)
14617683Spst{
14717683Spst	uint32_t device_id = pci_get_devid(self);
14817683Spst
14917683Spst	switch (device_id) {
15017683Spst	case 0x268c8086:
15117683Spst		return ("Intel 63XXESB USB 2.0 controller");
15217683Spst
15317683Spst	case 0x523910b9:
15417683Spst		return "ALi M5239 USB 2.0 controller";
15517683Spst
15617683Spst	case 0x10227463:
15717683Spst		return "AMD 8111 USB 2.0 controller";
15817683Spst
15917683Spst	case 0x20951022:
16017683Spst		return ("AMD CS5536 (Geode) USB 2.0 controller");
16117683Spst
16217683Spst	case 0x43451002:
16317683Spst		return "ATI SB200 USB 2.0 controller";
16417683Spst	case 0x43731002:
16517683Spst		return "ATI SB400 USB 2.0 controller";
16617683Spst
16717683Spst	case 0x25ad8086:
16817683Spst		return "Intel 6300ESB USB 2.0 controller";
16917683Spst	case 0x24cd8086:
17017683Spst		return "Intel 82801DB/L/M (ICH4) USB 2.0 controller";
17117683Spst	case 0x24dd8086:
17217683Spst		return "Intel 82801EB/R (ICH5) USB 2.0 controller";
17317683Spst	case 0x265c8086:
17417683Spst		return "Intel 82801FB (ICH6) USB 2.0 controller";
17517683Spst	case 0x27cc8086:
17617683Spst		return "Intel 82801GB/R (ICH7) USB 2.0 controller";
17717683Spst
17817683Spst	case 0x28368086:
17917683Spst		return "Intel 82801H (ICH8) USB 2.0 controller USB2-A";
18017683Spst	case 0x283a8086:
18117683Spst		return "Intel 82801H (ICH8) USB 2.0 controller USB2-B";
18217683Spst	case 0x293a8086:
18317683Spst		return "Intel 82801I (ICH9) USB 2.0 controller";
18417683Spst	case 0x293c8086:
18517683Spst		return "Intel 82801I (ICH9) USB 2.0 controller";
18617683Spst	case 0x3a3a8086:
18717683Spst		return "Intel 82801JI (ICH10) USB 2.0 controller USB-A";
18817683Spst	case 0x3a3c8086:
18917683Spst		return "Intel 82801JI (ICH10) USB 2.0 controller USB-B";
19017683Spst	case 0x3b348086:
19117683Spst		return ("Intel PCH USB 2.0 controller USB-A");
19217683Spst	case 0x3b3c8086:
19317683Spst		return ("Intel PCH USB 2.0 controller USB-B");
19417683Spst
19517683Spst	case 0x00e01033:
19617683Spst		return ("NEC uPD 720100 USB 2.0 controller");
19717683Spst
19817683Spst	case 0x006810de:
19917683Spst		return "NVIDIA nForce2 USB 2.0 controller";
20017683Spst	case 0x008810de:
20117683Spst		return "NVIDIA nForce2 Ultra 400 USB 2.0 controller";
20217683Spst	case 0x00d810de:
20317683Spst		return "NVIDIA nForce3 USB 2.0 controller";
20417683Spst	case 0x00e810de:
20517683Spst		return "NVIDIA nForce3 250 USB 2.0 controller";
20617683Spst	case 0x005b10de:
20717683Spst		return "NVIDIA nForce4 USB 2.0 controller";
20817683Spst	case 0x036d10de:
20917683Spst		return "NVIDIA nForce MCP55 USB 2.0 controller";
21017683Spst	case 0x03f210de:
21117683Spst		return "NVIDIA nForce MCP61 USB 2.0 controller";
21217683Spst	case 0x0aa610de:
21317683Spst		return "NVIDIA nForce MCP79 USB 2.0 controller";
21417683Spst	case 0x0aa910de:
21517683Spst		return "NVIDIA nForce MCP79 USB 2.0 controller";
21617683Spst	case 0x0aaa10de:
21717683Spst		return "NVIDIA nForce MCP79 USB 2.0 controller";
21817683Spst
21917683Spst	case 0x15621131:
22017683Spst		return "Philips ISP156x USB 2.0 controller";
22117683Spst
22217683Spst	case 0x31041106:
22317683Spst		return ("VIA VT6202 USB 2.0 controller");
22417683Spst
22517683Spst	default:
22617683Spst		break;
22717683Spst	}
22817683Spst
22917683Spst	if ((pci_get_class(self) == PCIC_SERIALBUS)
23017683Spst	    && (pci_get_subclass(self) == PCIS_SERIALBUS_USB)
23117683Spst	    && (pci_get_progif(self) == PCI_INTERFACE_EHCI)) {
23217683Spst		return ("EHCI (generic) USB 2.0 controller");
23317683Spst	}
23417683Spst	return (NULL);			/* dunno */
23517683Spst}
23617683Spst
23717683Spststatic int
23817683Spstehci_pci_probe(device_t self)
23917683Spst{
24017683Spst	const char *desc = ehci_pci_match(self);
24117683Spst
24217683Spst	if (desc) {
24317683Spst		device_set_desc(self, desc);
24417683Spst		return (0);
24517683Spst	} else {
24617683Spst		return (ENXIO);
24717683Spst	}
24817683Spst}
24917683Spst
25017683Spststatic void
25117683Spstehci_pci_ati_quirk(device_t self, uint8_t is_sb700)
25217683Spst{
25317683Spst	device_t smbdev;
25417683Spst	uint32_t val;
25517683Spst
25617683Spst	if (is_sb700) {
25717683Spst		/* Lookup SMBUS PCI device */
25817683Spst		smbdev = pci_find_device(PCI_EHCI_VENDORID_ATI, 0x4385);
25917683Spst		if (smbdev == NULL)
26017683Spst			return;
26117683Spst		val = pci_get_revid(smbdev);
26217683Spst		if (val != 0x3a && val != 0x3b)
26317683Spst			return;
26417683Spst	}
26517683Spst
26617683Spst	/*
26717683Spst	 * Note: this bit is described as reserved in SB700
26817683Spst	 * Register Reference Guide.
26917683Spst	 */
27017683Spst	val = pci_read_config(self, 0x53, 1);
27117683Spst	if (!(val & 0x8)) {
27217683Spst		val |= 0x8;
27317683Spst		pci_write_config(self, 0x53, val, 1);
27417683Spst		device_printf(self, "AMD SB600/700 quirk applied\n");
27517683Spst	}
27617683Spst}
27717683Spst
27817683Spststatic void
27917683Spstehci_pci_via_quirk(device_t self)
28017683Spst{
28117683Spst	uint32_t val;
282
283	if ((pci_get_device(self) == 0x3104) &&
284	    ((pci_get_revid(self) & 0xf0) == 0x60)) {
285		/* Correct schedule sleep time to 10us */
286		val = pci_read_config(self, 0x4b, 1);
287		if (val & 0x20)
288			return;
289		pci_write_config(self, 0x4b, val, 1);
290		device_printf(self, "VIA-quirk applied\n");
291	}
292}
293
294static int
295ehci_pci_attach(device_t self)
296{
297	ehci_softc_t *sc = device_get_softc(self);
298	int err;
299	int rid;
300
301	/* initialise some bus fields */
302	sc->sc_bus.parent = self;
303	sc->sc_bus.devices = sc->sc_devices;
304	sc->sc_bus.devices_max = EHCI_MAX_DEVICES;
305
306	/* get all DMA memory */
307	if (usb_bus_mem_alloc_all(&sc->sc_bus,
308	    USB_GET_DMA_TAG(self), &ehci_iterate_hw_softc)) {
309		return (ENOMEM);
310	}
311
312	pci_enable_busmaster(self);
313
314	switch (pci_read_config(self, PCI_USBREV, 1) & PCI_USB_REV_MASK) {
315	case PCI_USB_REV_PRE_1_0:
316	case PCI_USB_REV_1_0:
317	case PCI_USB_REV_1_1:
318		/*
319		 * NOTE: some EHCI USB controllers have the wrong USB
320		 * revision number. It appears those controllers are
321		 * fully compliant so we just ignore this value in
322		 * some common cases.
323		 */
324		device_printf(self, "pre-2.0 USB revision (ignored)\n");
325		/* fallthrough */
326	case PCI_USB_REV_2_0:
327		break;
328	default:
329		/* Quirk for Parallels Desktop 4.0 */
330		device_printf(self, "USB revision is unknown. Assuming v2.0.\n");
331		break;
332	}
333
334	rid = PCI_CBMEM;
335	sc->sc_io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid,
336	    RF_ACTIVE);
337	if (!sc->sc_io_res) {
338		device_printf(self, "Could not map memory\n");
339		goto error;
340	}
341	sc->sc_io_tag = rman_get_bustag(sc->sc_io_res);
342	sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res);
343	sc->sc_io_size = rman_get_size(sc->sc_io_res);
344
345	rid = 0;
346	sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid,
347	    RF_SHAREABLE | RF_ACTIVE);
348	if (sc->sc_irq_res == NULL) {
349		device_printf(self, "Could not allocate irq\n");
350		goto error;
351	}
352	sc->sc_bus.bdev = device_add_child(self, "usbus", -1);
353	if (!sc->sc_bus.bdev) {
354		device_printf(self, "Could not add USB device\n");
355		goto error;
356	}
357	device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
358
359	/*
360	 * ehci_pci_match will never return NULL if ehci_pci_probe
361	 * succeeded
362	 */
363	device_set_desc(sc->sc_bus.bdev, ehci_pci_match(self));
364	switch (pci_get_vendor(self)) {
365	case PCI_EHCI_VENDORID_ACERLABS:
366		sprintf(sc->sc_vendor, "AcerLabs");
367		break;
368	case PCI_EHCI_VENDORID_AMD:
369		sprintf(sc->sc_vendor, "AMD");
370		break;
371	case PCI_EHCI_VENDORID_APPLE:
372		sprintf(sc->sc_vendor, "Apple");
373		break;
374	case PCI_EHCI_VENDORID_ATI:
375		sprintf(sc->sc_vendor, "ATI");
376		break;
377	case PCI_EHCI_VENDORID_CMDTECH:
378		sprintf(sc->sc_vendor, "CMDTECH");
379		break;
380	case PCI_EHCI_VENDORID_INTEL:
381		sprintf(sc->sc_vendor, "Intel");
382		break;
383	case PCI_EHCI_VENDORID_NEC:
384		sprintf(sc->sc_vendor, "NEC");
385		break;
386	case PCI_EHCI_VENDORID_OPTI:
387		sprintf(sc->sc_vendor, "OPTi");
388		break;
389	case PCI_EHCI_VENDORID_PHILIPS:
390		sprintf(sc->sc_vendor, "Philips");
391		break;
392	case PCI_EHCI_VENDORID_SIS:
393		sprintf(sc->sc_vendor, "SiS");
394		break;
395	case PCI_EHCI_VENDORID_NVIDIA:
396	case PCI_EHCI_VENDORID_NVIDIA2:
397		sprintf(sc->sc_vendor, "nVidia");
398		break;
399	case PCI_EHCI_VENDORID_VIA:
400		sprintf(sc->sc_vendor, "VIA");
401		break;
402	default:
403		if (bootverbose)
404			device_printf(self, "(New EHCI DeviceId=0x%08x)\n",
405			    pci_get_devid(self));
406		sprintf(sc->sc_vendor, "(0x%04x)", pci_get_vendor(self));
407	}
408
409#if (__FreeBSD_version >= 700031)
410	err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
411	    NULL, (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl);
412#else
413	err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
414	    (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl);
415#endif
416	if (err) {
417		device_printf(self, "Could not setup irq, %d\n", err);
418		sc->sc_intr_hdl = NULL;
419		goto error;
420	}
421	ehci_pci_takecontroller(self);
422
423	/* Undocumented quirks taken from Linux */
424
425	switch (pci_get_vendor(self)) {
426	case PCI_EHCI_VENDORID_ATI:
427		/* SB600 and SB700 EHCI quirk */
428		switch (pci_get_device(self)) {
429		case 0x4386:
430			ehci_pci_ati_quirk(self, 0);
431			break;
432		case 0x4396:
433			ehci_pci_ati_quirk(self, 1);
434			break;
435		default:
436			break;
437		}
438		break;
439
440	case PCI_EHCI_VENDORID_VIA:
441		ehci_pci_via_quirk(self);
442		break;
443
444	default:
445		break;
446	}
447
448	/* Dropped interrupts workaround */
449	switch (pci_get_vendor(self)) {
450	case PCI_EHCI_VENDORID_ATI:
451	case PCI_EHCI_VENDORID_VIA:
452		sc->sc_flags |= EHCI_SCFLG_LOSTINTRBUG;
453		if (bootverbose)
454			device_printf(self,
455			    "Dropped interrupts workaround enabled\n");
456		break;
457	default:
458		break;
459	}
460
461	/* Doorbell feature workaround */
462	switch (pci_get_vendor(self)) {
463	case PCI_EHCI_VENDORID_NVIDIA:
464	case PCI_EHCI_VENDORID_NVIDIA2:
465		sc->sc_flags |= EHCI_SCFLG_IAADBUG;
466		if (bootverbose)
467			device_printf(self,
468			    "Doorbell workaround enabled\n");
469		break;
470	default:
471		break;
472	}
473
474	err = ehci_init(sc);
475	if (!err) {
476		err = device_probe_and_attach(sc->sc_bus.bdev);
477	}
478	if (err) {
479		device_printf(self, "USB init failed err=%d\n", err);
480		goto error;
481	}
482	return (0);
483
484error:
485	ehci_pci_detach(self);
486	return (ENXIO);
487}
488
489static int
490ehci_pci_detach(device_t self)
491{
492	ehci_softc_t *sc = device_get_softc(self);
493	device_t bdev;
494
495	if (sc->sc_bus.bdev) {
496		bdev = sc->sc_bus.bdev;
497		device_detach(bdev);
498		device_delete_child(self, bdev);
499	}
500	/* during module unload there are lots of children leftover */
501	device_delete_all_children(self);
502
503	pci_disable_busmaster(self);
504
505	/*
506	 * disable interrupts that might have been switched on in ehci_init
507	 */
508	if (sc->sc_io_res) {
509		EOWRITE4(sc, EHCI_USBINTR, 0);
510	}
511	if (sc->sc_irq_res && sc->sc_intr_hdl) {
512		/*
513		 * only call ehci_detach() after ehci_init()
514		 */
515		ehci_detach(sc);
516
517		int err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);
518
519		if (err)
520			/* XXX or should we panic? */
521			device_printf(self, "Could not tear down irq, %d\n",
522			    err);
523		sc->sc_intr_hdl = NULL;
524	}
525	if (sc->sc_irq_res) {
526		bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res);
527		sc->sc_irq_res = NULL;
528	}
529	if (sc->sc_io_res) {
530		bus_release_resource(self, SYS_RES_MEMORY, PCI_CBMEM,
531		    sc->sc_io_res);
532		sc->sc_io_res = NULL;
533	}
534	usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);
535
536	return (0);
537}
538
539static void
540ehci_pci_takecontroller(device_t self)
541{
542	ehci_softc_t *sc = device_get_softc(self);
543	uint32_t cparams;
544	uint32_t eec;
545	uint16_t to;
546	uint8_t eecp;
547	uint8_t bios_sem;
548
549	cparams = EREAD4(sc, EHCI_HCCPARAMS);
550
551	/* Synchronise with the BIOS if it owns the controller. */
552	for (eecp = EHCI_HCC_EECP(cparams); eecp != 0;
553	    eecp = EHCI_EECP_NEXT(eec)) {
554		eec = pci_read_config(self, eecp, 4);
555		if (EHCI_EECP_ID(eec) != EHCI_EC_LEGSUP) {
556			continue;
557		}
558		bios_sem = pci_read_config(self, eecp +
559		    EHCI_LEGSUP_BIOS_SEM, 1);
560		if (bios_sem == 0) {
561			continue;
562		}
563		device_printf(sc->sc_bus.bdev, "waiting for BIOS "
564		    "to give up control\n");
565		pci_write_config(self, eecp +
566		    EHCI_LEGSUP_OS_SEM, 1, 1);
567		to = 500;
568		while (1) {
569			bios_sem = pci_read_config(self, eecp +
570			    EHCI_LEGSUP_BIOS_SEM, 1);
571			if (bios_sem == 0)
572				break;
573
574			if (--to == 0) {
575				device_printf(sc->sc_bus.bdev,
576				    "timed out waiting for BIOS\n");
577				break;
578			}
579			usb_pause_mtx(NULL, hz / 100);	/* wait 10ms */
580		}
581	}
582}
583
584static driver_t ehci_driver =
585{
586	.name = "ehci",
587	.methods = (device_method_t[]){
588		/* device interface */
589		DEVMETHOD(device_probe, ehci_pci_probe),
590		DEVMETHOD(device_attach, ehci_pci_attach),
591		DEVMETHOD(device_detach, ehci_pci_detach),
592		DEVMETHOD(device_suspend, ehci_pci_suspend),
593		DEVMETHOD(device_resume, ehci_pci_resume),
594		DEVMETHOD(device_shutdown, ehci_pci_shutdown),
595		/* bus interface */
596		DEVMETHOD(bus_print_child, bus_generic_print_child),
597
598		{0, 0}
599	},
600	.size = sizeof(struct ehci_softc),
601};
602
603static devclass_t ehci_devclass;
604
605DRIVER_MODULE(ehci, pci, ehci_driver, ehci_devclass, 0, 0);
606MODULE_DEPEND(ehci, usb, 1, 1, 1);
607