root/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. rtl92e_suspend
  2. rtl92e_resume

   1 // SPDX-License-Identifier: GPL-2.0
   2 /*
   3  * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
   4  *
   5  * Contact Information: wlanfae <wlanfae@realtek.com>
   6  */
   7 #include "rtl_core.h"
   8 #include "r8192E_hw.h"
   9 #include "r8190P_rtl8256.h"
  10 #include "rtl_pm.h"
  11 
  12 
  13 int rtl92e_suspend(struct pci_dev *pdev, pm_message_t state)
  14 {
  15         struct net_device *dev = pci_get_drvdata(pdev);
  16         struct r8192_priv *priv = rtllib_priv(dev);
  17         u32     ulRegRead;
  18 
  19         netdev_info(dev, "============> r8192E suspend call.\n");
  20         del_timer_sync(&priv->gpio_polling_timer);
  21         cancel_delayed_work_sync(&priv->gpio_change_rf_wq);
  22         priv->polling_timer_on = 0;
  23 
  24         if (!netif_running(dev)) {
  25                 netdev_info(dev,
  26                             "RTL819XE:UI is open out of suspend function\n");
  27                 goto out_pci_suspend;
  28         }
  29 
  30         if (dev->netdev_ops->ndo_stop)
  31                 dev->netdev_ops->ndo_stop(dev);
  32         netif_device_detach(dev);
  33 
  34         if (!priv->rtllib->bSupportRemoteWakeUp) {
  35                 rtl92e_set_rf_state(dev, eRfOff, RF_CHANGE_BY_INIT);
  36                 ulRegRead = rtl92e_readl(dev, CPU_GEN);
  37                 ulRegRead |= CPU_GEN_SYSTEM_RESET;
  38                 rtl92e_writel(dev, CPU_GEN, ulRegRead);
  39         } else {
  40                 rtl92e_writel(dev, WFCRC0, 0xffffffff);
  41                 rtl92e_writel(dev, WFCRC1, 0xffffffff);
  42                 rtl92e_writel(dev, WFCRC2, 0xffffffff);
  43                 rtl92e_writeb(dev, PMR, 0x5);
  44                 rtl92e_writeb(dev, MacBlkCtrl, 0xa);
  45         }
  46 out_pci_suspend:
  47         netdev_info(dev, "WOL is %s\n", priv->rtllib->bSupportRemoteWakeUp ?
  48                             "Supported" : "Not supported");
  49         pci_save_state(pdev);
  50         pci_disable_device(pdev);
  51         pci_enable_wake(pdev, pci_choose_state(pdev, state),
  52                         priv->rtllib->bSupportRemoteWakeUp ? 1 : 0);
  53         pci_set_power_state(pdev, pci_choose_state(pdev, state));
  54 
  55         mdelay(20);
  56 
  57         return 0;
  58 }
  59 
  60 int rtl92e_resume(struct pci_dev *pdev)
  61 {
  62         struct net_device *dev = pci_get_drvdata(pdev);
  63         struct r8192_priv *priv = rtllib_priv(dev);
  64         int err;
  65         u32 val;
  66 
  67         netdev_info(dev, "================>r8192E resume call.\n");
  68 
  69         pci_set_power_state(pdev, PCI_D0);
  70 
  71         err = pci_enable_device(pdev);
  72         if (err) {
  73                 netdev_err(dev, "pci_enable_device failed on resume\n");
  74                 return err;
  75         }
  76         pci_restore_state(pdev);
  77 
  78         pci_read_config_dword(pdev, 0x40, &val);
  79         if ((val & 0x0000ff00) != 0)
  80                 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
  81 
  82         pci_enable_wake(pdev, PCI_D0, 0);
  83 
  84         if (priv->polling_timer_on == 0)
  85                 rtl92e_check_rfctrl_gpio_timer(&priv->gpio_polling_timer);
  86 
  87         if (!netif_running(dev)) {
  88                 netdev_info(dev,
  89                             "RTL819XE:UI is open out of resume function\n");
  90                 goto out;
  91         }
  92 
  93         netif_device_attach(dev);
  94         if (dev->netdev_ops->ndo_open)
  95                 dev->netdev_ops->ndo_open(dev);
  96 
  97         if (!priv->rtllib->bSupportRemoteWakeUp)
  98                 rtl92e_set_rf_state(dev, eRfOn, RF_CHANGE_BY_INIT);
  99 
 100 out:
 101         RT_TRACE(COMP_POWER, "<================r8192E resume call.\n");
 102         return 0;
 103 }
 104 

/* [<][>][^][v][top][bottom][index][help] */