17ff71d6aSMatt Porter /* 27ff71d6aSMatt Porter * EHCI HCD (Host Controller Driver) PCI Bus Glue. 37ff71d6aSMatt Porter * 47ff71d6aSMatt Porter * Copyright (c) 2000-2004 by David Brownell 57ff71d6aSMatt Porter * 67ff71d6aSMatt Porter * This program is free software; you can redistribute it and/or modify it 77ff71d6aSMatt Porter * under the terms of the GNU General Public License as published by the 87ff71d6aSMatt Porter * Free Software Foundation; either version 2 of the License, or (at your 97ff71d6aSMatt Porter * option) any later version. 107ff71d6aSMatt Porter * 117ff71d6aSMatt Porter * This program is distributed in the hope that it will be useful, but 127ff71d6aSMatt Porter * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 137ff71d6aSMatt Porter * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 147ff71d6aSMatt Porter * for more details. 157ff71d6aSMatt Porter * 167ff71d6aSMatt Porter * You should have received a copy of the GNU General Public License 177ff71d6aSMatt Porter * along with this program; if not, write to the Free Software Foundation, 187ff71d6aSMatt Porter * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 197ff71d6aSMatt Porter */ 207ff71d6aSMatt Porter 217ff71d6aSMatt Porter #ifndef CONFIG_PCI 227ff71d6aSMatt Porter #error "This file is PCI bus glue. CONFIG_PCI must be defined." 237ff71d6aSMatt Porter #endif 247ff71d6aSMatt Porter 254f683843SDirk Brandewie /* defined here to avoid adding to pci_ids.h for single instance use */ 264f683843SDirk Brandewie #define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70 274f683843SDirk Brandewie 287ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/ 297ff71d6aSMatt Porter 3018807521SDavid Brownell /* called after powerup, by probe or system-pm "wakeup" */ 3118807521SDavid Brownell static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) 3218807521SDavid Brownell { 3318807521SDavid Brownell int retval; 3418807521SDavid Brownell 35401feafaSDavid Brownell /* we expect static quirk code to handle the "extended capabilities" 36401feafaSDavid Brownell * (currently just BIOS handoff) allowed starting with EHCI 0.96 37401feafaSDavid Brownell */ 3818807521SDavid Brownell 3918807521SDavid Brownell /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */ 4018807521SDavid Brownell retval = pci_set_mwi(pdev); 4118807521SDavid Brownell if (!retval) 4218807521SDavid Brownell ehci_dbg(ehci, "MWI active\n"); 4318807521SDavid Brownell 4418807521SDavid Brownell return 0; 4518807521SDavid Brownell } 4618807521SDavid Brownell 478926bfa7SDavid Brownell /* called during probe() after chip reset completes */ 488926bfa7SDavid Brownell static int ehci_pci_setup(struct usb_hcd *hcd) 497ff71d6aSMatt Porter { 507ff71d6aSMatt Porter struct ehci_hcd *ehci = hcd_to_ehci(hcd); 51abcc9448SDavid Brownell struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 52b09bc6cbSAndiry Xu struct pci_dev *p_smbus; 53b09bc6cbSAndiry Xu u8 rev; 547ff71d6aSMatt Porter u32 temp; 5518807521SDavid Brownell int retval; 567ff71d6aSMatt Porter 57*1a49e2acSAlan Stern ehci->caps = hcd->regs; 58*1a49e2acSAlan Stern 59*1a49e2acSAlan Stern /* 60*1a49e2acSAlan Stern * ehci_init() causes memory for DMA transfers to be 61*1a49e2acSAlan Stern * allocated. Thus, any vendor-specific workarounds based on 62*1a49e2acSAlan Stern * limiting the type of memory used for DMA transfers must 63*1a49e2acSAlan Stern * happen before ehci_setup() is called. 64*1a49e2acSAlan Stern * 65*1a49e2acSAlan Stern * Most other workarounds can be done either before or after 66*1a49e2acSAlan Stern * init and reset; they are located here too. 67*1a49e2acSAlan Stern */ 68083522d7SBenjamin Herrenschmidt switch (pdev->vendor) { 69083522d7SBenjamin Herrenschmidt case PCI_VENDOR_ID_TOSHIBA_2: 70083522d7SBenjamin Herrenschmidt /* celleb's companion chip */ 71083522d7SBenjamin Herrenschmidt if (pdev->device == 0x01b5) { 72083522d7SBenjamin Herrenschmidt #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO 73083522d7SBenjamin Herrenschmidt ehci->big_endian_mmio = 1; 74083522d7SBenjamin Herrenschmidt #else 75083522d7SBenjamin Herrenschmidt ehci_warn(ehci, 76083522d7SBenjamin Herrenschmidt "unsupported big endian Toshiba quirk\n"); 77083522d7SBenjamin Herrenschmidt #endif 78083522d7SBenjamin Herrenschmidt } 79083522d7SBenjamin Herrenschmidt break; 80c32ba30fSPaul Serice case PCI_VENDOR_ID_NVIDIA: 81c32ba30fSPaul Serice /* NVidia reports that certain chips don't handle 82c32ba30fSPaul Serice * QH, ITD, or SITD addresses above 2GB. (But TD, 83c32ba30fSPaul Serice * data buffer, and periodic schedule are normal.) 84c32ba30fSPaul Serice */ 85c32ba30fSPaul Serice switch (pdev->device) { 86c32ba30fSPaul Serice case 0x003c: /* MCP04 */ 87c32ba30fSPaul Serice case 0x005b: /* CK804 */ 88c32ba30fSPaul Serice case 0x00d8: /* CK8 */ 89c32ba30fSPaul Serice case 0x00e8: /* CK8S */ 90c32ba30fSPaul Serice if (pci_set_consistent_dma_mask(pdev, 91929a22a5SYang Hongyang DMA_BIT_MASK(31)) < 0) 92c32ba30fSPaul Serice ehci_warn(ehci, "can't enable NVidia " 93c32ba30fSPaul Serice "workaround for >2GB RAM\n"); 94c32ba30fSPaul Serice break; 95*1a49e2acSAlan Stern 96*1a49e2acSAlan Stern /* Some NForce2 chips have problems with selective suspend; 97*1a49e2acSAlan Stern * fixed in newer silicon. 98*1a49e2acSAlan Stern */ 99*1a49e2acSAlan Stern case 0x0068: 100*1a49e2acSAlan Stern if (pdev->revision < 0xa4) 101*1a49e2acSAlan Stern ehci->no_selective_suspend = 1; 102c32ba30fSPaul Serice break; 103c32ba30fSPaul Serice } 1043681d8f3SDavid Miller break; 105403dbd36SAlek Du case PCI_VENDOR_ID_INTEL: 106ae68a83bSAlan Stern ehci->fs_i_thresh = 1; 107ee4ecb8aSOliver Neukum if (pdev->device == 0x27cc) { 108ee4ecb8aSOliver Neukum ehci->broken_periodic = 1; 109ee4ecb8aSOliver Neukum ehci_info(ehci, "using broken periodic workaround\n"); 110ee4ecb8aSOliver Neukum } 111*1a49e2acSAlan Stern if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB) 1124f683843SDirk Brandewie hcd->has_tt = 1; 113403dbd36SAlek Du break; 1147ff71d6aSMatt Porter case PCI_VENDOR_ID_TDI: 115*1a49e2acSAlan Stern if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) 1167329e211SAlan Stern hcd->has_tt = 1; 1177ff71d6aSMatt Porter break; 1187ff71d6aSMatt Porter case PCI_VENDOR_ID_AMD: 119ad93562bSAndiry Xu /* AMD PLL quirk */ 120ad93562bSAndiry Xu if (usb_amd_find_chipset_info()) 121ad93562bSAndiry Xu ehci->amd_pll_fix = 1; 1227ff71d6aSMatt Porter /* AMD8111 EHCI doesn't work, according to AMD errata */ 1237ff71d6aSMatt Porter if (pdev->device == 0x7463) { 1247ff71d6aSMatt Porter ehci_info(ehci, "ignoring AMD8111 (errata)\n"); 1258926bfa7SDavid Brownell retval = -EIO; 1268926bfa7SDavid Brownell goto done; 1277ff71d6aSMatt Porter } 128a85b4e7fSBrian J. Tarricone 129*1a49e2acSAlan Stern /* 130*1a49e2acSAlan Stern * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may 131*1a49e2acSAlan Stern * read/write memory space which does not belong to it when 132*1a49e2acSAlan Stern * there is NULL pointer with T-bit set to 1 in the frame list 133*1a49e2acSAlan Stern * table. To avoid the issue, the frame list link pointer 134*1a49e2acSAlan Stern * should always contain a valid pointer to a inactive qh. 135a85b4e7fSBrian J. Tarricone */ 136*1a49e2acSAlan Stern if (pdev->device == 0x7808) { 137*1a49e2acSAlan Stern ehci->use_dummy_qh = 1; 138*1a49e2acSAlan Stern ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n"); 1397ff71d6aSMatt Porter } 1407ff71d6aSMatt Porter break; 141055b93c9SRene Herman case PCI_VENDOR_ID_VIA: 142055b93c9SRene Herman if (pdev->device == 0x3104 && (pdev->revision & 0xf0) == 0x60) { 143055b93c9SRene Herman u8 tmp; 144055b93c9SRene Herman 145055b93c9SRene Herman /* The VT6212 defaults to a 1 usec EHCI sleep time which 146055b93c9SRene Herman * hogs the PCI bus *badly*. Setting bit 5 of 0x4B makes 147055b93c9SRene Herman * that sleep time use the conventional 10 usec. 148055b93c9SRene Herman */ 149055b93c9SRene Herman pci_read_config_byte(pdev, 0x4b, &tmp); 150055b93c9SRene Herman if (tmp & 0x20) 151055b93c9SRene Herman break; 152055b93c9SRene Herman pci_write_config_byte(pdev, 0x4b, tmp | 0x20); 153055b93c9SRene Herman } 154055b93c9SRene Herman break; 155b09bc6cbSAndiry Xu case PCI_VENDOR_ID_ATI: 156ad93562bSAndiry Xu /* AMD PLL quirk */ 157ad93562bSAndiry Xu if (usb_amd_find_chipset_info()) 158ad93562bSAndiry Xu ehci->amd_pll_fix = 1; 159*1a49e2acSAlan Stern 160*1a49e2acSAlan Stern /* 161*1a49e2acSAlan Stern * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may 162*1a49e2acSAlan Stern * read/write memory space which does not belong to it when 163*1a49e2acSAlan Stern * there is NULL pointer with T-bit set to 1 in the frame list 164*1a49e2acSAlan Stern * table. To avoid the issue, the frame list link pointer 165*1a49e2acSAlan Stern * should always contain a valid pointer to a inactive qh. 166*1a49e2acSAlan Stern */ 167*1a49e2acSAlan Stern if (pdev->device == 0x4396) { 168*1a49e2acSAlan Stern ehci->use_dummy_qh = 1; 169*1a49e2acSAlan Stern ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n"); 170*1a49e2acSAlan Stern } 1710a99e8acSShane Huang /* SB600 and old version of SB700 have a bug in EHCI controller, 172b09bc6cbSAndiry Xu * which causes usb devices lose response in some cases. 173b09bc6cbSAndiry Xu */ 1740a99e8acSShane Huang if ((pdev->device == 0x4386) || (pdev->device == 0x4396)) { 175b09bc6cbSAndiry Xu p_smbus = pci_get_device(PCI_VENDOR_ID_ATI, 176b09bc6cbSAndiry Xu PCI_DEVICE_ID_ATI_SBX00_SMBUS, 177b09bc6cbSAndiry Xu NULL); 178b09bc6cbSAndiry Xu if (!p_smbus) 179b09bc6cbSAndiry Xu break; 180b09bc6cbSAndiry Xu rev = p_smbus->revision; 1810a99e8acSShane Huang if ((pdev->device == 0x4386) || (rev == 0x3a) 1820a99e8acSShane Huang || (rev == 0x3b)) { 183b09bc6cbSAndiry Xu u8 tmp; 1840a99e8acSShane Huang ehci_info(ehci, "applying AMD SB600/SB700 USB " 1850a99e8acSShane Huang "freeze workaround\n"); 186b09bc6cbSAndiry Xu pci_read_config_byte(pdev, 0x53, &tmp); 187b09bc6cbSAndiry Xu pci_write_config_byte(pdev, 0x53, tmp | (1<<3)); 188b09bc6cbSAndiry Xu } 189b09bc6cbSAndiry Xu pci_dev_put(p_smbus); 190b09bc6cbSAndiry Xu } 191b09bc6cbSAndiry Xu break; 19268aa95d5SAlan Stern case PCI_VENDOR_ID_NETMOS: 19368aa95d5SAlan Stern /* MosChip frame-index-register bug */ 19468aa95d5SAlan Stern ehci_info(ehci, "applying MosChip frame-index workaround\n"); 19568aa95d5SAlan Stern ehci->frame_index_bug = 1; 19668aa95d5SAlan Stern break; 1977ff71d6aSMatt Porter } 1987ff71d6aSMatt Porter 199*1a49e2acSAlan Stern retval = ehci_setup(hcd); 200*1a49e2acSAlan Stern if (retval) 201*1a49e2acSAlan Stern return retval; 202*1a49e2acSAlan Stern 203*1a49e2acSAlan Stern /* These workarounds need to be applied after ehci_setup() */ 204*1a49e2acSAlan Stern switch (pdev->vendor) { 205*1a49e2acSAlan Stern case PCI_VENDOR_ID_NEC: 206*1a49e2acSAlan Stern ehci->need_io_watchdog = 0; 207*1a49e2acSAlan Stern break; 208*1a49e2acSAlan Stern case PCI_VENDOR_ID_INTEL: 209*1a49e2acSAlan Stern ehci->need_io_watchdog = 0; 210*1a49e2acSAlan Stern if (pdev->device == 0x0806 || pdev->device == 0x0811 211*1a49e2acSAlan Stern || pdev->device == 0x0829) { 212*1a49e2acSAlan Stern ehci_info(ehci, "disable lpm for langwell/penwell\n"); 213*1a49e2acSAlan Stern ehci->has_lpm = 0; 214*1a49e2acSAlan Stern } 215*1a49e2acSAlan Stern break; 216*1a49e2acSAlan Stern case PCI_VENDOR_ID_NVIDIA: 217*1a49e2acSAlan Stern switch (pdev->device) { 218*1a49e2acSAlan Stern /* MCP89 chips on the MacBookAir3,1 give EPROTO when 219*1a49e2acSAlan Stern * fetching device descriptors unless LPM is disabled. 220*1a49e2acSAlan Stern * There are also intermittent problems enumerating 221*1a49e2acSAlan Stern * devices with PPCD enabled. 222*1a49e2acSAlan Stern */ 223*1a49e2acSAlan Stern case 0x0d9d: 224*1a49e2acSAlan Stern ehci_info(ehci, "disable lpm/ppcd for nvidia mcp89"); 225*1a49e2acSAlan Stern ehci->has_lpm = 0; 226*1a49e2acSAlan Stern ehci->has_ppcd = 0; 227*1a49e2acSAlan Stern ehci->command &= ~CMD_PPCEE; 228*1a49e2acSAlan Stern break; 229*1a49e2acSAlan Stern } 230*1a49e2acSAlan Stern break; 231*1a49e2acSAlan Stern } 232*1a49e2acSAlan Stern 2338d053c79SJason Wessel /* optional debug port, normally in the first BAR */ 2348d053c79SJason Wessel temp = pci_find_capability(pdev, 0x0a); 2358d053c79SJason Wessel if (temp) { 2368d053c79SJason Wessel pci_read_config_dword(pdev, temp, &temp); 2378d053c79SJason Wessel temp >>= 16; 2388d053c79SJason Wessel if ((temp & (3 << 13)) == (1 << 13)) { 2398d053c79SJason Wessel temp &= 0x1fff; 240*1a49e2acSAlan Stern ehci->debug = hcd->regs + temp; 2418d053c79SJason Wessel temp = ehci_readl(ehci, &ehci->debug->control); 2428d053c79SJason Wessel ehci_info(ehci, "debug port %d%s\n", 2438d053c79SJason Wessel HCS_DEBUG_PORT(ehci->hcs_params), 2448d053c79SJason Wessel (temp & DBGP_ENABLED) 2458d053c79SJason Wessel ? " IN USE" 2468d053c79SJason Wessel : ""); 2478d053c79SJason Wessel if (!(temp & DBGP_ENABLED)) 2488d053c79SJason Wessel ehci->debug = NULL; 2498d053c79SJason Wessel } 2508d053c79SJason Wessel } 2518d053c79SJason Wessel 2527ff71d6aSMatt Porter /* at least the Genesys GL880S needs fixup here */ 2537ff71d6aSMatt Porter temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); 2547ff71d6aSMatt Porter temp &= 0x0f; 2557ff71d6aSMatt Porter if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) { 2567ff71d6aSMatt Porter ehci_dbg(ehci, "bogus port configuration: " 2577ff71d6aSMatt Porter "cc=%d x pcc=%d < ports=%d\n", 2587ff71d6aSMatt Porter HCS_N_CC(ehci->hcs_params), 2597ff71d6aSMatt Porter HCS_N_PCC(ehci->hcs_params), 2607ff71d6aSMatt Porter HCS_N_PORTS(ehci->hcs_params)); 2617ff71d6aSMatt Porter 2627ff71d6aSMatt Porter switch (pdev->vendor) { 2637ff71d6aSMatt Porter case 0x17a0: /* GENESYS */ 2647ff71d6aSMatt Porter /* GL880S: should be PORTS=2 */ 2657ff71d6aSMatt Porter temp |= (ehci->hcs_params & ~0xf); 2667ff71d6aSMatt Porter ehci->hcs_params = temp; 2677ff71d6aSMatt Porter break; 2687ff71d6aSMatt Porter case PCI_VENDOR_ID_NVIDIA: 2697ff71d6aSMatt Porter /* NF4: should be PCC=10 */ 2707ff71d6aSMatt Porter break; 2717ff71d6aSMatt Porter } 2727ff71d6aSMatt Porter } 2737ff71d6aSMatt Porter 2747ff71d6aSMatt Porter /* Serial Bus Release Number is at PCI 0x60 offset */ 2753a0bac06SAlessandro Rubini if (pdev->vendor == PCI_VENDOR_ID_STMICRO 2763a0bac06SAlessandro Rubini && pdev->device == PCI_DEVICE_ID_STMICRO_USB_HOST) 277*1a49e2acSAlan Stern ; /* ConneXT has no sbrn register */ 278*1a49e2acSAlan Stern else 279*1a49e2acSAlan Stern pci_read_config_byte(pdev, 0x60, &ehci->sbrn); 2807ff71d6aSMatt Porter 2816fd9086aSAlan Stern /* Keep this around for a while just in case some EHCI 2826fd9086aSAlan Stern * implementation uses legacy PCI PM support. This test 2836fd9086aSAlan Stern * can be removed on 17 Dec 2009 if the dev_warn() hasn't 2846fd9086aSAlan Stern * been triggered by then. 2852c1c3c4cSDavid Brownell */ 2862c1c3c4cSDavid Brownell if (!device_can_wakeup(&pdev->dev)) { 2872c1c3c4cSDavid Brownell u16 port_wake; 2882c1c3c4cSDavid Brownell 2892c1c3c4cSDavid Brownell pci_read_config_word(pdev, 0x62, &port_wake); 2906fd9086aSAlan Stern if (port_wake & 0x0001) { 2916fd9086aSAlan Stern dev_warn(&pdev->dev, "Enabling legacy PCI PM\n"); 292bcca06efSAlan Stern device_set_wakeup_capable(&pdev->dev, 1); 2932c1c3c4cSDavid Brownell } 2946fd9086aSAlan Stern } 2957ff71d6aSMatt Porter 296f8aeb3bbSDavid Brownell #ifdef CONFIG_USB_SUSPEND 297f8aeb3bbSDavid Brownell /* REVISIT: the controller works fine for wakeup iff the root hub 298f8aeb3bbSDavid Brownell * itself is "globally" suspended, but usbcore currently doesn't 299f8aeb3bbSDavid Brownell * understand such things. 300f8aeb3bbSDavid Brownell * 301f8aeb3bbSDavid Brownell * System suspend currently expects to be able to suspend the entire 302f8aeb3bbSDavid Brownell * device tree, device-at-a-time. If we failed selective suspend 303f8aeb3bbSDavid Brownell * reports, system suspend would fail; so the root hub code must claim 304411c9403SAnand Gadiyar * success. That's lying to usbcore, and it matters for runtime 305f8aeb3bbSDavid Brownell * PM scenarios with selective suspend and remote wakeup... 306f8aeb3bbSDavid Brownell */ 307f8aeb3bbSDavid Brownell if (ehci->no_selective_suspend && device_can_wakeup(&pdev->dev)) 308f8aeb3bbSDavid Brownell ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); 309f8aeb3bbSDavid Brownell #endif 310f8aeb3bbSDavid Brownell 311aff6d18fSAlan Stern ehci_port_power(ehci, 1); 31218807521SDavid Brownell retval = ehci_pci_reinit(ehci, pdev); 3138926bfa7SDavid Brownell done: 3148926bfa7SDavid Brownell return retval; 3157ff71d6aSMatt Porter } 3167ff71d6aSMatt Porter 3177ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/ 3187ff71d6aSMatt Porter 3197ff71d6aSMatt Porter #ifdef CONFIG_PM 3207ff71d6aSMatt Porter 3217ff71d6aSMatt Porter /* suspend/resume, section 4.3 */ 3227ff71d6aSMatt Porter 323f03c17fcSDavid Brownell /* These routines rely on the PCI bus glue 3247ff71d6aSMatt Porter * to handle powerdown and wakeup, and currently also on 3257ff71d6aSMatt Porter * transceivers that don't need any software attention to set up 3267ff71d6aSMatt Porter * the right sort of wakeup. 327f03c17fcSDavid Brownell * Also they depend on separate root hub suspend/resume. 3287ff71d6aSMatt Porter */ 3297ff71d6aSMatt Porter 3304147200dSAlan Stern static int ehci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) 3317ff71d6aSMatt Porter { 332c5cf9212SAlan Stern return ehci_suspend(hcd, do_wakeup); 3337ff71d6aSMatt Porter } 3347ff71d6aSMatt Porter 33569e848c2SSarah Sharp static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev) 33669e848c2SSarah Sharp { 33769e848c2SSarah Sharp return pdev->class == PCI_CLASS_SERIAL_USB_EHCI && 33869e848c2SSarah Sharp pdev->vendor == PCI_VENDOR_ID_INTEL && 3391c12443aSSarah Sharp (pdev->device == 0x1E26 || 3401c12443aSSarah Sharp pdev->device == 0x8C2D || 3411c12443aSSarah Sharp pdev->device == 0x8C26); 34269e848c2SSarah Sharp } 34369e848c2SSarah Sharp 34469e848c2SSarah Sharp static void ehci_enable_xhci_companion(void) 34569e848c2SSarah Sharp { 34669e848c2SSarah Sharp struct pci_dev *companion = NULL; 34769e848c2SSarah Sharp 34869e848c2SSarah Sharp /* The xHCI and EHCI controllers are not on the same PCI slot */ 34969e848c2SSarah Sharp for_each_pci_dev(companion) { 35069e848c2SSarah Sharp if (!usb_is_intel_switchable_xhci(companion)) 35169e848c2SSarah Sharp continue; 35269e848c2SSarah Sharp usb_enable_xhci_ports(companion); 35369e848c2SSarah Sharp return; 35469e848c2SSarah Sharp } 35569e848c2SSarah Sharp } 35669e848c2SSarah Sharp 3576ec4beb5SAlan Stern static int ehci_pci_resume(struct usb_hcd *hcd, bool hibernated) 3587ff71d6aSMatt Porter { 3597ff71d6aSMatt Porter struct ehci_hcd *ehci = hcd_to_ehci(hcd); 36018807521SDavid Brownell struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 3617ff71d6aSMatt Porter 36269e848c2SSarah Sharp /* The BIOS on systems with the Intel Panther Point chipset may or may 36369e848c2SSarah Sharp * not support xHCI natively. That means that during system resume, it 36469e848c2SSarah Sharp * may switch the ports back to EHCI so that users can use their 36569e848c2SSarah Sharp * keyboard to select a kernel from GRUB after resume from hibernate. 36669e848c2SSarah Sharp * 36769e848c2SSarah Sharp * The BIOS is supposed to remember whether the OS had xHCI ports 36869e848c2SSarah Sharp * enabled before resume, and switch the ports back to xHCI when the 36969e848c2SSarah Sharp * BIOS/OS semaphore is written, but we all know we can't trust BIOS 37069e848c2SSarah Sharp * writers. 37169e848c2SSarah Sharp * 37269e848c2SSarah Sharp * Unconditionally switch the ports back to xHCI after a system resume. 37369e848c2SSarah Sharp * We can't tell whether the EHCI or xHCI controller will be resumed 37469e848c2SSarah Sharp * first, so we have to do the port switchover in both drivers. Writing 37569e848c2SSarah Sharp * a '1' to the port switchover registers should have no effect if the 37669e848c2SSarah Sharp * port was already switched over. 37769e848c2SSarah Sharp */ 37869e848c2SSarah Sharp if (usb_is_intel_switchable_ehci(pdev)) 37969e848c2SSarah Sharp ehci_enable_xhci_companion(); 38069e848c2SSarah Sharp 381c5cf9212SAlan Stern if (ehci_resume(hcd, hibernated) != 0) 38218807521SDavid Brownell (void) ehci_pci_reinit(ehci, pdev); 3838c03356aSAlan Stern return 0; 3847ff71d6aSMatt Porter } 3857ff71d6aSMatt Porter #endif 3867ff71d6aSMatt Porter 38748f24970SAlek Du static int ehci_update_device(struct usb_hcd *hcd, struct usb_device *udev) 38848f24970SAlek Du { 38948f24970SAlek Du struct ehci_hcd *ehci = hcd_to_ehci(hcd); 39048f24970SAlek Du int rc = 0; 39148f24970SAlek Du 39248f24970SAlek Du if (!udev->parent) /* udev is root hub itself, impossible */ 39348f24970SAlek Du rc = -1; 39448f24970SAlek Du /* we only support lpm device connected to root hub yet */ 39548f24970SAlek Du if (ehci->has_lpm && !udev->parent->parent) { 39648f24970SAlek Du rc = ehci_lpm_set_da(ehci, udev->devnum, udev->portnum); 39748f24970SAlek Du if (!rc) 39848f24970SAlek Du rc = ehci_lpm_check(ehci, udev->portnum); 39948f24970SAlek Du } 40048f24970SAlek Du return rc; 40148f24970SAlek Du } 40248f24970SAlek Du 4037ff71d6aSMatt Porter static const struct hc_driver ehci_pci_hc_driver = { 4047ff71d6aSMatt Porter .description = hcd_name, 4057ff71d6aSMatt Porter .product_desc = "EHCI Host Controller", 4067ff71d6aSMatt Porter .hcd_priv_size = sizeof(struct ehci_hcd), 4077ff71d6aSMatt Porter 4087ff71d6aSMatt Porter /* 4097ff71d6aSMatt Porter * generic hardware linkage 4107ff71d6aSMatt Porter */ 4117ff71d6aSMatt Porter .irq = ehci_irq, 4127ff71d6aSMatt Porter .flags = HCD_MEMORY | HCD_USB2, 4137ff71d6aSMatt Porter 4147ff71d6aSMatt Porter /* 4157ff71d6aSMatt Porter * basic lifecycle operations 4167ff71d6aSMatt Porter */ 4178926bfa7SDavid Brownell .reset = ehci_pci_setup, 41818807521SDavid Brownell .start = ehci_run, 4197ff71d6aSMatt Porter #ifdef CONFIG_PM 4207be7d741SAlan Stern .pci_suspend = ehci_pci_suspend, 4217be7d741SAlan Stern .pci_resume = ehci_pci_resume, 4227ff71d6aSMatt Porter #endif 42318807521SDavid Brownell .stop = ehci_stop, 42464a21d02SAleksey Gorelov .shutdown = ehci_shutdown, 4257ff71d6aSMatt Porter 4267ff71d6aSMatt Porter /* 4277ff71d6aSMatt Porter * managing i/o requests and associated device resources 4287ff71d6aSMatt Porter */ 4297ff71d6aSMatt Porter .urb_enqueue = ehci_urb_enqueue, 4307ff71d6aSMatt Porter .urb_dequeue = ehci_urb_dequeue, 4317ff71d6aSMatt Porter .endpoint_disable = ehci_endpoint_disable, 432b18ffd49SAlan Stern .endpoint_reset = ehci_endpoint_reset, 4337ff71d6aSMatt Porter 4347ff71d6aSMatt Porter /* 4357ff71d6aSMatt Porter * scheduling support 4367ff71d6aSMatt Porter */ 4377ff71d6aSMatt Porter .get_frame_number = ehci_get_frame, 4387ff71d6aSMatt Porter 4397ff71d6aSMatt Porter /* 4407ff71d6aSMatt Porter * root hub support 4417ff71d6aSMatt Porter */ 4427ff71d6aSMatt Porter .hub_status_data = ehci_hub_status_data, 4437ff71d6aSMatt Porter .hub_control = ehci_hub_control, 4440c0382e3SAlan Stern .bus_suspend = ehci_bus_suspend, 4450c0382e3SAlan Stern .bus_resume = ehci_bus_resume, 44690da096eSBalaji Rao .relinquish_port = ehci_relinquish_port, 4473a31155cSAlan Stern .port_handed_over = ehci_port_handed_over, 448914b7012SAlan Stern 44948f24970SAlek Du /* 45048f24970SAlek Du * call back when device connected and addressed 45148f24970SAlek Du */ 45248f24970SAlek Du .update_device = ehci_update_device, 45348f24970SAlek Du 454914b7012SAlan Stern .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 4557ff71d6aSMatt Porter }; 4567ff71d6aSMatt Porter 4577ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/ 4587ff71d6aSMatt Porter 4597ff71d6aSMatt Porter /* PCI driver selection metadata; PCI hotplugging uses this */ 4607ff71d6aSMatt Porter static const struct pci_device_id pci_ids [] = { { 4617ff71d6aSMatt Porter /* handle any USB 2.0 EHCI controller */ 462c67808eeSJean Delvare PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0), 4637ff71d6aSMatt Porter .driver_data = (unsigned long) &ehci_pci_hc_driver, 4643a0bac06SAlessandro Rubini }, { 4653a0bac06SAlessandro Rubini PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST), 4663a0bac06SAlessandro Rubini .driver_data = (unsigned long) &ehci_pci_hc_driver, 4677ff71d6aSMatt Porter }, 4687ff71d6aSMatt Porter { /* end: all zeroes */ } 4697ff71d6aSMatt Porter }; 4707ff71d6aSMatt Porter MODULE_DEVICE_TABLE(pci, pci_ids); 4717ff71d6aSMatt Porter 4727ff71d6aSMatt Porter /* pci driver glue; this is a "new style" PCI driver module */ 4737ff71d6aSMatt Porter static struct pci_driver ehci_pci_driver = { 4747ff71d6aSMatt Porter .name = (char *) hcd_name, 4757ff71d6aSMatt Porter .id_table = pci_ids, 4767ff71d6aSMatt Porter 4777ff71d6aSMatt Porter .probe = usb_hcd_pci_probe, 4787ff71d6aSMatt Porter .remove = usb_hcd_pci_remove, 47964a21d02SAleksey Gorelov .shutdown = usb_hcd_pci_shutdown, 480abb30641SAlan Stern 481abb30641SAlan Stern #ifdef CONFIG_PM_SLEEP 482abb30641SAlan Stern .driver = { 483abb30641SAlan Stern .pm = &usb_hcd_pci_pm_ops 484abb30641SAlan Stern }, 485abb30641SAlan Stern #endif 4867ff71d6aSMatt Porter }; 487