hcd-pci.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /*
  2. * (C) Copyright David Brownell 2000-2002
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/module.h>
  20. #include <linux/pci.h>
  21. #include <linux/usb.h>
  22. #include <linux/usb/hcd.h>
  23. #include <asm/io.h>
  24. #include <asm/irq.h>
  25. #ifdef CONFIG_PPC_PMAC
  26. #include <asm/machdep.h>
  27. #include <asm/pmac_feature.h>
  28. #include <asm/pci-bridge.h>
  29. #include <asm/prom.h>
  30. #endif
  31. #include "usb.h"
  32. /* PCI-based HCs are common, but plenty of non-PCI HCs are used too */
  33. /*
  34. * Coordinate handoffs between EHCI and companion controllers
  35. * during EHCI probing and system resume.
  36. */
  37. static DECLARE_RWSEM(companions_rwsem);
  38. #define CL_UHCI PCI_CLASS_SERIAL_USB_UHCI
  39. #define CL_OHCI PCI_CLASS_SERIAL_USB_OHCI
  40. #define CL_EHCI PCI_CLASS_SERIAL_USB_EHCI
  41. static inline int is_ohci_or_uhci(struct pci_dev *pdev)
  42. {
  43. return pdev->class == CL_OHCI || pdev->class == CL_UHCI;
  44. }
  45. typedef void (*companion_fn)(struct pci_dev *pdev, struct usb_hcd *hcd,
  46. struct pci_dev *companion, struct usb_hcd *companion_hcd);
  47. /* Iterate over PCI devices in the same slot as pdev and call fn for each */
  48. static void for_each_companion(struct pci_dev *pdev, struct usb_hcd *hcd,
  49. companion_fn fn)
  50. {
  51. struct pci_dev *companion;
  52. struct usb_hcd *companion_hcd;
  53. unsigned int slot = PCI_SLOT(pdev->devfn);
  54. /*
  55. * Iterate through other PCI functions in the same slot.
  56. * If the function's drvdata isn't set then it isn't bound to
  57. * a USB host controller driver, so skip it.
  58. */
  59. companion = NULL;
  60. for_each_pci_dev(companion) {
  61. if (companion->bus != pdev->bus ||
  62. PCI_SLOT(companion->devfn) != slot)
  63. continue;
  64. companion_hcd = pci_get_drvdata(companion);
  65. if (!companion_hcd)
  66. continue;
  67. fn(pdev, hcd, companion, companion_hcd);
  68. }
  69. }
  70. /*
  71. * We're about to add an EHCI controller, which will unceremoniously grab
  72. * all the port connections away from its companions. To prevent annoying
  73. * error messages, lock the companion's root hub and gracefully unconfigure
  74. * it beforehand. Leave it locked until the EHCI controller is all set.
  75. */
  76. static void ehci_pre_add(struct pci_dev *pdev, struct usb_hcd *hcd,
  77. struct pci_dev *companion, struct usb_hcd *companion_hcd)
  78. {
  79. struct usb_device *udev;
  80. if (is_ohci_or_uhci(companion)) {
  81. udev = companion_hcd->self.root_hub;
  82. usb_lock_device(udev);
  83. usb_set_configuration(udev, 0);
  84. }
  85. }
  86. /*
  87. * Adding the EHCI controller has either succeeded or failed. Set the
  88. * companion pointer accordingly, and in either case, reconfigure and
  89. * unlock the root hub.
  90. */
  91. static void ehci_post_add(struct pci_dev *pdev, struct usb_hcd *hcd,
  92. struct pci_dev *companion, struct usb_hcd *companion_hcd)
  93. {
  94. struct usb_device *udev;
  95. if (is_ohci_or_uhci(companion)) {
  96. if (dev_get_drvdata(&pdev->dev)) { /* Succeeded */
  97. dev_dbg(&pdev->dev, "HS companion for %s\n",
  98. dev_name(&companion->dev));
  99. companion_hcd->self.hs_companion = &hcd->self;
  100. }
  101. udev = companion_hcd->self.root_hub;
  102. usb_set_configuration(udev, 1);
  103. usb_unlock_device(udev);
  104. }
  105. }
  106. /*
  107. * We just added a non-EHCI controller. Find the EHCI controller to
  108. * which it is a companion, and store a pointer to the bus structure.
  109. */
  110. static void non_ehci_add(struct pci_dev *pdev, struct usb_hcd *hcd,
  111. struct pci_dev *companion, struct usb_hcd *companion_hcd)
  112. {
  113. if (is_ohci_or_uhci(pdev) && companion->class == CL_EHCI) {
  114. dev_dbg(&pdev->dev, "FS/LS companion for %s\n",
  115. dev_name(&companion->dev));
  116. hcd->self.hs_companion = &companion_hcd->self;
  117. }
  118. }
  119. /* We are removing an EHCI controller. Clear the companions' pointers. */
  120. static void ehci_remove(struct pci_dev *pdev, struct usb_hcd *hcd,
  121. struct pci_dev *companion, struct usb_hcd *companion_hcd)
  122. {
  123. if (is_ohci_or_uhci(companion))
  124. companion_hcd->self.hs_companion = NULL;
  125. }
  126. #ifdef CONFIG_PM
  127. /* An EHCI controller must wait for its companions before resuming. */
  128. static void ehci_wait_for_companions(struct pci_dev *pdev, struct usb_hcd *hcd,
  129. struct pci_dev *companion, struct usb_hcd *companion_hcd)
  130. {
  131. if (is_ohci_or_uhci(companion))
  132. device_pm_wait_for_dev(&pdev->dev, &companion->dev);
  133. }
  134. #endif /* CONFIG_PM */
  135. /*-------------------------------------------------------------------------*/
  136. /* configure so an HC device and id are always provided */
  137. /* always called with process context; sleeping is OK */
  138. /**
  139. * usb_hcd_pci_probe - initialize PCI-based HCDs
  140. * @dev: USB Host Controller being probed
  141. * @id: pci hotplug id connecting controller to HCD framework
  142. * Context: !in_interrupt()
  143. *
  144. * Allocates basic PCI resources for this USB host controller, and
  145. * then invokes the start() method for the HCD associated with it
  146. * through the hotplug entry's driver_data.
  147. *
  148. * Store this function in the HCD's struct pci_driver as probe().
  149. */
  150. int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
  151. {
  152. struct hc_driver *driver;
  153. struct usb_hcd *hcd;
  154. int retval;
  155. int hcd_irq = 0;
  156. if (usb_disabled())
  157. return -ENODEV;
  158. if (!id)
  159. return -EINVAL;
  160. driver = (struct hc_driver *)id->driver_data;
  161. if (!driver)
  162. return -EINVAL;
  163. if (pci_enable_device(dev) < 0)
  164. return -ENODEV;
  165. dev->current_state = PCI_D0;
  166. /*
  167. * The xHCI driver has its own irq management
  168. * make sure irq setup is not touched for xhci in generic hcd code
  169. */
  170. if ((driver->flags & HCD_MASK) != HCD_USB3) {
  171. if (!dev->irq) {
  172. dev_err(&dev->dev,
  173. "Found HC with no IRQ. Check BIOS/PCI %s setup!\n",
  174. pci_name(dev));
  175. retval = -ENODEV;
  176. goto disable_pci;
  177. }
  178. hcd_irq = dev->irq;
  179. }
  180. hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev));
  181. if (!hcd) {
  182. retval = -ENOMEM;
  183. goto disable_pci;
  184. }
  185. if (driver->flags & HCD_MEMORY) {
  186. /* EHCI, OHCI */
  187. hcd->rsrc_start = pci_resource_start(dev, 0);
  188. hcd->rsrc_len = pci_resource_len(dev, 0);
  189. if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
  190. driver->description)) {
  191. dev_dbg(&dev->dev, "controller already in use\n");
  192. retval = -EBUSY;
  193. goto put_hcd;
  194. }
  195. hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
  196. if (hcd->regs == NULL) {
  197. dev_dbg(&dev->dev, "error mapping memory\n");
  198. retval = -EFAULT;
  199. goto release_mem_region;
  200. }
  201. } else {
  202. /* UHCI */
  203. int region;
  204. for (region = 0; region < PCI_ROM_RESOURCE; region++) {
  205. if (!(pci_resource_flags(dev, region) &
  206. IORESOURCE_IO))
  207. continue;
  208. hcd->rsrc_start = pci_resource_start(dev, region);
  209. hcd->rsrc_len = pci_resource_len(dev, region);
  210. if (request_region(hcd->rsrc_start, hcd->rsrc_len,
  211. driver->description))
  212. break;
  213. }
  214. if (region == PCI_ROM_RESOURCE) {
  215. dev_dbg(&dev->dev, "no i/o regions available\n");
  216. retval = -EBUSY;
  217. goto put_hcd;
  218. }
  219. }
  220. pci_set_master(dev);
  221. /* Note: dev_set_drvdata must be called while holding the rwsem */
  222. if (dev->class == CL_EHCI) {
  223. down_write(&companions_rwsem);
  224. dev_set_drvdata(&dev->dev, hcd);
  225. for_each_companion(dev, hcd, ehci_pre_add);
  226. retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED);
  227. if (retval != 0)
  228. dev_set_drvdata(&dev->dev, NULL);
  229. for_each_companion(dev, hcd, ehci_post_add);
  230. up_write(&companions_rwsem);
  231. } else {
  232. down_read(&companions_rwsem);
  233. dev_set_drvdata(&dev->dev, hcd);
  234. retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED);
  235. if (retval != 0)
  236. dev_set_drvdata(&dev->dev, NULL);
  237. else
  238. for_each_companion(dev, hcd, non_ehci_add);
  239. up_read(&companions_rwsem);
  240. }
  241. if (retval != 0)
  242. goto unmap_registers;
  243. if (pci_dev_run_wake(dev))
  244. pm_runtime_put_noidle(&dev->dev);
  245. return retval;
  246. unmap_registers:
  247. if (driver->flags & HCD_MEMORY) {
  248. iounmap(hcd->regs);
  249. release_mem_region:
  250. release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  251. } else
  252. release_region(hcd->rsrc_start, hcd->rsrc_len);
  253. put_hcd:
  254. usb_put_hcd(hcd);
  255. disable_pci:
  256. pci_disable_device(dev);
  257. dev_err(&dev->dev, "init %s fail, %d\n", pci_name(dev), retval);
  258. return retval;
  259. }
  260. EXPORT_SYMBOL_GPL(usb_hcd_pci_probe);
  261. /* may be called without controller electrically present */
  262. /* may be called with controller, bus, and devices active */
  263. /**
  264. * usb_hcd_pci_remove - shutdown processing for PCI-based HCDs
  265. * @dev: USB Host Controller being removed
  266. * Context: !in_interrupt()
  267. *
  268. * Reverses the effect of usb_hcd_pci_probe(), first invoking
  269. * the HCD's stop() method. It is always called from a thread
  270. * context, normally "rmmod", "apmd", or something similar.
  271. *
  272. * Store this function in the HCD's struct pci_driver as remove().
  273. */
  274. void usb_hcd_pci_remove(struct pci_dev *dev)
  275. {
  276. struct usb_hcd *hcd;
  277. hcd = pci_get_drvdata(dev);
  278. if (!hcd)
  279. return;
  280. if (pci_dev_run_wake(dev))
  281. pm_runtime_get_noresume(&dev->dev);
  282. /* Fake an interrupt request in order to give the driver a chance
  283. * to test whether the controller hardware has been removed (e.g.,
  284. * cardbus physical eject).
  285. */
  286. local_irq_disable();
  287. usb_hcd_irq(0, hcd);
  288. local_irq_enable();
  289. /* Note: dev_set_drvdata must be called while holding the rwsem */
  290. if (dev->class == CL_EHCI) {
  291. down_write(&companions_rwsem);
  292. for_each_companion(dev, hcd, ehci_remove);
  293. usb_remove_hcd(hcd);
  294. dev_set_drvdata(&dev->dev, NULL);
  295. up_write(&companions_rwsem);
  296. } else {
  297. /* Not EHCI; just clear the companion pointer */
  298. down_read(&companions_rwsem);
  299. hcd->self.hs_companion = NULL;
  300. usb_remove_hcd(hcd);
  301. dev_set_drvdata(&dev->dev, NULL);
  302. up_read(&companions_rwsem);
  303. }
  304. if (hcd->driver->flags & HCD_MEMORY) {
  305. iounmap(hcd->regs);
  306. release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  307. } else {
  308. release_region(hcd->rsrc_start, hcd->rsrc_len);
  309. }
  310. usb_put_hcd(hcd);
  311. pci_disable_device(dev);
  312. }
  313. EXPORT_SYMBOL_GPL(usb_hcd_pci_remove);
  314. /**
  315. * usb_hcd_pci_shutdown - shutdown host controller
  316. * @dev: USB Host Controller being shutdown
  317. */
  318. void usb_hcd_pci_shutdown(struct pci_dev *dev)
  319. {
  320. struct usb_hcd *hcd;
  321. hcd = pci_get_drvdata(dev);
  322. if (!hcd)
  323. return;
  324. if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) &&
  325. hcd->driver->shutdown) {
  326. hcd->driver->shutdown(hcd);
  327. pci_disable_device(dev);
  328. }
  329. }
  330. EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown);
  331. #ifdef CONFIG_PM
  332. #ifdef CONFIG_PPC_PMAC
  333. static void powermac_set_asic(struct pci_dev *pci_dev, int enable)
  334. {
  335. /* Enanble or disable ASIC clocks for USB */
  336. if (machine_is(powermac)) {
  337. struct device_node *of_node;
  338. of_node = pci_device_to_OF_node(pci_dev);
  339. if (of_node)
  340. pmac_call_feature(PMAC_FTR_USB_ENABLE,
  341. of_node, 0, enable);
  342. }
  343. }
  344. #else
  345. static inline void powermac_set_asic(struct pci_dev *pci_dev, int enable)
  346. {}
  347. #endif /* CONFIG_PPC_PMAC */
  348. static int check_root_hub_suspended(struct device *dev)
  349. {
  350. struct pci_dev *pci_dev = to_pci_dev(dev);
  351. struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
  352. if (HCD_RH_RUNNING(hcd)) {
  353. dev_warn(dev, "Root hub is not suspended\n");
  354. return -EBUSY;
  355. }
  356. if (hcd->shared_hcd) {
  357. hcd = hcd->shared_hcd;
  358. if (HCD_RH_RUNNING(hcd)) {
  359. dev_warn(dev, "Secondary root hub is not suspended\n");
  360. return -EBUSY;
  361. }
  362. }
  363. return 0;
  364. }
  365. #if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_RUNTIME)
  366. static int suspend_common(struct device *dev, bool do_wakeup)
  367. {
  368. struct pci_dev *pci_dev = to_pci_dev(dev);
  369. struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
  370. int retval;
  371. /* Root hub suspend should have stopped all downstream traffic,
  372. * and all bus master traffic. And done so for both the interface
  373. * and the stub usb_device (which we check here). But maybe it
  374. * didn't; writing sysfs power/state files ignores such rules...
  375. */
  376. retval = check_root_hub_suspended(dev);
  377. if (retval)
  378. return retval;
  379. if (hcd->driver->pci_suspend && !HCD_DEAD(hcd)) {
  380. /* Optimization: Don't suspend if a root-hub wakeup is
  381. * pending and it would cause the HCD to wake up anyway.
  382. */
  383. if (do_wakeup && HCD_WAKEUP_PENDING(hcd))
  384. return -EBUSY;
  385. if (do_wakeup && hcd->shared_hcd &&
  386. HCD_WAKEUP_PENDING(hcd->shared_hcd))
  387. return -EBUSY;
  388. retval = hcd->driver->pci_suspend(hcd, do_wakeup);
  389. suspend_report_result(hcd->driver->pci_suspend, retval);
  390. /* Check again in case wakeup raced with pci_suspend */
  391. if ((retval == 0 && do_wakeup && HCD_WAKEUP_PENDING(hcd)) ||
  392. (retval == 0 && do_wakeup && hcd->shared_hcd &&
  393. HCD_WAKEUP_PENDING(hcd->shared_hcd))) {
  394. if (hcd->driver->pci_resume)
  395. hcd->driver->pci_resume(hcd, false);
  396. retval = -EBUSY;
  397. }
  398. if (retval)
  399. return retval;
  400. }
  401. /* If MSI-X is enabled, the driver will have synchronized all vectors
  402. * in pci_suspend(). If MSI or legacy PCI is enabled, that will be
  403. * synchronized here.
  404. */
  405. if (!hcd->msix_enabled)
  406. synchronize_irq(pci_dev->irq);
  407. /* Downstream ports from this root hub should already be quiesced, so
  408. * there will be no DMA activity. Now we can shut down the upstream
  409. * link (except maybe for PME# resume signaling). We'll enter a
  410. * low power state during suspend_noirq, if the hardware allows.
  411. */
  412. pci_disable_device(pci_dev);
  413. return retval;
  414. }
  415. static int resume_common(struct device *dev, int event)
  416. {
  417. struct pci_dev *pci_dev = to_pci_dev(dev);
  418. struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
  419. int retval;
  420. if (HCD_RH_RUNNING(hcd) ||
  421. (hcd->shared_hcd &&
  422. HCD_RH_RUNNING(hcd->shared_hcd))) {
  423. dev_dbg(dev, "can't resume, not suspended!\n");
  424. return 0;
  425. }
  426. retval = pci_enable_device(pci_dev);
  427. if (retval < 0) {
  428. dev_err(dev, "can't re-enable after resume, %d!\n", retval);
  429. return retval;
  430. }
  431. pci_set_master(pci_dev);
  432. if (hcd->driver->pci_resume && !HCD_DEAD(hcd)) {
  433. /*
  434. * Only EHCI controllers have to wait for their companions.
  435. * No locking is needed because PCI controller drivers do not
  436. * get unbound during system resume.
  437. */
  438. if (pci_dev->class == CL_EHCI && event != PM_EVENT_AUTO_RESUME)
  439. for_each_companion(pci_dev, hcd,
  440. ehci_wait_for_companions);
  441. retval = hcd->driver->pci_resume(hcd,
  442. event == PM_EVENT_RESTORE);
  443. if (retval) {
  444. dev_err(dev, "PCI post-resume error %d!\n", retval);
  445. if (hcd->shared_hcd)
  446. usb_hc_died(hcd->shared_hcd);
  447. usb_hc_died(hcd);
  448. }
  449. }
  450. return retval;
  451. }
  452. #endif /* SLEEP || RUNTIME */
  453. #ifdef CONFIG_PM_SLEEP
  454. static int hcd_pci_suspend(struct device *dev)
  455. {
  456. return suspend_common(dev, device_may_wakeup(dev));
  457. }
  458. static int hcd_pci_suspend_noirq(struct device *dev)
  459. {
  460. struct pci_dev *pci_dev = to_pci_dev(dev);
  461. struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
  462. int retval;
  463. retval = check_root_hub_suspended(dev);
  464. if (retval)
  465. return retval;
  466. pci_save_state(pci_dev);
  467. /* If the root hub is dead rather than suspended, disallow remote
  468. * wakeup. usb_hc_died() should ensure that both hosts are marked as
  469. * dying, so we only need to check the primary roothub.
  470. */
  471. if (HCD_DEAD(hcd))
  472. device_set_wakeup_enable(dev, 0);
  473. dev_dbg(dev, "wakeup: %d\n", device_may_wakeup(dev));
  474. /* Possibly enable remote wakeup,
  475. * choose the appropriate low-power state, and go to that state.
  476. */
  477. retval = pci_prepare_to_sleep(pci_dev);
  478. if (retval == -EIO) { /* Low-power not supported */
  479. dev_dbg(dev, "--> PCI D0 legacy\n");
  480. retval = 0;
  481. } else if (retval == 0) {
  482. dev_dbg(dev, "--> PCI %s\n",
  483. pci_power_name(pci_dev->current_state));
  484. } else {
  485. suspend_report_result(pci_prepare_to_sleep, retval);
  486. return retval;
  487. }
  488. powermac_set_asic(pci_dev, 0);
  489. return retval;
  490. }
  491. static int hcd_pci_resume_noirq(struct device *dev)
  492. {
  493. struct pci_dev *pci_dev = to_pci_dev(dev);
  494. powermac_set_asic(pci_dev, 1);
  495. /* Go back to D0 and disable remote wakeup */
  496. pci_back_from_sleep(pci_dev);
  497. return 0;
  498. }
  499. static int hcd_pci_resume(struct device *dev)
  500. {
  501. return resume_common(dev, PM_EVENT_RESUME);
  502. }
  503. static int hcd_pci_restore(struct device *dev)
  504. {
  505. return resume_common(dev, PM_EVENT_RESTORE);
  506. }
  507. #else
  508. #define hcd_pci_suspend NULL
  509. #define hcd_pci_suspend_noirq NULL
  510. #define hcd_pci_resume_noirq NULL
  511. #define hcd_pci_resume NULL
  512. #define hcd_pci_restore NULL
  513. #endif /* CONFIG_PM_SLEEP */
  514. #ifdef CONFIG_PM_RUNTIME
  515. static int hcd_pci_runtime_suspend(struct device *dev)
  516. {
  517. int retval;
  518. retval = suspend_common(dev, true);
  519. if (retval == 0)
  520. powermac_set_asic(to_pci_dev(dev), 0);
  521. dev_dbg(dev, "hcd_pci_runtime_suspend: %d\n", retval);
  522. return retval;
  523. }
  524. static int hcd_pci_runtime_resume(struct device *dev)
  525. {
  526. int retval;
  527. powermac_set_asic(to_pci_dev(dev), 1);
  528. retval = resume_common(dev, PM_EVENT_AUTO_RESUME);
  529. dev_dbg(dev, "hcd_pci_runtime_resume: %d\n", retval);
  530. return retval;
  531. }
  532. #else
  533. #define hcd_pci_runtime_suspend NULL
  534. #define hcd_pci_runtime_resume NULL
  535. #endif /* CONFIG_PM_RUNTIME */
  536. const struct dev_pm_ops usb_hcd_pci_pm_ops = {
  537. .suspend = hcd_pci_suspend,
  538. .suspend_noirq = hcd_pci_suspend_noirq,
  539. .resume_noirq = hcd_pci_resume_noirq,
  540. .resume = hcd_pci_resume,
  541. .freeze = check_root_hub_suspended,
  542. .freeze_noirq = check_root_hub_suspended,
  543. .thaw_noirq = NULL,
  544. .thaw = NULL,
  545. .poweroff = hcd_pci_suspend,
  546. .poweroff_noirq = hcd_pci_suspend_noirq,
  547. .restore_noirq = hcd_pci_resume_noirq,
  548. .restore = hcd_pci_restore,
  549. .runtime_suspend = hcd_pci_runtime_suspend,
  550. .runtime_resume = hcd_pci_runtime_resume,
  551. };
  552. EXPORT_SYMBOL_GPL(usb_hcd_pci_pm_ops);
  553. #endif /* CONFIG_PM */