1 /******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
4 * This program is distributed in the hope that it will be useful, but WITHOUT
5 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
9 * You should have received a copy of the GNU General Public License along with
10 * this program; if not, write to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
13 * The full GNU General Public License is included in this distribution in the
14 * file called LICENSE.
16 * Contact Information:
17 * wlanfae <wlanfae@realtek.com>
18 ******************************************************************************/
21 #include "r8192E_hw.h"
22 #include "r8190P_rtl8256.h"
26 int rtl8192E_suspend(struct pci_dev *pdev, pm_message_t state)
28 struct net_device *dev = pci_get_drvdata(pdev);
29 struct r8192_priv *priv = rtllib_priv(dev);
32 netdev_info(dev, "============> r8192E suspend call.\n");
33 del_timer_sync(&priv->gpio_polling_timer);
34 cancel_delayed_work(&priv->gpio_change_rf_wq);
35 priv->polling_timer_on = 0;
37 if (!netif_running(dev)) {
39 "RTL819XE:UI is open out of suspend function\n");
43 if (dev->netdev_ops->ndo_stop)
44 dev->netdev_ops->ndo_stop(dev);
45 netif_device_detach(dev);
47 if (!priv->rtllib->bSupportRemoteWakeUp) {
48 MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_INIT, true);
49 ulRegRead = read_nic_dword(dev, CPU_GEN);
50 ulRegRead |= CPU_GEN_SYSTEM_RESET;
51 write_nic_dword(dev, CPU_GEN, ulRegRead);
53 write_nic_dword(dev, WFCRC0, 0xffffffff);
54 write_nic_dword(dev, WFCRC1, 0xffffffff);
55 write_nic_dword(dev, WFCRC2, 0xffffffff);
56 write_nic_byte(dev, PMR, 0x5);
57 write_nic_byte(dev, MacBlkCtrl, 0xa);
60 netdev_info(dev, "r8192E support WOL call??????????????????????\n");
61 if (priv->rtllib->bSupportRemoteWakeUp)
63 "r8192E support WOL call!!!!!!!!!!!!!!!!!!.\n");
65 pci_disable_device(pdev);
66 pci_enable_wake(pdev, pci_choose_state(pdev, state),
67 priv->rtllib->bSupportRemoteWakeUp ? 1 : 0);
68 pci_set_power_state(pdev, pci_choose_state(pdev, state));
75 int rtl8192E_resume(struct pci_dev *pdev)
77 struct net_device *dev = pci_get_drvdata(pdev);
78 struct r8192_priv *priv = rtllib_priv(dev);
82 netdev_info(dev, "================>r8192E resume call.\n");
84 pci_set_power_state(pdev, PCI_D0);
86 err = pci_enable_device(pdev);
88 netdev_err(dev, "pci_enable_device failed on resume\n");
91 pci_restore_state(pdev);
93 pci_read_config_dword(pdev, 0x40, &val);
94 if ((val & 0x0000ff00) != 0)
95 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
97 pci_enable_wake(pdev, PCI_D0, 0);
99 if (priv->polling_timer_on == 0)
100 check_rfctrl_gpio_timer((unsigned long)dev);
102 if (!netif_running(dev)) {
104 "RTL819XE:UI is open out of resume function\n");
108 netif_device_attach(dev);
109 if (dev->netdev_ops->ndo_open)
110 dev->netdev_ops->ndo_open(dev);
112 if (!priv->rtllib->bSupportRemoteWakeUp)
113 MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_INIT, true);
116 RT_TRACE(COMP_POWER, "<================r8192E resume call.\n");