hcd-pci.c 17 KB

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