Linux 4.14.51
[linux/fpc-iii.git] / drivers / usb / host / pci-quirks.c
blobe1faee1f860299829bf1beb6ae9ec3105860b63e
1 /*
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>
8 * (and others)
9 */
11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/pci.h>
14 #include <linux/delay.h>
15 #include <linux/export.h>
16 #include <linux/acpi.h>
17 #include <linux/dmi.h>
18 #include "pci-quirks.h"
19 #include "xhci-ext-caps.h"
22 #define UHCI_USBLEGSUP 0xc0 /* legacy support */
23 #define UHCI_USBCMD 0 /* command register */
24 #define UHCI_USBINTR 4 /* interrupt register */
25 #define UHCI_USBLEGSUP_RWC 0x8f00 /* the R/WC bits */
26 #define UHCI_USBLEGSUP_RO 0x5040 /* R/O and reserved bits */
27 #define UHCI_USBCMD_RUN 0x0001 /* RUN/STOP bit */
28 #define UHCI_USBCMD_HCRESET 0x0002 /* Host Controller reset */
29 #define UHCI_USBCMD_EGSM 0x0008 /* Global Suspend Mode */
30 #define UHCI_USBCMD_CONFIGURE 0x0040 /* Config Flag */
31 #define UHCI_USBINTR_RESUME 0x0002 /* Resume interrupt enable */
33 #define OHCI_CONTROL 0x04
34 #define OHCI_CMDSTATUS 0x08
35 #define OHCI_INTRSTATUS 0x0c
36 #define OHCI_INTRENABLE 0x10
37 #define OHCI_INTRDISABLE 0x14
38 #define OHCI_FMINTERVAL 0x34
39 #define OHCI_HCFS (3 << 6) /* hc functional state */
40 #define OHCI_HCR (1 << 0) /* host controller reset */
41 #define OHCI_OCR (1 << 3) /* ownership change request */
42 #define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */
43 #define OHCI_CTRL_IR (1 << 8) /* interrupt routing */
44 #define OHCI_INTR_OC (1 << 30) /* ownership change */
46 #define EHCI_HCC_PARAMS 0x08 /* extended capabilities */
47 #define EHCI_USBCMD 0 /* command register */
48 #define EHCI_USBCMD_RUN (1 << 0) /* RUN/STOP bit */
49 #define EHCI_USBSTS 4 /* status register */
50 #define EHCI_USBSTS_HALTED (1 << 12) /* HCHalted bit */
51 #define EHCI_USBINTR 8 /* interrupt register */
52 #define EHCI_CONFIGFLAG 0x40 /* configured flag register */
53 #define EHCI_USBLEGSUP 0 /* legacy support register */
54 #define EHCI_USBLEGSUP_BIOS (1 << 16) /* BIOS semaphore */
55 #define EHCI_USBLEGSUP_OS (1 << 24) /* OS semaphore */
56 #define EHCI_USBLEGCTLSTS 4 /* legacy control/status */
57 #define EHCI_USBLEGCTLSTS_SOOE (1 << 13) /* SMI on ownership change */
59 /* AMD quirk use */
60 #define AB_REG_BAR_LOW 0xe0
61 #define AB_REG_BAR_HIGH 0xe1
62 #define AB_REG_BAR_SB700 0xf0
63 #define AB_INDX(addr) ((addr) + 0x00)
64 #define AB_DATA(addr) ((addr) + 0x04)
65 #define AX_INDXC 0x30
66 #define AX_DATAC 0x34
68 #define PT_ADDR_INDX 0xE8
69 #define PT_READ_INDX 0xE4
70 #define PT_SIG_1_ADDR 0xA520
71 #define PT_SIG_2_ADDR 0xA521
72 #define PT_SIG_3_ADDR 0xA522
73 #define PT_SIG_4_ADDR 0xA523
74 #define PT_SIG_1_DATA 0x78
75 #define PT_SIG_2_DATA 0x56
76 #define PT_SIG_3_DATA 0x34
77 #define PT_SIG_4_DATA 0x12
78 #define PT4_P1_REG 0xB521
79 #define PT4_P2_REG 0xB522
80 #define PT2_P1_REG 0xD520
81 #define PT2_P2_REG 0xD521
82 #define PT1_P1_REG 0xD522
83 #define PT1_P2_REG 0xD523
85 #define NB_PCIE_INDX_ADDR 0xe0
86 #define NB_PCIE_INDX_DATA 0xe4
87 #define PCIE_P_CNTL 0x10040
88 #define BIF_NB 0x10002
89 #define NB_PIF0_PWRDOWN_0 0x01100012
90 #define NB_PIF0_PWRDOWN_1 0x01100013
92 #define USB_INTEL_XUSB2PR 0xD0
93 #define USB_INTEL_USB2PRM 0xD4
94 #define USB_INTEL_USB3_PSSEN 0xD8
95 #define USB_INTEL_USB3PRM 0xDC
97 /* ASMEDIA quirk use */
98 #define ASMT_DATA_WRITE0_REG 0xF8
99 #define ASMT_DATA_WRITE1_REG 0xFC
100 #define ASMT_CONTROL_REG 0xE0
101 #define ASMT_CONTROL_WRITE_BIT 0x02
102 #define ASMT_WRITEREG_CMD 0x10423
103 #define ASMT_FLOWCTL_ADDR 0xFA30
104 #define ASMT_FLOWCTL_DATA 0xBA
105 #define ASMT_PSEUDO_DATA 0
108 * amd_chipset_gen values represent AMD different chipset generations
110 enum amd_chipset_gen {
111 NOT_AMD_CHIPSET = 0,
112 AMD_CHIPSET_SB600,
113 AMD_CHIPSET_SB700,
114 AMD_CHIPSET_SB800,
115 AMD_CHIPSET_HUDSON2,
116 AMD_CHIPSET_BOLTON,
117 AMD_CHIPSET_YANGTZE,
118 AMD_CHIPSET_TAISHAN,
119 AMD_CHIPSET_UNKNOWN,
122 struct amd_chipset_type {
123 enum amd_chipset_gen gen;
124 u8 rev;
127 static struct amd_chipset_info {
128 struct pci_dev *nb_dev;
129 struct pci_dev *smbus_dev;
130 int nb_type;
131 struct amd_chipset_type sb_type;
132 int isoc_reqs;
133 int probe_count;
134 int probe_result;
135 } amd_chipset;
137 static DEFINE_SPINLOCK(amd_lock);
140 * amd_chipset_sb_type_init - initialize amd chipset southbridge type
142 * AMD FCH/SB generation and revision is identified by SMBus controller
143 * vendor, device and revision IDs.
145 * Returns: 1 if it is an AMD chipset, 0 otherwise.
147 static int amd_chipset_sb_type_init(struct amd_chipset_info *pinfo)
149 u8 rev = 0;
150 pinfo->sb_type.gen = AMD_CHIPSET_UNKNOWN;
152 pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_ATI,
153 PCI_DEVICE_ID_ATI_SBX00_SMBUS, NULL);
154 if (pinfo->smbus_dev) {
155 rev = pinfo->smbus_dev->revision;
156 if (rev >= 0x10 && rev <= 0x1f)
157 pinfo->sb_type.gen = AMD_CHIPSET_SB600;
158 else if (rev >= 0x30 && rev <= 0x3f)
159 pinfo->sb_type.gen = AMD_CHIPSET_SB700;
160 else if (rev >= 0x40 && rev <= 0x4f)
161 pinfo->sb_type.gen = AMD_CHIPSET_SB800;
162 } else {
163 pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD,
164 PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, NULL);
166 if (pinfo->smbus_dev) {
167 rev = pinfo->smbus_dev->revision;
168 if (rev >= 0x11 && rev <= 0x14)
169 pinfo->sb_type.gen = AMD_CHIPSET_HUDSON2;
170 else if (rev >= 0x15 && rev <= 0x18)
171 pinfo->sb_type.gen = AMD_CHIPSET_BOLTON;
172 else if (rev >= 0x39 && rev <= 0x3a)
173 pinfo->sb_type.gen = AMD_CHIPSET_YANGTZE;
174 } else {
175 pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD,
176 0x145c, NULL);
177 if (pinfo->smbus_dev) {
178 rev = pinfo->smbus_dev->revision;
179 pinfo->sb_type.gen = AMD_CHIPSET_TAISHAN;
180 } else {
181 pinfo->sb_type.gen = NOT_AMD_CHIPSET;
182 return 0;
186 pinfo->sb_type.rev = rev;
187 return 1;
190 void sb800_prefetch(struct device *dev, int on)
192 u16 misc;
193 struct pci_dev *pdev = to_pci_dev(dev);
195 pci_read_config_word(pdev, 0x50, &misc);
196 if (on == 0)
197 pci_write_config_word(pdev, 0x50, misc & 0xfcff);
198 else
199 pci_write_config_word(pdev, 0x50, misc | 0x0300);
201 EXPORT_SYMBOL_GPL(sb800_prefetch);
203 int usb_amd_find_chipset_info(void)
205 unsigned long flags;
206 struct amd_chipset_info info;
207 int ret;
209 spin_lock_irqsave(&amd_lock, flags);
211 /* probe only once */
212 if (amd_chipset.probe_count > 0) {
213 amd_chipset.probe_count++;
214 spin_unlock_irqrestore(&amd_lock, flags);
215 return amd_chipset.probe_result;
217 memset(&info, 0, sizeof(info));
218 spin_unlock_irqrestore(&amd_lock, flags);
220 if (!amd_chipset_sb_type_init(&info)) {
221 ret = 0;
222 goto commit;
225 /* Below chipset generations needn't enable AMD PLL quirk */
226 if (info.sb_type.gen == AMD_CHIPSET_UNKNOWN ||
227 info.sb_type.gen == AMD_CHIPSET_SB600 ||
228 info.sb_type.gen == AMD_CHIPSET_YANGTZE ||
229 (info.sb_type.gen == AMD_CHIPSET_SB700 &&
230 info.sb_type.rev > 0x3b)) {
231 if (info.smbus_dev) {
232 pci_dev_put(info.smbus_dev);
233 info.smbus_dev = NULL;
235 ret = 0;
236 goto commit;
239 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x9601, NULL);
240 if (info.nb_dev) {
241 info.nb_type = 1;
242 } else {
243 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1510, NULL);
244 if (info.nb_dev) {
245 info.nb_type = 2;
246 } else {
247 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD,
248 0x9600, NULL);
249 if (info.nb_dev)
250 info.nb_type = 3;
254 ret = info.probe_result = 1;
255 printk(KERN_DEBUG "QUIRK: Enable AMD PLL fix\n");
257 commit:
259 spin_lock_irqsave(&amd_lock, flags);
260 if (amd_chipset.probe_count > 0) {
261 /* race - someone else was faster - drop devices */
263 /* Mark that we where here */
264 amd_chipset.probe_count++;
265 ret = amd_chipset.probe_result;
267 spin_unlock_irqrestore(&amd_lock, flags);
269 pci_dev_put(info.nb_dev);
270 pci_dev_put(info.smbus_dev);
272 } else {
273 /* no race - commit the result */
274 info.probe_count++;
275 amd_chipset = info;
276 spin_unlock_irqrestore(&amd_lock, flags);
279 return ret;
281 EXPORT_SYMBOL_GPL(usb_amd_find_chipset_info);
283 int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *pdev)
285 /* Make sure amd chipset type has already been initialized */
286 usb_amd_find_chipset_info();
287 if (amd_chipset.sb_type.gen == AMD_CHIPSET_YANGTZE ||
288 amd_chipset.sb_type.gen == AMD_CHIPSET_TAISHAN) {
289 dev_dbg(&pdev->dev, "QUIRK: Enable AMD remote wakeup fix\n");
290 return 1;
292 return 0;
294 EXPORT_SYMBOL_GPL(usb_hcd_amd_remote_wakeup_quirk);
296 bool usb_amd_hang_symptom_quirk(void)
298 u8 rev;
300 usb_amd_find_chipset_info();
301 rev = amd_chipset.sb_type.rev;
302 /* SB600 and old version of SB700 have hang symptom bug */
303 return amd_chipset.sb_type.gen == AMD_CHIPSET_SB600 ||
304 (amd_chipset.sb_type.gen == AMD_CHIPSET_SB700 &&
305 rev >= 0x3a && rev <= 0x3b);
307 EXPORT_SYMBOL_GPL(usb_amd_hang_symptom_quirk);
309 bool usb_amd_prefetch_quirk(void)
311 usb_amd_find_chipset_info();
312 /* SB800 needs pre-fetch fix */
313 return amd_chipset.sb_type.gen == AMD_CHIPSET_SB800;
315 EXPORT_SYMBOL_GPL(usb_amd_prefetch_quirk);
318 * The hardware normally enables the A-link power management feature, which
319 * lets the system lower the power consumption in idle states.
321 * This USB quirk prevents the link going into that lower power state
322 * during isochronous transfers.
324 * Without this quirk, isochronous stream on OHCI/EHCI/xHCI controllers of
325 * some AMD platforms may stutter or have breaks occasionally.
327 static void usb_amd_quirk_pll(int disable)
329 u32 addr, addr_low, addr_high, val;
330 u32 bit = disable ? 0 : 1;
331 unsigned long flags;
333 spin_lock_irqsave(&amd_lock, flags);
335 if (disable) {
336 amd_chipset.isoc_reqs++;
337 if (amd_chipset.isoc_reqs > 1) {
338 spin_unlock_irqrestore(&amd_lock, flags);
339 return;
341 } else {
342 amd_chipset.isoc_reqs--;
343 if (amd_chipset.isoc_reqs > 0) {
344 spin_unlock_irqrestore(&amd_lock, flags);
345 return;
349 if (amd_chipset.sb_type.gen == AMD_CHIPSET_SB800 ||
350 amd_chipset.sb_type.gen == AMD_CHIPSET_HUDSON2 ||
351 amd_chipset.sb_type.gen == AMD_CHIPSET_BOLTON) {
352 outb_p(AB_REG_BAR_LOW, 0xcd6);
353 addr_low = inb_p(0xcd7);
354 outb_p(AB_REG_BAR_HIGH, 0xcd6);
355 addr_high = inb_p(0xcd7);
356 addr = addr_high << 8 | addr_low;
358 outl_p(0x30, AB_INDX(addr));
359 outl_p(0x40, AB_DATA(addr));
360 outl_p(0x34, AB_INDX(addr));
361 val = inl_p(AB_DATA(addr));
362 } else if (amd_chipset.sb_type.gen == AMD_CHIPSET_SB700 &&
363 amd_chipset.sb_type.rev <= 0x3b) {
364 pci_read_config_dword(amd_chipset.smbus_dev,
365 AB_REG_BAR_SB700, &addr);
366 outl(AX_INDXC, AB_INDX(addr));
367 outl(0x40, AB_DATA(addr));
368 outl(AX_DATAC, AB_INDX(addr));
369 val = inl(AB_DATA(addr));
370 } else {
371 spin_unlock_irqrestore(&amd_lock, flags);
372 return;
375 if (disable) {
376 val &= ~0x08;
377 val |= (1 << 4) | (1 << 9);
378 } else {
379 val |= 0x08;
380 val &= ~((1 << 4) | (1 << 9));
382 outl_p(val, AB_DATA(addr));
384 if (!amd_chipset.nb_dev) {
385 spin_unlock_irqrestore(&amd_lock, flags);
386 return;
389 if (amd_chipset.nb_type == 1 || amd_chipset.nb_type == 3) {
390 addr = PCIE_P_CNTL;
391 pci_write_config_dword(amd_chipset.nb_dev,
392 NB_PCIE_INDX_ADDR, addr);
393 pci_read_config_dword(amd_chipset.nb_dev,
394 NB_PCIE_INDX_DATA, &val);
396 val &= ~(1 | (1 << 3) | (1 << 4) | (1 << 9) | (1 << 12));
397 val |= bit | (bit << 3) | (bit << 12);
398 val |= ((!bit) << 4) | ((!bit) << 9);
399 pci_write_config_dword(amd_chipset.nb_dev,
400 NB_PCIE_INDX_DATA, val);
402 addr = BIF_NB;
403 pci_write_config_dword(amd_chipset.nb_dev,
404 NB_PCIE_INDX_ADDR, addr);
405 pci_read_config_dword(amd_chipset.nb_dev,
406 NB_PCIE_INDX_DATA, &val);
407 val &= ~(1 << 8);
408 val |= bit << 8;
410 pci_write_config_dword(amd_chipset.nb_dev,
411 NB_PCIE_INDX_DATA, val);
412 } else if (amd_chipset.nb_type == 2) {
413 addr = NB_PIF0_PWRDOWN_0;
414 pci_write_config_dword(amd_chipset.nb_dev,
415 NB_PCIE_INDX_ADDR, addr);
416 pci_read_config_dword(amd_chipset.nb_dev,
417 NB_PCIE_INDX_DATA, &val);
418 if (disable)
419 val &= ~(0x3f << 7);
420 else
421 val |= 0x3f << 7;
423 pci_write_config_dword(amd_chipset.nb_dev,
424 NB_PCIE_INDX_DATA, val);
426 addr = NB_PIF0_PWRDOWN_1;
427 pci_write_config_dword(amd_chipset.nb_dev,
428 NB_PCIE_INDX_ADDR, addr);
429 pci_read_config_dword(amd_chipset.nb_dev,
430 NB_PCIE_INDX_DATA, &val);
431 if (disable)
432 val &= ~(0x3f << 7);
433 else
434 val |= 0x3f << 7;
436 pci_write_config_dword(amd_chipset.nb_dev,
437 NB_PCIE_INDX_DATA, val);
440 spin_unlock_irqrestore(&amd_lock, flags);
441 return;
444 void usb_amd_quirk_pll_disable(void)
446 usb_amd_quirk_pll(1);
448 EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_disable);
450 static int usb_asmedia_wait_write(struct pci_dev *pdev)
452 unsigned long retry_count;
453 unsigned char value;
455 for (retry_count = 1000; retry_count > 0; --retry_count) {
457 pci_read_config_byte(pdev, ASMT_CONTROL_REG, &value);
459 if (value == 0xff) {
460 dev_err(&pdev->dev, "%s: check_ready ERROR", __func__);
461 return -EIO;
464 if ((value & ASMT_CONTROL_WRITE_BIT) == 0)
465 return 0;
467 udelay(50);
470 dev_warn(&pdev->dev, "%s: check_write_ready timeout", __func__);
471 return -ETIMEDOUT;
474 void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev)
476 if (usb_asmedia_wait_write(pdev) != 0)
477 return;
479 /* send command and address to device */
480 pci_write_config_dword(pdev, ASMT_DATA_WRITE0_REG, ASMT_WRITEREG_CMD);
481 pci_write_config_dword(pdev, ASMT_DATA_WRITE1_REG, ASMT_FLOWCTL_ADDR);
482 pci_write_config_byte(pdev, ASMT_CONTROL_REG, ASMT_CONTROL_WRITE_BIT);
484 if (usb_asmedia_wait_write(pdev) != 0)
485 return;
487 /* send data to device */
488 pci_write_config_dword(pdev, ASMT_DATA_WRITE0_REG, ASMT_FLOWCTL_DATA);
489 pci_write_config_dword(pdev, ASMT_DATA_WRITE1_REG, ASMT_PSEUDO_DATA);
490 pci_write_config_byte(pdev, ASMT_CONTROL_REG, ASMT_CONTROL_WRITE_BIT);
492 EXPORT_SYMBOL_GPL(usb_asmedia_modifyflowcontrol);
494 void usb_amd_quirk_pll_enable(void)
496 usb_amd_quirk_pll(0);
498 EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_enable);
500 void usb_amd_dev_put(void)
502 struct pci_dev *nb, *smbus;
503 unsigned long flags;
505 spin_lock_irqsave(&amd_lock, flags);
507 amd_chipset.probe_count--;
508 if (amd_chipset.probe_count > 0) {
509 spin_unlock_irqrestore(&amd_lock, flags);
510 return;
513 /* save them to pci_dev_put outside of spinlock */
514 nb = amd_chipset.nb_dev;
515 smbus = amd_chipset.smbus_dev;
517 amd_chipset.nb_dev = NULL;
518 amd_chipset.smbus_dev = NULL;
519 amd_chipset.nb_type = 0;
520 memset(&amd_chipset.sb_type, 0, sizeof(amd_chipset.sb_type));
521 amd_chipset.isoc_reqs = 0;
522 amd_chipset.probe_result = 0;
524 spin_unlock_irqrestore(&amd_lock, flags);
526 pci_dev_put(nb);
527 pci_dev_put(smbus);
529 EXPORT_SYMBOL_GPL(usb_amd_dev_put);
532 * Check if port is disabled in BIOS on AMD Promontory host.
533 * BIOS Disabled ports may wake on connect/disconnect and need
534 * driver workaround to keep them disabled.
535 * Returns true if port is marked disabled.
537 bool usb_amd_pt_check_port(struct device *device, int port)
539 unsigned char value, port_shift;
540 struct pci_dev *pdev;
541 u16 reg;
543 pdev = to_pci_dev(device);
544 pci_write_config_word(pdev, PT_ADDR_INDX, PT_SIG_1_ADDR);
546 pci_read_config_byte(pdev, PT_READ_INDX, &value);
547 if (value != PT_SIG_1_DATA)
548 return false;
550 pci_write_config_word(pdev, PT_ADDR_INDX, PT_SIG_2_ADDR);
552 pci_read_config_byte(pdev, PT_READ_INDX, &value);
553 if (value != PT_SIG_2_DATA)
554 return false;
556 pci_write_config_word(pdev, PT_ADDR_INDX, PT_SIG_3_ADDR);
558 pci_read_config_byte(pdev, PT_READ_INDX, &value);
559 if (value != PT_SIG_3_DATA)
560 return false;
562 pci_write_config_word(pdev, PT_ADDR_INDX, PT_SIG_4_ADDR);
564 pci_read_config_byte(pdev, PT_READ_INDX, &value);
565 if (value != PT_SIG_4_DATA)
566 return false;
568 /* Check disabled port setting, if bit is set port is enabled */
569 switch (pdev->device) {
570 case 0x43b9:
571 case 0x43ba:
573 * device is AMD_PROMONTORYA_4(0x43b9) or PROMONTORYA_3(0x43ba)
574 * PT4_P1_REG bits[7..1] represents USB2.0 ports 6 to 0
575 * PT4_P2_REG bits[6..0] represents ports 13 to 7
577 if (port > 6) {
578 reg = PT4_P2_REG;
579 port_shift = port - 7;
580 } else {
581 reg = PT4_P1_REG;
582 port_shift = port + 1;
584 break;
585 case 0x43bb:
587 * device is AMD_PROMONTORYA_2(0x43bb)
588 * PT2_P1_REG bits[7..5] represents USB2.0 ports 2 to 0
589 * PT2_P2_REG bits[5..0] represents ports 9 to 3
591 if (port > 2) {
592 reg = PT2_P2_REG;
593 port_shift = port - 3;
594 } else {
595 reg = PT2_P1_REG;
596 port_shift = port + 5;
598 break;
599 case 0x43bc:
601 * device is AMD_PROMONTORYA_1(0x43bc)
602 * PT1_P1_REG[7..4] represents USB2.0 ports 3 to 0
603 * PT1_P2_REG[5..0] represents ports 9 to 4
605 if (port > 3) {
606 reg = PT1_P2_REG;
607 port_shift = port - 4;
608 } else {
609 reg = PT1_P1_REG;
610 port_shift = port + 4;
612 break;
613 default:
614 return false;
616 pci_write_config_word(pdev, PT_ADDR_INDX, reg);
617 pci_read_config_byte(pdev, PT_READ_INDX, &value);
619 return !(value & BIT(port_shift));
621 EXPORT_SYMBOL_GPL(usb_amd_pt_check_port);
624 * Make sure the controller is completely inactive, unable to
625 * generate interrupts or do DMA.
627 void uhci_reset_hc(struct pci_dev *pdev, unsigned long base)
629 /* Turn off PIRQ enable and SMI enable. (This also turns off the
630 * BIOS's USB Legacy Support.) Turn off all the R/WC bits too.
632 pci_write_config_word(pdev, UHCI_USBLEGSUP, UHCI_USBLEGSUP_RWC);
634 /* Reset the HC - this will force us to get a
635 * new notification of any already connected
636 * ports due to the virtual disconnect that it
637 * implies.
639 outw(UHCI_USBCMD_HCRESET, base + UHCI_USBCMD);
640 mb();
641 udelay(5);
642 if (inw(base + UHCI_USBCMD) & UHCI_USBCMD_HCRESET)
643 dev_warn(&pdev->dev, "HCRESET not completed yet!\n");
645 /* Just to be safe, disable interrupt requests and
646 * make sure the controller is stopped.
648 outw(0, base + UHCI_USBINTR);
649 outw(0, base + UHCI_USBCMD);
651 EXPORT_SYMBOL_GPL(uhci_reset_hc);
654 * Initialize a controller that was newly discovered or has just been
655 * resumed. In either case we can't be sure of its previous state.
657 * Returns: 1 if the controller was reset, 0 otherwise.
659 int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base)
661 u16 legsup;
662 unsigned int cmd, intr;
665 * When restarting a suspended controller, we expect all the
666 * settings to be the same as we left them:
668 * PIRQ and SMI disabled, no R/W bits set in USBLEGSUP;
669 * Controller is stopped and configured with EGSM set;
670 * No interrupts enabled except possibly Resume Detect.
672 * If any of these conditions are violated we do a complete reset.
674 pci_read_config_word(pdev, UHCI_USBLEGSUP, &legsup);
675 if (legsup & ~(UHCI_USBLEGSUP_RO | UHCI_USBLEGSUP_RWC)) {
676 dev_dbg(&pdev->dev, "%s: legsup = 0x%04x\n",
677 __func__, legsup);
678 goto reset_needed;
681 cmd = inw(base + UHCI_USBCMD);
682 if ((cmd & UHCI_USBCMD_RUN) || !(cmd & UHCI_USBCMD_CONFIGURE) ||
683 !(cmd & UHCI_USBCMD_EGSM)) {
684 dev_dbg(&pdev->dev, "%s: cmd = 0x%04x\n",
685 __func__, cmd);
686 goto reset_needed;
689 intr = inw(base + UHCI_USBINTR);
690 if (intr & (~UHCI_USBINTR_RESUME)) {
691 dev_dbg(&pdev->dev, "%s: intr = 0x%04x\n",
692 __func__, intr);
693 goto reset_needed;
695 return 0;
697 reset_needed:
698 dev_dbg(&pdev->dev, "Performing full reset\n");
699 uhci_reset_hc(pdev, base);
700 return 1;
702 EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc);
704 static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask)
706 u16 cmd;
707 return !pci_read_config_word(pdev, PCI_COMMAND, &cmd) && (cmd & mask);
710 #define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO)
711 #define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY)
713 static void quirk_usb_handoff_uhci(struct pci_dev *pdev)
715 unsigned long base = 0;
716 int i;
718 if (!pio_enabled(pdev))
719 return;
721 for (i = 0; i < PCI_ROM_RESOURCE; i++)
722 if ((pci_resource_flags(pdev, i) & IORESOURCE_IO)) {
723 base = pci_resource_start(pdev, i);
724 break;
727 if (base)
728 uhci_check_and_reset_hc(pdev, base);
731 static int mmio_resource_enabled(struct pci_dev *pdev, int idx)
733 return pci_resource_start(pdev, idx) && mmio_enabled(pdev);
736 static void quirk_usb_handoff_ohci(struct pci_dev *pdev)
738 void __iomem *base;
739 u32 control;
740 u32 fminterval = 0;
741 bool no_fminterval = false;
742 int cnt;
744 if (!mmio_resource_enabled(pdev, 0))
745 return;
747 base = pci_ioremap_bar(pdev, 0);
748 if (base == NULL)
749 return;
752 * ULi M5237 OHCI controller locks the whole system when accessing
753 * the OHCI_FMINTERVAL offset.
755 if (pdev->vendor == PCI_VENDOR_ID_AL && pdev->device == 0x5237)
756 no_fminterval = true;
758 control = readl(base + OHCI_CONTROL);
760 /* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
761 #ifdef __hppa__
762 #define OHCI_CTRL_MASK (OHCI_CTRL_RWC | OHCI_CTRL_IR)
763 #else
764 #define OHCI_CTRL_MASK OHCI_CTRL_RWC
766 if (control & OHCI_CTRL_IR) {
767 int wait_time = 500; /* arbitrary; 5 seconds */
768 writel(OHCI_INTR_OC, base + OHCI_INTRENABLE);
769 writel(OHCI_OCR, base + OHCI_CMDSTATUS);
770 while (wait_time > 0 &&
771 readl(base + OHCI_CONTROL) & OHCI_CTRL_IR) {
772 wait_time -= 10;
773 msleep(10);
775 if (wait_time <= 0)
776 dev_warn(&pdev->dev,
777 "OHCI: BIOS handoff failed (BIOS bug?) %08x\n",
778 readl(base + OHCI_CONTROL));
780 #endif
782 /* disable interrupts */
783 writel((u32) ~0, base + OHCI_INTRDISABLE);
785 /* Reset the USB bus, if the controller isn't already in RESET */
786 if (control & OHCI_HCFS) {
787 /* Go into RESET, preserving RWC (and possibly IR) */
788 writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL);
789 readl(base + OHCI_CONTROL);
791 /* drive bus reset for at least 50 ms (7.1.7.5) */
792 msleep(50);
795 /* software reset of the controller, preserving HcFmInterval */
796 if (!no_fminterval)
797 fminterval = readl(base + OHCI_FMINTERVAL);
799 writel(OHCI_HCR, base + OHCI_CMDSTATUS);
801 /* reset requires max 10 us delay */
802 for (cnt = 30; cnt > 0; --cnt) { /* ... allow extra time */
803 if ((readl(base + OHCI_CMDSTATUS) & OHCI_HCR) == 0)
804 break;
805 udelay(1);
808 if (!no_fminterval)
809 writel(fminterval, base + OHCI_FMINTERVAL);
811 /* Now the controller is safely in SUSPEND and nothing can wake it up */
812 iounmap(base);
815 static const struct dmi_system_id ehci_dmi_nohandoff_table[] = {
817 /* Pegatron Lucid (ExoPC) */
818 .matches = {
819 DMI_MATCH(DMI_BOARD_NAME, "EXOPG06411"),
820 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-CE-133"),
824 /* Pegatron Lucid (Ordissimo AIRIS) */
825 .matches = {
826 DMI_MATCH(DMI_BOARD_NAME, "M11JB"),
827 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-"),
831 /* Pegatron Lucid (Ordissimo) */
832 .matches = {
833 DMI_MATCH(DMI_BOARD_NAME, "Ordissimo"),
834 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-"),
838 /* HASEE E200 */
839 .matches = {
840 DMI_MATCH(DMI_BOARD_VENDOR, "HASEE"),
841 DMI_MATCH(DMI_BOARD_NAME, "E210"),
842 DMI_MATCH(DMI_BIOS_VERSION, "6.00"),
848 static void ehci_bios_handoff(struct pci_dev *pdev,
849 void __iomem *op_reg_base,
850 u32 cap, u8 offset)
852 int try_handoff = 1, tried_handoff = 0;
855 * The Pegatron Lucid tablet sporadically waits for 98 seconds trying
856 * the handoff on its unused controller. Skip it.
858 * The HASEE E200 hangs when the semaphore is set (bugzilla #77021).
860 if (pdev->vendor == 0x8086 && (pdev->device == 0x283a ||
861 pdev->device == 0x27cc)) {
862 if (dmi_check_system(ehci_dmi_nohandoff_table))
863 try_handoff = 0;
866 if (try_handoff && (cap & EHCI_USBLEGSUP_BIOS)) {
867 dev_dbg(&pdev->dev, "EHCI: BIOS handoff\n");
869 #if 0
870 /* aleksey_gorelov@phoenix.com reports that some systems need SMI forced on,
871 * but that seems dubious in general (the BIOS left it off intentionally)
872 * and is known to prevent some systems from booting. so we won't do this
873 * unless maybe we can determine when we're on a system that needs SMI forced.
875 /* BIOS workaround (?): be sure the pre-Linux code
876 * receives the SMI
878 pci_read_config_dword(pdev, offset + EHCI_USBLEGCTLSTS, &val);
879 pci_write_config_dword(pdev, offset + EHCI_USBLEGCTLSTS,
880 val | EHCI_USBLEGCTLSTS_SOOE);
881 #endif
883 /* some systems get upset if this semaphore is
884 * set for any other reason than forcing a BIOS
885 * handoff..
887 pci_write_config_byte(pdev, offset + 3, 1);
890 /* if boot firmware now owns EHCI, spin till it hands it over. */
891 if (try_handoff) {
892 int msec = 1000;
893 while ((cap & EHCI_USBLEGSUP_BIOS) && (msec > 0)) {
894 tried_handoff = 1;
895 msleep(10);
896 msec -= 10;
897 pci_read_config_dword(pdev, offset, &cap);
901 if (cap & EHCI_USBLEGSUP_BIOS) {
902 /* well, possibly buggy BIOS... try to shut it down,
903 * and hope nothing goes too wrong
905 if (try_handoff)
906 dev_warn(&pdev->dev,
907 "EHCI: BIOS handoff failed (BIOS bug?) %08x\n",
908 cap);
909 pci_write_config_byte(pdev, offset + 2, 0);
912 /* just in case, always disable EHCI SMIs */
913 pci_write_config_dword(pdev, offset + EHCI_USBLEGCTLSTS, 0);
915 /* If the BIOS ever owned the controller then we can't expect
916 * any power sessions to remain intact.
918 if (tried_handoff)
919 writel(0, op_reg_base + EHCI_CONFIGFLAG);
922 static void quirk_usb_disable_ehci(struct pci_dev *pdev)
924 void __iomem *base, *op_reg_base;
925 u32 hcc_params, cap, val;
926 u8 offset, cap_length;
927 int wait_time, count = 256/4;
929 if (!mmio_resource_enabled(pdev, 0))
930 return;
932 base = pci_ioremap_bar(pdev, 0);
933 if (base == NULL)
934 return;
936 cap_length = readb(base);
937 op_reg_base = base + cap_length;
939 /* EHCI 0.96 and later may have "extended capabilities"
940 * spec section 5.1 explains the bios handoff, e.g. for
941 * booting from USB disk or using a usb keyboard
943 hcc_params = readl(base + EHCI_HCC_PARAMS);
944 offset = (hcc_params >> 8) & 0xff;
945 while (offset && --count) {
946 pci_read_config_dword(pdev, offset, &cap);
948 switch (cap & 0xff) {
949 case 1:
950 ehci_bios_handoff(pdev, op_reg_base, cap, offset);
951 break;
952 case 0: /* Illegal reserved cap, set cap=0 so we exit */
953 cap = 0; /* then fallthrough... */
954 default:
955 dev_warn(&pdev->dev,
956 "EHCI: unrecognized capability %02x\n",
957 cap & 0xff);
959 offset = (cap >> 8) & 0xff;
961 if (!count)
962 dev_printk(KERN_DEBUG, &pdev->dev, "EHCI: capability loop?\n");
965 * halt EHCI & disable its interrupts in any case
967 val = readl(op_reg_base + EHCI_USBSTS);
968 if ((val & EHCI_USBSTS_HALTED) == 0) {
969 val = readl(op_reg_base + EHCI_USBCMD);
970 val &= ~EHCI_USBCMD_RUN;
971 writel(val, op_reg_base + EHCI_USBCMD);
973 wait_time = 2000;
974 do {
975 writel(0x3f, op_reg_base + EHCI_USBSTS);
976 udelay(100);
977 wait_time -= 100;
978 val = readl(op_reg_base + EHCI_USBSTS);
979 if ((val == ~(u32)0) || (val & EHCI_USBSTS_HALTED)) {
980 break;
982 } while (wait_time > 0);
984 writel(0, op_reg_base + EHCI_USBINTR);
985 writel(0x3f, op_reg_base + EHCI_USBSTS);
987 iounmap(base);
991 * handshake - spin reading a register until handshake completes
992 * @ptr: address of hc register to be read
993 * @mask: bits to look at in result of read
994 * @done: value of those bits when handshake succeeds
995 * @wait_usec: timeout in microseconds
996 * @delay_usec: delay in microseconds to wait between polling
998 * Polls a register every delay_usec microseconds.
999 * Returns 0 when the mask bits have the value done.
1000 * Returns -ETIMEDOUT if this condition is not true after
1001 * wait_usec microseconds have passed.
1003 static int handshake(void __iomem *ptr, u32 mask, u32 done,
1004 int wait_usec, int delay_usec)
1006 u32 result;
1008 do {
1009 result = readl(ptr);
1010 result &= mask;
1011 if (result == done)
1012 return 0;
1013 udelay(delay_usec);
1014 wait_usec -= delay_usec;
1015 } while (wait_usec > 0);
1016 return -ETIMEDOUT;
1020 * Intel's Panther Point chipset has two host controllers (EHCI and xHCI) that
1021 * share some number of ports. These ports can be switched between either
1022 * controller. Not all of the ports under the EHCI host controller may be
1023 * switchable.
1025 * The ports should be switched over to xHCI before PCI probes for any device
1026 * start. This avoids active devices under EHCI being disconnected during the
1027 * port switchover, which could cause loss of data on USB storage devices, or
1028 * failed boot when the root file system is on a USB mass storage device and is
1029 * enumerated under EHCI first.
1031 * We write into the xHC's PCI configuration space in some Intel-specific
1032 * registers to switch the ports over. The USB 3.0 terminations and the USB
1033 * 2.0 data wires are switched separately. We want to enable the SuperSpeed
1034 * terminations before switching the USB 2.0 wires over, so that USB 3.0
1035 * devices connect at SuperSpeed, rather than at USB 2.0 speeds.
1037 void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
1039 u32 ports_available;
1040 bool ehci_found = false;
1041 struct pci_dev *companion = NULL;
1043 /* Sony VAIO t-series with subsystem device ID 90a8 is not capable of
1044 * switching ports from EHCI to xHCI
1046 if (xhci_pdev->subsystem_vendor == PCI_VENDOR_ID_SONY &&
1047 xhci_pdev->subsystem_device == 0x90a8)
1048 return;
1050 /* make sure an intel EHCI controller exists */
1051 for_each_pci_dev(companion) {
1052 if (companion->class == PCI_CLASS_SERIAL_USB_EHCI &&
1053 companion->vendor == PCI_VENDOR_ID_INTEL) {
1054 ehci_found = true;
1055 break;
1059 if (!ehci_found)
1060 return;
1062 /* Don't switchover the ports if the user hasn't compiled the xHCI
1063 * driver. Otherwise they will see "dead" USB ports that don't power
1064 * the devices.
1066 if (!IS_ENABLED(CONFIG_USB_XHCI_HCD)) {
1067 dev_warn(&xhci_pdev->dev,
1068 "CONFIG_USB_XHCI_HCD is turned off, defaulting to EHCI.\n");
1069 dev_warn(&xhci_pdev->dev,
1070 "USB 3.0 devices will work at USB 2.0 speeds.\n");
1071 usb_disable_xhci_ports(xhci_pdev);
1072 return;
1075 /* Read USB3PRM, the USB 3.0 Port Routing Mask Register
1076 * Indicate the ports that can be changed from OS.
1078 pci_read_config_dword(xhci_pdev, USB_INTEL_USB3PRM,
1079 &ports_available);
1081 dev_dbg(&xhci_pdev->dev, "Configurable ports to enable SuperSpeed: 0x%x\n",
1082 ports_available);
1084 /* Write USB3_PSSEN, the USB 3.0 Port SuperSpeed Enable
1085 * Register, to turn on SuperSpeed terminations for the
1086 * switchable ports.
1088 pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN,
1089 ports_available);
1091 pci_read_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN,
1092 &ports_available);
1093 dev_dbg(&xhci_pdev->dev,
1094 "USB 3.0 ports that are now enabled under xHCI: 0x%x\n",
1095 ports_available);
1097 /* Read XUSB2PRM, xHCI USB 2.0 Port Routing Mask Register
1098 * Indicate the USB 2.0 ports to be controlled by the xHCI host.
1101 pci_read_config_dword(xhci_pdev, USB_INTEL_USB2PRM,
1102 &ports_available);
1104 dev_dbg(&xhci_pdev->dev, "Configurable USB 2.0 ports to hand over to xCHI: 0x%x\n",
1105 ports_available);
1107 /* Write XUSB2PR, the xHC USB 2.0 Port Routing Register, to
1108 * switch the USB 2.0 power and data lines over to the xHCI
1109 * host.
1111 pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR,
1112 ports_available);
1114 pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR,
1115 &ports_available);
1116 dev_dbg(&xhci_pdev->dev,
1117 "USB 2.0 ports that are now switched over to xHCI: 0x%x\n",
1118 ports_available);
1120 EXPORT_SYMBOL_GPL(usb_enable_intel_xhci_ports);
1122 void usb_disable_xhci_ports(struct pci_dev *xhci_pdev)
1124 pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, 0x0);
1125 pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, 0x0);
1127 EXPORT_SYMBOL_GPL(usb_disable_xhci_ports);
1130 * PCI Quirks for xHCI.
1132 * Takes care of the handoff between the Pre-OS (i.e. BIOS) and the OS.
1133 * It signals to the BIOS that the OS wants control of the host controller,
1134 * and then waits 1 second for the BIOS to hand over control.
1135 * If we timeout, assume the BIOS is broken and take control anyway.
1137 static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
1139 void __iomem *base;
1140 int ext_cap_offset;
1141 void __iomem *op_reg_base;
1142 u32 val;
1143 int timeout;
1144 int len = pci_resource_len(pdev, 0);
1146 if (!mmio_resource_enabled(pdev, 0))
1147 return;
1149 base = ioremap_nocache(pci_resource_start(pdev, 0), len);
1150 if (base == NULL)
1151 return;
1154 * Find the Legacy Support Capability register -
1155 * this is optional for xHCI host controllers.
1157 ext_cap_offset = xhci_find_next_ext_cap(base, 0, XHCI_EXT_CAPS_LEGACY);
1159 if (!ext_cap_offset)
1160 goto hc_init;
1162 if ((ext_cap_offset + sizeof(val)) > len) {
1163 /* We're reading garbage from the controller */
1164 dev_warn(&pdev->dev, "xHCI controller failing to respond");
1165 goto iounmap;
1167 val = readl(base + ext_cap_offset);
1169 /* Auto handoff never worked for these devices. Force it and continue */
1170 if ((pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241) ||
1171 (pdev->vendor == PCI_VENDOR_ID_RENESAS
1172 && pdev->device == 0x0014)) {
1173 val = (val | XHCI_HC_OS_OWNED) & ~XHCI_HC_BIOS_OWNED;
1174 writel(val, base + ext_cap_offset);
1177 /* If the BIOS owns the HC, signal that the OS wants it, and wait */
1178 if (val & XHCI_HC_BIOS_OWNED) {
1179 writel(val | XHCI_HC_OS_OWNED, base + ext_cap_offset);
1181 /* Wait for 1 second with 10 microsecond polling interval */
1182 timeout = handshake(base + ext_cap_offset, XHCI_HC_BIOS_OWNED,
1183 0, 1000000, 10);
1185 /* Assume a buggy BIOS and take HC ownership anyway */
1186 if (timeout) {
1187 dev_warn(&pdev->dev,
1188 "xHCI BIOS handoff failed (BIOS bug ?) %08x\n",
1189 val);
1190 writel(val & ~XHCI_HC_BIOS_OWNED, base + ext_cap_offset);
1194 val = readl(base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET);
1195 /* Mask off (turn off) any enabled SMIs */
1196 val &= XHCI_LEGACY_DISABLE_SMI;
1197 /* Mask all SMI events bits, RW1C */
1198 val |= XHCI_LEGACY_SMI_EVENTS;
1199 /* Disable any BIOS SMIs and clear all SMI events*/
1200 writel(val, base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET);
1202 hc_init:
1203 if (pdev->vendor == PCI_VENDOR_ID_INTEL)
1204 usb_enable_intel_xhci_ports(pdev);
1206 op_reg_base = base + XHCI_HC_LENGTH(readl(base));
1208 /* Wait for the host controller to be ready before writing any
1209 * operational or runtime registers. Wait 5 seconds and no more.
1211 timeout = handshake(op_reg_base + XHCI_STS_OFFSET, XHCI_STS_CNR, 0,
1212 5000000, 10);
1213 /* Assume a buggy HC and start HC initialization anyway */
1214 if (timeout) {
1215 val = readl(op_reg_base + XHCI_STS_OFFSET);
1216 dev_warn(&pdev->dev,
1217 "xHCI HW not ready after 5 sec (HC bug?) status = 0x%x\n",
1218 val);
1221 /* Send the halt and disable interrupts command */
1222 val = readl(op_reg_base + XHCI_CMD_OFFSET);
1223 val &= ~(XHCI_CMD_RUN | XHCI_IRQS);
1224 writel(val, op_reg_base + XHCI_CMD_OFFSET);
1226 /* Wait for the HC to halt - poll every 125 usec (one microframe). */
1227 timeout = handshake(op_reg_base + XHCI_STS_OFFSET, XHCI_STS_HALT, 1,
1228 XHCI_MAX_HALT_USEC, 125);
1229 if (timeout) {
1230 val = readl(op_reg_base + XHCI_STS_OFFSET);
1231 dev_warn(&pdev->dev,
1232 "xHCI HW did not halt within %d usec status = 0x%x\n",
1233 XHCI_MAX_HALT_USEC, val);
1236 iounmap:
1237 iounmap(base);
1240 static void quirk_usb_early_handoff(struct pci_dev *pdev)
1242 /* Skip Netlogic mips SoC's internal PCI USB controller.
1243 * This device does not need/support EHCI/OHCI handoff
1245 if (pdev->vendor == 0x184e) /* vendor Netlogic */
1246 return;
1247 if (pdev->class != PCI_CLASS_SERIAL_USB_UHCI &&
1248 pdev->class != PCI_CLASS_SERIAL_USB_OHCI &&
1249 pdev->class != PCI_CLASS_SERIAL_USB_EHCI &&
1250 pdev->class != PCI_CLASS_SERIAL_USB_XHCI)
1251 return;
1253 if (pci_enable_device(pdev) < 0) {
1254 dev_warn(&pdev->dev,
1255 "Can't enable PCI device, BIOS handoff failed.\n");
1256 return;
1258 if (pdev->class == PCI_CLASS_SERIAL_USB_UHCI)
1259 quirk_usb_handoff_uhci(pdev);
1260 else if (pdev->class == PCI_CLASS_SERIAL_USB_OHCI)
1261 quirk_usb_handoff_ohci(pdev);
1262 else if (pdev->class == PCI_CLASS_SERIAL_USB_EHCI)
1263 quirk_usb_disable_ehci(pdev);
1264 else if (pdev->class == PCI_CLASS_SERIAL_USB_XHCI)
1265 quirk_usb_handoff_xhci(pdev);
1266 pci_disable_device(pdev);
1268 DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
1269 PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff);
1271 bool usb_xhci_needs_pci_reset(struct pci_dev *pdev)
1274 * Our dear uPD72020{1,2} friend only partially resets when
1275 * asked to via the XHCI interface, and may end up doing DMA
1276 * at the wrong addresses, as it keeps the top 32bit of some
1277 * addresses from its previous programming under obscure
1278 * circumstances.
1279 * Give it a good wack at probe time. Unfortunately, this
1280 * needs to happen before we've had a chance to discover any
1281 * quirk, or the system will be in a rather bad state.
1283 if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
1284 (pdev->device == 0x0014 || pdev->device == 0x0015))
1285 return true;
1287 return false;
1289 EXPORT_SYMBOL_GPL(usb_xhci_needs_pci_reset);