xref: /linux/drivers/usb/host/ehci-pci.c (revision 2c1c3c4cd5f796b1912c65aaf3bf48c0ddf11f5e)
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 
257ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/
267ff71d6aSMatt Porter 
277ff71d6aSMatt Porter /* EHCI 0.96 (and later) section 5.1 says how to kick BIOS/SMM/...
287ff71d6aSMatt Porter  * off the controller (maybe it can boot from highspeed USB disks).
297ff71d6aSMatt Porter  */
307ff71d6aSMatt Porter static int bios_handoff(struct ehci_hcd *ehci, int where, u32 cap)
317ff71d6aSMatt Porter {
327ff71d6aSMatt Porter 	struct pci_dev *pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller);
337ff71d6aSMatt Porter 
347ff71d6aSMatt Porter 	/* always say Linux will own the hardware */
357ff71d6aSMatt Porter 	pci_write_config_byte(pdev, where + 3, 1);
367ff71d6aSMatt Porter 
377ff71d6aSMatt Porter 	/* maybe wait a while for BIOS to respond */
387ff71d6aSMatt Porter 	if (cap & (1 << 16)) {
397ff71d6aSMatt Porter 		int msec = 5000;
407ff71d6aSMatt Porter 
417ff71d6aSMatt Porter 		do {
427ff71d6aSMatt Porter 			msleep(10);
437ff71d6aSMatt Porter 			msec -= 10;
447ff71d6aSMatt Porter 			pci_read_config_dword(pdev, where, &cap);
457ff71d6aSMatt Porter 		} while ((cap & (1 << 16)) && msec);
467ff71d6aSMatt Porter 		if (cap & (1 << 16)) {
477ff71d6aSMatt Porter 			ehci_err(ehci, "BIOS handoff failed (%d, %08x)\n",
487ff71d6aSMatt Porter 				where, cap);
497ff71d6aSMatt Porter 			// some BIOS versions seem buggy...
507ff71d6aSMatt Porter 			// return 1;
517ff71d6aSMatt Porter 			ehci_warn(ehci, "continuing after BIOS bug...\n");
527ff71d6aSMatt Porter 			/* disable all SMIs, and clear "BIOS owns" flag */
537ff71d6aSMatt Porter 			pci_write_config_dword(pdev, where + 4, 0);
547ff71d6aSMatt Porter 			pci_write_config_byte(pdev, where + 2, 0);
557ff71d6aSMatt Porter 		} else
567ff71d6aSMatt Porter 			ehci_dbg(ehci, "BIOS handoff succeeded\n");
577ff71d6aSMatt Porter 	}
587ff71d6aSMatt Porter 	return 0;
597ff71d6aSMatt Porter }
607ff71d6aSMatt Porter 
6118807521SDavid Brownell /* called after powerup, by probe or system-pm "wakeup" */
6218807521SDavid Brownell static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
6318807521SDavid Brownell {
6418807521SDavid Brownell 	u32			temp;
6518807521SDavid Brownell 	int			retval;
6618807521SDavid Brownell 	unsigned		count = 256/4;
6718807521SDavid Brownell 
6818807521SDavid Brownell 	/* optional debug port, normally in the first BAR */
6918807521SDavid Brownell 	temp = pci_find_capability(pdev, 0x0a);
7018807521SDavid Brownell 	if (temp) {
7118807521SDavid Brownell 		pci_read_config_dword(pdev, temp, &temp);
7218807521SDavid Brownell 		temp >>= 16;
7318807521SDavid Brownell 		if ((temp & (3 << 13)) == (1 << 13)) {
7418807521SDavid Brownell 			temp &= 0x1fff;
7518807521SDavid Brownell 			ehci->debug = ehci_to_hcd(ehci)->regs + temp;
7618807521SDavid Brownell 			temp = readl(&ehci->debug->control);
7718807521SDavid Brownell 			ehci_info(ehci, "debug port %d%s\n",
7818807521SDavid Brownell 				HCS_DEBUG_PORT(ehci->hcs_params),
7918807521SDavid Brownell 				(temp & DBGP_ENABLED)
8018807521SDavid Brownell 					? " IN USE"
8118807521SDavid Brownell 					: "");
8218807521SDavid Brownell 			if (!(temp & DBGP_ENABLED))
8318807521SDavid Brownell 				ehci->debug = NULL;
8418807521SDavid Brownell 		}
8518807521SDavid Brownell 	}
8618807521SDavid Brownell 
8718807521SDavid Brownell 	temp = HCC_EXT_CAPS(readl(&ehci->caps->hcc_params));
8818807521SDavid Brownell 
8918807521SDavid Brownell 	/* EHCI 0.96 and later may have "extended capabilities" */
9018807521SDavid Brownell 	while (temp && count--) {
9118807521SDavid Brownell 		u32		cap;
9218807521SDavid Brownell 
9318807521SDavid Brownell 		pci_read_config_dword(pdev, temp, &cap);
9418807521SDavid Brownell 		ehci_dbg(ehci, "capability %04x at %02x\n", cap, temp);
9518807521SDavid Brownell 		switch (cap & 0xff) {
9618807521SDavid Brownell 		case 1:			/* BIOS/SMM/... handoff */
9718807521SDavid Brownell 			if (bios_handoff(ehci, temp, cap) != 0)
9818807521SDavid Brownell 				return -EOPNOTSUPP;
9918807521SDavid Brownell 			break;
10018807521SDavid Brownell 		case 0:			/* illegal reserved capability */
10118807521SDavid Brownell 			ehci_dbg(ehci, "illegal capability!\n");
10218807521SDavid Brownell 			cap = 0;
10318807521SDavid Brownell 			/* FALLTHROUGH */
10418807521SDavid Brownell 		default:		/* unknown */
10518807521SDavid Brownell 			break;
10618807521SDavid Brownell 		}
10718807521SDavid Brownell 		temp = (cap >> 8) & 0xff;
10818807521SDavid Brownell 	}
10918807521SDavid Brownell 	if (!count) {
11018807521SDavid Brownell 		ehci_err(ehci, "bogus capabilities ... PCI problems!\n");
11118807521SDavid Brownell 		return -EIO;
11218807521SDavid Brownell 	}
11318807521SDavid Brownell 
11418807521SDavid Brownell 	/* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */
11518807521SDavid Brownell 	retval = pci_set_mwi(pdev);
11618807521SDavid Brownell 	if (!retval)
11718807521SDavid Brownell 		ehci_dbg(ehci, "MWI active\n");
11818807521SDavid Brownell 
11918807521SDavid Brownell 	ehci_port_power(ehci, 0);
12018807521SDavid Brownell 
12118807521SDavid Brownell 	return 0;
12218807521SDavid Brownell }
12318807521SDavid Brownell 
1248926bfa7SDavid Brownell /* called during probe() after chip reset completes */
1258926bfa7SDavid Brownell static int ehci_pci_setup(struct usb_hcd *hcd)
1267ff71d6aSMatt Porter {
1277ff71d6aSMatt Porter 	struct ehci_hcd		*ehci = hcd_to_ehci(hcd);
128abcc9448SDavid Brownell 	struct pci_dev		*pdev = to_pci_dev(hcd->self.controller);
1297ff71d6aSMatt Porter 	u32			temp;
13018807521SDavid Brownell 	int			retval;
1317ff71d6aSMatt Porter 
1327ff71d6aSMatt Porter 	ehci->caps = hcd->regs;
1337ff71d6aSMatt Porter 	ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase));
1347ff71d6aSMatt Porter 	dbg_hcs_params(ehci, "reset");
1357ff71d6aSMatt Porter 	dbg_hcc_params(ehci, "reset");
1367ff71d6aSMatt Porter 
1377ff71d6aSMatt Porter 	/* cache this readonly data; minimize chip reads */
1387ff71d6aSMatt Porter 	ehci->hcs_params = readl(&ehci->caps->hcs_params);
1397ff71d6aSMatt Porter 
14018807521SDavid Brownell 	retval = ehci_halt(ehci);
14118807521SDavid Brownell 	if (retval)
14218807521SDavid Brownell 		return retval;
14318807521SDavid Brownell 
1448926bfa7SDavid Brownell 	/* data structure init */
1458926bfa7SDavid Brownell 	retval = ehci_init(hcd);
1468926bfa7SDavid Brownell 	if (retval)
1478926bfa7SDavid Brownell 		return retval;
1488926bfa7SDavid Brownell 
149abcc9448SDavid Brownell 	/* NOTE:  only the parts below this line are PCI-specific */
1507ff71d6aSMatt Porter 
1517ff71d6aSMatt Porter 	switch (pdev->vendor) {
1527ff71d6aSMatt Porter 	case PCI_VENDOR_ID_TDI:
1537ff71d6aSMatt Porter 		if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) {
1547ff71d6aSMatt Porter 			ehci->is_tdi_rh_tt = 1;
1557ff71d6aSMatt Porter 			tdi_reset(ehci);
1567ff71d6aSMatt Porter 		}
1577ff71d6aSMatt Porter 		break;
1587ff71d6aSMatt Porter 	case PCI_VENDOR_ID_AMD:
1597ff71d6aSMatt Porter 		/* AMD8111 EHCI doesn't work, according to AMD errata */
1607ff71d6aSMatt Porter 		if (pdev->device == 0x7463) {
1617ff71d6aSMatt Porter 			ehci_info(ehci, "ignoring AMD8111 (errata)\n");
1628926bfa7SDavid Brownell 			retval = -EIO;
1638926bfa7SDavid Brownell 			goto done;
1647ff71d6aSMatt Porter 		}
1657ff71d6aSMatt Porter 		break;
1667ff71d6aSMatt Porter 	case PCI_VENDOR_ID_NVIDIA:
1677ff71d6aSMatt Porter 		/* NVidia reports that certain chips don't handle
1687ff71d6aSMatt Porter 		 * QH, ITD, or SITD addresses above 2GB.  (But TD,
1697ff71d6aSMatt Porter 		 * data buffer, and periodic schedule are normal.)
1707ff71d6aSMatt Porter 		 */
1717ff71d6aSMatt Porter 		switch (pdev->device) {
1727ff71d6aSMatt Porter 		case 0x003c:	/* MCP04 */
1737ff71d6aSMatt Porter 		case 0x005b:	/* CK804 */
1747ff71d6aSMatt Porter 		case 0x00d8:	/* CK8 */
1757ff71d6aSMatt Porter 		case 0x00e8:	/* CK8S */
1767ff71d6aSMatt Porter 			if (pci_set_consistent_dma_mask(pdev,
1777ff71d6aSMatt Porter 						DMA_31BIT_MASK) < 0)
1787ff71d6aSMatt Porter 				ehci_warn(ehci, "can't enable NVidia "
1797ff71d6aSMatt Porter 					"workaround for >2GB RAM\n");
1807ff71d6aSMatt Porter 			break;
1817ff71d6aSMatt Porter 		}
1827ff71d6aSMatt Porter 		break;
1837ff71d6aSMatt Porter 	}
1847ff71d6aSMatt Porter 
1857ff71d6aSMatt Porter 	if (ehci_is_TDI(ehci))
1867ff71d6aSMatt Porter 		ehci_reset(ehci);
1877ff71d6aSMatt Porter 
1887ff71d6aSMatt Porter 	/* at least the Genesys GL880S needs fixup here */
1897ff71d6aSMatt Porter 	temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params);
1907ff71d6aSMatt Porter 	temp &= 0x0f;
1917ff71d6aSMatt Porter 	if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) {
1927ff71d6aSMatt Porter 		ehci_dbg(ehci, "bogus port configuration: "
1937ff71d6aSMatt Porter 			"cc=%d x pcc=%d < ports=%d\n",
1947ff71d6aSMatt Porter 			HCS_N_CC(ehci->hcs_params),
1957ff71d6aSMatt Porter 			HCS_N_PCC(ehci->hcs_params),
1967ff71d6aSMatt Porter 			HCS_N_PORTS(ehci->hcs_params));
1977ff71d6aSMatt Porter 
1987ff71d6aSMatt Porter 		switch (pdev->vendor) {
1997ff71d6aSMatt Porter 		case 0x17a0:		/* GENESYS */
2007ff71d6aSMatt Porter 			/* GL880S: should be PORTS=2 */
2017ff71d6aSMatt Porter 			temp |= (ehci->hcs_params & ~0xf);
2027ff71d6aSMatt Porter 			ehci->hcs_params = temp;
2037ff71d6aSMatt Porter 			break;
2047ff71d6aSMatt Porter 		case PCI_VENDOR_ID_NVIDIA:
2057ff71d6aSMatt Porter 			/* NF4: should be PCC=10 */
2067ff71d6aSMatt Porter 			break;
2077ff71d6aSMatt Porter 		}
2087ff71d6aSMatt Porter 	}
2097ff71d6aSMatt Porter 
2107ff71d6aSMatt Porter 	/* Serial Bus Release Number is at PCI 0x60 offset */
2117ff71d6aSMatt Porter 	pci_read_config_byte(pdev, 0x60, &ehci->sbrn);
2127ff71d6aSMatt Porter 
213*2c1c3c4cSDavid Brownell 	/* Workaround current PCI init glitch:  wakeup bits aren't
214*2c1c3c4cSDavid Brownell 	 * being set from PCI PM capability.
215*2c1c3c4cSDavid Brownell 	 */
216*2c1c3c4cSDavid Brownell 	if (!device_can_wakeup(&pdev->dev)) {
217*2c1c3c4cSDavid Brownell 		u16	port_wake;
218*2c1c3c4cSDavid Brownell 
219*2c1c3c4cSDavid Brownell 		pci_read_config_word(pdev, 0x62, &port_wake);
220*2c1c3c4cSDavid Brownell 		if (port_wake & 0x0001)
221*2c1c3c4cSDavid Brownell 			device_init_wakeup(&pdev->dev, 1);
222*2c1c3c4cSDavid Brownell 	}
2237ff71d6aSMatt Porter 
22418807521SDavid Brownell 	retval = ehci_pci_reinit(ehci, pdev);
2258926bfa7SDavid Brownell done:
2268926bfa7SDavid Brownell 	return retval;
2277ff71d6aSMatt Porter }
2287ff71d6aSMatt Porter 
2297ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/
2307ff71d6aSMatt Porter 
2317ff71d6aSMatt Porter #ifdef	CONFIG_PM
2327ff71d6aSMatt Porter 
2337ff71d6aSMatt Porter /* suspend/resume, section 4.3 */
2347ff71d6aSMatt Porter 
235f03c17fcSDavid Brownell /* These routines rely on the PCI bus glue
2367ff71d6aSMatt Porter  * to handle powerdown and wakeup, and currently also on
2377ff71d6aSMatt Porter  * transceivers that don't need any software attention to set up
2387ff71d6aSMatt Porter  * the right sort of wakeup.
239f03c17fcSDavid Brownell  * Also they depend on separate root hub suspend/resume.
2407ff71d6aSMatt Porter  */
2417ff71d6aSMatt Porter 
2427ff71d6aSMatt Porter static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
2437ff71d6aSMatt Porter {
2447ff71d6aSMatt Porter 	struct ehci_hcd		*ehci = hcd_to_ehci(hcd);
2458de98402SBenjamin Herrenschmidt 	unsigned long		flags;
2468de98402SBenjamin Herrenschmidt 	int			rc = 0;
2477ff71d6aSMatt Porter 
2487ff71d6aSMatt Porter 	if (time_before(jiffies, ehci->next_statechange))
249f03c17fcSDavid Brownell 		msleep(10);
2507ff71d6aSMatt Porter 
2518de98402SBenjamin Herrenschmidt 	/* Root hub was already suspended. Disable irq emission and
2528de98402SBenjamin Herrenschmidt 	 * mark HW unaccessible, bail out if RH has been resumed. Use
2538de98402SBenjamin Herrenschmidt 	 * the spinlock to properly synchronize with possible pending
2548de98402SBenjamin Herrenschmidt 	 * RH suspend or resume activity.
2558de98402SBenjamin Herrenschmidt 	 *
2568de98402SBenjamin Herrenschmidt 	 * This is still racy as hcd->state is manipulated outside of
2578de98402SBenjamin Herrenschmidt 	 * any locks =P But that will be a different fix.
2588de98402SBenjamin Herrenschmidt 	 */
2598de98402SBenjamin Herrenschmidt 	spin_lock_irqsave (&ehci->lock, flags);
2608de98402SBenjamin Herrenschmidt 	if (hcd->state != HC_STATE_SUSPENDED) {
2618de98402SBenjamin Herrenschmidt 		rc = -EINVAL;
2628de98402SBenjamin Herrenschmidt 		goto bail;
2638de98402SBenjamin Herrenschmidt 	}
2648de98402SBenjamin Herrenschmidt 	writel (0, &ehci->regs->intr_enable);
2658de98402SBenjamin Herrenschmidt 	(void)readl(&ehci->regs->intr_enable);
2668de98402SBenjamin Herrenschmidt 
2678de98402SBenjamin Herrenschmidt 	clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
2688de98402SBenjamin Herrenschmidt  bail:
2698de98402SBenjamin Herrenschmidt 	spin_unlock_irqrestore (&ehci->lock, flags);
2708de98402SBenjamin Herrenschmidt 
271f03c17fcSDavid Brownell 	// could save FLADJ in case of Vaux power loss
2727ff71d6aSMatt Porter 	// ... we'd only use it to handle clock skew
2737ff71d6aSMatt Porter 
2748de98402SBenjamin Herrenschmidt 	return rc;
2757ff71d6aSMatt Porter }
2767ff71d6aSMatt Porter 
2777ff71d6aSMatt Porter static int ehci_pci_resume(struct usb_hcd *hcd)
2787ff71d6aSMatt Porter {
2797ff71d6aSMatt Porter 	struct ehci_hcd		*ehci = hcd_to_ehci(hcd);
2807ff71d6aSMatt Porter 	unsigned		port;
2817ff71d6aSMatt Porter 	struct usb_device	*root = hcd->self.root_hub;
28218807521SDavid Brownell 	struct pci_dev		*pdev = to_pci_dev(hcd->self.controller);
2837ff71d6aSMatt Porter 	int			retval = -EINVAL;
2847ff71d6aSMatt Porter 
285f03c17fcSDavid Brownell 	// maybe restore FLADJ
2867ff71d6aSMatt Porter 
2877ff71d6aSMatt Porter 	if (time_before(jiffies, ehci->next_statechange))
2887ff71d6aSMatt Porter 		msleep(100);
2897ff71d6aSMatt Porter 
2908de98402SBenjamin Herrenschmidt 	/* Mark hardware accessible again as we are out of D3 state by now */
2918de98402SBenjamin Herrenschmidt 	set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
2928de98402SBenjamin Herrenschmidt 
293f03c17fcSDavid Brownell 	/* If CF is clear, we lost PCI Vaux power and need to restart.  */
29418807521SDavid Brownell 	if (readl(&ehci->regs->configured_flag) != FLAG_CF)
295f03c17fcSDavid Brownell 		goto restart;
296f03c17fcSDavid Brownell 
2977ff71d6aSMatt Porter 	/* If any port is suspended (or owned by the companion),
2987ff71d6aSMatt Porter 	 * we know we can/must resume the HC (and mustn't reset it).
299f03c17fcSDavid Brownell 	 * We just defer that to the root hub code.
3007ff71d6aSMatt Porter 	 */
3017ff71d6aSMatt Porter 	for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) {
3027ff71d6aSMatt Porter 		u32	status;
3037ff71d6aSMatt Porter 		port--;
3047ff71d6aSMatt Porter 		status = readl(&ehci->regs->port_status [port]);
3057ff71d6aSMatt Porter 		if (!(status & PORT_POWER))
3067ff71d6aSMatt Porter 			continue;
307f03c17fcSDavid Brownell 		if (status & (PORT_SUSPEND | PORT_RESUME | PORT_OWNER)) {
308f03c17fcSDavid Brownell 			usb_hcd_resume_root_hub(hcd);
309f03c17fcSDavid Brownell 			return 0;
3107ff71d6aSMatt Porter 		}
311f03c17fcSDavid Brownell 	}
312f03c17fcSDavid Brownell 
313f03c17fcSDavid Brownell restart:
314f03c17fcSDavid Brownell 	ehci_dbg(ehci, "lost power, restarting\n");
315f03c17fcSDavid Brownell 	for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) {
316f03c17fcSDavid Brownell 		port--;
3177ff71d6aSMatt Porter 		if (!root->children [port])
3187ff71d6aSMatt Porter 			continue;
3197ff71d6aSMatt Porter 		usb_set_device_state(root->children[port],
3207ff71d6aSMatt Porter 					USB_STATE_NOTATTACHED);
3217ff71d6aSMatt Porter 	}
3227ff71d6aSMatt Porter 
3237ff71d6aSMatt Porter 	/* Else reset, to cope with power loss or flush-to-storage
324f03c17fcSDavid Brownell 	 * style "resume" having let BIOS kick in during reboot.
3257ff71d6aSMatt Porter 	 */
3267ff71d6aSMatt Porter 	(void) ehci_halt(ehci);
3277ff71d6aSMatt Porter 	(void) ehci_reset(ehci);
32818807521SDavid Brownell 	(void) ehci_pci_reinit(ehci, pdev);
3297ff71d6aSMatt Porter 
3307ff71d6aSMatt Porter 	/* emptying the schedule aborts any urbs */
3317ff71d6aSMatt Porter 	spin_lock_irq(&ehci->lock);
3327ff71d6aSMatt Porter 	if (ehci->reclaim)
3337ff71d6aSMatt Porter 		ehci->reclaim_ready = 1;
3347ff71d6aSMatt Porter 	ehci_work(ehci, NULL);
3357ff71d6aSMatt Porter 	spin_unlock_irq(&ehci->lock);
3367ff71d6aSMatt Porter 
3377ff71d6aSMatt Porter 	/* restart; khubd will disconnect devices */
3387ff71d6aSMatt Porter 	retval = ehci_run(hcd);
3397ff71d6aSMatt Porter 
34018807521SDavid Brownell 	/* here we "know" root ports should always stay powered */
3417ff71d6aSMatt Porter 	ehci_port_power(ehci, 1);
3427ff71d6aSMatt Porter 
3437ff71d6aSMatt Porter 	return retval;
3447ff71d6aSMatt Porter }
3457ff71d6aSMatt Porter #endif
3467ff71d6aSMatt Porter 
3477ff71d6aSMatt Porter static const struct hc_driver ehci_pci_hc_driver = {
3487ff71d6aSMatt Porter 	.description =		hcd_name,
3497ff71d6aSMatt Porter 	.product_desc =		"EHCI Host Controller",
3507ff71d6aSMatt Porter 	.hcd_priv_size =	sizeof(struct ehci_hcd),
3517ff71d6aSMatt Porter 
3527ff71d6aSMatt Porter 	/*
3537ff71d6aSMatt Porter 	 * generic hardware linkage
3547ff71d6aSMatt Porter 	 */
3557ff71d6aSMatt Porter 	.irq =			ehci_irq,
3567ff71d6aSMatt Porter 	.flags =		HCD_MEMORY | HCD_USB2,
3577ff71d6aSMatt Porter 
3587ff71d6aSMatt Porter 	/*
3597ff71d6aSMatt Porter 	 * basic lifecycle operations
3607ff71d6aSMatt Porter 	 */
3618926bfa7SDavid Brownell 	.reset =		ehci_pci_setup,
36218807521SDavid Brownell 	.start =		ehci_run,
3637ff71d6aSMatt Porter #ifdef	CONFIG_PM
3647ff71d6aSMatt Porter 	.suspend =		ehci_pci_suspend,
3657ff71d6aSMatt Porter 	.resume =		ehci_pci_resume,
3667ff71d6aSMatt Porter #endif
36718807521SDavid Brownell 	.stop =			ehci_stop,
3687ff71d6aSMatt Porter 
3697ff71d6aSMatt Porter 	/*
3707ff71d6aSMatt Porter 	 * managing i/o requests and associated device resources
3717ff71d6aSMatt Porter 	 */
3727ff71d6aSMatt Porter 	.urb_enqueue =		ehci_urb_enqueue,
3737ff71d6aSMatt Porter 	.urb_dequeue =		ehci_urb_dequeue,
3747ff71d6aSMatt Porter 	.endpoint_disable =	ehci_endpoint_disable,
3757ff71d6aSMatt Porter 
3767ff71d6aSMatt Porter 	/*
3777ff71d6aSMatt Porter 	 * scheduling support
3787ff71d6aSMatt Porter 	 */
3797ff71d6aSMatt Porter 	.get_frame_number =	ehci_get_frame,
3807ff71d6aSMatt Porter 
3817ff71d6aSMatt Porter 	/*
3827ff71d6aSMatt Porter 	 * root hub support
3837ff71d6aSMatt Porter 	 */
3847ff71d6aSMatt Porter 	.hub_status_data =	ehci_hub_status_data,
3857ff71d6aSMatt Porter 	.hub_control =		ehci_hub_control,
3860c0382e3SAlan Stern 	.bus_suspend =		ehci_bus_suspend,
3870c0382e3SAlan Stern 	.bus_resume =		ehci_bus_resume,
3887ff71d6aSMatt Porter };
3897ff71d6aSMatt Porter 
3907ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/
3917ff71d6aSMatt Porter 
3927ff71d6aSMatt Porter /* PCI driver selection metadata; PCI hotplugging uses this */
3937ff71d6aSMatt Porter static const struct pci_device_id pci_ids [] = { {
3947ff71d6aSMatt Porter 	/* handle any USB 2.0 EHCI controller */
3957ff71d6aSMatt Porter 	PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x20), ~0),
3967ff71d6aSMatt Porter 	.driver_data =	(unsigned long) &ehci_pci_hc_driver,
3977ff71d6aSMatt Porter 	},
3987ff71d6aSMatt Porter 	{ /* end: all zeroes */ }
3997ff71d6aSMatt Porter };
4007ff71d6aSMatt Porter MODULE_DEVICE_TABLE(pci, pci_ids);
4017ff71d6aSMatt Porter 
4027ff71d6aSMatt Porter /* pci driver glue; this is a "new style" PCI driver module */
4037ff71d6aSMatt Porter static struct pci_driver ehci_pci_driver = {
4047ff71d6aSMatt Porter 	.name =		(char *) hcd_name,
4057ff71d6aSMatt Porter 	.id_table =	pci_ids,
4067ff71d6aSMatt Porter 
4077ff71d6aSMatt Porter 	.probe =	usb_hcd_pci_probe,
4087ff71d6aSMatt Porter 	.remove =	usb_hcd_pci_remove,
4097ff71d6aSMatt Porter 
4107ff71d6aSMatt Porter #ifdef	CONFIG_PM
4117ff71d6aSMatt Porter 	.suspend =	usb_hcd_pci_suspend,
4127ff71d6aSMatt Porter 	.resume =	usb_hcd_pci_resume,
4137ff71d6aSMatt Porter #endif
4147ff71d6aSMatt Porter };
4157ff71d6aSMatt Porter 
4167ff71d6aSMatt Porter static int __init ehci_hcd_pci_init(void)
4177ff71d6aSMatt Porter {
4187ff71d6aSMatt Porter 	if (usb_disabled())
4197ff71d6aSMatt Porter 		return -ENODEV;
4207ff71d6aSMatt Porter 
4217ff71d6aSMatt Porter 	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
4227ff71d6aSMatt Porter 		hcd_name,
4237ff71d6aSMatt Porter 		sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
4247ff71d6aSMatt Porter 		sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
4257ff71d6aSMatt Porter 
4267ff71d6aSMatt Porter 	return pci_register_driver(&ehci_pci_driver);
4277ff71d6aSMatt Porter }
4287ff71d6aSMatt Porter module_init(ehci_hcd_pci_init);
4297ff71d6aSMatt Porter 
4307ff71d6aSMatt Porter static void __exit ehci_hcd_pci_cleanup(void)
4317ff71d6aSMatt Porter {
4327ff71d6aSMatt Porter 	pci_unregister_driver(&ehci_pci_driver);
4337ff71d6aSMatt Porter }
4347ff71d6aSMatt Porter module_exit(ehci_hcd_pci_cleanup);
435