xref: /linux/drivers/usb/host/ehci-pci.c (revision ceb6c9c862c86423f41c1e20ecf8d454f837f519)
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 
21adfa79d1SAlan Stern #include <linux/kernel.h>
22adfa79d1SAlan Stern #include <linux/module.h>
23adfa79d1SAlan Stern #include <linux/pci.h>
24adfa79d1SAlan Stern #include <linux/usb.h>
25adfa79d1SAlan Stern #include <linux/usb/hcd.h>
26adfa79d1SAlan Stern 
27adfa79d1SAlan Stern #include "ehci.h"
28adfa79d1SAlan Stern #include "pci-quirks.h"
29adfa79d1SAlan Stern 
30adfa79d1SAlan Stern #define DRIVER_DESC "EHCI PCI platform driver"
31adfa79d1SAlan Stern 
32adfa79d1SAlan Stern static const char hcd_name[] = "ehci-pci";
337ff71d6aSMatt Porter 
344f683843SDirk Brandewie /* defined here to avoid adding to pci_ids.h for single instance use */
354f683843SDirk Brandewie #define PCI_DEVICE_ID_INTEL_CE4100_USB	0x2e70
364f683843SDirk Brandewie 
377ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/
386e693739SBryan O'Donoghue #define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC		0x0939
396e693739SBryan O'Donoghue static inline bool is_intel_quark_x1000(struct pci_dev *pdev)
406e693739SBryan O'Donoghue {
416e693739SBryan O'Donoghue 	return pdev->vendor == PCI_VENDOR_ID_INTEL &&
426e693739SBryan O'Donoghue 		pdev->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC;
436e693739SBryan O'Donoghue }
446e693739SBryan O'Donoghue 
456e693739SBryan O'Donoghue /*
466e693739SBryan O'Donoghue  * 0x84 is the offset of in/out threshold register,
476e693739SBryan O'Donoghue  * and it is the same offset as the register of 'hostpc'.
486e693739SBryan O'Donoghue  */
496e693739SBryan O'Donoghue #define	intel_quark_x1000_insnreg01	hostpc
506e693739SBryan O'Donoghue 
516e693739SBryan O'Donoghue /* Maximum usable threshold value is 0x7f dwords for both IN and OUT */
526e693739SBryan O'Donoghue #define INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD	0x007f007f
537ff71d6aSMatt Porter 
5418807521SDavid Brownell /* called after powerup, by probe or system-pm "wakeup" */
5518807521SDavid Brownell static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
5618807521SDavid Brownell {
5718807521SDavid Brownell 	int			retval;
5818807521SDavid Brownell 
59401feafaSDavid Brownell 	/* we expect static quirk code to handle the "extended capabilities"
60401feafaSDavid Brownell 	 * (currently just BIOS handoff) allowed starting with EHCI 0.96
61401feafaSDavid Brownell 	 */
6218807521SDavid Brownell 
6318807521SDavid Brownell 	/* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */
6418807521SDavid Brownell 	retval = pci_set_mwi(pdev);
6518807521SDavid Brownell 	if (!retval)
6618807521SDavid Brownell 		ehci_dbg(ehci, "MWI active\n");
6718807521SDavid Brownell 
686e693739SBryan O'Donoghue 	/* Reset the threshold limit */
696e693739SBryan O'Donoghue 	if (is_intel_quark_x1000(pdev)) {
706e693739SBryan O'Donoghue 		/*
716e693739SBryan O'Donoghue 		 * For the Intel QUARK X1000, raise the I/O threshold to the
726e693739SBryan O'Donoghue 		 * maximum usable value in order to improve performance.
736e693739SBryan O'Donoghue 		 */
746e693739SBryan O'Donoghue 		ehci_writel(ehci, INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD,
756e693739SBryan O'Donoghue 			ehci->regs->intel_quark_x1000_insnreg01);
766e693739SBryan O'Donoghue 	}
776e693739SBryan O'Donoghue 
7818807521SDavid Brownell 	return 0;
7918807521SDavid Brownell }
8018807521SDavid Brownell 
818926bfa7SDavid Brownell /* called during probe() after chip reset completes */
828926bfa7SDavid Brownell static int ehci_pci_setup(struct usb_hcd *hcd)
837ff71d6aSMatt Porter {
847ff71d6aSMatt Porter 	struct ehci_hcd		*ehci = hcd_to_ehci(hcd);
85abcc9448SDavid Brownell 	struct pci_dev		*pdev = to_pci_dev(hcd->self.controller);
867ff71d6aSMatt Porter 	u32			temp;
8718807521SDavid Brownell 	int			retval;
887ff71d6aSMatt Porter 
891a49e2acSAlan Stern 	ehci->caps = hcd->regs;
901a49e2acSAlan Stern 
911a49e2acSAlan Stern 	/*
921a49e2acSAlan Stern 	 * ehci_init() causes memory for DMA transfers to be
931a49e2acSAlan Stern 	 * allocated.  Thus, any vendor-specific workarounds based on
941a49e2acSAlan Stern 	 * limiting the type of memory used for DMA transfers must
951a49e2acSAlan Stern 	 * happen before ehci_setup() is called.
961a49e2acSAlan Stern 	 *
971a49e2acSAlan Stern 	 * Most other workarounds can be done either before or after
981a49e2acSAlan Stern 	 * init and reset; they are located here too.
991a49e2acSAlan Stern 	 */
100083522d7SBenjamin Herrenschmidt 	switch (pdev->vendor) {
101083522d7SBenjamin Herrenschmidt 	case PCI_VENDOR_ID_TOSHIBA_2:
102083522d7SBenjamin Herrenschmidt 		/* celleb's companion chip */
103083522d7SBenjamin Herrenschmidt 		if (pdev->device == 0x01b5) {
104083522d7SBenjamin Herrenschmidt #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
105083522d7SBenjamin Herrenschmidt 			ehci->big_endian_mmio = 1;
106083522d7SBenjamin Herrenschmidt #else
107083522d7SBenjamin Herrenschmidt 			ehci_warn(ehci,
108083522d7SBenjamin Herrenschmidt 				  "unsupported big endian Toshiba quirk\n");
109083522d7SBenjamin Herrenschmidt #endif
110083522d7SBenjamin Herrenschmidt 		}
111083522d7SBenjamin Herrenschmidt 		break;
112c32ba30fSPaul Serice 	case PCI_VENDOR_ID_NVIDIA:
113c32ba30fSPaul Serice 		/* NVidia reports that certain chips don't handle
114c32ba30fSPaul Serice 		 * QH, ITD, or SITD addresses above 2GB.  (But TD,
115c32ba30fSPaul Serice 		 * data buffer, and periodic schedule are normal.)
116c32ba30fSPaul Serice 		 */
117c32ba30fSPaul Serice 		switch (pdev->device) {
118c32ba30fSPaul Serice 		case 0x003c:	/* MCP04 */
119c32ba30fSPaul Serice 		case 0x005b:	/* CK804 */
120c32ba30fSPaul Serice 		case 0x00d8:	/* CK8 */
121c32ba30fSPaul Serice 		case 0x00e8:	/* CK8S */
122c32ba30fSPaul Serice 			if (pci_set_consistent_dma_mask(pdev,
123929a22a5SYang Hongyang 						DMA_BIT_MASK(31)) < 0)
124c32ba30fSPaul Serice 				ehci_warn(ehci, "can't enable NVidia "
125c32ba30fSPaul Serice 					"workaround for >2GB RAM\n");
126c32ba30fSPaul Serice 			break;
1271a49e2acSAlan Stern 
1281a49e2acSAlan Stern 		/* Some NForce2 chips have problems with selective suspend;
1291a49e2acSAlan Stern 		 * fixed in newer silicon.
1301a49e2acSAlan Stern 		 */
1311a49e2acSAlan Stern 		case 0x0068:
1321a49e2acSAlan Stern 			if (pdev->revision < 0xa4)
1331a49e2acSAlan Stern 				ehci->no_selective_suspend = 1;
134c32ba30fSPaul Serice 			break;
135c32ba30fSPaul Serice 		}
1363681d8f3SDavid Miller 		break;
137403dbd36SAlek Du 	case PCI_VENDOR_ID_INTEL:
1381a49e2acSAlan Stern 		if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB)
1394f683843SDirk Brandewie 			hcd->has_tt = 1;
140403dbd36SAlek Du 		break;
1417ff71d6aSMatt Porter 	case PCI_VENDOR_ID_TDI:
1421a49e2acSAlan Stern 		if (pdev->device == PCI_DEVICE_ID_TDI_EHCI)
1437329e211SAlan Stern 			hcd->has_tt = 1;
1447ff71d6aSMatt Porter 		break;
1457ff71d6aSMatt Porter 	case PCI_VENDOR_ID_AMD:
146ad93562bSAndiry Xu 		/* AMD PLL quirk */
147ad93562bSAndiry Xu 		if (usb_amd_find_chipset_info())
148ad93562bSAndiry Xu 			ehci->amd_pll_fix = 1;
1497ff71d6aSMatt Porter 		/* AMD8111 EHCI doesn't work, according to AMD errata */
1507ff71d6aSMatt Porter 		if (pdev->device == 0x7463) {
1517ff71d6aSMatt Porter 			ehci_info(ehci, "ignoring AMD8111 (errata)\n");
1528926bfa7SDavid Brownell 			retval = -EIO;
1538926bfa7SDavid Brownell 			goto done;
1547ff71d6aSMatt Porter 		}
155a85b4e7fSBrian J. Tarricone 
1561a49e2acSAlan Stern 		/*
1571a49e2acSAlan Stern 		 * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may
1581a49e2acSAlan Stern 		 * read/write memory space which does not belong to it when
1591a49e2acSAlan Stern 		 * there is NULL pointer with T-bit set to 1 in the frame list
1601a49e2acSAlan Stern 		 * table. To avoid the issue, the frame list link pointer
1611a49e2acSAlan Stern 		 * should always contain a valid pointer to a inactive qh.
162a85b4e7fSBrian J. Tarricone 		 */
1631a49e2acSAlan Stern 		if (pdev->device == 0x7808) {
1641a49e2acSAlan Stern 			ehci->use_dummy_qh = 1;
1651a49e2acSAlan Stern 			ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n");
1667ff71d6aSMatt Porter 		}
1677ff71d6aSMatt Porter 		break;
168055b93c9SRene Herman 	case PCI_VENDOR_ID_VIA:
169055b93c9SRene Herman 		if (pdev->device == 0x3104 && (pdev->revision & 0xf0) == 0x60) {
170055b93c9SRene Herman 			u8 tmp;
171055b93c9SRene Herman 
172055b93c9SRene Herman 			/* The VT6212 defaults to a 1 usec EHCI sleep time which
173055b93c9SRene Herman 			 * hogs the PCI bus *badly*. Setting bit 5 of 0x4B makes
174055b93c9SRene Herman 			 * that sleep time use the conventional 10 usec.
175055b93c9SRene Herman 			 */
176055b93c9SRene Herman 			pci_read_config_byte(pdev, 0x4b, &tmp);
177055b93c9SRene Herman 			if (tmp & 0x20)
178055b93c9SRene Herman 				break;
179055b93c9SRene Herman 			pci_write_config_byte(pdev, 0x4b, tmp | 0x20);
180055b93c9SRene Herman 		}
181055b93c9SRene Herman 		break;
182b09bc6cbSAndiry Xu 	case PCI_VENDOR_ID_ATI:
183ad93562bSAndiry Xu 		/* AMD PLL quirk */
184ad93562bSAndiry Xu 		if (usb_amd_find_chipset_info())
185ad93562bSAndiry Xu 			ehci->amd_pll_fix = 1;
1861a49e2acSAlan Stern 
1871a49e2acSAlan Stern 		/*
1881a49e2acSAlan Stern 		 * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may
1891a49e2acSAlan Stern 		 * read/write memory space which does not belong to it when
1901a49e2acSAlan Stern 		 * there is NULL pointer with T-bit set to 1 in the frame list
1911a49e2acSAlan Stern 		 * table. To avoid the issue, the frame list link pointer
1921a49e2acSAlan Stern 		 * should always contain a valid pointer to a inactive qh.
1931a49e2acSAlan Stern 		 */
1941a49e2acSAlan Stern 		if (pdev->device == 0x4396) {
1951a49e2acSAlan Stern 			ehci->use_dummy_qh = 1;
1961a49e2acSAlan Stern 			ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n");
1971a49e2acSAlan Stern 		}
1980a99e8acSShane Huang 		/* SB600 and old version of SB700 have a bug in EHCI controller,
199b09bc6cbSAndiry Xu 		 * which causes usb devices lose response in some cases.
200b09bc6cbSAndiry Xu 		 */
2013ad145b6SHuang Rui 		if ((pdev->device == 0x4386 || pdev->device == 0x4396) &&
2023ad145b6SHuang Rui 				usb_amd_hang_symptom_quirk()) {
203b09bc6cbSAndiry Xu 			u8 tmp;
2043ad145b6SHuang Rui 			ehci_info(ehci, "applying AMD SB600/SB700 USB freeze workaround\n");
205b09bc6cbSAndiry Xu 			pci_read_config_byte(pdev, 0x53, &tmp);
206b09bc6cbSAndiry Xu 			pci_write_config_byte(pdev, 0x53, tmp | (1<<3));
207b09bc6cbSAndiry Xu 		}
208b09bc6cbSAndiry Xu 		break;
20968aa95d5SAlan Stern 	case PCI_VENDOR_ID_NETMOS:
21068aa95d5SAlan Stern 		/* MosChip frame-index-register bug */
21168aa95d5SAlan Stern 		ehci_info(ehci, "applying MosChip frame-index workaround\n");
21268aa95d5SAlan Stern 		ehci->frame_index_bug = 1;
21368aa95d5SAlan Stern 		break;
2147ff71d6aSMatt Porter 	}
2157ff71d6aSMatt Porter 
21675e1a2aeSJan Beulich 	/* optional debug port, normally in the first BAR */
21775e1a2aeSJan Beulich 	temp = pci_find_capability(pdev, PCI_CAP_ID_DBG);
21875e1a2aeSJan Beulich 	if (temp) {
21975e1a2aeSJan Beulich 		pci_read_config_dword(pdev, temp, &temp);
22075e1a2aeSJan Beulich 		temp >>= 16;
22175e1a2aeSJan Beulich 		if (((temp >> 13) & 7) == 1) {
22275e1a2aeSJan Beulich 			u32 hcs_params = ehci_readl(ehci,
22375e1a2aeSJan Beulich 						    &ehci->caps->hcs_params);
22475e1a2aeSJan Beulich 
22575e1a2aeSJan Beulich 			temp &= 0x1fff;
22675e1a2aeSJan Beulich 			ehci->debug = hcd->regs + temp;
22775e1a2aeSJan Beulich 			temp = ehci_readl(ehci, &ehci->debug->control);
22875e1a2aeSJan Beulich 			ehci_info(ehci, "debug port %d%s\n",
22975e1a2aeSJan Beulich 				  HCS_DEBUG_PORT(hcs_params),
23075e1a2aeSJan Beulich 				  (temp & DBGP_ENABLED) ? " IN USE" : "");
23175e1a2aeSJan Beulich 			if (!(temp & DBGP_ENABLED))
23275e1a2aeSJan Beulich 				ehci->debug = NULL;
23375e1a2aeSJan Beulich 		}
23475e1a2aeSJan Beulich 	}
23575e1a2aeSJan Beulich 
2361a49e2acSAlan Stern 	retval = ehci_setup(hcd);
2371a49e2acSAlan Stern 	if (retval)
2381a49e2acSAlan Stern 		return retval;
2391a49e2acSAlan Stern 
2401a49e2acSAlan Stern 	/* These workarounds need to be applied after ehci_setup() */
2411a49e2acSAlan Stern 	switch (pdev->vendor) {
2421a49e2acSAlan Stern 	case PCI_VENDOR_ID_NEC:
2431a49e2acSAlan Stern 		ehci->need_io_watchdog = 0;
2441a49e2acSAlan Stern 		break;
2451a49e2acSAlan Stern 	case PCI_VENDOR_ID_INTEL:
2461a49e2acSAlan Stern 		ehci->need_io_watchdog = 0;
2471a49e2acSAlan Stern 		break;
2481a49e2acSAlan Stern 	case PCI_VENDOR_ID_NVIDIA:
2491a49e2acSAlan Stern 		switch (pdev->device) {
2501a49e2acSAlan Stern 		/* MCP89 chips on the MacBookAir3,1 give EPROTO when
2511a49e2acSAlan Stern 		 * fetching device descriptors unless LPM is disabled.
2521a49e2acSAlan Stern 		 * There are also intermittent problems enumerating
2531a49e2acSAlan Stern 		 * devices with PPCD enabled.
2541a49e2acSAlan Stern 		 */
2551a49e2acSAlan Stern 		case 0x0d9d:
2564968f951SAlan Stern 			ehci_info(ehci, "disable ppcd for nvidia mcp89\n");
2571a49e2acSAlan Stern 			ehci->has_ppcd = 0;
2581a49e2acSAlan Stern 			ehci->command &= ~CMD_PPCEE;
2591a49e2acSAlan Stern 			break;
2601a49e2acSAlan Stern 		}
2611a49e2acSAlan Stern 		break;
2621a49e2acSAlan Stern 	}
2631a49e2acSAlan Stern 
2647ff71d6aSMatt Porter 	/* at least the Genesys GL880S needs fixup here */
2657ff71d6aSMatt Porter 	temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params);
2667ff71d6aSMatt Porter 	temp &= 0x0f;
2677ff71d6aSMatt Porter 	if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) {
2687ff71d6aSMatt Porter 		ehci_dbg(ehci, "bogus port configuration: "
2697ff71d6aSMatt Porter 			"cc=%d x pcc=%d < ports=%d\n",
2707ff71d6aSMatt Porter 			HCS_N_CC(ehci->hcs_params),
2717ff71d6aSMatt Porter 			HCS_N_PCC(ehci->hcs_params),
2727ff71d6aSMatt Porter 			HCS_N_PORTS(ehci->hcs_params));
2737ff71d6aSMatt Porter 
2747ff71d6aSMatt Porter 		switch (pdev->vendor) {
2757ff71d6aSMatt Porter 		case 0x17a0:		/* GENESYS */
2767ff71d6aSMatt Porter 			/* GL880S: should be PORTS=2 */
2777ff71d6aSMatt Porter 			temp |= (ehci->hcs_params & ~0xf);
2787ff71d6aSMatt Porter 			ehci->hcs_params = temp;
2797ff71d6aSMatt Porter 			break;
2807ff71d6aSMatt Porter 		case PCI_VENDOR_ID_NVIDIA:
2817ff71d6aSMatt Porter 			/* NF4: should be PCC=10 */
2827ff71d6aSMatt Porter 			break;
2837ff71d6aSMatt Porter 		}
2847ff71d6aSMatt Porter 	}
2857ff71d6aSMatt Porter 
2867ff71d6aSMatt Porter 	/* Serial Bus Release Number is at PCI 0x60 offset */
2873a0bac06SAlessandro Rubini 	if (pdev->vendor == PCI_VENDOR_ID_STMICRO
2883a0bac06SAlessandro Rubini 	    && pdev->device == PCI_DEVICE_ID_STMICRO_USB_HOST)
2891a49e2acSAlan Stern 		;	/* ConneXT has no sbrn register */
2901a49e2acSAlan Stern 	else
2911a49e2acSAlan Stern 		pci_read_config_byte(pdev, 0x60, &ehci->sbrn);
2927ff71d6aSMatt Porter 
2936fd9086aSAlan Stern 	/* Keep this around for a while just in case some EHCI
2946fd9086aSAlan Stern 	 * implementation uses legacy PCI PM support.  This test
2956fd9086aSAlan Stern 	 * can be removed on 17 Dec 2009 if the dev_warn() hasn't
2966fd9086aSAlan Stern 	 * been triggered by then.
2972c1c3c4cSDavid Brownell 	 */
2982c1c3c4cSDavid Brownell 	if (!device_can_wakeup(&pdev->dev)) {
2992c1c3c4cSDavid Brownell 		u16	port_wake;
3002c1c3c4cSDavid Brownell 
3012c1c3c4cSDavid Brownell 		pci_read_config_word(pdev, 0x62, &port_wake);
3026fd9086aSAlan Stern 		if (port_wake & 0x0001) {
3036fd9086aSAlan Stern 			dev_warn(&pdev->dev, "Enabling legacy PCI PM\n");
304bcca06efSAlan Stern 			device_set_wakeup_capable(&pdev->dev, 1);
3052c1c3c4cSDavid Brownell 		}
3066fd9086aSAlan Stern 	}
3077ff71d6aSMatt Porter 
308*ceb6c9c8SRafael J. Wysocki #ifdef	CONFIG_PM
309f8aeb3bbSDavid Brownell 	if (ehci->no_selective_suspend && device_can_wakeup(&pdev->dev))
310f8aeb3bbSDavid Brownell 		ehci_warn(ehci, "selective suspend/wakeup unavailable\n");
311f8aeb3bbSDavid Brownell #endif
312f8aeb3bbSDavid Brownell 
31318807521SDavid Brownell 	retval = ehci_pci_reinit(ehci, pdev);
3148926bfa7SDavid Brownell done:
3158926bfa7SDavid Brownell 	return retval;
3167ff71d6aSMatt Porter }
3177ff71d6aSMatt Porter 
3187ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/
3197ff71d6aSMatt Porter 
3207ff71d6aSMatt Porter #ifdef	CONFIG_PM
3217ff71d6aSMatt Porter 
3227ff71d6aSMatt Porter /* suspend/resume, section 4.3 */
3237ff71d6aSMatt Porter 
324f03c17fcSDavid Brownell /* These routines rely on the PCI bus glue
3257ff71d6aSMatt Porter  * to handle powerdown and wakeup, and currently also on
3267ff71d6aSMatt Porter  * transceivers that don't need any software attention to set up
3277ff71d6aSMatt Porter  * the right sort of wakeup.
328f03c17fcSDavid Brownell  * Also they depend on separate root hub suspend/resume.
3297ff71d6aSMatt Porter  */
3307ff71d6aSMatt Porter 
3316ec4beb5SAlan Stern static int ehci_pci_resume(struct usb_hcd *hcd, bool hibernated)
3327ff71d6aSMatt Porter {
3337ff71d6aSMatt Porter 	struct ehci_hcd		*ehci = hcd_to_ehci(hcd);
33418807521SDavid Brownell 	struct pci_dev		*pdev = to_pci_dev(hcd->self.controller);
3357ff71d6aSMatt Porter 
336c5cf9212SAlan Stern 	if (ehci_resume(hcd, hibernated) != 0)
33718807521SDavid Brownell 		(void) ehci_pci_reinit(ehci, pdev);
3388c03356aSAlan Stern 	return 0;
3397ff71d6aSMatt Porter }
3407ff71d6aSMatt Porter 
341adfa79d1SAlan Stern #else
3427ff71d6aSMatt Porter 
343adfa79d1SAlan Stern #define ehci_suspend		NULL
344adfa79d1SAlan Stern #define ehci_pci_resume		NULL
345adfa79d1SAlan Stern #endif	/* CONFIG_PM */
3467ff71d6aSMatt Porter 
347adfa79d1SAlan Stern static struct hc_driver __read_mostly ehci_pci_hc_driver;
348adfa79d1SAlan Stern 
34962d08a11SAndi Kleen static const struct ehci_driver_overrides pci_overrides __initconst = {
3508926bfa7SDavid Brownell 	.reset =		ehci_pci_setup,
3517ff71d6aSMatt Porter };
3527ff71d6aSMatt Porter 
3537ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/
3547ff71d6aSMatt Porter 
3557ff71d6aSMatt Porter /* PCI driver selection metadata; PCI hotplugging uses this */
3567ff71d6aSMatt Porter static const struct pci_device_id pci_ids [] = { {
3577ff71d6aSMatt Porter 	/* handle any USB 2.0 EHCI controller */
358c67808eeSJean Delvare 	PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0),
3597ff71d6aSMatt Porter 	.driver_data =	(unsigned long) &ehci_pci_hc_driver,
3603a0bac06SAlessandro Rubini 	}, {
3613a0bac06SAlessandro Rubini 	PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST),
3623a0bac06SAlessandro Rubini 	.driver_data = (unsigned long) &ehci_pci_hc_driver,
3637ff71d6aSMatt Porter 	},
3647ff71d6aSMatt Porter 	{ /* end: all zeroes */ }
3657ff71d6aSMatt Porter };
3667ff71d6aSMatt Porter MODULE_DEVICE_TABLE(pci, pci_ids);
3677ff71d6aSMatt Porter 
3687ff71d6aSMatt Porter /* pci driver glue; this is a "new style" PCI driver module */
3697ff71d6aSMatt Porter static struct pci_driver ehci_pci_driver = {
3707ff71d6aSMatt Porter 	.name =		(char *) hcd_name,
3717ff71d6aSMatt Porter 	.id_table =	pci_ids,
3727ff71d6aSMatt Porter 
3737ff71d6aSMatt Porter 	.probe =	usb_hcd_pci_probe,
3747ff71d6aSMatt Porter 	.remove =	usb_hcd_pci_remove,
37564a21d02SAleksey Gorelov 	.shutdown = 	usb_hcd_pci_shutdown,
376abb30641SAlan Stern 
377f875fdbfSAlan Stern #ifdef CONFIG_PM
378abb30641SAlan Stern 	.driver =	{
379abb30641SAlan Stern 		.pm =	&usb_hcd_pci_pm_ops
380abb30641SAlan Stern 	},
381abb30641SAlan Stern #endif
3827ff71d6aSMatt Porter };
383adfa79d1SAlan Stern 
384adfa79d1SAlan Stern static int __init ehci_pci_init(void)
385adfa79d1SAlan Stern {
386adfa79d1SAlan Stern 	if (usb_disabled())
387adfa79d1SAlan Stern 		return -ENODEV;
388adfa79d1SAlan Stern 
389adfa79d1SAlan Stern 	pr_info("%s: " DRIVER_DESC "\n", hcd_name);
390adfa79d1SAlan Stern 
3911b36810eSAlan Stern 	ehci_init_driver(&ehci_pci_hc_driver, &pci_overrides);
392adfa79d1SAlan Stern 
393adfa79d1SAlan Stern 	/* Entries for the PCI suspend/resume callbacks are special */
394adfa79d1SAlan Stern 	ehci_pci_hc_driver.pci_suspend = ehci_suspend;
395adfa79d1SAlan Stern 	ehci_pci_hc_driver.pci_resume = ehci_pci_resume;
396adfa79d1SAlan Stern 
397adfa79d1SAlan Stern 	return pci_register_driver(&ehci_pci_driver);
398adfa79d1SAlan Stern }
399adfa79d1SAlan Stern module_init(ehci_pci_init);
400adfa79d1SAlan Stern 
401adfa79d1SAlan Stern static void __exit ehci_pci_cleanup(void)
402adfa79d1SAlan Stern {
403adfa79d1SAlan Stern 	pci_unregister_driver(&ehci_pci_driver);
404adfa79d1SAlan Stern }
405adfa79d1SAlan Stern module_exit(ehci_pci_cleanup);
406adfa79d1SAlan Stern 
407adfa79d1SAlan Stern MODULE_DESCRIPTION(DRIVER_DESC);
408adfa79d1SAlan Stern MODULE_AUTHOR("David Brownell");
409adfa79d1SAlan Stern MODULE_AUTHOR("Alan Stern");
410adfa79d1SAlan Stern MODULE_LICENSE("GPL");
411