2 * This file contains code to reset and initialize USB host controllers.
3 * Some of it includes work-arounds for PCI hardware and BIOS quirks.
4 * It may need to run early during booting -- before USB would normally
5 * initialize -- to ensure that Linux doesn't use any legacy modes.
7 * Copyright (c) 1999 Martin Mares <mj@ucw.cz>
11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/pci.h>
14 #include <linux/init.h>
15 #include <linux/delay.h>
16 #include <linux/acpi.h>
17 #include "pci-quirks.h"
18 #include "xhci-ext-caps.h"
21 #define UHCI_USBLEGSUP 0xc0 /* legacy support */
22 #define UHCI_USBCMD 0 /* command register */
23 #define UHCI_USBINTR 4 /* interrupt register */
24 #define UHCI_USBLEGSUP_RWC 0x8f00 /* the R/WC bits */
25 #define UHCI_USBLEGSUP_RO 0x5040 /* R/O and reserved bits */
26 #define UHCI_USBCMD_RUN 0x0001 /* RUN/STOP bit */
27 #define UHCI_USBCMD_HCRESET 0x0002 /* Host Controller reset */
28 #define UHCI_USBCMD_EGSM 0x0008 /* Global Suspend Mode */
29 #define UHCI_USBCMD_CONFIGURE 0x0040 /* Config Flag */
30 #define UHCI_USBINTR_RESUME 0x0002 /* Resume interrupt enable */
32 #define OHCI_CONTROL 0x04
33 #define OHCI_CMDSTATUS 0x08
34 #define OHCI_INTRSTATUS 0x0c
35 #define OHCI_INTRENABLE 0x10
36 #define OHCI_INTRDISABLE 0x14
37 #define OHCI_OCR (1 << 3) /* ownership change request */
38 #define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */
39 #define OHCI_CTRL_IR (1 << 8) /* interrupt routing */
40 #define OHCI_INTR_OC (1 << 30) /* ownership change */
42 #define EHCI_HCC_PARAMS 0x08 /* extended capabilities */
43 #define EHCI_USBCMD 0 /* command register */
44 #define EHCI_USBCMD_RUN (1 << 0) /* RUN/STOP bit */
45 #define EHCI_USBSTS 4 /* status register */
46 #define EHCI_USBSTS_HALTED (1 << 12) /* HCHalted bit */
47 #define EHCI_USBINTR 8 /* interrupt register */
48 #define EHCI_CONFIGFLAG 0x40 /* configured flag register */
49 #define EHCI_USBLEGSUP 0 /* legacy support register */
50 #define EHCI_USBLEGSUP_BIOS (1 << 16) /* BIOS semaphore */
51 #define EHCI_USBLEGSUP_OS (1 << 24) /* OS semaphore */
52 #define EHCI_USBLEGCTLSTS 4 /* legacy control/status */
53 #define EHCI_USBLEGCTLSTS_SOOE (1 << 13) /* SMI on ownership change */
56 #define AB_REG_BAR_LOW 0xe0
57 #define AB_REG_BAR_HIGH 0xe1
58 #define AB_REG_BAR_SB700 0xf0
59 #define AB_INDX(addr) ((addr) + 0x00)
60 #define AB_DATA(addr) ((addr) + 0x04)
64 #define NB_PCIE_INDX_ADDR 0xe0
65 #define NB_PCIE_INDX_DATA 0xe4
66 #define PCIE_P_CNTL 0x10040
67 #define BIF_NB 0x10002
68 #define NB_PIF0_PWRDOWN_0 0x01100012
69 #define NB_PIF0_PWRDOWN_1 0x01100013
71 static struct amd_chipset_info
{
72 struct pci_dev
*nb_dev
;
73 struct pci_dev
*smbus_dev
;
81 static DEFINE_SPINLOCK(amd_lock
);
83 int usb_amd_find_chipset_info(void)
88 spin_lock_irqsave(&amd_lock
, flags
);
90 amd_chipset
.probe_count
++;
92 if (amd_chipset
.probe_count
> 1) {
93 spin_unlock_irqrestore(&amd_lock
, flags
);
94 return amd_chipset
.probe_result
;
97 amd_chipset
.smbus_dev
= pci_get_device(PCI_VENDOR_ID_ATI
, 0x4385, NULL
);
98 if (amd_chipset
.smbus_dev
) {
99 rev
= amd_chipset
.smbus_dev
->revision
;
101 amd_chipset
.sb_type
= 1;
102 else if (rev
>= 0x30 && rev
<= 0x3b)
103 amd_chipset
.sb_type
= 3;
105 amd_chipset
.smbus_dev
= pci_get_device(PCI_VENDOR_ID_AMD
,
107 if (!amd_chipset
.smbus_dev
) {
108 spin_unlock_irqrestore(&amd_lock
, flags
);
111 rev
= amd_chipset
.smbus_dev
->revision
;
112 if (rev
>= 0x11 && rev
<= 0x18)
113 amd_chipset
.sb_type
= 2;
116 if (amd_chipset
.sb_type
== 0) {
117 if (amd_chipset
.smbus_dev
) {
118 pci_dev_put(amd_chipset
.smbus_dev
);
119 amd_chipset
.smbus_dev
= NULL
;
121 spin_unlock_irqrestore(&amd_lock
, flags
);
125 amd_chipset
.nb_dev
= pci_get_device(PCI_VENDOR_ID_AMD
, 0x9601, NULL
);
126 if (amd_chipset
.nb_dev
) {
127 amd_chipset
.nb_type
= 1;
129 amd_chipset
.nb_dev
= pci_get_device(PCI_VENDOR_ID_AMD
,
131 if (amd_chipset
.nb_dev
) {
132 amd_chipset
.nb_type
= 2;
134 amd_chipset
.nb_dev
= pci_get_device(PCI_VENDOR_ID_AMD
,
136 if (amd_chipset
.nb_dev
)
137 amd_chipset
.nb_type
= 3;
141 amd_chipset
.probe_result
= 1;
142 printk(KERN_DEBUG
"QUIRK: Enable AMD PLL fix\n");
144 spin_unlock_irqrestore(&amd_lock
, flags
);
145 return amd_chipset
.probe_result
;
147 EXPORT_SYMBOL_GPL(usb_amd_find_chipset_info
);
150 * The hardware normally enables the A-link power management feature, which
151 * lets the system lower the power consumption in idle states.
153 * This USB quirk prevents the link going into that lower power state
154 * during isochronous transfers.
156 * Without this quirk, isochronous stream on OHCI/EHCI/xHCI controllers of
157 * some AMD platforms may stutter or have breaks occasionally.
159 static void usb_amd_quirk_pll(int disable
)
161 u32 addr
, addr_low
, addr_high
, val
;
162 u32 bit
= disable
? 0 : 1;
165 spin_lock_irqsave(&amd_lock
, flags
);
168 amd_chipset
.isoc_reqs
++;
169 if (amd_chipset
.isoc_reqs
> 1) {
170 spin_unlock_irqrestore(&amd_lock
, flags
);
174 amd_chipset
.isoc_reqs
--;
175 if (amd_chipset
.isoc_reqs
> 0) {
176 spin_unlock_irqrestore(&amd_lock
, flags
);
181 if (amd_chipset
.sb_type
== 1 || amd_chipset
.sb_type
== 2) {
182 outb_p(AB_REG_BAR_LOW
, 0xcd6);
183 addr_low
= inb_p(0xcd7);
184 outb_p(AB_REG_BAR_HIGH
, 0xcd6);
185 addr_high
= inb_p(0xcd7);
186 addr
= addr_high
<< 8 | addr_low
;
188 outl_p(0x30, AB_INDX(addr
));
189 outl_p(0x40, AB_DATA(addr
));
190 outl_p(0x34, AB_INDX(addr
));
191 val
= inl_p(AB_DATA(addr
));
192 } else if (amd_chipset
.sb_type
== 3) {
193 pci_read_config_dword(amd_chipset
.smbus_dev
,
194 AB_REG_BAR_SB700
, &addr
);
195 outl(AX_INDXC
, AB_INDX(addr
));
196 outl(0x40, AB_DATA(addr
));
197 outl(AX_DATAC
, AB_INDX(addr
));
198 val
= inl(AB_DATA(addr
));
200 spin_unlock_irqrestore(&amd_lock
, flags
);
206 val
|= (1 << 4) | (1 << 9);
209 val
&= ~((1 << 4) | (1 << 9));
211 outl_p(val
, AB_DATA(addr
));
213 if (!amd_chipset
.nb_dev
) {
214 spin_unlock_irqrestore(&amd_lock
, flags
);
218 if (amd_chipset
.nb_type
== 1 || amd_chipset
.nb_type
== 3) {
220 pci_write_config_dword(amd_chipset
.nb_dev
,
221 NB_PCIE_INDX_ADDR
, addr
);
222 pci_read_config_dword(amd_chipset
.nb_dev
,
223 NB_PCIE_INDX_DATA
, &val
);
225 val
&= ~(1 | (1 << 3) | (1 << 4) | (1 << 9) | (1 << 12));
226 val
|= bit
| (bit
<< 3) | (bit
<< 12);
227 val
|= ((!bit
) << 4) | ((!bit
) << 9);
228 pci_write_config_dword(amd_chipset
.nb_dev
,
229 NB_PCIE_INDX_DATA
, val
);
232 pci_write_config_dword(amd_chipset
.nb_dev
,
233 NB_PCIE_INDX_ADDR
, addr
);
234 pci_read_config_dword(amd_chipset
.nb_dev
,
235 NB_PCIE_INDX_DATA
, &val
);
239 pci_write_config_dword(amd_chipset
.nb_dev
,
240 NB_PCIE_INDX_DATA
, val
);
241 } else if (amd_chipset
.nb_type
== 2) {
242 addr
= NB_PIF0_PWRDOWN_0
;
243 pci_write_config_dword(amd_chipset
.nb_dev
,
244 NB_PCIE_INDX_ADDR
, addr
);
245 pci_read_config_dword(amd_chipset
.nb_dev
,
246 NB_PCIE_INDX_DATA
, &val
);
252 pci_write_config_dword(amd_chipset
.nb_dev
,
253 NB_PCIE_INDX_DATA
, val
);
255 addr
= NB_PIF0_PWRDOWN_1
;
256 pci_write_config_dword(amd_chipset
.nb_dev
,
257 NB_PCIE_INDX_ADDR
, addr
);
258 pci_read_config_dword(amd_chipset
.nb_dev
,
259 NB_PCIE_INDX_DATA
, &val
);
265 pci_write_config_dword(amd_chipset
.nb_dev
,
266 NB_PCIE_INDX_DATA
, val
);
269 spin_unlock_irqrestore(&amd_lock
, flags
);
273 void usb_amd_quirk_pll_disable(void)
275 usb_amd_quirk_pll(1);
277 EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_disable
);
279 void usb_amd_quirk_pll_enable(void)
281 usb_amd_quirk_pll(0);
283 EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_enable
);
285 void usb_amd_dev_put(void)
289 spin_lock_irqsave(&amd_lock
, flags
);
291 amd_chipset
.probe_count
--;
292 if (amd_chipset
.probe_count
> 0) {
293 spin_unlock_irqrestore(&amd_lock
, flags
);
297 if (amd_chipset
.nb_dev
) {
298 pci_dev_put(amd_chipset
.nb_dev
);
299 amd_chipset
.nb_dev
= NULL
;
301 if (amd_chipset
.smbus_dev
) {
302 pci_dev_put(amd_chipset
.smbus_dev
);
303 amd_chipset
.smbus_dev
= NULL
;
305 amd_chipset
.nb_type
= 0;
306 amd_chipset
.sb_type
= 0;
307 amd_chipset
.isoc_reqs
= 0;
308 amd_chipset
.probe_result
= 0;
310 spin_unlock_irqrestore(&amd_lock
, flags
);
312 EXPORT_SYMBOL_GPL(usb_amd_dev_put
);
315 * Make sure the controller is completely inactive, unable to
316 * generate interrupts or do DMA.
318 void uhci_reset_hc(struct pci_dev
*pdev
, unsigned long base
)
320 /* Turn off PIRQ enable and SMI enable. (This also turns off the
321 * BIOS's USB Legacy Support.) Turn off all the R/WC bits too.
323 pci_write_config_word(pdev
, UHCI_USBLEGSUP
, UHCI_USBLEGSUP_RWC
);
325 /* Reset the HC - this will force us to get a
326 * new notification of any already connected
327 * ports due to the virtual disconnect that it
330 outw(UHCI_USBCMD_HCRESET
, base
+ UHCI_USBCMD
);
333 if (inw(base
+ UHCI_USBCMD
) & UHCI_USBCMD_HCRESET
)
334 dev_warn(&pdev
->dev
, "HCRESET not completed yet!\n");
336 /* Just to be safe, disable interrupt requests and
337 * make sure the controller is stopped.
339 outw(0, base
+ UHCI_USBINTR
);
340 outw(0, base
+ UHCI_USBCMD
);
342 EXPORT_SYMBOL_GPL(uhci_reset_hc
);
345 * Initialize a controller that was newly discovered or has just been
346 * resumed. In either case we can't be sure of its previous state.
348 * Returns: 1 if the controller was reset, 0 otherwise.
350 int uhci_check_and_reset_hc(struct pci_dev
*pdev
, unsigned long base
)
353 unsigned int cmd
, intr
;
356 * When restarting a suspended controller, we expect all the
357 * settings to be the same as we left them:
359 * PIRQ and SMI disabled, no R/W bits set in USBLEGSUP;
360 * Controller is stopped and configured with EGSM set;
361 * No interrupts enabled except possibly Resume Detect.
363 * If any of these conditions are violated we do a complete reset.
365 pci_read_config_word(pdev
, UHCI_USBLEGSUP
, &legsup
);
366 if (legsup
& ~(UHCI_USBLEGSUP_RO
| UHCI_USBLEGSUP_RWC
)) {
367 dev_dbg(&pdev
->dev
, "%s: legsup = 0x%04x\n",
372 cmd
= inw(base
+ UHCI_USBCMD
);
373 if ((cmd
& UHCI_USBCMD_RUN
) || !(cmd
& UHCI_USBCMD_CONFIGURE
) ||
374 !(cmd
& UHCI_USBCMD_EGSM
)) {
375 dev_dbg(&pdev
->dev
, "%s: cmd = 0x%04x\n",
380 intr
= inw(base
+ UHCI_USBINTR
);
381 if (intr
& (~UHCI_USBINTR_RESUME
)) {
382 dev_dbg(&pdev
->dev
, "%s: intr = 0x%04x\n",
389 dev_dbg(&pdev
->dev
, "Performing full reset\n");
390 uhci_reset_hc(pdev
, base
);
393 EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc
);
395 static inline int io_type_enabled(struct pci_dev
*pdev
, unsigned int mask
)
398 return !pci_read_config_word(pdev
, PCI_COMMAND
, &cmd
) && (cmd
& mask
);
401 #define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO)
402 #define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY)
404 static void __devinit
quirk_usb_handoff_uhci(struct pci_dev
*pdev
)
406 unsigned long base
= 0;
409 if (!pio_enabled(pdev
))
412 for (i
= 0; i
< PCI_ROM_RESOURCE
; i
++)
413 if ((pci_resource_flags(pdev
, i
) & IORESOURCE_IO
)) {
414 base
= pci_resource_start(pdev
, i
);
419 uhci_check_and_reset_hc(pdev
, base
);
422 static int __devinit
mmio_resource_enabled(struct pci_dev
*pdev
, int idx
)
424 return pci_resource_start(pdev
, idx
) && mmio_enabled(pdev
);
427 static void __devinit
quirk_usb_handoff_ohci(struct pci_dev
*pdev
)
432 if (!mmio_resource_enabled(pdev
, 0))
435 base
= pci_ioremap_bar(pdev
, 0);
439 control
= readl(base
+ OHCI_CONTROL
);
441 /* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
443 #define OHCI_CTRL_MASK (OHCI_CTRL_RWC | OHCI_CTRL_IR)
445 #define OHCI_CTRL_MASK OHCI_CTRL_RWC
447 if (control
& OHCI_CTRL_IR
) {
448 int wait_time
= 500; /* arbitrary; 5 seconds */
449 writel(OHCI_INTR_OC
, base
+ OHCI_INTRENABLE
);
450 writel(OHCI_OCR
, base
+ OHCI_CMDSTATUS
);
451 while (wait_time
> 0 &&
452 readl(base
+ OHCI_CONTROL
) & OHCI_CTRL_IR
) {
457 dev_warn(&pdev
->dev
, "OHCI: BIOS handoff failed"
458 " (BIOS bug?) %08x\n",
459 readl(base
+ OHCI_CONTROL
));
463 /* reset controller, preserving RWC (and possibly IR) */
464 writel(control
& OHCI_CTRL_MASK
, base
+ OHCI_CONTROL
);
469 writel(~(u32
)0, base
+ OHCI_INTRDISABLE
);
470 writel(~(u32
)0, base
+ OHCI_INTRSTATUS
);
475 static void __devinit
quirk_usb_disable_ehci(struct pci_dev
*pdev
)
477 int wait_time
, delta
;
478 void __iomem
*base
, *op_reg_base
;
480 u8 offset
, cap_length
;
482 int tried_handoff
= 0;
484 if (!mmio_resource_enabled(pdev
, 0))
487 base
= pci_ioremap_bar(pdev
, 0);
491 cap_length
= readb(base
);
492 op_reg_base
= base
+ cap_length
;
494 /* EHCI 0.96 and later may have "extended capabilities"
495 * spec section 5.1 explains the bios handoff, e.g. for
496 * booting from USB disk or using a usb keyboard
498 hcc_params
= readl(base
+ EHCI_HCC_PARAMS
);
499 offset
= (hcc_params
>> 8) & 0xff;
500 while (offset
&& --count
) {
504 pci_read_config_dword(pdev
, offset
, &cap
);
505 switch (cap
& 0xff) {
506 case 1: /* BIOS/SMM/... handoff support */
507 if ((cap
& EHCI_USBLEGSUP_BIOS
)) {
508 dev_dbg(&pdev
->dev
, "EHCI: BIOS handoff\n");
511 /* aleksey_gorelov@phoenix.com reports that some systems need SMI forced on,
512 * but that seems dubious in general (the BIOS left it off intentionally)
513 * and is known to prevent some systems from booting. so we won't do this
514 * unless maybe we can determine when we're on a system that needs SMI forced.
516 /* BIOS workaround (?): be sure the
517 * pre-Linux code receives the SMI
519 pci_read_config_dword(pdev
,
520 offset
+ EHCI_USBLEGCTLSTS
,
522 pci_write_config_dword(pdev
,
523 offset
+ EHCI_USBLEGCTLSTS
,
524 val
| EHCI_USBLEGCTLSTS_SOOE
);
527 /* some systems get upset if this semaphore is
528 * set for any other reason than forcing a BIOS
531 pci_write_config_byte(pdev
, offset
+ 3, 1);
534 /* if boot firmware now owns EHCI, spin till
538 while ((cap
& EHCI_USBLEGSUP_BIOS
) && (msec
> 0)) {
542 pci_read_config_dword(pdev
, offset
, &cap
);
545 if (cap
& EHCI_USBLEGSUP_BIOS
) {
546 /* well, possibly buggy BIOS... try to shut
547 * it down, and hope nothing goes too wrong
549 dev_warn(&pdev
->dev
, "EHCI: BIOS handoff failed"
550 " (BIOS bug?) %08x\n", cap
);
551 pci_write_config_byte(pdev
, offset
+ 2, 0);
554 /* just in case, always disable EHCI SMIs */
555 pci_write_config_dword(pdev
,
556 offset
+ EHCI_USBLEGCTLSTS
,
559 /* If the BIOS ever owned the controller then we
560 * can't expect any power sessions to remain intact.
563 writel(0, op_reg_base
+ EHCI_CONFIGFLAG
);
565 case 0: /* illegal reserved capability */
569 dev_warn(&pdev
->dev
, "EHCI: unrecognized capability "
570 "%02x\n", cap
& 0xff);
573 offset
= (cap
>> 8) & 0xff;
576 dev_printk(KERN_DEBUG
, &pdev
->dev
, "EHCI: capability loop?\n");
579 * halt EHCI & disable its interrupts in any case
581 val
= readl(op_reg_base
+ EHCI_USBSTS
);
582 if ((val
& EHCI_USBSTS_HALTED
) == 0) {
583 val
= readl(op_reg_base
+ EHCI_USBCMD
);
584 val
&= ~EHCI_USBCMD_RUN
;
585 writel(val
, op_reg_base
+ EHCI_USBCMD
);
590 writel(0x3f, op_reg_base
+ EHCI_USBSTS
);
593 val
= readl(op_reg_base
+ EHCI_USBSTS
);
594 if ((val
== ~(u32
)0) || (val
& EHCI_USBSTS_HALTED
)) {
597 } while (wait_time
> 0);
599 writel(0, op_reg_base
+ EHCI_USBINTR
);
600 writel(0x3f, op_reg_base
+ EHCI_USBSTS
);
606 * handshake - spin reading a register until handshake completes
607 * @ptr: address of hc register to be read
608 * @mask: bits to look at in result of read
609 * @done: value of those bits when handshake succeeds
610 * @wait_usec: timeout in microseconds
611 * @delay_usec: delay in microseconds to wait between polling
613 * Polls a register every delay_usec microseconds.
614 * Returns 0 when the mask bits have the value done.
615 * Returns -ETIMEDOUT if this condition is not true after
616 * wait_usec microseconds have passed.
618 static int handshake(void __iomem
*ptr
, u32 mask
, u32 done
,
619 int wait_usec
, int delay_usec
)
629 wait_usec
-= delay_usec
;
630 } while (wait_usec
> 0);
635 * PCI Quirks for xHCI.
637 * Takes care of the handoff between the Pre-OS (i.e. BIOS) and the OS.
638 * It signals to the BIOS that the OS wants control of the host controller,
639 * and then waits 5 seconds for the BIOS to hand over control.
640 * If we timeout, assume the BIOS is broken and take control anyway.
642 static void __devinit
quirk_usb_handoff_xhci(struct pci_dev
*pdev
)
646 void __iomem
*op_reg_base
;
650 if (!mmio_resource_enabled(pdev
, 0))
653 base
= ioremap_nocache(pci_resource_start(pdev
, 0),
654 pci_resource_len(pdev
, 0));
659 * Find the Legacy Support Capability register -
660 * this is optional for xHCI host controllers.
662 ext_cap_offset
= xhci_find_next_cap_offset(base
, XHCI_HCC_PARAMS_OFFSET
);
665 /* We've reached the end of the extended capabilities */
667 val
= readl(base
+ ext_cap_offset
);
668 if (XHCI_EXT_CAPS_ID(val
) == XHCI_EXT_CAPS_LEGACY
)
670 ext_cap_offset
= xhci_find_next_cap_offset(base
, ext_cap_offset
);
673 /* If the BIOS owns the HC, signal that the OS wants it, and wait */
674 if (val
& XHCI_HC_BIOS_OWNED
) {
675 writel(val
& XHCI_HC_OS_OWNED
, base
+ ext_cap_offset
);
677 /* Wait for 5 seconds with 10 microsecond polling interval */
678 timeout
= handshake(base
+ ext_cap_offset
, XHCI_HC_BIOS_OWNED
,
681 /* Assume a buggy BIOS and take HC ownership anyway */
683 dev_warn(&pdev
->dev
, "xHCI BIOS handoff failed"
684 " (BIOS bug ?) %08x\n", val
);
685 writel(val
& ~XHCI_HC_BIOS_OWNED
, base
+ ext_cap_offset
);
689 /* Disable any BIOS SMIs */
690 writel(XHCI_LEGACY_DISABLE_SMI
,
691 base
+ ext_cap_offset
+ XHCI_LEGACY_CONTROL_OFFSET
);
694 op_reg_base
= base
+ XHCI_HC_LENGTH(readl(base
));
696 /* Wait for the host controller to be ready before writing any
697 * operational or runtime registers. Wait 5 seconds and no more.
699 timeout
= handshake(op_reg_base
+ XHCI_STS_OFFSET
, XHCI_STS_CNR
, 0,
701 /* Assume a buggy HC and start HC initialization anyway */
703 val
= readl(op_reg_base
+ XHCI_STS_OFFSET
);
705 "xHCI HW not ready after 5 sec (HC bug?) "
706 "status = 0x%x\n", val
);
709 /* Send the halt and disable interrupts command */
710 val
= readl(op_reg_base
+ XHCI_CMD_OFFSET
);
711 val
&= ~(XHCI_CMD_RUN
| XHCI_IRQS
);
712 writel(val
, op_reg_base
+ XHCI_CMD_OFFSET
);
714 /* Wait for the HC to halt - poll every 125 usec (one microframe). */
715 timeout
= handshake(op_reg_base
+ XHCI_STS_OFFSET
, XHCI_STS_HALT
, 1,
716 XHCI_MAX_HALT_USEC
, 125);
718 val
= readl(op_reg_base
+ XHCI_STS_OFFSET
);
720 "xHCI HW did not halt within %d usec "
721 "status = 0x%x\n", XHCI_MAX_HALT_USEC
, val
);
727 static void __devinit
quirk_usb_early_handoff(struct pci_dev
*pdev
)
729 if (pdev
->class == PCI_CLASS_SERIAL_USB_UHCI
)
730 quirk_usb_handoff_uhci(pdev
);
731 else if (pdev
->class == PCI_CLASS_SERIAL_USB_OHCI
)
732 quirk_usb_handoff_ohci(pdev
);
733 else if (pdev
->class == PCI_CLASS_SERIAL_USB_EHCI
)
734 quirk_usb_disable_ehci(pdev
);
735 else if (pdev
->class == PCI_CLASS_SERIAL_USB_XHCI
)
736 quirk_usb_handoff_xhci(pdev
);
738 DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID
, PCI_ANY_ID
, quirk_usb_early_handoff
);