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

Cache object: 759a86f09bdcf4afd040f9b097b48063


[ 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.