xref: /OK3568_Linux_fs/kernel/drivers/usb/host/ehci-pci.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0+
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * EHCI HCD (Host Controller Driver) PCI Bus Glue.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (c) 2000-2004 by David Brownell
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #include <linux/kernel.h>
9*4882a593Smuzhiyun #include <linux/module.h>
10*4882a593Smuzhiyun #include <linux/pci.h>
11*4882a593Smuzhiyun #include <linux/usb.h>
12*4882a593Smuzhiyun #include <linux/usb/hcd.h>
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun #include "ehci.h"
15*4882a593Smuzhiyun #include "pci-quirks.h"
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #define DRIVER_DESC "EHCI PCI platform driver"
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun static const char hcd_name[] = "ehci-pci";
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun /* defined here to avoid adding to pci_ids.h for single instance use */
22*4882a593Smuzhiyun #define PCI_DEVICE_ID_INTEL_CE4100_USB	0x2e70
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun #define PCI_VENDOR_ID_ASPEED		0x1a03
25*4882a593Smuzhiyun #define PCI_DEVICE_ID_ASPEED_EHCI	0x2603
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun /*-------------------------------------------------------------------------*/
28*4882a593Smuzhiyun #define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC		0x0939
is_intel_quark_x1000(struct pci_dev * pdev)29*4882a593Smuzhiyun static inline bool is_intel_quark_x1000(struct pci_dev *pdev)
30*4882a593Smuzhiyun {
31*4882a593Smuzhiyun 	return pdev->vendor == PCI_VENDOR_ID_INTEL &&
32*4882a593Smuzhiyun 		pdev->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC;
33*4882a593Smuzhiyun }
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun /*
36*4882a593Smuzhiyun  * This is the list of PCI IDs for the devices that have EHCI USB class and
37*4882a593Smuzhiyun  * specific drivers for that. One of the example is a ChipIdea device installed
38*4882a593Smuzhiyun  * on some Intel MID platforms.
39*4882a593Smuzhiyun  */
40*4882a593Smuzhiyun static const struct pci_device_id bypass_pci_id_table[] = {
41*4882a593Smuzhiyun 	/* ChipIdea on Intel MID platform */
42*4882a593Smuzhiyun 	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0811), },
43*4882a593Smuzhiyun 	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0829), },
44*4882a593Smuzhiyun 	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe006), },
45*4882a593Smuzhiyun 	{}
46*4882a593Smuzhiyun };
47*4882a593Smuzhiyun 
is_bypassed_id(struct pci_dev * pdev)48*4882a593Smuzhiyun static inline bool is_bypassed_id(struct pci_dev *pdev)
49*4882a593Smuzhiyun {
50*4882a593Smuzhiyun 	return !!pci_match_id(bypass_pci_id_table, pdev);
51*4882a593Smuzhiyun }
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun /*
54*4882a593Smuzhiyun  * 0x84 is the offset of in/out threshold register,
55*4882a593Smuzhiyun  * and it is the same offset as the register of 'hostpc'.
56*4882a593Smuzhiyun  */
57*4882a593Smuzhiyun #define	intel_quark_x1000_insnreg01	hostpc
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun /* Maximum usable threshold value is 0x7f dwords for both IN and OUT */
60*4882a593Smuzhiyun #define INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD	0x007f007f
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun /* called after powerup, by probe or system-pm "wakeup" */
ehci_pci_reinit(struct ehci_hcd * ehci,struct pci_dev * pdev)63*4882a593Smuzhiyun static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
64*4882a593Smuzhiyun {
65*4882a593Smuzhiyun 	int			retval;
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun 	/* we expect static quirk code to handle the "extended capabilities"
68*4882a593Smuzhiyun 	 * (currently just BIOS handoff) allowed starting with EHCI 0.96
69*4882a593Smuzhiyun 	 */
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun 	/* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */
72*4882a593Smuzhiyun 	retval = pci_set_mwi(pdev);
73*4882a593Smuzhiyun 	if (!retval)
74*4882a593Smuzhiyun 		ehci_dbg(ehci, "MWI active\n");
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun 	/* Reset the threshold limit */
77*4882a593Smuzhiyun 	if (is_intel_quark_x1000(pdev)) {
78*4882a593Smuzhiyun 		/*
79*4882a593Smuzhiyun 		 * For the Intel QUARK X1000, raise the I/O threshold to the
80*4882a593Smuzhiyun 		 * maximum usable value in order to improve performance.
81*4882a593Smuzhiyun 		 */
82*4882a593Smuzhiyun 		ehci_writel(ehci, INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD,
83*4882a593Smuzhiyun 			ehci->regs->intel_quark_x1000_insnreg01);
84*4882a593Smuzhiyun 	}
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun 	return 0;
87*4882a593Smuzhiyun }
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun /* called during probe() after chip reset completes */
ehci_pci_setup(struct usb_hcd * hcd)90*4882a593Smuzhiyun static int ehci_pci_setup(struct usb_hcd *hcd)
91*4882a593Smuzhiyun {
92*4882a593Smuzhiyun 	struct ehci_hcd		*ehci = hcd_to_ehci(hcd);
93*4882a593Smuzhiyun 	struct pci_dev		*pdev = to_pci_dev(hcd->self.controller);
94*4882a593Smuzhiyun 	u32			temp;
95*4882a593Smuzhiyun 	int			retval;
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun 	ehci->caps = hcd->regs;
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun 	/*
100*4882a593Smuzhiyun 	 * ehci_init() causes memory for DMA transfers to be
101*4882a593Smuzhiyun 	 * allocated.  Thus, any vendor-specific workarounds based on
102*4882a593Smuzhiyun 	 * limiting the type of memory used for DMA transfers must
103*4882a593Smuzhiyun 	 * happen before ehci_setup() is called.
104*4882a593Smuzhiyun 	 *
105*4882a593Smuzhiyun 	 * Most other workarounds can be done either before or after
106*4882a593Smuzhiyun 	 * init and reset; they are located here too.
107*4882a593Smuzhiyun 	 */
108*4882a593Smuzhiyun 	switch (pdev->vendor) {
109*4882a593Smuzhiyun 	case PCI_VENDOR_ID_TOSHIBA_2:
110*4882a593Smuzhiyun 		/* celleb's companion chip */
111*4882a593Smuzhiyun 		if (pdev->device == 0x01b5) {
112*4882a593Smuzhiyun #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
113*4882a593Smuzhiyun 			ehci->big_endian_mmio = 1;
114*4882a593Smuzhiyun #else
115*4882a593Smuzhiyun 			ehci_warn(ehci,
116*4882a593Smuzhiyun 				  "unsupported big endian Toshiba quirk\n");
117*4882a593Smuzhiyun #endif
118*4882a593Smuzhiyun 		}
119*4882a593Smuzhiyun 		break;
120*4882a593Smuzhiyun 	case PCI_VENDOR_ID_NVIDIA:
121*4882a593Smuzhiyun 		/* NVidia reports that certain chips don't handle
122*4882a593Smuzhiyun 		 * QH, ITD, or SITD addresses above 2GB.  (But TD,
123*4882a593Smuzhiyun 		 * data buffer, and periodic schedule are normal.)
124*4882a593Smuzhiyun 		 */
125*4882a593Smuzhiyun 		switch (pdev->device) {
126*4882a593Smuzhiyun 		case 0x003c:	/* MCP04 */
127*4882a593Smuzhiyun 		case 0x005b:	/* CK804 */
128*4882a593Smuzhiyun 		case 0x00d8:	/* CK8 */
129*4882a593Smuzhiyun 		case 0x00e8:	/* CK8S */
130*4882a593Smuzhiyun 			if (dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(31)) < 0)
131*4882a593Smuzhiyun 				ehci_warn(ehci, "can't enable NVidia "
132*4882a593Smuzhiyun 					"workaround for >2GB RAM\n");
133*4882a593Smuzhiyun 			break;
134*4882a593Smuzhiyun 
135*4882a593Smuzhiyun 		/* Some NForce2 chips have problems with selective suspend;
136*4882a593Smuzhiyun 		 * fixed in newer silicon.
137*4882a593Smuzhiyun 		 */
138*4882a593Smuzhiyun 		case 0x0068:
139*4882a593Smuzhiyun 			if (pdev->revision < 0xa4)
140*4882a593Smuzhiyun 				ehci->no_selective_suspend = 1;
141*4882a593Smuzhiyun 			break;
142*4882a593Smuzhiyun 		}
143*4882a593Smuzhiyun 		break;
144*4882a593Smuzhiyun 	case PCI_VENDOR_ID_INTEL:
145*4882a593Smuzhiyun 		if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB)
146*4882a593Smuzhiyun 			hcd->has_tt = 1;
147*4882a593Smuzhiyun 		break;
148*4882a593Smuzhiyun 	case PCI_VENDOR_ID_TDI:
149*4882a593Smuzhiyun 		if (pdev->device == PCI_DEVICE_ID_TDI_EHCI)
150*4882a593Smuzhiyun 			hcd->has_tt = 1;
151*4882a593Smuzhiyun 		break;
152*4882a593Smuzhiyun 	case PCI_VENDOR_ID_AMD:
153*4882a593Smuzhiyun 		/* AMD PLL quirk */
154*4882a593Smuzhiyun 		if (usb_amd_quirk_pll_check())
155*4882a593Smuzhiyun 			ehci->amd_pll_fix = 1;
156*4882a593Smuzhiyun 		/* AMD8111 EHCI doesn't work, according to AMD errata */
157*4882a593Smuzhiyun 		if (pdev->device == 0x7463) {
158*4882a593Smuzhiyun 			ehci_info(ehci, "ignoring AMD8111 (errata)\n");
159*4882a593Smuzhiyun 			retval = -EIO;
160*4882a593Smuzhiyun 			goto done;
161*4882a593Smuzhiyun 		}
162*4882a593Smuzhiyun 
163*4882a593Smuzhiyun 		/*
164*4882a593Smuzhiyun 		 * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may
165*4882a593Smuzhiyun 		 * read/write memory space which does not belong to it when
166*4882a593Smuzhiyun 		 * there is NULL pointer with T-bit set to 1 in the frame list
167*4882a593Smuzhiyun 		 * table. To avoid the issue, the frame list link pointer
168*4882a593Smuzhiyun 		 * should always contain a valid pointer to a inactive qh.
169*4882a593Smuzhiyun 		 */
170*4882a593Smuzhiyun 		if (pdev->device == 0x7808) {
171*4882a593Smuzhiyun 			ehci->use_dummy_qh = 1;
172*4882a593Smuzhiyun 			ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n");
173*4882a593Smuzhiyun 		}
174*4882a593Smuzhiyun 		break;
175*4882a593Smuzhiyun 	case PCI_VENDOR_ID_VIA:
176*4882a593Smuzhiyun 		if (pdev->device == 0x3104 && (pdev->revision & 0xf0) == 0x60) {
177*4882a593Smuzhiyun 			u8 tmp;
178*4882a593Smuzhiyun 
179*4882a593Smuzhiyun 			/* The VT6212 defaults to a 1 usec EHCI sleep time which
180*4882a593Smuzhiyun 			 * hogs the PCI bus *badly*. Setting bit 5 of 0x4B makes
181*4882a593Smuzhiyun 			 * that sleep time use the conventional 10 usec.
182*4882a593Smuzhiyun 			 */
183*4882a593Smuzhiyun 			pci_read_config_byte(pdev, 0x4b, &tmp);
184*4882a593Smuzhiyun 			if (tmp & 0x20)
185*4882a593Smuzhiyun 				break;
186*4882a593Smuzhiyun 			pci_write_config_byte(pdev, 0x4b, tmp | 0x20);
187*4882a593Smuzhiyun 		}
188*4882a593Smuzhiyun 		break;
189*4882a593Smuzhiyun 	case PCI_VENDOR_ID_ATI:
190*4882a593Smuzhiyun 		/* AMD PLL quirk */
191*4882a593Smuzhiyun 		if (usb_amd_quirk_pll_check())
192*4882a593Smuzhiyun 			ehci->amd_pll_fix = 1;
193*4882a593Smuzhiyun 
194*4882a593Smuzhiyun 		/*
195*4882a593Smuzhiyun 		 * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may
196*4882a593Smuzhiyun 		 * read/write memory space which does not belong to it when
197*4882a593Smuzhiyun 		 * there is NULL pointer with T-bit set to 1 in the frame list
198*4882a593Smuzhiyun 		 * table. To avoid the issue, the frame list link pointer
199*4882a593Smuzhiyun 		 * should always contain a valid pointer to a inactive qh.
200*4882a593Smuzhiyun 		 */
201*4882a593Smuzhiyun 		if (pdev->device == 0x4396) {
202*4882a593Smuzhiyun 			ehci->use_dummy_qh = 1;
203*4882a593Smuzhiyun 			ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n");
204*4882a593Smuzhiyun 		}
205*4882a593Smuzhiyun 		/* SB600 and old version of SB700 have a bug in EHCI controller,
206*4882a593Smuzhiyun 		 * which causes usb devices lose response in some cases.
207*4882a593Smuzhiyun 		 */
208*4882a593Smuzhiyun 		if ((pdev->device == 0x4386 || pdev->device == 0x4396) &&
209*4882a593Smuzhiyun 				usb_amd_hang_symptom_quirk()) {
210*4882a593Smuzhiyun 			u8 tmp;
211*4882a593Smuzhiyun 			ehci_info(ehci, "applying AMD SB600/SB700 USB freeze workaround\n");
212*4882a593Smuzhiyun 			pci_read_config_byte(pdev, 0x53, &tmp);
213*4882a593Smuzhiyun 			pci_write_config_byte(pdev, 0x53, tmp | (1<<3));
214*4882a593Smuzhiyun 		}
215*4882a593Smuzhiyun 		break;
216*4882a593Smuzhiyun 	case PCI_VENDOR_ID_NETMOS:
217*4882a593Smuzhiyun 		/* MosChip frame-index-register bug */
218*4882a593Smuzhiyun 		ehci_info(ehci, "applying MosChip frame-index workaround\n");
219*4882a593Smuzhiyun 		ehci->frame_index_bug = 1;
220*4882a593Smuzhiyun 		break;
221*4882a593Smuzhiyun 	case PCI_VENDOR_ID_HUAWEI:
222*4882a593Smuzhiyun 		/* Synopsys HC bug */
223*4882a593Smuzhiyun 		if (pdev->device == 0xa239) {
224*4882a593Smuzhiyun 			ehci_info(ehci, "applying Synopsys HC workaround\n");
225*4882a593Smuzhiyun 			ehci->has_synopsys_hc_bug = 1;
226*4882a593Smuzhiyun 		}
227*4882a593Smuzhiyun 		break;
228*4882a593Smuzhiyun 	case PCI_VENDOR_ID_ASPEED:
229*4882a593Smuzhiyun 		if (pdev->device == PCI_DEVICE_ID_ASPEED_EHCI) {
230*4882a593Smuzhiyun 			ehci_info(ehci, "applying Aspeed HC workaround\n");
231*4882a593Smuzhiyun 			ehci->is_aspeed = 1;
232*4882a593Smuzhiyun 		}
233*4882a593Smuzhiyun 		break;
234*4882a593Smuzhiyun 	}
235*4882a593Smuzhiyun 
236*4882a593Smuzhiyun 	/* optional debug port, normally in the first BAR */
237*4882a593Smuzhiyun 	temp = pci_find_capability(pdev, PCI_CAP_ID_DBG);
238*4882a593Smuzhiyun 	if (temp) {
239*4882a593Smuzhiyun 		pci_read_config_dword(pdev, temp, &temp);
240*4882a593Smuzhiyun 		temp >>= 16;
241*4882a593Smuzhiyun 		if (((temp >> 13) & 7) == 1) {
242*4882a593Smuzhiyun 			u32 hcs_params = ehci_readl(ehci,
243*4882a593Smuzhiyun 						    &ehci->caps->hcs_params);
244*4882a593Smuzhiyun 
245*4882a593Smuzhiyun 			temp &= 0x1fff;
246*4882a593Smuzhiyun 			ehci->debug = hcd->regs + temp;
247*4882a593Smuzhiyun 			temp = ehci_readl(ehci, &ehci->debug->control);
248*4882a593Smuzhiyun 			ehci_info(ehci, "debug port %d%s\n",
249*4882a593Smuzhiyun 				  HCS_DEBUG_PORT(hcs_params),
250*4882a593Smuzhiyun 				  (temp & DBGP_ENABLED) ? " IN USE" : "");
251*4882a593Smuzhiyun 			if (!(temp & DBGP_ENABLED))
252*4882a593Smuzhiyun 				ehci->debug = NULL;
253*4882a593Smuzhiyun 		}
254*4882a593Smuzhiyun 	}
255*4882a593Smuzhiyun 
256*4882a593Smuzhiyun 	retval = ehci_setup(hcd);
257*4882a593Smuzhiyun 	if (retval)
258*4882a593Smuzhiyun 		return retval;
259*4882a593Smuzhiyun 
260*4882a593Smuzhiyun 	/* These workarounds need to be applied after ehci_setup() */
261*4882a593Smuzhiyun 	switch (pdev->vendor) {
262*4882a593Smuzhiyun 	case PCI_VENDOR_ID_NEC:
263*4882a593Smuzhiyun 	case PCI_VENDOR_ID_INTEL:
264*4882a593Smuzhiyun 	case PCI_VENDOR_ID_AMD:
265*4882a593Smuzhiyun 		ehci->need_io_watchdog = 0;
266*4882a593Smuzhiyun 		break;
267*4882a593Smuzhiyun 	case PCI_VENDOR_ID_NVIDIA:
268*4882a593Smuzhiyun 		switch (pdev->device) {
269*4882a593Smuzhiyun 		/* MCP89 chips on the MacBookAir3,1 give EPROTO when
270*4882a593Smuzhiyun 		 * fetching device descriptors unless LPM is disabled.
271*4882a593Smuzhiyun 		 * There are also intermittent problems enumerating
272*4882a593Smuzhiyun 		 * devices with PPCD enabled.
273*4882a593Smuzhiyun 		 */
274*4882a593Smuzhiyun 		case 0x0d9d:
275*4882a593Smuzhiyun 			ehci_info(ehci, "disable ppcd for nvidia mcp89\n");
276*4882a593Smuzhiyun 			ehci->has_ppcd = 0;
277*4882a593Smuzhiyun 			ehci->command &= ~CMD_PPCEE;
278*4882a593Smuzhiyun 			break;
279*4882a593Smuzhiyun 		}
280*4882a593Smuzhiyun 		break;
281*4882a593Smuzhiyun 	}
282*4882a593Smuzhiyun 
283*4882a593Smuzhiyun 	/* at least the Genesys GL880S needs fixup here */
284*4882a593Smuzhiyun 	temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params);
285*4882a593Smuzhiyun 	temp &= 0x0f;
286*4882a593Smuzhiyun 	if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) {
287*4882a593Smuzhiyun 		ehci_dbg(ehci, "bogus port configuration: "
288*4882a593Smuzhiyun 			"cc=%d x pcc=%d < ports=%d\n",
289*4882a593Smuzhiyun 			HCS_N_CC(ehci->hcs_params),
290*4882a593Smuzhiyun 			HCS_N_PCC(ehci->hcs_params),
291*4882a593Smuzhiyun 			HCS_N_PORTS(ehci->hcs_params));
292*4882a593Smuzhiyun 
293*4882a593Smuzhiyun 		switch (pdev->vendor) {
294*4882a593Smuzhiyun 		case 0x17a0:		/* GENESYS */
295*4882a593Smuzhiyun 			/* GL880S: should be PORTS=2 */
296*4882a593Smuzhiyun 			temp |= (ehci->hcs_params & ~0xf);
297*4882a593Smuzhiyun 			ehci->hcs_params = temp;
298*4882a593Smuzhiyun 			break;
299*4882a593Smuzhiyun 		case PCI_VENDOR_ID_NVIDIA:
300*4882a593Smuzhiyun 			/* NF4: should be PCC=10 */
301*4882a593Smuzhiyun 			break;
302*4882a593Smuzhiyun 		}
303*4882a593Smuzhiyun 	}
304*4882a593Smuzhiyun 
305*4882a593Smuzhiyun 	/* Serial Bus Release Number is at PCI 0x60 offset */
306*4882a593Smuzhiyun 	if (pdev->vendor == PCI_VENDOR_ID_STMICRO
307*4882a593Smuzhiyun 	    && pdev->device == PCI_DEVICE_ID_STMICRO_USB_HOST)
308*4882a593Smuzhiyun 		;	/* ConneXT has no sbrn register */
309*4882a593Smuzhiyun 	else if (pdev->vendor == PCI_VENDOR_ID_HUAWEI
310*4882a593Smuzhiyun 			 && pdev->device == 0xa239)
311*4882a593Smuzhiyun 		;	/* HUAWEI Kunpeng920 USB EHCI has no sbrn register */
312*4882a593Smuzhiyun 	else
313*4882a593Smuzhiyun 		pci_read_config_byte(pdev, 0x60, &ehci->sbrn);
314*4882a593Smuzhiyun 
315*4882a593Smuzhiyun 	/* Keep this around for a while just in case some EHCI
316*4882a593Smuzhiyun 	 * implementation uses legacy PCI PM support.  This test
317*4882a593Smuzhiyun 	 * can be removed on 17 Dec 2009 if the dev_warn() hasn't
318*4882a593Smuzhiyun 	 * been triggered by then.
319*4882a593Smuzhiyun 	 */
320*4882a593Smuzhiyun 	if (!device_can_wakeup(&pdev->dev)) {
321*4882a593Smuzhiyun 		u16	port_wake;
322*4882a593Smuzhiyun 
323*4882a593Smuzhiyun 		pci_read_config_word(pdev, 0x62, &port_wake);
324*4882a593Smuzhiyun 		if (port_wake & 0x0001) {
325*4882a593Smuzhiyun 			dev_warn(&pdev->dev, "Enabling legacy PCI PM\n");
326*4882a593Smuzhiyun 			device_set_wakeup_capable(&pdev->dev, 1);
327*4882a593Smuzhiyun 		}
328*4882a593Smuzhiyun 	}
329*4882a593Smuzhiyun 
330*4882a593Smuzhiyun #ifdef	CONFIG_PM
331*4882a593Smuzhiyun 	if (ehci->no_selective_suspend && device_can_wakeup(&pdev->dev))
332*4882a593Smuzhiyun 		ehci_warn(ehci, "selective suspend/wakeup unavailable\n");
333*4882a593Smuzhiyun #endif
334*4882a593Smuzhiyun 
335*4882a593Smuzhiyun 	retval = ehci_pci_reinit(ehci, pdev);
336*4882a593Smuzhiyun done:
337*4882a593Smuzhiyun 	return retval;
338*4882a593Smuzhiyun }
339*4882a593Smuzhiyun 
340*4882a593Smuzhiyun /*-------------------------------------------------------------------------*/
341*4882a593Smuzhiyun 
342*4882a593Smuzhiyun #ifdef	CONFIG_PM
343*4882a593Smuzhiyun 
344*4882a593Smuzhiyun /* suspend/resume, section 4.3 */
345*4882a593Smuzhiyun 
346*4882a593Smuzhiyun /* These routines rely on the PCI bus glue
347*4882a593Smuzhiyun  * to handle powerdown and wakeup, and currently also on
348*4882a593Smuzhiyun  * transceivers that don't need any software attention to set up
349*4882a593Smuzhiyun  * the right sort of wakeup.
350*4882a593Smuzhiyun  * Also they depend on separate root hub suspend/resume.
351*4882a593Smuzhiyun  */
352*4882a593Smuzhiyun 
ehci_pci_resume(struct usb_hcd * hcd,bool hibernated)353*4882a593Smuzhiyun static int ehci_pci_resume(struct usb_hcd *hcd, bool hibernated)
354*4882a593Smuzhiyun {
355*4882a593Smuzhiyun 	struct ehci_hcd		*ehci = hcd_to_ehci(hcd);
356*4882a593Smuzhiyun 	struct pci_dev		*pdev = to_pci_dev(hcd->self.controller);
357*4882a593Smuzhiyun 
358*4882a593Smuzhiyun 	if (ehci_resume(hcd, hibernated) != 0)
359*4882a593Smuzhiyun 		(void) ehci_pci_reinit(ehci, pdev);
360*4882a593Smuzhiyun 	return 0;
361*4882a593Smuzhiyun }
362*4882a593Smuzhiyun 
363*4882a593Smuzhiyun #else
364*4882a593Smuzhiyun 
365*4882a593Smuzhiyun #define ehci_suspend		NULL
366*4882a593Smuzhiyun #define ehci_pci_resume		NULL
367*4882a593Smuzhiyun #endif	/* CONFIG_PM */
368*4882a593Smuzhiyun 
369*4882a593Smuzhiyun static struct hc_driver __read_mostly ehci_pci_hc_driver;
370*4882a593Smuzhiyun 
371*4882a593Smuzhiyun static const struct ehci_driver_overrides pci_overrides __initconst = {
372*4882a593Smuzhiyun 	.reset =		ehci_pci_setup,
373*4882a593Smuzhiyun };
374*4882a593Smuzhiyun 
375*4882a593Smuzhiyun /*-------------------------------------------------------------------------*/
376*4882a593Smuzhiyun 
ehci_pci_probe(struct pci_dev * pdev,const struct pci_device_id * id)377*4882a593Smuzhiyun static int ehci_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
378*4882a593Smuzhiyun {
379*4882a593Smuzhiyun 	if (is_bypassed_id(pdev))
380*4882a593Smuzhiyun 		return -ENODEV;
381*4882a593Smuzhiyun 	return usb_hcd_pci_probe(pdev, id, &ehci_pci_hc_driver);
382*4882a593Smuzhiyun }
383*4882a593Smuzhiyun 
ehci_pci_remove(struct pci_dev * pdev)384*4882a593Smuzhiyun static void ehci_pci_remove(struct pci_dev *pdev)
385*4882a593Smuzhiyun {
386*4882a593Smuzhiyun 	pci_clear_mwi(pdev);
387*4882a593Smuzhiyun 	usb_hcd_pci_remove(pdev);
388*4882a593Smuzhiyun }
389*4882a593Smuzhiyun 
390*4882a593Smuzhiyun /* PCI driver selection metadata; PCI hotplugging uses this */
391*4882a593Smuzhiyun static const struct pci_device_id pci_ids [] = { {
392*4882a593Smuzhiyun 	/* handle any USB 2.0 EHCI controller */
393*4882a593Smuzhiyun 	PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0),
394*4882a593Smuzhiyun 	}, {
395*4882a593Smuzhiyun 	PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST),
396*4882a593Smuzhiyun 	},
397*4882a593Smuzhiyun 	{ /* end: all zeroes */ }
398*4882a593Smuzhiyun };
399*4882a593Smuzhiyun MODULE_DEVICE_TABLE(pci, pci_ids);
400*4882a593Smuzhiyun 
401*4882a593Smuzhiyun /* pci driver glue; this is a "new style" PCI driver module */
402*4882a593Smuzhiyun static struct pci_driver ehci_pci_driver = {
403*4882a593Smuzhiyun 	.name =		hcd_name,
404*4882a593Smuzhiyun 	.id_table =	pci_ids,
405*4882a593Smuzhiyun 
406*4882a593Smuzhiyun 	.probe =	ehci_pci_probe,
407*4882a593Smuzhiyun 	.remove =	ehci_pci_remove,
408*4882a593Smuzhiyun 	.shutdown = 	usb_hcd_pci_shutdown,
409*4882a593Smuzhiyun 
410*4882a593Smuzhiyun #ifdef CONFIG_PM
411*4882a593Smuzhiyun 	.driver =	{
412*4882a593Smuzhiyun 		.pm =	&usb_hcd_pci_pm_ops
413*4882a593Smuzhiyun 	},
414*4882a593Smuzhiyun #endif
415*4882a593Smuzhiyun };
416*4882a593Smuzhiyun 
ehci_pci_init(void)417*4882a593Smuzhiyun static int __init ehci_pci_init(void)
418*4882a593Smuzhiyun {
419*4882a593Smuzhiyun 	if (usb_disabled())
420*4882a593Smuzhiyun 		return -ENODEV;
421*4882a593Smuzhiyun 
422*4882a593Smuzhiyun 	pr_info("%s: " DRIVER_DESC "\n", hcd_name);
423*4882a593Smuzhiyun 
424*4882a593Smuzhiyun 	ehci_init_driver(&ehci_pci_hc_driver, &pci_overrides);
425*4882a593Smuzhiyun 
426*4882a593Smuzhiyun 	/* Entries for the PCI suspend/resume callbacks are special */
427*4882a593Smuzhiyun 	ehci_pci_hc_driver.pci_suspend = ehci_suspend;
428*4882a593Smuzhiyun 	ehci_pci_hc_driver.pci_resume = ehci_pci_resume;
429*4882a593Smuzhiyun 
430*4882a593Smuzhiyun 	return pci_register_driver(&ehci_pci_driver);
431*4882a593Smuzhiyun }
432*4882a593Smuzhiyun module_init(ehci_pci_init);
433*4882a593Smuzhiyun 
ehci_pci_cleanup(void)434*4882a593Smuzhiyun static void __exit ehci_pci_cleanup(void)
435*4882a593Smuzhiyun {
436*4882a593Smuzhiyun 	pci_unregister_driver(&ehci_pci_driver);
437*4882a593Smuzhiyun }
438*4882a593Smuzhiyun module_exit(ehci_pci_cleanup);
439*4882a593Smuzhiyun 
440*4882a593Smuzhiyun MODULE_DESCRIPTION(DRIVER_DESC);
441*4882a593Smuzhiyun MODULE_AUTHOR("David Brownell");
442*4882a593Smuzhiyun MODULE_AUTHOR("Alan Stern");
443*4882a593Smuzhiyun MODULE_LICENSE("GPL");
444