Lines Matching +full:generic +full:- +full:xhci
1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright David Brownell 2000-2002
24 /* PCI-based HCs are common, but plenty of non-PCI HCs are used too */
39 return pdev->class == CL_OHCI || pdev->class == CL_UHCI; in is_ohci_or_uhci()
51 unsigned int slot = PCI_SLOT(pdev->devfn); in for_each_companion()
60 if (companion->bus != pdev->bus || in for_each_companion()
61 PCI_SLOT(companion->devfn) != slot) in for_each_companion()
68 if (companion->class != CL_UHCI && companion->class != CL_OHCI && in for_each_companion()
69 companion->class != CL_EHCI) in for_each_companion()
73 if (!companion_hcd || !companion_hcd->self.root_hub) in for_each_companion()
91 udev = companion_hcd->self.root_hub; in ehci_pre_add()
108 if (dev_get_drvdata(&pdev->dev)) { /* Succeeded */ in ehci_post_add()
109 dev_dbg(&pdev->dev, "HS companion for %s\n", in ehci_post_add()
110 dev_name(&companion->dev)); in ehci_post_add()
111 companion_hcd->self.hs_companion = &hcd->self; in ehci_post_add()
113 udev = companion_hcd->self.root_hub; in ehci_post_add()
120 * We just added a non-EHCI controller. Find the EHCI controller to
126 if (is_ohci_or_uhci(pdev) && companion->class == CL_EHCI) { in non_ehci_add()
127 dev_dbg(&pdev->dev, "FS/LS companion for %s\n", in non_ehci_add()
128 dev_name(&companion->dev)); in non_ehci_add()
129 hcd->self.hs_companion = &companion_hcd->self; in non_ehci_add()
138 companion_hcd->self.hs_companion = NULL; in ehci_remove()
148 device_pm_wait_for_dev(&pdev->dev, &companion->dev); in ehci_wait_for_companions()
153 /*-------------------------------------------------------------------------*/
159 * usb_hcd_pci_probe - initialize PCI-based HCDs
182 return -ENODEV; in usb_hcd_pci_probe()
185 return -EINVAL; in usb_hcd_pci_probe()
188 return -EINVAL; in usb_hcd_pci_probe()
191 return -ENODEV; in usb_hcd_pci_probe()
194 * The xHCI driver has its own irq management in usb_hcd_pci_probe()
195 * make sure irq setup is not touched for xhci in generic hcd code in usb_hcd_pci_probe()
197 if ((driver->flags & HCD_MASK) < HCD_USB3) { in usb_hcd_pci_probe()
200 dev_err(&dev->dev, in usb_hcd_pci_probe()
203 retval = -ENODEV; in usb_hcd_pci_probe()
209 hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev)); in usb_hcd_pci_probe()
211 retval = -ENOMEM; in usb_hcd_pci_probe()
215 hcd->amd_resume_bug = (usb_hcd_amd_remote_wakeup_quirk(dev) && in usb_hcd_pci_probe()
216 driver->flags & (HCD_USB11 | HCD_USB3)) ? 1 : 0; in usb_hcd_pci_probe()
218 if (driver->flags & HCD_MEMORY) { in usb_hcd_pci_probe()
220 hcd->rsrc_start = pci_resource_start(dev, 0); in usb_hcd_pci_probe()
221 hcd->rsrc_len = pci_resource_len(dev, 0); in usb_hcd_pci_probe()
222 if (!devm_request_mem_region(&dev->dev, hcd->rsrc_start, in usb_hcd_pci_probe()
223 hcd->rsrc_len, driver->description)) { in usb_hcd_pci_probe()
224 dev_dbg(&dev->dev, "controller already in use\n"); in usb_hcd_pci_probe()
225 retval = -EBUSY; in usb_hcd_pci_probe()
228 hcd->regs = devm_ioremap(&dev->dev, hcd->rsrc_start, in usb_hcd_pci_probe()
229 hcd->rsrc_len); in usb_hcd_pci_probe()
230 if (hcd->regs == NULL) { in usb_hcd_pci_probe()
231 dev_dbg(&dev->dev, "error mapping memory\n"); in usb_hcd_pci_probe()
232 retval = -EFAULT; in usb_hcd_pci_probe()
245 hcd->rsrc_start = pci_resource_start(dev, region); in usb_hcd_pci_probe()
246 hcd->rsrc_len = pci_resource_len(dev, region); in usb_hcd_pci_probe()
247 if (devm_request_region(&dev->dev, hcd->rsrc_start, in usb_hcd_pci_probe()
248 hcd->rsrc_len, driver->description)) in usb_hcd_pci_probe()
252 dev_dbg(&dev->dev, "no i/o regions available\n"); in usb_hcd_pci_probe()
253 retval = -EBUSY; in usb_hcd_pci_probe()
261 if (dev->class == CL_EHCI) { in usb_hcd_pci_probe()
263 dev_set_drvdata(&dev->dev, hcd); in usb_hcd_pci_probe()
267 dev_set_drvdata(&dev->dev, NULL); in usb_hcd_pci_probe()
272 dev_set_drvdata(&dev->dev, hcd); in usb_hcd_pci_probe()
275 dev_set_drvdata(&dev->dev, NULL); in usb_hcd_pci_probe()
283 device_wakeup_enable(hcd->self.controller); in usb_hcd_pci_probe()
286 pm_runtime_put_noidle(&dev->dev); in usb_hcd_pci_probe()
292 if ((driver->flags & HCD_MASK) < HCD_USB3) in usb_hcd_pci_probe()
296 dev_err(&dev->dev, "init %s fail, %d\n", pci_name(dev), retval); in usb_hcd_pci_probe()
306 * usb_hcd_pci_remove - shutdown processing for PCI-based HCDs
326 hcd_driver_flags = hcd->driver->flags; in usb_hcd_pci_remove()
329 pm_runtime_get_noresume(&dev->dev); in usb_hcd_pci_remove()
340 if (dev->class == CL_EHCI) { in usb_hcd_pci_remove()
344 dev_set_drvdata(&dev->dev, NULL); in usb_hcd_pci_remove()
349 hcd->self.hs_companion = NULL; in usb_hcd_pci_remove()
351 dev_set_drvdata(&dev->dev, NULL); in usb_hcd_pci_remove()
362 * usb_hcd_pci_shutdown - shutdown host controller
373 if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) && in usb_hcd_pci_shutdown()
374 hcd->driver->shutdown) { in usb_hcd_pci_shutdown()
375 hcd->driver->shutdown(hcd); in usb_hcd_pci_shutdown()
376 if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0) in usb_hcd_pci_shutdown()
377 free_irq(hcd->irq, hcd); in usb_hcd_pci_shutdown()
412 return -EBUSY; in check_root_hub_suspended()
414 if (hcd->shared_hcd) { in check_root_hub_suspended()
415 hcd = hcd->shared_hcd; in check_root_hub_suspended()
418 return -EBUSY; in check_root_hub_suspended()
439 if (hcd->driver->pci_suspend && !HCD_DEAD(hcd)) { in suspend_common()
440 /* Optimization: Don't suspend if a root-hub wakeup is in suspend_common()
444 return -EBUSY; in suspend_common()
445 if (do_wakeup && hcd->shared_hcd && in suspend_common()
446 HCD_WAKEUP_PENDING(hcd->shared_hcd)) in suspend_common()
447 return -EBUSY; in suspend_common()
448 retval = hcd->driver->pci_suspend(hcd, do_wakeup); in suspend_common()
449 suspend_report_result(hcd->driver->pci_suspend, retval); in suspend_common()
453 (retval == 0 && do_wakeup && hcd->shared_hcd && in suspend_common()
454 HCD_WAKEUP_PENDING(hcd->shared_hcd))) { in suspend_common()
455 if (hcd->driver->pci_resume) in suspend_common()
456 hcd->driver->pci_resume(hcd, false); in suspend_common()
457 retval = -EBUSY; in suspend_common()
463 /* If MSI-X is enabled, the driver will have synchronized all vectors in suspend_common()
467 if (!hcd->msix_enabled) in suspend_common()
486 (hcd->shared_hcd && in resume_common()
487 HCD_RH_RUNNING(hcd->shared_hcd))) { in resume_common()
494 dev_err(dev, "can't re-enable after resume, %d!\n", retval); in resume_common()
500 if (hcd->driver->pci_resume && !HCD_DEAD(hcd)) { in resume_common()
507 if (pci_dev->class == CL_EHCI && event != PM_EVENT_AUTO_RESUME) in resume_common()
511 retval = hcd->driver->pci_resume(hcd, in resume_common()
514 dev_err(dev, "PCI post-resume error %d!\n", retval); in resume_common()
549 * choose the appropriate low-power state, and go to that state. in hcd_pci_suspend_noirq()
552 if (retval == -EIO) { /* Low-power not supported */ in hcd_pci_suspend_noirq()
553 dev_dbg(dev, "--> PCI D0 legacy\n"); in hcd_pci_suspend_noirq()
556 dev_dbg(dev, "--> PCI %s\n", in hcd_pci_suspend_noirq()
557 pci_power_name(pci_dev->current_state)); in hcd_pci_suspend_noirq()