1*5fd54aceSGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0+ 27ff71d6aSMatt Porter /* 37ff71d6aSMatt Porter * EHCI HCD (Host Controller Driver) PCI Bus Glue. 47ff71d6aSMatt Porter * 57ff71d6aSMatt Porter * Copyright (c) 2000-2004 by David Brownell 67ff71d6aSMatt Porter * 77ff71d6aSMatt Porter * This program is free software; you can redistribute it and/or modify it 87ff71d6aSMatt Porter * under the terms of the GNU General Public License as published by the 97ff71d6aSMatt Porter * Free Software Foundation; either version 2 of the License, or (at your 107ff71d6aSMatt Porter * option) any later version. 117ff71d6aSMatt Porter * 127ff71d6aSMatt Porter * This program is distributed in the hope that it will be useful, but 137ff71d6aSMatt Porter * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 147ff71d6aSMatt Porter * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 157ff71d6aSMatt Porter * for more details. 167ff71d6aSMatt Porter * 177ff71d6aSMatt Porter * You should have received a copy of the GNU General Public License 187ff71d6aSMatt Porter * along with this program; if not, write to the Free Software Foundation, 197ff71d6aSMatt Porter * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 207ff71d6aSMatt Porter */ 217ff71d6aSMatt Porter 22adfa79d1SAlan Stern #include <linux/kernel.h> 23adfa79d1SAlan Stern #include <linux/module.h> 24adfa79d1SAlan Stern #include <linux/pci.h> 25adfa79d1SAlan Stern #include <linux/usb.h> 26adfa79d1SAlan Stern #include <linux/usb/hcd.h> 27adfa79d1SAlan Stern 28adfa79d1SAlan Stern #include "ehci.h" 29adfa79d1SAlan Stern #include "pci-quirks.h" 30adfa79d1SAlan Stern 31adfa79d1SAlan Stern #define DRIVER_DESC "EHCI PCI platform driver" 32adfa79d1SAlan Stern 33adfa79d1SAlan Stern static const char hcd_name[] = "ehci-pci"; 347ff71d6aSMatt Porter 354f683843SDirk Brandewie /* defined here to avoid adding to pci_ids.h for single instance use */ 364f683843SDirk Brandewie #define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70 374f683843SDirk Brandewie 387ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/ 396e693739SBryan O'Donoghue #define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC 0x0939 406e693739SBryan O'Donoghue static inline bool is_intel_quark_x1000(struct pci_dev *pdev) 416e693739SBryan O'Donoghue { 426e693739SBryan O'Donoghue return pdev->vendor == PCI_VENDOR_ID_INTEL && 436e693739SBryan O'Donoghue pdev->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC; 446e693739SBryan O'Donoghue } 456e693739SBryan O'Donoghue 46518ca8d9SAndy Shevchenko /* 47518ca8d9SAndy Shevchenko * This is the list of PCI IDs for the devices that have EHCI USB class and 48518ca8d9SAndy Shevchenko * specific drivers for that. One of the example is a ChipIdea device installed 49518ca8d9SAndy Shevchenko * on some Intel MID platforms. 50518ca8d9SAndy Shevchenko */ 51518ca8d9SAndy Shevchenko static const struct pci_device_id bypass_pci_id_table[] = { 52518ca8d9SAndy Shevchenko /* ChipIdea on Intel MID platform */ 53cefa9a31SAndy Shevchenko { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0811), }, 54cefa9a31SAndy Shevchenko { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0829), }, 55cefa9a31SAndy Shevchenko { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe006), }, 56cefa9a31SAndy Shevchenko {} 57cefa9a31SAndy Shevchenko }; 58cefa9a31SAndy Shevchenko 59518ca8d9SAndy Shevchenko static inline bool is_bypassed_id(struct pci_dev *pdev) 60cefa9a31SAndy Shevchenko { 61518ca8d9SAndy Shevchenko return !!pci_match_id(bypass_pci_id_table, pdev); 62cefa9a31SAndy Shevchenko } 63cefa9a31SAndy Shevchenko 646e693739SBryan O'Donoghue /* 656e693739SBryan O'Donoghue * 0x84 is the offset of in/out threshold register, 666e693739SBryan O'Donoghue * and it is the same offset as the register of 'hostpc'. 676e693739SBryan O'Donoghue */ 686e693739SBryan O'Donoghue #define intel_quark_x1000_insnreg01 hostpc 696e693739SBryan O'Donoghue 706e693739SBryan O'Donoghue /* Maximum usable threshold value is 0x7f dwords for both IN and OUT */ 716e693739SBryan O'Donoghue #define INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD 0x007f007f 727ff71d6aSMatt Porter 7318807521SDavid Brownell /* called after powerup, by probe or system-pm "wakeup" */ 7418807521SDavid Brownell static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) 7518807521SDavid Brownell { 7618807521SDavid Brownell int retval; 7718807521SDavid Brownell 78401feafaSDavid Brownell /* we expect static quirk code to handle the "extended capabilities" 79401feafaSDavid Brownell * (currently just BIOS handoff) allowed starting with EHCI 0.96 80401feafaSDavid Brownell */ 8118807521SDavid Brownell 8218807521SDavid Brownell /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */ 8318807521SDavid Brownell retval = pci_set_mwi(pdev); 8418807521SDavid Brownell if (!retval) 8518807521SDavid Brownell ehci_dbg(ehci, "MWI active\n"); 8618807521SDavid Brownell 876e693739SBryan O'Donoghue /* Reset the threshold limit */ 886e693739SBryan O'Donoghue if (is_intel_quark_x1000(pdev)) { 896e693739SBryan O'Donoghue /* 906e693739SBryan O'Donoghue * For the Intel QUARK X1000, raise the I/O threshold to the 916e693739SBryan O'Donoghue * maximum usable value in order to improve performance. 926e693739SBryan O'Donoghue */ 936e693739SBryan O'Donoghue ehci_writel(ehci, INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD, 946e693739SBryan O'Donoghue ehci->regs->intel_quark_x1000_insnreg01); 956e693739SBryan O'Donoghue } 966e693739SBryan O'Donoghue 9718807521SDavid Brownell return 0; 9818807521SDavid Brownell } 9918807521SDavid Brownell 1008926bfa7SDavid Brownell /* called during probe() after chip reset completes */ 1018926bfa7SDavid Brownell static int ehci_pci_setup(struct usb_hcd *hcd) 1027ff71d6aSMatt Porter { 1037ff71d6aSMatt Porter struct ehci_hcd *ehci = hcd_to_ehci(hcd); 104abcc9448SDavid Brownell struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 1057ff71d6aSMatt Porter u32 temp; 10618807521SDavid Brownell int retval; 1077ff71d6aSMatt Porter 1081a49e2acSAlan Stern ehci->caps = hcd->regs; 1091a49e2acSAlan Stern 1101a49e2acSAlan Stern /* 1111a49e2acSAlan Stern * ehci_init() causes memory for DMA transfers to be 1121a49e2acSAlan Stern * allocated. Thus, any vendor-specific workarounds based on 1131a49e2acSAlan Stern * limiting the type of memory used for DMA transfers must 1141a49e2acSAlan Stern * happen before ehci_setup() is called. 1151a49e2acSAlan Stern * 1161a49e2acSAlan Stern * Most other workarounds can be done either before or after 1171a49e2acSAlan Stern * init and reset; they are located here too. 1181a49e2acSAlan Stern */ 119083522d7SBenjamin Herrenschmidt switch (pdev->vendor) { 120083522d7SBenjamin Herrenschmidt case PCI_VENDOR_ID_TOSHIBA_2: 121083522d7SBenjamin Herrenschmidt /* celleb's companion chip */ 122083522d7SBenjamin Herrenschmidt if (pdev->device == 0x01b5) { 123083522d7SBenjamin Herrenschmidt #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO 124083522d7SBenjamin Herrenschmidt ehci->big_endian_mmio = 1; 125083522d7SBenjamin Herrenschmidt #else 126083522d7SBenjamin Herrenschmidt ehci_warn(ehci, 127083522d7SBenjamin Herrenschmidt "unsupported big endian Toshiba quirk\n"); 128083522d7SBenjamin Herrenschmidt #endif 129083522d7SBenjamin Herrenschmidt } 130083522d7SBenjamin Herrenschmidt break; 131c32ba30fSPaul Serice case PCI_VENDOR_ID_NVIDIA: 132c32ba30fSPaul Serice /* NVidia reports that certain chips don't handle 133c32ba30fSPaul Serice * QH, ITD, or SITD addresses above 2GB. (But TD, 134c32ba30fSPaul Serice * data buffer, and periodic schedule are normal.) 135c32ba30fSPaul Serice */ 136c32ba30fSPaul Serice switch (pdev->device) { 137c32ba30fSPaul Serice case 0x003c: /* MCP04 */ 138c32ba30fSPaul Serice case 0x005b: /* CK804 */ 139c32ba30fSPaul Serice case 0x00d8: /* CK8 */ 140c32ba30fSPaul Serice case 0x00e8: /* CK8S */ 141c32ba30fSPaul Serice if (pci_set_consistent_dma_mask(pdev, 142929a22a5SYang Hongyang DMA_BIT_MASK(31)) < 0) 143c32ba30fSPaul Serice ehci_warn(ehci, "can't enable NVidia " 144c32ba30fSPaul Serice "workaround for >2GB RAM\n"); 145c32ba30fSPaul Serice break; 1461a49e2acSAlan Stern 1471a49e2acSAlan Stern /* Some NForce2 chips have problems with selective suspend; 1481a49e2acSAlan Stern * fixed in newer silicon. 1491a49e2acSAlan Stern */ 1501a49e2acSAlan Stern case 0x0068: 1511a49e2acSAlan Stern if (pdev->revision < 0xa4) 1521a49e2acSAlan Stern ehci->no_selective_suspend = 1; 153c32ba30fSPaul Serice break; 154c32ba30fSPaul Serice } 1553681d8f3SDavid Miller break; 156403dbd36SAlek Du case PCI_VENDOR_ID_INTEL: 1571a49e2acSAlan Stern if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB) 1584f683843SDirk Brandewie hcd->has_tt = 1; 159403dbd36SAlek Du break; 1607ff71d6aSMatt Porter case PCI_VENDOR_ID_TDI: 1611a49e2acSAlan Stern if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) 1627329e211SAlan Stern hcd->has_tt = 1; 1637ff71d6aSMatt Porter break; 1647ff71d6aSMatt Porter case PCI_VENDOR_ID_AMD: 165ad93562bSAndiry Xu /* AMD PLL quirk */ 166ad93562bSAndiry Xu if (usb_amd_find_chipset_info()) 167ad93562bSAndiry Xu ehci->amd_pll_fix = 1; 1687ff71d6aSMatt Porter /* AMD8111 EHCI doesn't work, according to AMD errata */ 1697ff71d6aSMatt Porter if (pdev->device == 0x7463) { 1707ff71d6aSMatt Porter ehci_info(ehci, "ignoring AMD8111 (errata)\n"); 1718926bfa7SDavid Brownell retval = -EIO; 1728926bfa7SDavid Brownell goto done; 1737ff71d6aSMatt Porter } 174a85b4e7fSBrian J. Tarricone 1751a49e2acSAlan Stern /* 1761a49e2acSAlan Stern * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may 1771a49e2acSAlan Stern * read/write memory space which does not belong to it when 1781a49e2acSAlan Stern * there is NULL pointer with T-bit set to 1 in the frame list 1791a49e2acSAlan Stern * table. To avoid the issue, the frame list link pointer 1801a49e2acSAlan Stern * should always contain a valid pointer to a inactive qh. 181a85b4e7fSBrian J. Tarricone */ 1821a49e2acSAlan Stern if (pdev->device == 0x7808) { 1831a49e2acSAlan Stern ehci->use_dummy_qh = 1; 1841a49e2acSAlan Stern ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n"); 1857ff71d6aSMatt Porter } 1867ff71d6aSMatt Porter break; 187055b93c9SRene Herman case PCI_VENDOR_ID_VIA: 188055b93c9SRene Herman if (pdev->device == 0x3104 && (pdev->revision & 0xf0) == 0x60) { 189055b93c9SRene Herman u8 tmp; 190055b93c9SRene Herman 191055b93c9SRene Herman /* The VT6212 defaults to a 1 usec EHCI sleep time which 192055b93c9SRene Herman * hogs the PCI bus *badly*. Setting bit 5 of 0x4B makes 193055b93c9SRene Herman * that sleep time use the conventional 10 usec. 194055b93c9SRene Herman */ 195055b93c9SRene Herman pci_read_config_byte(pdev, 0x4b, &tmp); 196055b93c9SRene Herman if (tmp & 0x20) 197055b93c9SRene Herman break; 198055b93c9SRene Herman pci_write_config_byte(pdev, 0x4b, tmp | 0x20); 199055b93c9SRene Herman } 200055b93c9SRene Herman break; 201b09bc6cbSAndiry Xu case PCI_VENDOR_ID_ATI: 202ad93562bSAndiry Xu /* AMD PLL quirk */ 203ad93562bSAndiry Xu if (usb_amd_find_chipset_info()) 204ad93562bSAndiry Xu ehci->amd_pll_fix = 1; 2051a49e2acSAlan Stern 2061a49e2acSAlan Stern /* 2071a49e2acSAlan Stern * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may 2081a49e2acSAlan Stern * read/write memory space which does not belong to it when 2091a49e2acSAlan Stern * there is NULL pointer with T-bit set to 1 in the frame list 2101a49e2acSAlan Stern * table. To avoid the issue, the frame list link pointer 2111a49e2acSAlan Stern * should always contain a valid pointer to a inactive qh. 2121a49e2acSAlan Stern */ 2131a49e2acSAlan Stern if (pdev->device == 0x4396) { 2141a49e2acSAlan Stern ehci->use_dummy_qh = 1; 2151a49e2acSAlan Stern ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n"); 2161a49e2acSAlan Stern } 2170a99e8acSShane Huang /* SB600 and old version of SB700 have a bug in EHCI controller, 218b09bc6cbSAndiry Xu * which causes usb devices lose response in some cases. 219b09bc6cbSAndiry Xu */ 2203ad145b6SHuang Rui if ((pdev->device == 0x4386 || pdev->device == 0x4396) && 2213ad145b6SHuang Rui usb_amd_hang_symptom_quirk()) { 222b09bc6cbSAndiry Xu u8 tmp; 2233ad145b6SHuang Rui ehci_info(ehci, "applying AMD SB600/SB700 USB freeze workaround\n"); 224b09bc6cbSAndiry Xu pci_read_config_byte(pdev, 0x53, &tmp); 225b09bc6cbSAndiry Xu pci_write_config_byte(pdev, 0x53, tmp | (1<<3)); 226b09bc6cbSAndiry Xu } 227b09bc6cbSAndiry Xu break; 22868aa95d5SAlan Stern case PCI_VENDOR_ID_NETMOS: 22968aa95d5SAlan Stern /* MosChip frame-index-register bug */ 23068aa95d5SAlan Stern ehci_info(ehci, "applying MosChip frame-index workaround\n"); 23168aa95d5SAlan Stern ehci->frame_index_bug = 1; 23268aa95d5SAlan Stern break; 2337ff71d6aSMatt Porter } 2347ff71d6aSMatt Porter 23575e1a2aeSJan Beulich /* optional debug port, normally in the first BAR */ 23675e1a2aeSJan Beulich temp = pci_find_capability(pdev, PCI_CAP_ID_DBG); 23775e1a2aeSJan Beulich if (temp) { 23875e1a2aeSJan Beulich pci_read_config_dword(pdev, temp, &temp); 23975e1a2aeSJan Beulich temp >>= 16; 24075e1a2aeSJan Beulich if (((temp >> 13) & 7) == 1) { 24175e1a2aeSJan Beulich u32 hcs_params = ehci_readl(ehci, 24275e1a2aeSJan Beulich &ehci->caps->hcs_params); 24375e1a2aeSJan Beulich 24475e1a2aeSJan Beulich temp &= 0x1fff; 24575e1a2aeSJan Beulich ehci->debug = hcd->regs + temp; 24675e1a2aeSJan Beulich temp = ehci_readl(ehci, &ehci->debug->control); 24775e1a2aeSJan Beulich ehci_info(ehci, "debug port %d%s\n", 24875e1a2aeSJan Beulich HCS_DEBUG_PORT(hcs_params), 24975e1a2aeSJan Beulich (temp & DBGP_ENABLED) ? " IN USE" : ""); 25075e1a2aeSJan Beulich if (!(temp & DBGP_ENABLED)) 25175e1a2aeSJan Beulich ehci->debug = NULL; 25275e1a2aeSJan Beulich } 25375e1a2aeSJan Beulich } 25475e1a2aeSJan Beulich 2551a49e2acSAlan Stern retval = ehci_setup(hcd); 2561a49e2acSAlan Stern if (retval) 2571a49e2acSAlan Stern return retval; 2581a49e2acSAlan Stern 2591a49e2acSAlan Stern /* These workarounds need to be applied after ehci_setup() */ 2601a49e2acSAlan Stern switch (pdev->vendor) { 2611a49e2acSAlan Stern case PCI_VENDOR_ID_NEC: 2621a49e2acSAlan Stern case PCI_VENDOR_ID_INTEL: 2635c2ad982SLucas Stach case PCI_VENDOR_ID_AMD: 2641a49e2acSAlan Stern ehci->need_io_watchdog = 0; 2651a49e2acSAlan Stern break; 2661a49e2acSAlan Stern case PCI_VENDOR_ID_NVIDIA: 2671a49e2acSAlan Stern switch (pdev->device) { 2681a49e2acSAlan Stern /* MCP89 chips on the MacBookAir3,1 give EPROTO when 2691a49e2acSAlan Stern * fetching device descriptors unless LPM is disabled. 2701a49e2acSAlan Stern * There are also intermittent problems enumerating 2711a49e2acSAlan Stern * devices with PPCD enabled. 2721a49e2acSAlan Stern */ 2731a49e2acSAlan Stern case 0x0d9d: 2744968f951SAlan Stern ehci_info(ehci, "disable ppcd for nvidia mcp89\n"); 2751a49e2acSAlan Stern ehci->has_ppcd = 0; 2761a49e2acSAlan Stern ehci->command &= ~CMD_PPCEE; 2771a49e2acSAlan Stern break; 2781a49e2acSAlan Stern } 2791a49e2acSAlan Stern break; 2801a49e2acSAlan Stern } 2811a49e2acSAlan Stern 2827ff71d6aSMatt Porter /* at least the Genesys GL880S needs fixup here */ 2837ff71d6aSMatt Porter temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); 2847ff71d6aSMatt Porter temp &= 0x0f; 2857ff71d6aSMatt Porter if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) { 2867ff71d6aSMatt Porter ehci_dbg(ehci, "bogus port configuration: " 2877ff71d6aSMatt Porter "cc=%d x pcc=%d < ports=%d\n", 2887ff71d6aSMatt Porter HCS_N_CC(ehci->hcs_params), 2897ff71d6aSMatt Porter HCS_N_PCC(ehci->hcs_params), 2907ff71d6aSMatt Porter HCS_N_PORTS(ehci->hcs_params)); 2917ff71d6aSMatt Porter 2927ff71d6aSMatt Porter switch (pdev->vendor) { 2937ff71d6aSMatt Porter case 0x17a0: /* GENESYS */ 2947ff71d6aSMatt Porter /* GL880S: should be PORTS=2 */ 2957ff71d6aSMatt Porter temp |= (ehci->hcs_params & ~0xf); 2967ff71d6aSMatt Porter ehci->hcs_params = temp; 2977ff71d6aSMatt Porter break; 2987ff71d6aSMatt Porter case PCI_VENDOR_ID_NVIDIA: 2997ff71d6aSMatt Porter /* NF4: should be PCC=10 */ 3007ff71d6aSMatt Porter break; 3017ff71d6aSMatt Porter } 3027ff71d6aSMatt Porter } 3037ff71d6aSMatt Porter 3047ff71d6aSMatt Porter /* Serial Bus Release Number is at PCI 0x60 offset */ 3053a0bac06SAlessandro Rubini if (pdev->vendor == PCI_VENDOR_ID_STMICRO 3063a0bac06SAlessandro Rubini && pdev->device == PCI_DEVICE_ID_STMICRO_USB_HOST) 3071a49e2acSAlan Stern ; /* ConneXT has no sbrn register */ 3081a49e2acSAlan Stern else 3091a49e2acSAlan Stern pci_read_config_byte(pdev, 0x60, &ehci->sbrn); 3107ff71d6aSMatt Porter 3116fd9086aSAlan Stern /* Keep this around for a while just in case some EHCI 3126fd9086aSAlan Stern * implementation uses legacy PCI PM support. This test 3136fd9086aSAlan Stern * can be removed on 17 Dec 2009 if the dev_warn() hasn't 3146fd9086aSAlan Stern * been triggered by then. 3152c1c3c4cSDavid Brownell */ 3162c1c3c4cSDavid Brownell if (!device_can_wakeup(&pdev->dev)) { 3172c1c3c4cSDavid Brownell u16 port_wake; 3182c1c3c4cSDavid Brownell 3192c1c3c4cSDavid Brownell pci_read_config_word(pdev, 0x62, &port_wake); 3206fd9086aSAlan Stern if (port_wake & 0x0001) { 3216fd9086aSAlan Stern dev_warn(&pdev->dev, "Enabling legacy PCI PM\n"); 322bcca06efSAlan Stern device_set_wakeup_capable(&pdev->dev, 1); 3232c1c3c4cSDavid Brownell } 3246fd9086aSAlan Stern } 3257ff71d6aSMatt Porter 326ceb6c9c8SRafael J. Wysocki #ifdef CONFIG_PM 327f8aeb3bbSDavid Brownell if (ehci->no_selective_suspend && device_can_wakeup(&pdev->dev)) 328f8aeb3bbSDavid Brownell ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); 329f8aeb3bbSDavid Brownell #endif 330f8aeb3bbSDavid Brownell 33118807521SDavid Brownell retval = ehci_pci_reinit(ehci, pdev); 3328926bfa7SDavid Brownell done: 3338926bfa7SDavid Brownell return retval; 3347ff71d6aSMatt Porter } 3357ff71d6aSMatt Porter 3367ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/ 3377ff71d6aSMatt Porter 3387ff71d6aSMatt Porter #ifdef CONFIG_PM 3397ff71d6aSMatt Porter 3407ff71d6aSMatt Porter /* suspend/resume, section 4.3 */ 3417ff71d6aSMatt Porter 342f03c17fcSDavid Brownell /* These routines rely on the PCI bus glue 3437ff71d6aSMatt Porter * to handle powerdown and wakeup, and currently also on 3447ff71d6aSMatt Porter * transceivers that don't need any software attention to set up 3457ff71d6aSMatt Porter * the right sort of wakeup. 346f03c17fcSDavid Brownell * Also they depend on separate root hub suspend/resume. 3477ff71d6aSMatt Porter */ 3487ff71d6aSMatt Porter 3496ec4beb5SAlan Stern static int ehci_pci_resume(struct usb_hcd *hcd, bool hibernated) 3507ff71d6aSMatt Porter { 3517ff71d6aSMatt Porter struct ehci_hcd *ehci = hcd_to_ehci(hcd); 35218807521SDavid Brownell struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 3537ff71d6aSMatt Porter 354c5cf9212SAlan Stern if (ehci_resume(hcd, hibernated) != 0) 35518807521SDavid Brownell (void) ehci_pci_reinit(ehci, pdev); 3568c03356aSAlan Stern return 0; 3577ff71d6aSMatt Porter } 3587ff71d6aSMatt Porter 359adfa79d1SAlan Stern #else 3607ff71d6aSMatt Porter 361adfa79d1SAlan Stern #define ehci_suspend NULL 362adfa79d1SAlan Stern #define ehci_pci_resume NULL 363adfa79d1SAlan Stern #endif /* CONFIG_PM */ 3647ff71d6aSMatt Porter 365adfa79d1SAlan Stern static struct hc_driver __read_mostly ehci_pci_hc_driver; 366adfa79d1SAlan Stern 36762d08a11SAndi Kleen static const struct ehci_driver_overrides pci_overrides __initconst = { 3688926bfa7SDavid Brownell .reset = ehci_pci_setup, 3697ff71d6aSMatt Porter }; 3707ff71d6aSMatt Porter 3717ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/ 3727ff71d6aSMatt Porter 373cefa9a31SAndy Shevchenko static int ehci_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) 374cefa9a31SAndy Shevchenko { 375518ca8d9SAndy Shevchenko if (is_bypassed_id(pdev)) 376cefa9a31SAndy Shevchenko return -ENODEV; 377cefa9a31SAndy Shevchenko return usb_hcd_pci_probe(pdev, id); 378cefa9a31SAndy Shevchenko } 379cefa9a31SAndy Shevchenko 380e3e2e36cSJia-Ju Bai static void ehci_pci_remove(struct pci_dev *pdev) 381e3e2e36cSJia-Ju Bai { 382e3e2e36cSJia-Ju Bai pci_clear_mwi(pdev); 383e3e2e36cSJia-Ju Bai usb_hcd_pci_remove(pdev); 384e3e2e36cSJia-Ju Bai } 385e3e2e36cSJia-Ju Bai 3867ff71d6aSMatt Porter /* PCI driver selection metadata; PCI hotplugging uses this */ 3877ff71d6aSMatt Porter static const struct pci_device_id pci_ids [] = { { 3887ff71d6aSMatt Porter /* handle any USB 2.0 EHCI controller */ 389c67808eeSJean Delvare PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0), 3907ff71d6aSMatt Porter .driver_data = (unsigned long) &ehci_pci_hc_driver, 3913a0bac06SAlessandro Rubini }, { 3923a0bac06SAlessandro Rubini PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST), 3933a0bac06SAlessandro Rubini .driver_data = (unsigned long) &ehci_pci_hc_driver, 3947ff71d6aSMatt Porter }, 3957ff71d6aSMatt Porter { /* end: all zeroes */ } 3967ff71d6aSMatt Porter }; 3977ff71d6aSMatt Porter MODULE_DEVICE_TABLE(pci, pci_ids); 3987ff71d6aSMatt Porter 3997ff71d6aSMatt Porter /* pci driver glue; this is a "new style" PCI driver module */ 4007ff71d6aSMatt Porter static struct pci_driver ehci_pci_driver = { 4017ff71d6aSMatt Porter .name = (char *) hcd_name, 4027ff71d6aSMatt Porter .id_table = pci_ids, 4037ff71d6aSMatt Porter 404cefa9a31SAndy Shevchenko .probe = ehci_pci_probe, 405e3e2e36cSJia-Ju Bai .remove = ehci_pci_remove, 40664a21d02SAleksey Gorelov .shutdown = usb_hcd_pci_shutdown, 407abb30641SAlan Stern 408f875fdbfSAlan Stern #ifdef CONFIG_PM 409abb30641SAlan Stern .driver = { 410abb30641SAlan Stern .pm = &usb_hcd_pci_pm_ops 411abb30641SAlan Stern }, 412abb30641SAlan Stern #endif 4137ff71d6aSMatt Porter }; 414adfa79d1SAlan Stern 415adfa79d1SAlan Stern static int __init ehci_pci_init(void) 416adfa79d1SAlan Stern { 417adfa79d1SAlan Stern if (usb_disabled()) 418adfa79d1SAlan Stern return -ENODEV; 419adfa79d1SAlan Stern 420adfa79d1SAlan Stern pr_info("%s: " DRIVER_DESC "\n", hcd_name); 421adfa79d1SAlan Stern 4221b36810eSAlan Stern ehci_init_driver(&ehci_pci_hc_driver, &pci_overrides); 423adfa79d1SAlan Stern 424adfa79d1SAlan Stern /* Entries for the PCI suspend/resume callbacks are special */ 425adfa79d1SAlan Stern ehci_pci_hc_driver.pci_suspend = ehci_suspend; 426adfa79d1SAlan Stern ehci_pci_hc_driver.pci_resume = ehci_pci_resume; 427adfa79d1SAlan Stern 428adfa79d1SAlan Stern return pci_register_driver(&ehci_pci_driver); 429adfa79d1SAlan Stern } 430adfa79d1SAlan Stern module_init(ehci_pci_init); 431adfa79d1SAlan Stern 432adfa79d1SAlan Stern static void __exit ehci_pci_cleanup(void) 433adfa79d1SAlan Stern { 434adfa79d1SAlan Stern pci_unregister_driver(&ehci_pci_driver); 435adfa79d1SAlan Stern } 436adfa79d1SAlan Stern module_exit(ehci_pci_cleanup); 437adfa79d1SAlan Stern 438adfa79d1SAlan Stern MODULE_DESCRIPTION(DRIVER_DESC); 439adfa79d1SAlan Stern MODULE_AUTHOR("David Brownell"); 440adfa79d1SAlan Stern MODULE_AUTHOR("Alan Stern"); 441adfa79d1SAlan Stern MODULE_LICENSE("GPL"); 442