hcd-pci.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  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 || !companion_hcd->self.root_hub)
  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. * Return: 0 if successful.
  151. */
  152. int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
  153. {
  154. struct hc_driver *driver;
  155. struct usb_hcd *hcd;
  156. int retval;
  157. int hcd_irq = 0;
  158. if (usb_disabled())
  159. return -ENODEV;
  160. if (!id)
  161. return -EINVAL;
  162. driver = (struct hc_driver *)id->driver_data;
  163. if (!driver)
  164. return -EINVAL;
  165. if (pci_enable_device(dev) < 0)
  166. return -ENODEV;
  167. dev->current_state = PCI_D0;
  168. /*
  169. * The xHCI driver has its own irq management
  170. * make sure irq setup is not touched for xhci in generic hcd code
  171. */
  172. if ((driver->flags & HCD_MASK) != HCD_USB3) {
  173. if (!dev->irq) {
  174. dev_err(&dev->dev,
  175. "Found HC with no IRQ. Check BIOS/PCI %s setup!\n",
  176. pci_name(dev));
  177. retval = -ENODEV;
  178. goto disable_pci;
  179. }
  180. hcd_irq = dev->irq;
  181. }
  182. hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev));
  183. if (!hcd) {
  184. retval = -ENOMEM;
  185. goto disable_pci;
  186. }
  187. hcd->amd_resume_bug = (usb_hcd_amd_remote_wakeup_quirk(dev) &&
  188. driver->flags & (HCD_USB11 | HCD_USB3)) ? 1 : 0;
  189. if (driver->flags & HCD_MEMORY) {
  190. /* EHCI, OHCI */
  191. hcd->rsrc_start = pci_resource_start(dev, 0);
  192. hcd->rsrc_len = pci_resource_len(dev, 0);
  193. if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
  194. driver->description)) {
  195. dev_dbg(&dev->dev, "controller already in use\n");
  196. retval = -EBUSY;
  197. goto put_hcd;
  198. }
  199. hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
  200. if (hcd->regs == NULL) {
  201. dev_dbg(&dev->dev, "error mapping memory\n");
  202. retval = -EFAULT;
  203. goto release_mem_region;
  204. }
  205. } else {
  206. /* UHCI */
  207. int region;
  208. for (region = 0; region < PCI_ROM_RESOURCE; region++) {
  209. if (!(pci_resource_flags(dev, region) &
  210. IORESOURCE_IO))
  211. continue;
  212. hcd->rsrc_start = pci_resource_start(dev, region);
  213. hcd->rsrc_len = pci_resource_len(dev, region);
  214. if (request_region(hcd->rsrc_start, hcd->rsrc_len,
  215. driver->description))
  216. break;
  217. }
  218. if (region == PCI_ROM_RESOURCE) {
  219. dev_dbg(&dev->dev, "no i/o regions available\n");
  220. retval = -EBUSY;
  221. goto put_hcd;
  222. }
  223. }
  224. pci_set_master(dev);
  225. /* Note: dev_set_drvdata must be called while holding the rwsem */
  226. if (dev->class == CL_EHCI) {
  227. down_write(&companions_rwsem);
  228. dev_set_drvdata(&dev->dev, hcd);
  229. for_each_companion(dev, hcd, ehci_pre_add);
  230. retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED);
  231. if (retval != 0)
  232. dev_set_drvdata(&dev->dev, NULL);
  233. for_each_companion(dev, hcd, ehci_post_add);
  234. up_write(&companions_rwsem);
  235. } else {
  236. down_read(&companions_rwsem);
  237. dev_set_drvdata(&dev->dev, hcd);
  238. retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED);
  239. if (retval != 0)
  240. dev_set_drvdata(&dev->dev, NULL);
  241. else
  242. for_each_companion(dev, hcd, non_ehci_add);
  243. up_read(&companions_rwsem);
  244. }
  245. if (retval != 0)
  246. goto unmap_registers;
  247. device_wakeup_enable(hcd->self.controller);
  248. if (pci_dev_run_wake(dev))
  249. pm_runtime_put_noidle(&dev->dev);
  250. return retval;
  251. unmap_registers:
  252. if (driver->flags & HCD_MEMORY) {
  253. iounmap(hcd->regs);
  254. release_mem_region:
  255. release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  256. } else
  257. release_region(hcd->rsrc_start, hcd->rsrc_len);
  258. put_hcd:
  259. usb_put_hcd(hcd);
  260. disable_pci:
  261. pci_disable_device(dev);
  262. dev_err(&dev->dev, "init %s fail, %d\n", pci_name(dev), retval);
  263. return retval;
  264. }
  265. EXPORT_SYMBOL_GPL(usb_hcd_pci_probe);
  266. /* may be called without controller electrically present */
  267. /* may be called with controller, bus, and devices active */
  268. /**
  269. * usb_hcd_pci_remove - shutdown processing for PCI-based HCDs
  270. * @dev: USB Host Controller being removed
  271. * Context: !in_interrupt()
  272. *
  273. * Reverses the effect of usb_hcd_pci_probe(), first invoking
  274. * the HCD's stop() method. It is always called from a thread
  275. * context, normally "rmmod", "apmd", or something similar.
  276. *
  277. * Store this function in the HCD's struct pci_driver as remove().
  278. */
  279. void usb_hcd_pci_remove(struct pci_dev *dev)
  280. {
  281. struct usb_hcd *hcd;
  282. hcd = pci_get_drvdata(dev);
  283. if (!hcd)
  284. return;
  285. if (pci_dev_run_wake(dev))
  286. pm_runtime_get_noresume(&dev->dev);
  287. /* Fake an interrupt request in order to give the driver a chance
  288. * to test whether the controller hardware has been removed (e.g.,
  289. * cardbus physical eject).
  290. */
  291. local_irq_disable();
  292. usb_hcd_irq(0, hcd);
  293. local_irq_enable();
  294. /* Note: dev_set_drvdata must be called while holding the rwsem */
  295. if (dev->class == CL_EHCI) {
  296. down_write(&companions_rwsem);
  297. for_each_companion(dev, hcd, ehci_remove);
  298. usb_remove_hcd(hcd);
  299. dev_set_drvdata(&dev->dev, NULL);
  300. up_write(&companions_rwsem);
  301. } else {
  302. /* Not EHCI; just clear the companion pointer */
  303. down_read(&companions_rwsem);
  304. hcd->self.hs_companion = NULL;
  305. usb_remove_hcd(hcd);
  306. dev_set_drvdata(&dev->dev, NULL);
  307. up_read(&companions_rwsem);
  308. }
  309. if (hcd->driver->flags & HCD_MEMORY) {
  310. iounmap(hcd->regs);
  311. release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  312. } else {
  313. release_region(hcd->rsrc_start, hcd->rsrc_len);
  314. }
  315. usb_put_hcd(hcd);
  316. pci_disable_device(dev);
  317. }
  318. EXPORT_SYMBOL_GPL(usb_hcd_pci_remove);
  319. /**
  320. * usb_hcd_pci_shutdown - shutdown host controller
  321. * @dev: USB Host Controller being shutdown
  322. */
  323. void usb_hcd_pci_shutdown(struct pci_dev *dev)
  324. {
  325. struct usb_hcd *hcd;
  326. hcd = pci_get_drvdata(dev);
  327. if (!hcd)
  328. return;
  329. if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) &&
  330. hcd->driver->shutdown) {
  331. hcd->driver->shutdown(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. #if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_RUNTIME)
  371. static int suspend_common(struct device *dev, bool do_wakeup)
  372. {
  373. struct pci_dev *pci_dev = to_pci_dev(dev);
  374. struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
  375. int retval;
  376. /* Root hub suspend should have stopped all downstream traffic,
  377. * and all bus master traffic. And done so for both the interface
  378. * and the stub usb_device (which we check here). But maybe it
  379. * didn't; writing sysfs power/state files ignores such rules...
  380. */
  381. retval = check_root_hub_suspended(dev);
  382. if (retval)
  383. return retval;
  384. if (hcd->driver->pci_suspend && !HCD_DEAD(hcd)) {
  385. /* Optimization: Don't suspend if a root-hub wakeup is
  386. * pending and it would cause the HCD to wake up anyway.
  387. */
  388. if (do_wakeup && HCD_WAKEUP_PENDING(hcd))
  389. return -EBUSY;
  390. if (do_wakeup && hcd->shared_hcd &&
  391. HCD_WAKEUP_PENDING(hcd->shared_hcd))
  392. return -EBUSY;
  393. retval = hcd->driver->pci_suspend(hcd, do_wakeup);
  394. suspend_report_result(hcd->driver->pci_suspend, retval);
  395. /* Check again in case wakeup raced with pci_suspend */
  396. if ((retval == 0 && do_wakeup && HCD_WAKEUP_PENDING(hcd)) ||
  397. (retval == 0 && do_wakeup && hcd->shared_hcd &&
  398. HCD_WAKEUP_PENDING(hcd->shared_hcd))) {
  399. if (hcd->driver->pci_resume)
  400. hcd->driver->pci_resume(hcd, false);
  401. retval = -EBUSY;
  402. }
  403. if (retval)
  404. return retval;
  405. }
  406. /* If MSI-X is enabled, the driver will have synchronized all vectors
  407. * in pci_suspend(). If MSI or legacy PCI is enabled, that will be
  408. * synchronized here.
  409. */
  410. if (!hcd->msix_enabled)
  411. synchronize_irq(pci_dev->irq);
  412. /* Downstream ports from this root hub should already be quiesced, so
  413. * there will be no DMA activity. Now we can shut down the upstream
  414. * link (except maybe for PME# resume signaling). We'll enter a
  415. * low power state during suspend_noirq, if the hardware allows.
  416. */
  417. pci_disable_device(pci_dev);
  418. return retval;
  419. }
  420. static int resume_common(struct device *dev, int event)
  421. {
  422. struct pci_dev *pci_dev = to_pci_dev(dev);
  423. struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
  424. int retval;
  425. if (HCD_RH_RUNNING(hcd) ||
  426. (hcd->shared_hcd &&
  427. HCD_RH_RUNNING(hcd->shared_hcd))) {
  428. dev_dbg(dev, "can't resume, not suspended!\n");
  429. return 0;
  430. }
  431. retval = pci_enable_device(pci_dev);
  432. if (retval < 0) {
  433. dev_err(dev, "can't re-enable after resume, %d!\n", retval);
  434. return retval;
  435. }
  436. pci_set_master(pci_dev);
  437. if (hcd->driver->pci_resume && !HCD_DEAD(hcd)) {
  438. /*
  439. * Only EHCI controllers have to wait for their companions.
  440. * No locking is needed because PCI controller drivers do not
  441. * get unbound during system resume.
  442. */
  443. if (pci_dev->class == CL_EHCI && event != PM_EVENT_AUTO_RESUME)
  444. for_each_companion(pci_dev, hcd,
  445. ehci_wait_for_companions);
  446. retval = hcd->driver->pci_resume(hcd,
  447. event == PM_EVENT_RESTORE);
  448. if (retval) {
  449. dev_err(dev, "PCI post-resume error %d!\n", retval);
  450. if (hcd->shared_hcd)
  451. usb_hc_died(hcd->shared_hcd);
  452. usb_hc_died(hcd);
  453. }
  454. }
  455. return retval;
  456. }
  457. #endif /* SLEEP || RUNTIME */
  458. #ifdef CONFIG_PM_SLEEP
  459. static int hcd_pci_suspend(struct device *dev)
  460. {
  461. return suspend_common(dev, device_may_wakeup(dev));
  462. }
  463. static int hcd_pci_suspend_noirq(struct device *dev)
  464. {
  465. struct pci_dev *pci_dev = to_pci_dev(dev);
  466. struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
  467. int retval;
  468. retval = check_root_hub_suspended(dev);
  469. if (retval)
  470. return retval;
  471. pci_save_state(pci_dev);
  472. /* If the root hub is dead rather than suspended, disallow remote
  473. * wakeup. usb_hc_died() should ensure that both hosts are marked as
  474. * dying, so we only need to check the primary roothub.
  475. */
  476. if (HCD_DEAD(hcd))
  477. device_set_wakeup_enable(dev, 0);
  478. dev_dbg(dev, "wakeup: %d\n", device_may_wakeup(dev));
  479. /* Possibly enable remote wakeup,
  480. * choose the appropriate low-power state, and go to that state.
  481. */
  482. retval = pci_prepare_to_sleep(pci_dev);
  483. if (retval == -EIO) { /* Low-power not supported */
  484. dev_dbg(dev, "--> PCI D0 legacy\n");
  485. retval = 0;
  486. } else if (retval == 0) {
  487. dev_dbg(dev, "--> PCI %s\n",
  488. pci_power_name(pci_dev->current_state));
  489. } else {
  490. suspend_report_result(pci_prepare_to_sleep, retval);
  491. return retval;
  492. }
  493. powermac_set_asic(pci_dev, 0);
  494. return retval;
  495. }
  496. static int hcd_pci_resume_noirq(struct device *dev)
  497. {
  498. struct pci_dev *pci_dev = to_pci_dev(dev);
  499. powermac_set_asic(pci_dev, 1);
  500. /* Go back to D0 and disable remote wakeup */
  501. pci_back_from_sleep(pci_dev);
  502. return 0;
  503. }
  504. static int hcd_pci_resume(struct device *dev)
  505. {
  506. return resume_common(dev, PM_EVENT_RESUME);
  507. }
  508. static int hcd_pci_restore(struct device *dev)
  509. {
  510. return resume_common(dev, PM_EVENT_RESTORE);
  511. }
  512. #else
  513. #define hcd_pci_suspend NULL
  514. #define hcd_pci_suspend_noirq NULL
  515. #define hcd_pci_resume_noirq NULL
  516. #define hcd_pci_resume NULL
  517. #define hcd_pci_restore NULL
  518. #endif /* CONFIG_PM_SLEEP */
  519. #ifdef CONFIG_PM_RUNTIME
  520. static int hcd_pci_runtime_suspend(struct device *dev)
  521. {
  522. int retval;
  523. retval = suspend_common(dev, true);
  524. if (retval == 0)
  525. powermac_set_asic(to_pci_dev(dev), 0);
  526. dev_dbg(dev, "hcd_pci_runtime_suspend: %d\n", retval);
  527. return retval;
  528. }
  529. static int hcd_pci_runtime_resume(struct device *dev)
  530. {
  531. int retval;
  532. powermac_set_asic(to_pci_dev(dev), 1);
  533. retval = resume_common(dev, PM_EVENT_AUTO_RESUME);
  534. dev_dbg(dev, "hcd_pci_runtime_resume: %d\n", retval);
  535. return retval;
  536. }
  537. #else
  538. #define hcd_pci_runtime_suspend NULL
  539. #define hcd_pci_runtime_resume NULL
  540. #endif /* CONFIG_PM_RUNTIME */
  541. const struct dev_pm_ops usb_hcd_pci_pm_ops = {
  542. .suspend = hcd_pci_suspend,
  543. .suspend_noirq = hcd_pci_suspend_noirq,
  544. .resume_noirq = hcd_pci_resume_noirq,
  545. .resume = hcd_pci_resume,
  546. .freeze = check_root_hub_suspended,
  547. .freeze_noirq = check_root_hub_suspended,
  548. .thaw_noirq = NULL,
  549. .thaw = NULL,
  550. .poweroff = hcd_pci_suspend,
  551. .poweroff_noirq = hcd_pci_suspend_noirq,
  552. .restore_noirq = hcd_pci_resume_noirq,
  553. .restore = hcd_pci_restore,
  554. .runtime_suspend = hcd_pci_runtime_suspend,
  555. .runtime_resume = hcd_pci_runtime_resume,
  556. };
  557. EXPORT_SYMBOL_GPL(usb_hcd_pci_pm_ops);
  558. #endif /* CONFIG_PM */