ehci_pci.c (198500) | ehci_pci.c (198501) |
---|---|
1/*- 2 * Copyright (c) 1998 The NetBSD Foundation, Inc. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to The NetBSD Foundation 6 * by Lennart Augustsson (augustss@carlstedt.se) at 7 * Carlstedt Research & Technology. 8 * --- 22 unchanged lines hidden (view full) --- 31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998 The NetBSD Foundation, Inc. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to The NetBSD Foundation 6 * by Lennart Augustsson (augustss@carlstedt.se) at 7 * Carlstedt Research & Technology. 8 * --- 22 unchanged lines hidden (view full) --- 31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/sys/dev/usb/controller/ehci_pci.c 198500 2009-10-26 20:23:15Z thompsa $"); | 39__FBSDID("$FreeBSD: head/sys/dev/usb/controller/ehci_pci.c 198501 2009-10-26 21:47:16Z thompsa $"); |
40 41/* 42 * USB Enhanced Host Controller Driver, a.k.a. USB 2.0 controller. 43 * 44 * The EHCI 1.0 spec can be found at 45 * http://developer.intel.com/technology/usb/download/ehci-r10.pdf 46 * and the USB 2.0 spec at 47 * http://www.usb.org/developers/docs/usb_20.zip --- 49 unchanged lines hidden (view full) --- 97#define PCI_EHCI_VENDORID_PHILIPS 0x1131 98#define PCI_EHCI_VENDORID_SIS 0x1039 99#define PCI_EHCI_VENDORID_NVIDIA 0x12D2 100#define PCI_EHCI_VENDORID_NVIDIA2 0x10DE 101#define PCI_EHCI_VENDORID_VIA 0x1106 102 103#define PCI_EHCI_BASE_REG 0x10 104 | 40 41/* 42 * USB Enhanced Host Controller Driver, a.k.a. USB 2.0 controller. 43 * 44 * The EHCI 1.0 spec can be found at 45 * http://developer.intel.com/technology/usb/download/ehci-r10.pdf 46 * and the USB 2.0 spec at 47 * http://www.usb.org/developers/docs/usb_20.zip --- 49 unchanged lines hidden (view full) --- 97#define PCI_EHCI_VENDORID_PHILIPS 0x1131 98#define PCI_EHCI_VENDORID_SIS 0x1039 99#define PCI_EHCI_VENDORID_NVIDIA 0x12D2 100#define PCI_EHCI_VENDORID_NVIDIA2 0x10DE 101#define PCI_EHCI_VENDORID_VIA 0x1106 102 103#define PCI_EHCI_BASE_REG 0x10 104 |
105static void ehci_pci_takecontroller(device_t self); 106 |
|
105static device_probe_t ehci_pci_probe; 106static device_attach_t ehci_pci_attach; 107static device_detach_t ehci_pci_detach; 108static device_suspend_t ehci_pci_suspend; 109static device_resume_t ehci_pci_resume; 110static device_shutdown_t ehci_pci_shutdown; 111 112static int --- 9 unchanged lines hidden (view full) --- 122 return (0); 123} 124 125static int 126ehci_pci_resume(device_t self) 127{ 128 ehci_softc_t *sc = device_get_softc(self); 129 | 107static device_probe_t ehci_pci_probe; 108static device_attach_t ehci_pci_attach; 109static device_detach_t ehci_pci_detach; 110static device_suspend_t ehci_pci_suspend; 111static device_resume_t ehci_pci_resume; 112static device_shutdown_t ehci_pci_shutdown; 113 114static int --- 9 unchanged lines hidden (view full) --- 124 return (0); 125} 126 127static int 128ehci_pci_resume(device_t self) 129{ 130 ehci_softc_t *sc = device_get_softc(self); 131 |
132 ehci_pci_takecontroller(self); |
|
130 ehci_resume(sc); 131 132 bus_generic_resume(self); 133 134 return (0); 135} 136 137static int --- 268 unchanged lines hidden (view full) --- 406 err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, 407 (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl); 408#endif 409 if (err) { 410 device_printf(self, "Could not setup irq, %d\n", err); 411 sc->sc_intr_hdl = NULL; 412 goto error; 413 } | 133 ehci_resume(sc); 134 135 bus_generic_resume(self); 136 137 return (0); 138} 139 140static int --- 268 unchanged lines hidden (view full) --- 409 err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, 410 (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl); 411#endif 412 if (err) { 413 device_printf(self, "Could not setup irq, %d\n", err); 414 sc->sc_intr_hdl = NULL; 415 goto error; 416 } |
417 ehci_pci_takecontroller(self); |
|
414 415 /* Undocumented quirks taken from Linux */ 416 417 switch (pci_get_vendor(self)) { 418 case PCI_EHCI_VENDORID_ATI: 419 /* SB600 and SB700 EHCI quirk */ 420 switch (pci_get_device(self)) { 421 case 0x4386: --- 75 unchanged lines hidden (view full) --- 497 sc->sc_io_res); 498 sc->sc_io_res = NULL; 499 } 500 usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc); 501 502 return (0); 503} 504 | 418 419 /* Undocumented quirks taken from Linux */ 420 421 switch (pci_get_vendor(self)) { 422 case PCI_EHCI_VENDORID_ATI: 423 /* SB600 and SB700 EHCI quirk */ 424 switch (pci_get_device(self)) { 425 case 0x4386: --- 75 unchanged lines hidden (view full) --- 501 sc->sc_io_res); 502 sc->sc_io_res = NULL; 503 } 504 usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc); 505 506 return (0); 507} 508 |
509static void 510ehci_pci_takecontroller(device_t self) 511{ 512 ehci_softc_t *sc = device_get_softc(self); 513 uint32_t cparams; 514 uint32_t eec; 515 uint16_t to; 516 uint8_t eecp; 517 uint8_t bios_sem; 518 519 cparams = EREAD4(sc, EHCI_HCCPARAMS); 520 521 /* Synchronise with the BIOS if it owns the controller. */ 522 for (eecp = EHCI_HCC_EECP(cparams); eecp != 0; 523 eecp = EHCI_EECP_NEXT(eec)) { 524 eec = pci_read_config(self, eecp, 4); 525 if (EHCI_EECP_ID(eec) != EHCI_EC_LEGSUP) { 526 continue; 527 } 528 bios_sem = pci_read_config(self, eecp + 529 EHCI_LEGSUP_BIOS_SEM, 1); 530 if (bios_sem == 0) { 531 continue; 532 } 533 device_printf(sc->sc_bus.bdev, "waiting for BIOS " 534 "to give up control\n"); 535 pci_write_config(self, eecp + 536 EHCI_LEGSUP_OS_SEM, 1, 1); 537 to = 500; 538 while (1) { 539 bios_sem = pci_read_config(self, eecp + 540 EHCI_LEGSUP_BIOS_SEM, 1); 541 if (bios_sem == 0) 542 break; 543 544 if (--to == 0) { 545 device_printf(sc->sc_bus.bdev, 546 "timed out waiting for BIOS\n"); 547 break; 548 } 549 usb_pause_mtx(NULL, hz / 100); /* wait 10ms */ 550 } 551 } 552} 553 |
|
505static driver_t ehci_driver = 506{ 507 .name = "ehci", 508 .methods = (device_method_t[]){ 509 /* device interface */ 510 DEVMETHOD(device_probe, ehci_pci_probe), 511 DEVMETHOD(device_attach, ehci_pci_attach), 512 DEVMETHOD(device_detach, ehci_pci_detach), --- 15 unchanged lines hidden --- | 554static driver_t ehci_driver = 555{ 556 .name = "ehci", 557 .methods = (device_method_t[]){ 558 /* device interface */ 559 DEVMETHOD(device_probe, ehci_pci_probe), 560 DEVMETHOD(device_attach, ehci_pci_attach), 561 DEVMETHOD(device_detach, ehci_pci_detach), --- 15 unchanged lines hidden --- |