static int rtsx_resume(struct pci_dev *pci) { struct rtsx_dev *dev = (struct rtsx_dev *)pci_get_drvdata(pci); struct rtsx_chip *chip; printk(KERN_INFO "Ready to resume\n"); if (!dev) { printk(KERN_ERR "Invalid memory\n"); return 0; } chip = dev->chip; /* lock the device pointers */ mutex_lock(&(dev->dev_mutex)); pci_set_power_state(pci, PCI_D0); pci_restore_state(pci); if (pci_enable_device(pci) < 0) { printk(KERN_ERR "%s: pci_enable_device failed, " "disabling device\n", CR_DRIVER_NAME); /* unlock the device pointers */ mutex_unlock(&dev->dev_mutex); return -EIO; } pci_set_master(pci); if (chip->msi_en) { if (pci_enable_msi(pci) < 0) chip->msi_en = 0; } if (rtsx_acquire_irq(dev) < 0) { /* unlock the device pointers */ mutex_unlock(&dev->dev_mutex); return -EIO; } rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, 0x00); rtsx_init_chip(chip); /* unlock the device pointers */ mutex_unlock(&dev->dev_mutex); return 0; }
int snd_cs5535audio_resume(struct pci_dev *pci) { struct snd_card *card = pci_get_drvdata(pci); struct cs5535audio *cs5535au = card->private_data; u32 tmp; int timeout; int i; pci_set_power_state(pci, PCI_D0); pci_restore_state(pci); if (pci_enable_device(pci) < 0) { printk(KERN_ERR "cs5535audio: pci_enable_device failed, " "disabling device\n"); snd_card_disconnect(card); return -EIO; } pci_set_master(pci); /* set LNK_WRM_RST to reset AC link */ cs_writel(cs5535au, ACC_CODEC_CNTL, ACC_CODEC_CNTL_LNK_WRM_RST); timeout = 50; do { tmp = cs_readl(cs5535au, ACC_CODEC_STATUS); if (tmp & PRM_RDY_STS) break; udelay(1); } while (--timeout); if (!timeout) snd_printk(KERN_ERR "Failure getting AC Link ready\n"); /* set up rate regs, dma. actual initiation is done in trig */ for (i = 0; i < NUM_CS5535AUDIO_DMAS; i++) { struct cs5535audio_dma *dma = &cs5535au->dmas[i]; if (dma && dma->substream) { dma->substream->ops->prepare(dma->substream); dma->ops->setup_prd(cs5535au, dma->saved_prd); } } /* we depend on ac97 to perform the codec power up */ snd_ac97_resume(cs5535au->ac97); snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; }
int rtl8192E_suspend(struct pci_dev *pdev, pm_message_t state) { struct net_device *dev = pci_get_drvdata(pdev); struct r8192_priv *priv = rtllib_priv(dev); u32 ulRegRead; netdev_info(dev, "============> r8192E suspend call.\n"); del_timer_sync(&priv->gpio_polling_timer); cancel_delayed_work(&priv->gpio_change_rf_wq); priv->polling_timer_on = 0; if (!netif_running(dev)) { netdev_info(dev, "RTL819XE:UI is open out of suspend function\n"); goto out_pci_suspend; } if (dev->netdev_ops->ndo_stop) dev->netdev_ops->ndo_stop(dev); netif_device_detach(dev); if (!priv->rtllib->bSupportRemoteWakeUp) { MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_INIT, true); ulRegRead = read_nic_dword(dev, CPU_GEN); ulRegRead |= CPU_GEN_SYSTEM_RESET; write_nic_dword(dev, CPU_GEN, ulRegRead); } else { write_nic_dword(dev, WFCRC0, 0xffffffff); write_nic_dword(dev, WFCRC1, 0xffffffff); write_nic_dword(dev, WFCRC2, 0xffffffff); write_nic_byte(dev, PMR, 0x5); write_nic_byte(dev, MacBlkCtrl, 0xa); } out_pci_suspend: netdev_info(dev, "WOL is %s\n", priv->rtllib->bSupportRemoteWakeUp ? "Supported" : "Not supported"); pci_save_state(pdev); pci_disable_device(pdev); pci_enable_wake(pdev, pci_choose_state(pdev, state), priv->rtllib->bSupportRemoteWakeUp ? 1 : 0); pci_set_power_state(pdev, pci_choose_state(pdev, state)); mdelay(20); return 0; }
static void xhci_pci_remove(struct pci_dev *dev) { struct xhci_hcd *xhci; xhci = hcd_to_xhci(pci_get_drvdata(dev)); xhci->xhc_state |= XHCI_STATE_REMOVING; if (xhci->shared_hcd) { usb_remove_hcd(xhci->shared_hcd); usb_put_hcd(xhci->shared_hcd); } /* Workaround for spurious wakeups at shutdown with HSW */ if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) pci_set_power_state(dev, PCI_D3hot); usb_hcd_pci_remove(dev); }
static int snd_vx222_resume(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_vx222 *vx = card->private_data; pci_set_power_state(pci, PCI_D0); pci_restore_state(pci); if (pci_enable_device(pci) < 0) { printk(KERN_ERR "vx222: pci_enable_device failed, " "disabling device\n"); snd_card_disconnect(card); return -EIO; } pci_set_master(pci); return snd_vx_resume(&vx->core); }
static void bbswitch_on(void) { if (!is_card_disabled()) return; printk(KERN_INFO "bbswitch: enabling discrete graphics\n"); if (bbswitch_acpi_on()) printk(KERN_WARNING "bbswitch: The discrete card could not be enabled" " by a _DSM call\n"); pci_set_power_state(dis_dev, PCI_D0); pci_restore_state(dis_dev); if (pci_enable_device(dis_dev)) printk(KERN_WARNING "bbswitch: failed to enable %s\n", dev_name(&dis_dev->dev)); pci_set_master(dis_dev); }
static int pch_phub_suspend(struct pci_dev *pdev, pm_message_t state) { int ret; pch_phub_save_reg_conf(pdev); ret = pci_save_state(pdev); if (ret) { dev_err(&pdev->dev, " %s -pci_save_state returns %d\n", __func__, ret); return ret; } pci_enable_wake(pdev, PCI_D3hot, 0); pci_disable_device(pdev); pci_set_power_state(pdev, pci_choose_state(pdev, state)); return 0; }
static int ahc_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg) { struct ahc_softc *ahc = pci_get_drvdata(pdev); int rc; if ((rc = ahc_suspend(ahc))) return rc; pci_save_state(pdev); pci_disable_device(pdev); if (mesg.event == PM_EVENT_SUSPEND) pci_set_power_state(pdev, PCI_D3hot); return rc; }
MHI_STATUS mhi_turn_on_pcie_link(mhi_device_ctxt *mhi_dev_ctxt) { int r = 0; struct pci_dev *pcie_dev; MHI_STATUS ret_val = MHI_STATUS_SUCCESS; pcie_dev = mhi_dev_ctxt->dev_info->pcie_device; mutex_lock(&mhi_dev_ctxt->mhi_link_state); mhi_log(MHI_MSG_INFO, "Entered...\n"); if (mhi_dev_ctxt->flags.link_up) goto exit; r = exynos_pcie_pm_resume(0); if (r) { mhi_log(MHI_MSG_CRITICAL | MHI_DBG_POWER, "Failed to resume PCIe RC driver ret %d\n", r); ret_val = MHI_STATUS_ERROR; goto exit; } atomic_dec(&mhi_dev_ctxt->flags.mhi_link_off); r = pci_set_power_state(mhi_dev_ctxt->dev_info->pcie_device, PCI_D0); if (r) { mhi_log(MHI_MSG_CRITICAL | MHI_DBG_POWER, "Failed to load stored state ret %d\n", r); ret_val = MHI_STATUS_ERROR; goto exit; } /* Restore pcie config space */ r = exynos_pcie_restore_config(mhi_dev_ctxt->dev_info->pcie_device); if (r) { mhi_log(MHI_MSG_CRITICAL | MHI_DBG_POWER, "Failed to save pcie config space: %x\n", r); ret_val = MHI_STATUS_ERROR; goto exit; } mhi_dev_ctxt->flags.link_up = 1; exit: mutex_unlock(&mhi_dev_ctxt->mhi_link_state); mhi_log(MHI_MSG_INFO, "Exited...\n"); return ret_val; }
/** * usb_hcd_pci_resume - power management resume of a PCI-based HCD * @dev: USB Host Controller being resumed * * Store this function in the HCD's struct pci_driver as resume(). */ int usb_hcd_pci_resume (struct pci_dev *dev) { struct usb_hcd *hcd; int retval; int has_pci_pm; hcd = pci_get_drvdata(dev); has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM); if (has_pci_pm) dev_dbg(hcd->self.controller, "resume from state D%d\n", dev->current_state); if (hcd->state != HCD_STATE_SUSPENDED) { dev_dbg (hcd->self.controller, "can't resume, not suspended!\n"); return -EL3HLT; } hcd->state = USB_STATE_RESUMING; if (has_pci_pm) pci_set_power_state (dev, 0); dev->dev.power.power_state = 0; retval = request_irq (dev->irq, usb_hcd_irq, SA_SHIRQ, hcd->description, hcd); if (retval < 0) { dev_err (hcd->self.controller, "can't restore IRQ after resume!\n"); return retval; } pci_set_master (dev); pci_restore_state (dev, hcd->pci_state); #ifdef CONFIG_USB_SUSPEND pci_enable_wake (dev, dev->current_state, 0); pci_enable_wake (dev, 4, 0); #endif retval = hcd->driver->resume (hcd); if (!HCD_IS_RUNNING (hcd->state)) { dev_dbg (hcd->self.controller, "resume fail, retval %d\n", retval); usb_hc_died (hcd); } return retval; }
static int pch_phub_resume(struct pci_dev *pdev) { int ret; pci_set_power_state(pdev, PCI_D0); pci_restore_state(pdev); ret = pci_enable_device(pdev); if (ret) { dev_err(&pdev->dev, "%s-pci_enable_device failed(ret=%d) ", __func__, ret); return ret; } pci_enable_wake(pdev, PCI_D3hot, 0); pch_phub_restore_reg_conf(pdev); return 0; }
/* * power management */ static int snd_atiixp_suspend(snd_card_t *card, unsigned int state) { atiixp_t *chip = card->pm_private_data; int i; for (i = 0; i < NUM_ATI_PCMDEVS; i++) if (chip->pcmdevs[i]) snd_pcm_suspend_all(chip->pcmdevs[i]); for (i = 0; i < NUM_ATI_CODECS; i++) if (chip->ac97[i]) snd_ac97_suspend(chip->ac97[i]); snd_atiixp_aclink_down(chip); snd_atiixp_chip_stop(chip); pci_set_power_state(chip->pci, 3); pci_disable_device(chip->pci); return 0; }
static int snd_atiixp_resume(snd_card_t *card, unsigned int state) { atiixp_t *chip = card->pm_private_data; int i; pci_enable_device(chip->pci); pci_set_power_state(chip->pci, 0); pci_set_master(chip->pci); snd_atiixp_aclink_reset(chip); snd_atiixp_chip_start(chip); for (i = 0; i < NUM_ATI_CODECS; i++) if (chip->ac97[i]) snd_ac97_resume(chip->ac97[i]); return 0; }
int rtl8180_suspend (struct pci_dev *pdev, pm_message_t state) { struct net_device *dev = pci_get_drvdata(pdev); // struct r8180_priv *priv = ieee80211_priv(dev); if (!netif_running(dev)) goto out_pci_suspend; dev->stop(dev); netif_device_detach(dev); out_pci_suspend: pci_save_state(pdev); pci_disable_device(pdev); pci_set_power_state(pdev,pci_choose_state(pdev,state)); return 0; }
static int tw68_suspend(struct pci_dev *pci_dev , pm_message_t state) { struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); struct tw68_dev *dev = container_of(v4l2_dev, struct tw68_dev, v4l2_dev); tw_clearl(TW68_DMAC, TW68_DMAP_EN | TW68_FIFO_EN); dev->pci_irqmask &= ~TW68_VID_INTS; tw_writel(TW68_INTMASK, 0); synchronize_irq(pci_dev->irq); pci_save_state(pci_dev); pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)); vb2_discard_done(&dev->vidq); return 0; }
int rtl8192E_resume(struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); struct r8192_priv *priv = rtllib_priv(dev); int err; u32 val; netdev_info(dev, "================>r8192E resume call.\n"); pci_set_power_state(pdev, PCI_D0); err = pci_enable_device(pdev); if (err) { netdev_err(dev, "pci_enable_device failed on resume\n"); return err; } pci_restore_state(pdev); pci_read_config_dword(pdev, 0x40, &val); if ((val & 0x0000ff00) != 0) pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); pci_enable_wake(pdev, PCI_D0, 0); if (priv->polling_timer_on == 0) check_rfctrl_gpio_timer((unsigned long)dev); if (!netif_running(dev)) { netdev_info(dev, "RTL819XE:UI is open out of resume function\n"); goto out; } netif_device_attach(dev); if (dev->netdev_ops->ndo_open) dev->netdev_ops->ndo_open(dev); if (!priv->rtllib->bSupportRemoteWakeUp) MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_INIT, true); out: RT_TRACE(COMP_POWER, "<================r8192E resume call.\n"); return 0; }
int rtl8192E_resume (struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); int err; u32 val; RT_TRACE(COMP_POWER, "================>r8192E resume call."); pci_set_power_state(pdev, PCI_D0); err = pci_enable_device(pdev); if(err) { printk(KERN_ERR "%s: pci_enable_device failed on resume\n", dev->name); return err; } pci_restore_state(pdev); pci_read_config_dword(pdev, 0x40, &val); if ((val & 0x0000ff00) != 0) { pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); } pci_enable_wake(pdev, PCI_D0, 0); if(!netif_running(dev)) goto out; netif_device_attach(dev); if (dev->netdev_ops->ndo_open) dev->netdev_ops->ndo_open(dev); out: RT_TRACE(COMP_POWER, "<================r8192E resume call.\n"); return 0; }
static int rtsx_resume(struct pci_dev *pci) { struct rtsx_dev *dev = pci_get_drvdata(pci); struct rtsx_chip *chip; if (!dev) return 0; chip = dev->chip; /* lock the device pointers */ mutex_lock(&dev->dev_mutex); pci_set_power_state(pci, PCI_D0); pci_restore_state(pci); if (pci_enable_device(pci) < 0) { dev_err(&dev->pci->dev, "%s: pci_enable_device failed, disabling device\n", CR_DRIVER_NAME); /* unlock the device pointers */ mutex_unlock(&dev->dev_mutex); return -EIO; } pci_set_master(pci); if (chip->msi_en) { if (pci_enable_msi(pci) < 0) chip->msi_en = 0; } if (rtsx_acquire_irq(dev) < 0) { /* unlock the device pointers */ mutex_unlock(&dev->dev_mutex); return -EIO; } rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, 0x00); rtsx_init_chip(chip); /* unlock the device pointers */ mutex_unlock(&dev->dev_mutex); return 0; }
static int delkin_cb_resume(struct pci_dev *dev) { struct ide_host *host = pci_get_drvdata(dev); int rc; pci_set_power_state(dev, PCI_D0); rc = pci_enable_device(dev); if (rc) return rc; pci_restore_state(dev); pci_set_master(dev); if (host->init_chipset) host->init_chipset(dev); return 0; }
static int brcmf_pcie_resume(struct pci_dev *pdev) { int err; brcmf_dbg(PCIE, "Enter, pdev=%p\n", pdev); err = pci_set_power_state(pdev, PCI_D0); if (err) { brcmf_err("pci_set_power_state failed, err=%d\n", err); return err; } pci_restore_state(pdev); err = brcmf_pcie_probe(pdev, NULL); if (err) brcmf_err("probe after resume failed, err=%d\n", err); return err; }
static void i915_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_state state) { struct drm_device *dev = pci_get_drvdata(pdev); pm_message_t pmm = { .event = PM_EVENT_SUSPEND }; if (state == VGA_SWITCHEROO_ON) { pr_info("switched on\n"); dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; /* i915 resume handler doesn't set to D0 */ pci_set_power_state(dev->pdev, PCI_D0); i915_resume_legacy(dev); dev->switch_power_state = DRM_SWITCH_POWER_ON; } else { pr_err("switched off\n"); dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; i915_suspend_legacy(dev, pmm); dev->switch_power_state = DRM_SWITCH_POWER_OFF; } }
/* * power management */ static int snd_via82xx_suspend(struct pci_dev *pci, pm_message_t state) { struct snd_card *card = pci_get_drvdata(pci); struct via82xx_modem *chip = card->private_data; int i; snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for (i = 0; i < 2; i++) snd_pcm_suspend_all(chip->pcms[i]); for (i = 0; i < chip->num_devs; i++) snd_via82xx_channel_reset(chip, &chip->devs[i]); synchronize_irq(chip->irq); snd_ac97_suspend(chip->ac97); pci_disable_device(pci); pci_save_state(pci); pci_set_power_state(pci, pci_choose_state(pci, state)); return 0; }
static void bbswitch_on(void) { if (!is_card_disabled()) { pr_info("discrete graphics already enabled\n"); return; } pr_info("enabling discrete graphics\n"); if (bbswitch_acpi_on()) pr_warn("The discrete card could not be enabled by a _DSM call\n"); if (pci_set_power_state(dis_dev, PCI_D0)) pr_warn("The discrete card could not be set to D0 (awake) state\n"); pci_restore_state(dis_dev); if (pci_enable_device(dis_dev)) pr_warn("failed to enable %s\n", dev_name(&dis_dev->dev)); pci_set_master(dis_dev); }
/*************************************************************************/ /*! @Function OSPCISuspendDev @Description Prepare PCI device to be turned off by power management @Input hPVRPCI PCI device handle @Return PVRSRV_ERROR Services error code */ /**************************************************************************/ PVRSRV_ERROR OSPCISuspendDev(PVRSRV_PCI_DEV_HANDLE hPVRPCI) { PVR_PCI_DEV *psPVRPCI = (PVR_PCI_DEV *)hPVRPCI; int i; int err; /* Release all PCI regions that are currently in use */ for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { if (psPVRPCI->abPCIResourceInUse[i]) { pci_release_region(psPVRPCI->psPCIDev, i); } } err = pci_save_state(psPVRPCI->psPCIDev); if (err != 0) { printk(KERN_ERR "OSPCISuspendDev: pci_save_state_failed (%d)", err); return PVRSRV_ERROR_PCI_CALL_FAILED; } pci_disable_device(psPVRPCI->psPCIDev); err = pci_set_power_state(psPVRPCI->psPCIDev, pci_choose_state(psPVRPCI->psPCIDev, PMSG_SUSPEND)); switch(err) { case 0: break; case -EIO: printk(KERN_ERR "OSPCISuspendDev: device doesn't support PCI PM"); break; case -EINVAL: printk(KERN_ERR "OSPCISuspendDev: can't enter requested power state"); break; default: printk(KERN_ERR "OSPCISuspendDev: pci_set_power_state failed (%d)", err); break; } return PVRSRV_OK; }
static int cp_resume (struct pci_dev *pdev) { struct net_device *dev; struct cp_private *cp; dev = pci_get_drvdata (pdev); cp = netdev_priv(dev); netif_device_attach (dev); if (cp->pdev && cp->wol_enabled) { pci_set_power_state (cp->pdev, PCI_D0); pci_restore_state (cp->pdev); } cp_init_hw (cp); netif_start_queue (dev); return 0; }
static int intelce_wdt_resume(struct pci_dev *pdev) { int retval = 0; /*PCI device restore*/ pci_set_power_state(pdev, PCI_D0); pci_restore_state(pdev); retval = pci_enable_device(pdev); if (retval) return retval; /* Restore watchdog state. */ intelce_wdt_unlock_registers(); writel(wtreload_save, INTELCE_WDT_RELOAD); /* Reset count */ writel(wtctrl_save, INTELCE_WDT_CTRL); printk(KERN_INFO PFX "watchdog %sabled\n", (wtctrl_save & INTELCE_WTCON_ENABLE) ? "en" : "dis"); return 0; }
static int i915_pm_suspend(struct device *dev) { struct pci_dev *pdev = to_pci_dev(dev); struct drm_device *drm_dev = pci_get_drvdata(pdev); int error; if (!drm_dev || !drm_dev->dev_private) { dev_err(dev, "DRM not initialized, aborting suspend.\n"); return -ENODEV; } error = i915_drm_freeze(drm_dev); if (error) return error; pci_disable_device(pdev); pci_set_power_state(pdev, PCI_D3hot); return 0; }
static int be_suspend(struct pci_dev *pdev, pm_message_t state) { struct be_adapter *adapter = pci_get_drvdata(pdev); struct net_device *netdev = adapter->netdevp; struct be_net_object *pnob = netdev_priv(netdev); adapter->dev_pm_state = adapter->dev_state; adapter->dev_state = BE_DEV_STATE_SUSPEND; netif_device_detach(netdev); if (netif_running(netdev)) be_pm_cleanup(adapter, pnob, netdev); pci_enable_wake(pdev, 3, 1); pci_enable_wake(pdev, 4, 1); /* D3 Cold = 4 */ pci_save_state(pdev); pci_disable_device(pdev); pci_set_power_state(pdev, pci_choose_state(pdev, state)); return 0; }
static int serial_hsu_resume(struct pci_dev *pdev) { void *priv = pci_get_drvdata(pdev); struct uart_hsu_port *up; int ret; pci_set_power_state(pdev, PCI_D0); pci_restore_state(pdev); ret = pci_enable_device(pdev); if (ret) dev_warn(&pdev->dev, "HSU: can't re-enable device, try to continue\n"); if (priv && (pdev->device != 0x081E)) { up = priv; uart_resume_port(&serial_hsu_reg, &up->port); } return 0; }
MHI_STATUS mhi_turn_off_pcie_link(mhi_device_ctxt *mhi_dev_ctxt) { int r; struct pci_dev *pcie_dev; MHI_STATUS ret_val = MHI_STATUS_SUCCESS; mhi_log(MHI_MSG_INFO, "Entered...\n"); pcie_dev = mhi_dev_ctxt->dev_info->pcie_device; mutex_lock(&mhi_dev_ctxt->mhi_link_state); if (0 == mhi_dev_ctxt->flags.link_up) { mhi_log(MHI_MSG_CRITICAL | MHI_DBG_POWER, "Link already marked as down, nothing to do\n"); goto exit; } exynos_pcie_disable_l1ss(0); r = pci_set_power_state(mhi_dev_ctxt->dev_info->pcie_device, PCI_D3hot); if (r) { mhi_log(MHI_MSG_CRITICAL | MHI_DBG_POWER, "Failed to set pcie power state to D3 hotret: %x\n", r); ret_val = MHI_STATUS_ERROR; goto exit; } r = exynos_pcie_pm_suspend(0); if (r) { mhi_log(MHI_MSG_CRITICAL | MHI_DBG_POWER, "Failed to suspend PCIe RC driver ret 0x%x\n", r); ret_val = MHI_STATUS_ERROR; goto exit; } // TODO MODIFY Temporary delay for MDM pcie down stability mdelay(10); mhi_dev_ctxt->flags.link_up = 0; exit: mutex_unlock(&mhi_dev_ctxt->mhi_link_state); mhi_log(MHI_MSG_INFO, "Exited...\n"); return ret_val; }