15fd54aceSGreg 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 8adfa79d1SAlan Stern #include <linux/kernel.h> 9adfa79d1SAlan Stern #include <linux/module.h> 10adfa79d1SAlan Stern #include <linux/pci.h> 11adfa79d1SAlan Stern #include <linux/usb.h> 12adfa79d1SAlan Stern #include <linux/usb/hcd.h> 13adfa79d1SAlan Stern 14adfa79d1SAlan Stern #include "ehci.h" 15adfa79d1SAlan Stern #include "pci-quirks.h" 16adfa79d1SAlan Stern 17adfa79d1SAlan Stern #define DRIVER_DESC "EHCI PCI platform driver" 18adfa79d1SAlan Stern 19adfa79d1SAlan Stern static const char hcd_name[] = "ehci-pci"; 207ff71d6aSMatt Porter 214f683843SDirk Brandewie /* defined here to avoid adding to pci_ids.h for single instance use */ 224f683843SDirk Brandewie #define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70 234f683843SDirk Brandewie 247ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/ 256e693739SBryan O'Donoghue #define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC 0x0939 266e693739SBryan O'Donoghue static inline bool is_intel_quark_x1000(struct pci_dev *pdev) 276e693739SBryan O'Donoghue { 286e693739SBryan O'Donoghue return pdev->vendor == PCI_VENDOR_ID_INTEL && 296e693739SBryan O'Donoghue pdev->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC; 306e693739SBryan O'Donoghue } 316e693739SBryan O'Donoghue 32518ca8d9SAndy Shevchenko /* 33518ca8d9SAndy Shevchenko * This is the list of PCI IDs for the devices that have EHCI USB class and 34518ca8d9SAndy Shevchenko * specific drivers for that. One of the example is a ChipIdea device installed 35518ca8d9SAndy Shevchenko * on some Intel MID platforms. 36518ca8d9SAndy Shevchenko */ 37518ca8d9SAndy Shevchenko static const struct pci_device_id bypass_pci_id_table[] = { 38518ca8d9SAndy Shevchenko /* ChipIdea on Intel MID platform */ 39cefa9a31SAndy Shevchenko { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0811), }, 40cefa9a31SAndy Shevchenko { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0829), }, 41cefa9a31SAndy Shevchenko { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe006), }, 42cefa9a31SAndy Shevchenko {} 43cefa9a31SAndy Shevchenko }; 44cefa9a31SAndy Shevchenko 45518ca8d9SAndy Shevchenko static inline bool is_bypassed_id(struct pci_dev *pdev) 46cefa9a31SAndy Shevchenko { 47518ca8d9SAndy Shevchenko return !!pci_match_id(bypass_pci_id_table, pdev); 48cefa9a31SAndy Shevchenko } 49cefa9a31SAndy Shevchenko 506e693739SBryan O'Donoghue /* 516e693739SBryan O'Donoghue * 0x84 is the offset of in/out threshold register, 526e693739SBryan O'Donoghue * and it is the same offset as the register of 'hostpc'. 536e693739SBryan O'Donoghue */ 546e693739SBryan O'Donoghue #define intel_quark_x1000_insnreg01 hostpc 556e693739SBryan O'Donoghue 566e693739SBryan O'Donoghue /* Maximum usable threshold value is 0x7f dwords for both IN and OUT */ 576e693739SBryan O'Donoghue #define INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD 0x007f007f 587ff71d6aSMatt Porter 5918807521SDavid Brownell /* called after powerup, by probe or system-pm "wakeup" */ 6018807521SDavid Brownell static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) 6118807521SDavid Brownell { 6218807521SDavid Brownell int retval; 6318807521SDavid Brownell 64401feafaSDavid Brownell /* we expect static quirk code to handle the "extended capabilities" 65401feafaSDavid Brownell * (currently just BIOS handoff) allowed starting with EHCI 0.96 66401feafaSDavid Brownell */ 6718807521SDavid Brownell 6818807521SDavid Brownell /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */ 6918807521SDavid Brownell retval = pci_set_mwi(pdev); 7018807521SDavid Brownell if (!retval) 7118807521SDavid Brownell ehci_dbg(ehci, "MWI active\n"); 7218807521SDavid Brownell 736e693739SBryan O'Donoghue /* Reset the threshold limit */ 746e693739SBryan O'Donoghue if (is_intel_quark_x1000(pdev)) { 756e693739SBryan O'Donoghue /* 766e693739SBryan O'Donoghue * For the Intel QUARK X1000, raise the I/O threshold to the 776e693739SBryan O'Donoghue * maximum usable value in order to improve performance. 786e693739SBryan O'Donoghue */ 796e693739SBryan O'Donoghue ehci_writel(ehci, INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD, 806e693739SBryan O'Donoghue ehci->regs->intel_quark_x1000_insnreg01); 816e693739SBryan O'Donoghue } 826e693739SBryan O'Donoghue 8318807521SDavid Brownell return 0; 8418807521SDavid Brownell } 8518807521SDavid Brownell 868926bfa7SDavid Brownell /* called during probe() after chip reset completes */ 878926bfa7SDavid Brownell static int ehci_pci_setup(struct usb_hcd *hcd) 887ff71d6aSMatt Porter { 897ff71d6aSMatt Porter struct ehci_hcd *ehci = hcd_to_ehci(hcd); 90abcc9448SDavid Brownell struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 917ff71d6aSMatt Porter u32 temp; 9218807521SDavid Brownell int retval; 937ff71d6aSMatt Porter 941a49e2acSAlan Stern ehci->caps = hcd->regs; 951a49e2acSAlan Stern 961a49e2acSAlan Stern /* 971a49e2acSAlan Stern * ehci_init() causes memory for DMA transfers to be 981a49e2acSAlan Stern * allocated. Thus, any vendor-specific workarounds based on 991a49e2acSAlan Stern * limiting the type of memory used for DMA transfers must 1001a49e2acSAlan Stern * happen before ehci_setup() is called. 1011a49e2acSAlan Stern * 1021a49e2acSAlan Stern * Most other workarounds can be done either before or after 1031a49e2acSAlan Stern * init and reset; they are located here too. 1041a49e2acSAlan Stern */ 105083522d7SBenjamin Herrenschmidt switch (pdev->vendor) { 106083522d7SBenjamin Herrenschmidt case PCI_VENDOR_ID_TOSHIBA_2: 107083522d7SBenjamin Herrenschmidt /* celleb's companion chip */ 108083522d7SBenjamin Herrenschmidt if (pdev->device == 0x01b5) { 109083522d7SBenjamin Herrenschmidt #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO 110083522d7SBenjamin Herrenschmidt ehci->big_endian_mmio = 1; 111083522d7SBenjamin Herrenschmidt #else 112083522d7SBenjamin Herrenschmidt ehci_warn(ehci, 113083522d7SBenjamin Herrenschmidt "unsupported big endian Toshiba quirk\n"); 114083522d7SBenjamin Herrenschmidt #endif 115083522d7SBenjamin Herrenschmidt } 116083522d7SBenjamin Herrenschmidt break; 117c32ba30fSPaul Serice case PCI_VENDOR_ID_NVIDIA: 118c32ba30fSPaul Serice /* NVidia reports that certain chips don't handle 119c32ba30fSPaul Serice * QH, ITD, or SITD addresses above 2GB. (But TD, 120c32ba30fSPaul Serice * data buffer, and periodic schedule are normal.) 121c32ba30fSPaul Serice */ 122c32ba30fSPaul Serice switch (pdev->device) { 123c32ba30fSPaul Serice case 0x003c: /* MCP04 */ 124c32ba30fSPaul Serice case 0x005b: /* CK804 */ 125c32ba30fSPaul Serice case 0x00d8: /* CK8 */ 126c32ba30fSPaul Serice case 0x00e8: /* CK8S */ 127c32ba30fSPaul Serice if (pci_set_consistent_dma_mask(pdev, 128929a22a5SYang Hongyang DMA_BIT_MASK(31)) < 0) 129c32ba30fSPaul Serice ehci_warn(ehci, "can't enable NVidia " 130c32ba30fSPaul Serice "workaround for >2GB RAM\n"); 131c32ba30fSPaul Serice break; 1321a49e2acSAlan Stern 1331a49e2acSAlan Stern /* Some NForce2 chips have problems with selective suspend; 1341a49e2acSAlan Stern * fixed in newer silicon. 1351a49e2acSAlan Stern */ 1361a49e2acSAlan Stern case 0x0068: 1371a49e2acSAlan Stern if (pdev->revision < 0xa4) 1381a49e2acSAlan Stern ehci->no_selective_suspend = 1; 139c32ba30fSPaul Serice break; 140c32ba30fSPaul Serice } 1413681d8f3SDavid Miller break; 142403dbd36SAlek Du case PCI_VENDOR_ID_INTEL: 1431a49e2acSAlan Stern if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB) 1444f683843SDirk Brandewie hcd->has_tt = 1; 145403dbd36SAlek Du break; 1467ff71d6aSMatt Porter case PCI_VENDOR_ID_TDI: 1471a49e2acSAlan Stern if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) 1487329e211SAlan Stern hcd->has_tt = 1; 1497ff71d6aSMatt Porter break; 1507ff71d6aSMatt Porter case PCI_VENDOR_ID_AMD: 151ad93562bSAndiry Xu /* AMD PLL quirk */ 1524fbb8aa7SRyan Kennedy if (usb_amd_quirk_pll_check()) 153ad93562bSAndiry Xu ehci->amd_pll_fix = 1; 1547ff71d6aSMatt Porter /* AMD8111 EHCI doesn't work, according to AMD errata */ 1557ff71d6aSMatt Porter if (pdev->device == 0x7463) { 1567ff71d6aSMatt Porter ehci_info(ehci, "ignoring AMD8111 (errata)\n"); 1578926bfa7SDavid Brownell retval = -EIO; 1588926bfa7SDavid Brownell goto done; 1597ff71d6aSMatt Porter } 160a85b4e7fSBrian J. Tarricone 1611a49e2acSAlan Stern /* 1621a49e2acSAlan Stern * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may 1631a49e2acSAlan Stern * read/write memory space which does not belong to it when 1641a49e2acSAlan Stern * there is NULL pointer with T-bit set to 1 in the frame list 1651a49e2acSAlan Stern * table. To avoid the issue, the frame list link pointer 1661a49e2acSAlan Stern * should always contain a valid pointer to a inactive qh. 167a85b4e7fSBrian J. Tarricone */ 1681a49e2acSAlan Stern if (pdev->device == 0x7808) { 1691a49e2acSAlan Stern ehci->use_dummy_qh = 1; 1701a49e2acSAlan Stern ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n"); 1717ff71d6aSMatt Porter } 1727ff71d6aSMatt Porter break; 173055b93c9SRene Herman case PCI_VENDOR_ID_VIA: 174055b93c9SRene Herman if (pdev->device == 0x3104 && (pdev->revision & 0xf0) == 0x60) { 175055b93c9SRene Herman u8 tmp; 176055b93c9SRene Herman 177055b93c9SRene Herman /* The VT6212 defaults to a 1 usec EHCI sleep time which 178055b93c9SRene Herman * hogs the PCI bus *badly*. Setting bit 5 of 0x4B makes 179055b93c9SRene Herman * that sleep time use the conventional 10 usec. 180055b93c9SRene Herman */ 181055b93c9SRene Herman pci_read_config_byte(pdev, 0x4b, &tmp); 182055b93c9SRene Herman if (tmp & 0x20) 183055b93c9SRene Herman break; 184055b93c9SRene Herman pci_write_config_byte(pdev, 0x4b, tmp | 0x20); 185055b93c9SRene Herman } 186055b93c9SRene Herman break; 187b09bc6cbSAndiry Xu case PCI_VENDOR_ID_ATI: 188ad93562bSAndiry Xu /* AMD PLL quirk */ 1894fbb8aa7SRyan Kennedy if (usb_amd_quirk_pll_check()) 190ad93562bSAndiry Xu ehci->amd_pll_fix = 1; 1911a49e2acSAlan Stern 1921a49e2acSAlan Stern /* 1931a49e2acSAlan Stern * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may 1941a49e2acSAlan Stern * read/write memory space which does not belong to it when 1951a49e2acSAlan Stern * there is NULL pointer with T-bit set to 1 in the frame list 1961a49e2acSAlan Stern * table. To avoid the issue, the frame list link pointer 1971a49e2acSAlan Stern * should always contain a valid pointer to a inactive qh. 1981a49e2acSAlan Stern */ 1991a49e2acSAlan Stern if (pdev->device == 0x4396) { 2001a49e2acSAlan Stern ehci->use_dummy_qh = 1; 2011a49e2acSAlan Stern ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n"); 2021a49e2acSAlan Stern } 2030a99e8acSShane Huang /* SB600 and old version of SB700 have a bug in EHCI controller, 204b09bc6cbSAndiry Xu * which causes usb devices lose response in some cases. 205b09bc6cbSAndiry Xu */ 2063ad145b6SHuang Rui if ((pdev->device == 0x4386 || pdev->device == 0x4396) && 2073ad145b6SHuang Rui usb_amd_hang_symptom_quirk()) { 208b09bc6cbSAndiry Xu u8 tmp; 2093ad145b6SHuang Rui ehci_info(ehci, "applying AMD SB600/SB700 USB freeze workaround\n"); 210b09bc6cbSAndiry Xu pci_read_config_byte(pdev, 0x53, &tmp); 211b09bc6cbSAndiry Xu pci_write_config_byte(pdev, 0x53, tmp | (1<<3)); 212b09bc6cbSAndiry Xu } 213b09bc6cbSAndiry Xu break; 21468aa95d5SAlan Stern case PCI_VENDOR_ID_NETMOS: 21568aa95d5SAlan Stern /* MosChip frame-index-register bug */ 21668aa95d5SAlan Stern ehci_info(ehci, "applying MosChip frame-index workaround\n"); 21768aa95d5SAlan Stern ehci->frame_index_bug = 1; 21868aa95d5SAlan Stern break; 219*1ddcb71aSLongfang Liu case PCI_VENDOR_ID_HUAWEI: 220*1ddcb71aSLongfang Liu /* Synopsys HC bug */ 221*1ddcb71aSLongfang Liu if (pdev->device == 0xa239) { 222*1ddcb71aSLongfang Liu ehci_info(ehci, "applying Synopsys HC workaround\n"); 223*1ddcb71aSLongfang Liu ehci->has_synopsys_hc_bug = 1; 224*1ddcb71aSLongfang Liu } 225*1ddcb71aSLongfang Liu break; 2267ff71d6aSMatt Porter } 2277ff71d6aSMatt Porter 22875e1a2aeSJan Beulich /* optional debug port, normally in the first BAR */ 22975e1a2aeSJan Beulich temp = pci_find_capability(pdev, PCI_CAP_ID_DBG); 23075e1a2aeSJan Beulich if (temp) { 23175e1a2aeSJan Beulich pci_read_config_dword(pdev, temp, &temp); 23275e1a2aeSJan Beulich temp >>= 16; 23375e1a2aeSJan Beulich if (((temp >> 13) & 7) == 1) { 23475e1a2aeSJan Beulich u32 hcs_params = ehci_readl(ehci, 23575e1a2aeSJan Beulich &ehci->caps->hcs_params); 23675e1a2aeSJan Beulich 23775e1a2aeSJan Beulich temp &= 0x1fff; 23875e1a2aeSJan Beulich ehci->debug = hcd->regs + temp; 23975e1a2aeSJan Beulich temp = ehci_readl(ehci, &ehci->debug->control); 24075e1a2aeSJan Beulich ehci_info(ehci, "debug port %d%s\n", 24175e1a2aeSJan Beulich HCS_DEBUG_PORT(hcs_params), 24275e1a2aeSJan Beulich (temp & DBGP_ENABLED) ? " IN USE" : ""); 24375e1a2aeSJan Beulich if (!(temp & DBGP_ENABLED)) 24475e1a2aeSJan Beulich ehci->debug = NULL; 24575e1a2aeSJan Beulich } 24675e1a2aeSJan Beulich } 24775e1a2aeSJan Beulich 2481a49e2acSAlan Stern retval = ehci_setup(hcd); 2491a49e2acSAlan Stern if (retval) 2501a49e2acSAlan Stern return retval; 2511a49e2acSAlan Stern 2521a49e2acSAlan Stern /* These workarounds need to be applied after ehci_setup() */ 2531a49e2acSAlan Stern switch (pdev->vendor) { 2541a49e2acSAlan Stern case PCI_VENDOR_ID_NEC: 2551a49e2acSAlan Stern case PCI_VENDOR_ID_INTEL: 2565c2ad982SLucas Stach case PCI_VENDOR_ID_AMD: 2571a49e2acSAlan Stern ehci->need_io_watchdog = 0; 2581a49e2acSAlan Stern break; 2591a49e2acSAlan Stern case PCI_VENDOR_ID_NVIDIA: 2601a49e2acSAlan Stern switch (pdev->device) { 2611a49e2acSAlan Stern /* MCP89 chips on the MacBookAir3,1 give EPROTO when 2621a49e2acSAlan Stern * fetching device descriptors unless LPM is disabled. 2631a49e2acSAlan Stern * There are also intermittent problems enumerating 2641a49e2acSAlan Stern * devices with PPCD enabled. 2651a49e2acSAlan Stern */ 2661a49e2acSAlan Stern case 0x0d9d: 2674968f951SAlan Stern ehci_info(ehci, "disable ppcd for nvidia mcp89\n"); 2681a49e2acSAlan Stern ehci->has_ppcd = 0; 2691a49e2acSAlan Stern ehci->command &= ~CMD_PPCEE; 2701a49e2acSAlan Stern break; 2711a49e2acSAlan Stern } 2721a49e2acSAlan Stern break; 2731a49e2acSAlan Stern } 2741a49e2acSAlan Stern 2757ff71d6aSMatt Porter /* at least the Genesys GL880S needs fixup here */ 2767ff71d6aSMatt Porter temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); 2777ff71d6aSMatt Porter temp &= 0x0f; 2787ff71d6aSMatt Porter if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) { 2797ff71d6aSMatt Porter ehci_dbg(ehci, "bogus port configuration: " 2807ff71d6aSMatt Porter "cc=%d x pcc=%d < ports=%d\n", 2817ff71d6aSMatt Porter HCS_N_CC(ehci->hcs_params), 2827ff71d6aSMatt Porter HCS_N_PCC(ehci->hcs_params), 2837ff71d6aSMatt Porter HCS_N_PORTS(ehci->hcs_params)); 2847ff71d6aSMatt Porter 2857ff71d6aSMatt Porter switch (pdev->vendor) { 2867ff71d6aSMatt Porter case 0x17a0: /* GENESYS */ 2877ff71d6aSMatt Porter /* GL880S: should be PORTS=2 */ 2887ff71d6aSMatt Porter temp |= (ehci->hcs_params & ~0xf); 2897ff71d6aSMatt Porter ehci->hcs_params = temp; 2907ff71d6aSMatt Porter break; 2917ff71d6aSMatt Porter case PCI_VENDOR_ID_NVIDIA: 2927ff71d6aSMatt Porter /* NF4: should be PCC=10 */ 2937ff71d6aSMatt Porter break; 2947ff71d6aSMatt Porter } 2957ff71d6aSMatt Porter } 2967ff71d6aSMatt Porter 2977ff71d6aSMatt Porter /* Serial Bus Release Number is at PCI 0x60 offset */ 2983a0bac06SAlessandro Rubini if (pdev->vendor == PCI_VENDOR_ID_STMICRO 2993a0bac06SAlessandro Rubini && pdev->device == PCI_DEVICE_ID_STMICRO_USB_HOST) 3001a49e2acSAlan Stern ; /* ConneXT has no sbrn register */ 3011a49e2acSAlan Stern else 3021a49e2acSAlan Stern pci_read_config_byte(pdev, 0x60, &ehci->sbrn); 3037ff71d6aSMatt Porter 3046fd9086aSAlan Stern /* Keep this around for a while just in case some EHCI 3056fd9086aSAlan Stern * implementation uses legacy PCI PM support. This test 3066fd9086aSAlan Stern * can be removed on 17 Dec 2009 if the dev_warn() hasn't 3076fd9086aSAlan Stern * been triggered by then. 3082c1c3c4cSDavid Brownell */ 3092c1c3c4cSDavid Brownell if (!device_can_wakeup(&pdev->dev)) { 3102c1c3c4cSDavid Brownell u16 port_wake; 3112c1c3c4cSDavid Brownell 3122c1c3c4cSDavid Brownell pci_read_config_word(pdev, 0x62, &port_wake); 3136fd9086aSAlan Stern if (port_wake & 0x0001) { 3146fd9086aSAlan Stern dev_warn(&pdev->dev, "Enabling legacy PCI PM\n"); 315bcca06efSAlan Stern device_set_wakeup_capable(&pdev->dev, 1); 3162c1c3c4cSDavid Brownell } 3176fd9086aSAlan Stern } 3187ff71d6aSMatt Porter 319ceb6c9c8SRafael J. Wysocki #ifdef CONFIG_PM 320f8aeb3bbSDavid Brownell if (ehci->no_selective_suspend && device_can_wakeup(&pdev->dev)) 321f8aeb3bbSDavid Brownell ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); 322f8aeb3bbSDavid Brownell #endif 323f8aeb3bbSDavid Brownell 32418807521SDavid Brownell retval = ehci_pci_reinit(ehci, pdev); 3258926bfa7SDavid Brownell done: 3268926bfa7SDavid Brownell return retval; 3277ff71d6aSMatt Porter } 3287ff71d6aSMatt Porter 3297ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/ 3307ff71d6aSMatt Porter 3317ff71d6aSMatt Porter #ifdef CONFIG_PM 3327ff71d6aSMatt Porter 3337ff71d6aSMatt Porter /* suspend/resume, section 4.3 */ 3347ff71d6aSMatt Porter 335f03c17fcSDavid Brownell /* These routines rely on the PCI bus glue 3367ff71d6aSMatt Porter * to handle powerdown and wakeup, and currently also on 3377ff71d6aSMatt Porter * transceivers that don't need any software attention to set up 3387ff71d6aSMatt Porter * the right sort of wakeup. 339f03c17fcSDavid Brownell * Also they depend on separate root hub suspend/resume. 3407ff71d6aSMatt Porter */ 3417ff71d6aSMatt Porter 3426ec4beb5SAlan Stern static int ehci_pci_resume(struct usb_hcd *hcd, bool hibernated) 3437ff71d6aSMatt Porter { 3447ff71d6aSMatt Porter struct ehci_hcd *ehci = hcd_to_ehci(hcd); 34518807521SDavid Brownell struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 3467ff71d6aSMatt Porter 347c5cf9212SAlan Stern if (ehci_resume(hcd, hibernated) != 0) 34818807521SDavid Brownell (void) ehci_pci_reinit(ehci, pdev); 3498c03356aSAlan Stern return 0; 3507ff71d6aSMatt Porter } 3517ff71d6aSMatt Porter 352adfa79d1SAlan Stern #else 3537ff71d6aSMatt Porter 354adfa79d1SAlan Stern #define ehci_suspend NULL 355adfa79d1SAlan Stern #define ehci_pci_resume NULL 356adfa79d1SAlan Stern #endif /* CONFIG_PM */ 3577ff71d6aSMatt Porter 358adfa79d1SAlan Stern static struct hc_driver __read_mostly ehci_pci_hc_driver; 359adfa79d1SAlan Stern 36062d08a11SAndi Kleen static const struct ehci_driver_overrides pci_overrides __initconst = { 3618926bfa7SDavid Brownell .reset = ehci_pci_setup, 3627ff71d6aSMatt Porter }; 3637ff71d6aSMatt Porter 3647ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/ 3657ff71d6aSMatt Porter 366cefa9a31SAndy Shevchenko static int ehci_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) 367cefa9a31SAndy Shevchenko { 368518ca8d9SAndy Shevchenko if (is_bypassed_id(pdev)) 369cefa9a31SAndy Shevchenko return -ENODEV; 370ff4c65caSVinod Koul return usb_hcd_pci_probe(pdev, id, &ehci_pci_hc_driver); 371cefa9a31SAndy Shevchenko } 372cefa9a31SAndy Shevchenko 373e3e2e36cSJia-Ju Bai static void ehci_pci_remove(struct pci_dev *pdev) 374e3e2e36cSJia-Ju Bai { 375e3e2e36cSJia-Ju Bai pci_clear_mwi(pdev); 376e3e2e36cSJia-Ju Bai usb_hcd_pci_remove(pdev); 377e3e2e36cSJia-Ju Bai } 378e3e2e36cSJia-Ju Bai 3797ff71d6aSMatt Porter /* PCI driver selection metadata; PCI hotplugging uses this */ 3807ff71d6aSMatt Porter static const struct pci_device_id pci_ids [] = { { 3817ff71d6aSMatt Porter /* handle any USB 2.0 EHCI controller */ 382c67808eeSJean Delvare PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0), 3833a0bac06SAlessandro Rubini }, { 3843a0bac06SAlessandro Rubini PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST), 3857ff71d6aSMatt Porter }, 3867ff71d6aSMatt Porter { /* end: all zeroes */ } 3877ff71d6aSMatt Porter }; 3887ff71d6aSMatt Porter MODULE_DEVICE_TABLE(pci, pci_ids); 3897ff71d6aSMatt Porter 3907ff71d6aSMatt Porter /* pci driver glue; this is a "new style" PCI driver module */ 3917ff71d6aSMatt Porter static struct pci_driver ehci_pci_driver = { 3927cbfeb65SCorentin Labbe .name = hcd_name, 3937ff71d6aSMatt Porter .id_table = pci_ids, 3947ff71d6aSMatt Porter 395cefa9a31SAndy Shevchenko .probe = ehci_pci_probe, 396e3e2e36cSJia-Ju Bai .remove = ehci_pci_remove, 39764a21d02SAleksey Gorelov .shutdown = usb_hcd_pci_shutdown, 398abb30641SAlan Stern 399f875fdbfSAlan Stern #ifdef CONFIG_PM 400abb30641SAlan Stern .driver = { 401abb30641SAlan Stern .pm = &usb_hcd_pci_pm_ops 402abb30641SAlan Stern }, 403abb30641SAlan Stern #endif 4047ff71d6aSMatt Porter }; 405adfa79d1SAlan Stern 406adfa79d1SAlan Stern static int __init ehci_pci_init(void) 407adfa79d1SAlan Stern { 408adfa79d1SAlan Stern if (usb_disabled()) 409adfa79d1SAlan Stern return -ENODEV; 410adfa79d1SAlan Stern 411adfa79d1SAlan Stern pr_info("%s: " DRIVER_DESC "\n", hcd_name); 412adfa79d1SAlan Stern 4131b36810eSAlan Stern ehci_init_driver(&ehci_pci_hc_driver, &pci_overrides); 414adfa79d1SAlan Stern 415adfa79d1SAlan Stern /* Entries for the PCI suspend/resume callbacks are special */ 416adfa79d1SAlan Stern ehci_pci_hc_driver.pci_suspend = ehci_suspend; 417adfa79d1SAlan Stern ehci_pci_hc_driver.pci_resume = ehci_pci_resume; 418adfa79d1SAlan Stern 419adfa79d1SAlan Stern return pci_register_driver(&ehci_pci_driver); 420adfa79d1SAlan Stern } 421adfa79d1SAlan Stern module_init(ehci_pci_init); 422adfa79d1SAlan Stern 423adfa79d1SAlan Stern static void __exit ehci_pci_cleanup(void) 424adfa79d1SAlan Stern { 425adfa79d1SAlan Stern pci_unregister_driver(&ehci_pci_driver); 426adfa79d1SAlan Stern } 427adfa79d1SAlan Stern module_exit(ehci_pci_cleanup); 428adfa79d1SAlan Stern 429adfa79d1SAlan Stern MODULE_DESCRIPTION(DRIVER_DESC); 430adfa79d1SAlan Stern MODULE_AUTHOR("David Brownell"); 431adfa79d1SAlan Stern MODULE_AUTHOR("Alan Stern"); 432adfa79d1SAlan Stern MODULE_LICENSE("GPL"); 433