The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/usb/controller/ehci_pci.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
    3  *
    4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Lennart Augustsson (augustss@carlstedt.se) at
    9  * Carlstedt Research & Technology.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   30  * POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 #include <sys/cdefs.h>
   34 __FBSDID("$FreeBSD$");
   35 
   36 /*
   37  * USB Enhanced Host Controller Driver, a.k.a. USB 2.0 controller.
   38  *
   39  * The EHCI 1.0 spec can be found at
   40  * http://developer.intel.com/technology/usb/download/ehci-r10.pdf
   41  * and the USB 2.0 spec at
   42  * http://www.usb.org/developers/docs/usb_20.zip
   43  */
   44 
   45 /* The low level controller code for EHCI has been split into
   46  * PCI probes and EHCI specific code. This was done to facilitate the
   47  * sharing of code between *BSD's
   48  */
   49 
   50 #include <sys/stdint.h>
   51 #include <sys/stddef.h>
   52 #include <sys/param.h>
   53 #include <sys/queue.h>
   54 #include <sys/types.h>
   55 #include <sys/systm.h>
   56 #include <sys/kernel.h>
   57 #include <sys/bus.h>
   58 #include <sys/module.h>
   59 #include <sys/lock.h>
   60 #include <sys/mutex.h>
   61 #include <sys/condvar.h>
   62 #include <sys/sysctl.h>
   63 #include <sys/sx.h>
   64 #include <sys/unistd.h>
   65 #include <sys/callout.h>
   66 #include <sys/malloc.h>
   67 #include <sys/priv.h>
   68 
   69 #include <dev/usb/usb.h>
   70 #include <dev/usb/usbdi.h>
   71 
   72 #include <dev/usb/usb_core.h>
   73 #include <dev/usb/usb_busdma.h>
   74 #include <dev/usb/usb_process.h>
   75 #include <dev/usb/usb_util.h>
   76 
   77 #include <dev/usb/usb_controller.h>
   78 #include <dev/usb/usb_bus.h>
   79 #include <dev/usb/usb_pci.h>
   80 #include <dev/usb/controller/ehci.h>
   81 #include <dev/usb/controller/ehcireg.h>
   82 #include "usb_if.h"
   83 
   84 #define PCI_EHCI_VENDORID_ACERLABS      0x10b9
   85 #define PCI_EHCI_VENDORID_AMD           0x1022
   86 #define PCI_EHCI_VENDORID_APPLE         0x106b
   87 #define PCI_EHCI_VENDORID_ATI           0x1002
   88 #define PCI_EHCI_VENDORID_CMDTECH       0x1095
   89 #define PCI_EHCI_VENDORID_HYGON         0x1d94
   90 #define PCI_EHCI_VENDORID_INTEL         0x8086
   91 #define PCI_EHCI_VENDORID_NEC           0x1033
   92 #define PCI_EHCI_VENDORID_OPTI          0x1045
   93 #define PCI_EHCI_VENDORID_PHILIPS       0x1131
   94 #define PCI_EHCI_VENDORID_SIS           0x1039
   95 #define PCI_EHCI_VENDORID_NVIDIA        0x12D2
   96 #define PCI_EHCI_VENDORID_NVIDIA2       0x10DE
   97 #define PCI_EHCI_VENDORID_VIA           0x1106
   98 
   99 static device_probe_t ehci_pci_probe;
  100 static device_attach_t ehci_pci_attach;
  101 static device_detach_t ehci_pci_detach;
  102 static usb_take_controller_t ehci_pci_take_controller;
  103 
  104 static const char *
  105 ehci_pci_match(device_t self)
  106 {
  107         uint32_t device_id = pci_get_devid(self);
  108 
  109         switch (device_id) {
  110         case 0x523910b9:
  111                 return "ALi M5239 USB 2.0 controller";
  112 
  113         case 0x10227463:
  114                 return "AMD 8111 USB 2.0 controller";
  115 
  116         case 0x20951022:
  117                 return ("AMD CS5536 (Geode) USB 2.0 controller");
  118         case 0x78081022:
  119                 return ("AMD FCH USB 2.0 controller");
  120 
  121         case 0x43451002:
  122                 return "ATI SB200 USB 2.0 controller";
  123         case 0x43731002:
  124                 return "ATI SB400 USB 2.0 controller";
  125         case 0x43961002:
  126                 return ("AMD SB7x0/SB8x0/SB9x0 USB 2.0 controller");
  127 
  128         case 0x0f348086:
  129                 return ("Intel BayTrail USB 2.0 controller");
  130         case 0x1c268086:
  131                 return ("Intel Cougar Point USB 2.0 controller");
  132         case 0x1c2d8086:
  133                 return ("Intel Cougar Point USB 2.0 controller");
  134         case 0x1d268086:
  135                 return ("Intel Patsburg USB 2.0 controller");
  136         case 0x1d2d8086:
  137                 return ("Intel Patsburg USB 2.0 controller");
  138         case 0x1e268086:
  139                 return ("Intel Panther Point USB 2.0 controller");
  140         case 0x1e2d8086:
  141                 return ("Intel Panther Point USB 2.0 controller");
  142         case 0x1f2c8086:
  143                 return ("Intel Avoton USB 2.0 controller");
  144         case 0x25ad8086:
  145                 return "Intel 6300ESB USB 2.0 controller";
  146         case 0x24cd8086:
  147                 return "Intel 82801DB/L/M (ICH4) USB 2.0 controller";
  148         case 0x24dd8086:
  149                 return "Intel 82801EB/R (ICH5) USB 2.0 controller";
  150         case 0x265c8086:
  151                 return "Intel 82801FB (ICH6) USB 2.0 controller";
  152         case 0x268c8086:
  153                 return ("Intel 63XXESB USB 2.0 controller");
  154         case 0x27cc8086:
  155                 return "Intel 82801GB/R (ICH7) USB 2.0 controller";
  156         case 0x28368086:
  157                 return "Intel 82801H (ICH8) USB 2.0 controller USB2-A";
  158         case 0x283a8086:
  159                 return "Intel 82801H (ICH8) USB 2.0 controller USB2-B";
  160         case 0x293a8086:
  161                 return "Intel 82801I (ICH9) USB 2.0 controller";
  162         case 0x293c8086:
  163                 return "Intel 82801I (ICH9) USB 2.0 controller";
  164         case 0x3a3a8086:
  165                 return "Intel 82801JI (ICH10) USB 2.0 controller USB-A";
  166         case 0x3a3c8086:
  167                 return "Intel 82801JI (ICH10) USB 2.0 controller USB-B";
  168         case 0x3b348086:
  169                 return ("Intel PCH USB 2.0 controller USB-A");
  170         case 0x3b3c8086:
  171                 return ("Intel PCH USB 2.0 controller USB-B");
  172         case 0x8c268086:
  173                 return ("Intel Lynx Point USB 2.0 controller USB-A");
  174         case 0x8c2d8086:
  175                 return ("Intel Lynx Point USB 2.0 controller USB-B");
  176         case 0x8ca68086:
  177                 return ("Intel Wildcat Point USB 2.0 controller USB-A");
  178         case 0x8cad8086:
  179                 return ("Intel Wildcat Point USB 2.0 controller USB-B");
  180         case 0x8d268086:
  181                 return ("Intel Wellsburg USB 2.0 controller");
  182         case 0x8d2d8086:
  183                 return ("Intel Wellsburg USB 2.0 controller");
  184         case 0x9c268086:
  185                 return ("Intel Lynx Point-LP USB 2.0 controller");
  186         case 0x9ca68086:
  187                 return ("Intel Wildcat Point-LP USB 2.0 controller");
  188 
  189         case 0x00e01033:
  190                 return ("NEC uPD 72010x USB 2.0 controller");
  191 
  192         case 0x006810de:
  193                 return "NVIDIA nForce2 USB 2.0 controller";
  194         case 0x008810de:
  195                 return "NVIDIA nForce2 Ultra 400 USB 2.0 controller";
  196         case 0x00d810de:
  197                 return "NVIDIA nForce3 USB 2.0 controller";
  198         case 0x00e810de:
  199                 return "NVIDIA nForce3 250 USB 2.0 controller";
  200         case 0x005b10de:
  201                 return "NVIDIA nForce CK804 USB 2.0 controller";
  202         case 0x036d10de:
  203                 return "NVIDIA nForce MCP55 USB 2.0 controller";
  204         case 0x03f210de:
  205                 return "NVIDIA nForce MCP61 USB 2.0 controller";
  206         case 0x0aa610de:
  207                 return "NVIDIA nForce MCP79 USB 2.0 controller";
  208         case 0x0aa910de:
  209                 return "NVIDIA nForce MCP79 USB 2.0 controller";
  210         case 0x0aaa10de:
  211                 return "NVIDIA nForce MCP79 USB 2.0 controller";
  212 
  213         case 0x15621131:
  214                 return "Philips ISP156x USB 2.0 controller";
  215 
  216         case 0x31041106:
  217                 return ("VIA VT6202 USB 2.0 controller");
  218 
  219         default:
  220                 break;
  221         }
  222 
  223         if ((pci_get_class(self) == PCIC_SERIALBUS)
  224             && (pci_get_subclass(self) == PCIS_SERIALBUS_USB)
  225             && (pci_get_progif(self) == PCI_INTERFACE_EHCI)) {
  226                 return ("EHCI (generic) USB 2.0 controller");
  227         }
  228         return (NULL);                  /* dunno */
  229 }
  230 
  231 static int
  232 ehci_pci_probe(device_t self)
  233 {
  234         const char *desc = ehci_pci_match(self);
  235 
  236         if (desc) {
  237                 device_set_desc(self, desc);
  238                 return (BUS_PROBE_DEFAULT);
  239         } else {
  240                 return (ENXIO);
  241         }
  242 }
  243 
  244 static void
  245 ehci_pci_ati_quirk(device_t self, uint8_t is_sb700)
  246 {
  247         device_t smbdev;
  248         uint32_t val;
  249 
  250         if (is_sb700) {
  251                 /* Lookup SMBUS PCI device */
  252                 smbdev = pci_find_device(PCI_EHCI_VENDORID_ATI, 0x4385);
  253                 if (smbdev == NULL)
  254                         return;
  255                 val = pci_get_revid(smbdev);
  256                 if (val != 0x3a && val != 0x3b)
  257                         return;
  258         }
  259 
  260         /*
  261          * Note: this bit is described as reserved in SB700
  262          * Register Reference Guide.
  263          */
  264         val = pci_read_config(self, 0x53, 1);
  265         if (!(val & 0x8)) {
  266                 val |= 0x8;
  267                 pci_write_config(self, 0x53, val, 1);
  268                 device_printf(self, "AMD SB600/700 quirk applied\n");
  269         }
  270 }
  271 
  272 static void
  273 ehci_pci_via_quirk(device_t self)
  274 {
  275         uint32_t val;
  276 
  277         if ((pci_get_device(self) == 0x3104) && 
  278             ((pci_get_revid(self) & 0xf0) == 0x60)) {
  279                 /* Correct schedule sleep time to 10us */
  280                 val = pci_read_config(self, 0x4b, 1);
  281                 if (val & 0x20)
  282                         return;
  283                 val |= 0x20;
  284                 pci_write_config(self, 0x4b, val, 1);
  285                 device_printf(self, "VIA-quirk applied\n");
  286         }
  287 }
  288 
  289 static int
  290 ehci_pci_attach(device_t self)
  291 {
  292         ehci_softc_t *sc = device_get_softc(self);
  293         int err;
  294         int rid;
  295 
  296         /* initialise some bus fields */
  297         sc->sc_bus.parent = self;
  298         sc->sc_bus.devices = sc->sc_devices;
  299         sc->sc_bus.devices_max = EHCI_MAX_DEVICES;
  300         sc->sc_bus.dma_bits = 32;
  301 
  302         /* get all DMA memory */
  303         if (usb_bus_mem_alloc_all(&sc->sc_bus,
  304             USB_GET_DMA_TAG(self), &ehci_iterate_hw_softc)) {
  305                 return (ENOMEM);
  306         }
  307 
  308         pci_enable_busmaster(self);
  309 
  310         switch (pci_read_config(self, PCI_USBREV, 1) & PCI_USB_REV_MASK) {
  311         case PCI_USB_REV_PRE_1_0:
  312         case PCI_USB_REV_1_0:
  313         case PCI_USB_REV_1_1:
  314                 /*
  315                  * NOTE: some EHCI USB controllers have the wrong USB
  316                  * revision number. It appears those controllers are
  317                  * fully compliant so we just ignore this value in
  318                  * some common cases.
  319                  */
  320                 device_printf(self, "pre-2.0 USB revision (ignored)\n");
  321                 /* fallthrough */
  322         case PCI_USB_REV_2_0:
  323                 break;
  324         default:
  325                 /* Quirk for Parallels Desktop 4.0 */
  326                 device_printf(self, "USB revision is unknown. Assuming v2.0.\n");
  327                 break;
  328         }
  329 
  330         rid = PCI_CBMEM;
  331         sc->sc_io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid,
  332             RF_ACTIVE);
  333         if (!sc->sc_io_res) {
  334                 device_printf(self, "Could not map memory\n");
  335                 goto error;
  336         }
  337         sc->sc_io_tag = rman_get_bustag(sc->sc_io_res);
  338         sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res);
  339         sc->sc_io_size = rman_get_size(sc->sc_io_res);
  340 
  341         rid = 0;
  342         sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid,
  343             RF_SHAREABLE | RF_ACTIVE);
  344         if (sc->sc_irq_res == NULL) {
  345                 device_printf(self, "Could not allocate irq\n");
  346                 goto error;
  347         }
  348         sc->sc_bus.bdev = device_add_child(self, "usbus", -1);
  349         if (!sc->sc_bus.bdev) {
  350                 device_printf(self, "Could not add USB device\n");
  351                 goto error;
  352         }
  353         device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
  354 
  355         /*
  356          * ehci_pci_match will never return NULL if ehci_pci_probe
  357          * succeeded
  358          */
  359         device_set_desc(sc->sc_bus.bdev, ehci_pci_match(self));
  360         switch (pci_get_vendor(self)) {
  361         case PCI_EHCI_VENDORID_ACERLABS:
  362                 sprintf(sc->sc_vendor, "AcerLabs");
  363                 break;
  364         case PCI_EHCI_VENDORID_AMD:
  365                 sprintf(sc->sc_vendor, "AMD");
  366                 break;
  367         case PCI_EHCI_VENDORID_APPLE:
  368                 sprintf(sc->sc_vendor, "Apple");
  369                 break;
  370         case PCI_EHCI_VENDORID_ATI:
  371                 sprintf(sc->sc_vendor, "ATI");
  372                 break;
  373         case PCI_EHCI_VENDORID_CMDTECH:
  374                 sprintf(sc->sc_vendor, "CMDTECH");
  375                 break;
  376         case PCI_EHCI_VENDORID_HYGON:
  377                 sprintf(sc->sc_vendor, "Hygon");
  378                 break;
  379         case PCI_EHCI_VENDORID_INTEL:
  380                 sprintf(sc->sc_vendor, "Intel");
  381                 break;
  382         case PCI_EHCI_VENDORID_NEC:
  383                 sprintf(sc->sc_vendor, "NEC");
  384                 break;
  385         case PCI_EHCI_VENDORID_OPTI:
  386                 sprintf(sc->sc_vendor, "OPTi");
  387                 break;
  388         case PCI_EHCI_VENDORID_PHILIPS:
  389                 sprintf(sc->sc_vendor, "Philips");
  390                 break;
  391         case PCI_EHCI_VENDORID_SIS:
  392                 sprintf(sc->sc_vendor, "SiS");
  393                 break;
  394         case PCI_EHCI_VENDORID_NVIDIA:
  395         case PCI_EHCI_VENDORID_NVIDIA2:
  396                 sprintf(sc->sc_vendor, "nVidia");
  397                 break;
  398         case PCI_EHCI_VENDORID_VIA:
  399                 sprintf(sc->sc_vendor, "VIA");
  400                 break;
  401         default:
  402                 if (bootverbose)
  403                         device_printf(self, "(New EHCI DeviceId=0x%08x)\n",
  404                             pci_get_devid(self));
  405                 sprintf(sc->sc_vendor, "(0x%04x)", pci_get_vendor(self));
  406         }
  407 
  408 #if (__FreeBSD_version >= 700031)
  409         err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
  410             NULL, (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl);
  411 #else
  412         err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
  413             (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl);
  414 #endif
  415         if (err) {
  416                 device_printf(self, "Could not setup irq, %d\n", err);
  417                 sc->sc_intr_hdl = NULL;
  418                 goto error;
  419         }
  420         ehci_pci_take_controller(self);
  421 
  422         /* Undocumented quirks taken from Linux */
  423 
  424         switch (pci_get_vendor(self)) {
  425         case PCI_EHCI_VENDORID_ATI:
  426                 /* SB600 and SB700 EHCI quirk */
  427                 switch (pci_get_device(self)) {
  428                 case 0x4386:
  429                         ehci_pci_ati_quirk(self, 0);
  430                         break;
  431                 case 0x4396:
  432                         ehci_pci_ati_quirk(self, 1);
  433                         break;
  434                 default:
  435                         break;
  436                 }
  437                 break;
  438 
  439         case PCI_EHCI_VENDORID_VIA:
  440                 ehci_pci_via_quirk(self);
  441                 break;
  442 
  443         default:
  444                 break;
  445         }
  446 
  447         /* Dropped interrupts workaround */
  448         switch (pci_get_vendor(self)) {
  449         case PCI_EHCI_VENDORID_ATI:
  450         case PCI_EHCI_VENDORID_VIA:
  451                 sc->sc_flags |= EHCI_SCFLG_LOSTINTRBUG;
  452                 if (bootverbose)
  453                         device_printf(self,
  454                             "Dropped interrupts workaround enabled\n");
  455                 break;
  456         default:
  457                 break;
  458         }
  459 
  460         /* Doorbell feature workaround */
  461         switch (pci_get_vendor(self)) {
  462         case PCI_EHCI_VENDORID_NVIDIA:
  463         case PCI_EHCI_VENDORID_NVIDIA2:
  464                 sc->sc_flags |= EHCI_SCFLG_IAADBUG;
  465                 if (bootverbose)
  466                         device_printf(self,
  467                             "Doorbell workaround enabled\n");
  468                 break;
  469         default:
  470                 break;
  471         }
  472 
  473         err = ehci_init(sc);
  474         if (!err) {
  475                 err = device_probe_and_attach(sc->sc_bus.bdev);
  476         }
  477         if (err) {
  478                 device_printf(self, "USB init failed err=%d\n", err);
  479                 goto error;
  480         }
  481         return (0);
  482 
  483 error:
  484         ehci_pci_detach(self);
  485         return (ENXIO);
  486 }
  487 
  488 static int
  489 ehci_pci_detach(device_t self)
  490 {
  491         ehci_softc_t *sc = device_get_softc(self);
  492 
  493         /* during module unload there are lots of children leftover */
  494         device_delete_children(self);
  495 
  496         pci_disable_busmaster(self);
  497 
  498         if (sc->sc_irq_res && sc->sc_intr_hdl) {
  499                 /*
  500                  * only call ehci_detach() after ehci_init()
  501                  */
  502                 ehci_detach(sc);
  503 
  504                 int err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);
  505 
  506                 if (err)
  507                         /* XXX or should we panic? */
  508                         device_printf(self, "Could not tear down irq, %d\n",
  509                             err);
  510                 sc->sc_intr_hdl = NULL;
  511         }
  512         if (sc->sc_irq_res) {
  513                 bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res);
  514                 sc->sc_irq_res = NULL;
  515         }
  516         if (sc->sc_io_res) {
  517                 bus_release_resource(self, SYS_RES_MEMORY, PCI_CBMEM,
  518                     sc->sc_io_res);
  519                 sc->sc_io_res = NULL;
  520         }
  521         usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);
  522 
  523         return (0);
  524 }
  525 
  526 static int
  527 ehci_pci_take_controller(device_t self)
  528 {
  529         ehci_softc_t *sc = device_get_softc(self);
  530         uint32_t cparams;
  531         uint32_t eec;
  532         uint16_t to;
  533         uint8_t eecp;
  534         uint8_t bios_sem;
  535 
  536         cparams = EREAD4(sc, EHCI_HCCPARAMS);
  537 
  538         /* Synchronise with the BIOS if it owns the controller. */
  539         for (eecp = EHCI_HCC_EECP(cparams); eecp != 0;
  540             eecp = EHCI_EECP_NEXT(eec)) {
  541                 eec = pci_read_config(self, eecp, 4);
  542                 if (EHCI_EECP_ID(eec) != EHCI_EC_LEGSUP) {
  543                         continue;
  544                 }
  545                 bios_sem = pci_read_config(self, eecp +
  546                     EHCI_LEGSUP_BIOS_SEM, 1);
  547                 if (bios_sem == 0) {
  548                         continue;
  549                 }
  550                 device_printf(sc->sc_bus.bdev, "waiting for BIOS "
  551                     "to give up control\n");
  552                 pci_write_config(self, eecp +
  553                     EHCI_LEGSUP_OS_SEM, 1, 1);
  554                 to = 500;
  555                 while (1) {
  556                         bios_sem = pci_read_config(self, eecp +
  557                             EHCI_LEGSUP_BIOS_SEM, 1);
  558                         if (bios_sem == 0)
  559                                 break;
  560 
  561                         if (--to == 0) {
  562                                 device_printf(sc->sc_bus.bdev,
  563                                     "timed out waiting for BIOS\n");
  564                                 break;
  565                         }
  566                         usb_pause_mtx(NULL, hz / 100);  /* wait 10ms */
  567                 }
  568         }
  569         return (0);
  570 }
  571 
  572 static device_method_t ehci_pci_methods[] = {
  573         /* Device interface */
  574         DEVMETHOD(device_probe, ehci_pci_probe),
  575         DEVMETHOD(device_attach, ehci_pci_attach),
  576         DEVMETHOD(device_detach, ehci_pci_detach),
  577         DEVMETHOD(device_suspend, bus_generic_suspend),
  578         DEVMETHOD(device_resume, bus_generic_resume),
  579         DEVMETHOD(device_shutdown, bus_generic_shutdown),
  580         DEVMETHOD(usb_take_controller, ehci_pci_take_controller),
  581 
  582         DEVMETHOD_END
  583 };
  584 
  585 static driver_t ehci_driver = {
  586         .name = "ehci",
  587         .methods = ehci_pci_methods,
  588         .size = sizeof(struct ehci_softc),
  589 };
  590 
  591 static devclass_t ehci_devclass;
  592 
  593 DRIVER_MODULE(ehci, pci, ehci_driver, ehci_devclass, 0, 0);
  594 MODULE_DEPEND(ehci, usb, 1, 1, 1);

Cache object: 078b7b89c744458f3bf23017bc5ea52e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.