Merge remote-tracking branch 'linus/master' into x86/urgent
[deliverable/linux.git] / drivers / staging / rtl8192e / rtl8192e / rtl_pm.c
1 /******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
3 *
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
7 * more details.
8 *
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
12 *
13 * The full GNU General Public License is included in this distribution in the
14 * file called LICENSE.
15 *
16 * Contact Information:
17 * wlanfae <wlanfae@realtek.com>
18 ******************************************************************************/
19
20 #include "rtl_core.h"
21 #include "r8192E_hw.h"
22 #include "r8190P_rtl8256.h"
23 #include "rtl_pm.h"
24
25 int rtl8192E_save_state(struct pci_dev *dev, pm_message_t state)
26 {
27 printk(KERN_NOTICE "r8192E save state call (state %u).\n", state.event);
28 return -EAGAIN;
29 }
30
31
32 int rtl8192E_suspend(struct pci_dev *pdev, pm_message_t state)
33 {
34 struct net_device *dev = pci_get_drvdata(pdev);
35 struct r8192_priv *priv = rtllib_priv(dev);
36 u32 ulRegRead;
37
38 printk(KERN_INFO "============> r8192E suspend call.\n");
39 del_timer_sync(&priv->gpio_polling_timer);
40 cancel_delayed_work(&priv->gpio_change_rf_wq);
41 priv->polling_timer_on = 0;
42
43 if (!netif_running(dev)) {
44 printk(KERN_INFO "RTL819XE:UI is open out of suspend "
45 "function\n");
46 goto out_pci_suspend;
47 }
48
49 if (dev->netdev_ops->ndo_stop)
50 dev->netdev_ops->ndo_stop(dev);
51 netif_device_detach(dev);
52
53 if (!priv->rtllib->bSupportRemoteWakeUp) {
54 MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_INIT, true);
55 ulRegRead = read_nic_dword(dev, CPU_GEN);
56 ulRegRead |= CPU_GEN_SYSTEM_RESET;
57 write_nic_dword(dev, CPU_GEN, ulRegRead);
58 } else {
59 write_nic_dword(dev, WFCRC0, 0xffffffff);
60 write_nic_dword(dev, WFCRC1, 0xffffffff);
61 write_nic_dword(dev, WFCRC2, 0xffffffff);
62 write_nic_byte(dev, PMR, 0x5);
63 write_nic_byte(dev, MacBlkCtrl, 0xa);
64 }
65 out_pci_suspend:
66 printk("r8192E support WOL call??????????????????????\n");
67 if (priv->rtllib->bSupportRemoteWakeUp)
68 RT_TRACE(COMP_POWER, "r8192E support WOL call!!!!!!!"
69 "!!!!!!!!!!!.\n");
70 pci_save_state(pdev);
71 pci_disable_device(pdev);
72 pci_enable_wake(pdev, pci_choose_state(pdev, state),
73 priv->rtllib->bSupportRemoteWakeUp ? 1 : 0);
74 pci_set_power_state(pdev, pci_choose_state(pdev, state));
75
76 mdelay(20);
77
78 return 0;
79 }
80
81 int rtl8192E_resume(struct pci_dev *pdev)
82 {
83 struct net_device *dev = pci_get_drvdata(pdev);
84 struct r8192_priv *priv = rtllib_priv(dev);
85 int err;
86 u32 val;
87
88 printk(KERN_INFO "================>r8192E resume call.\n");
89
90 pci_set_power_state(pdev, PCI_D0);
91
92 err = pci_enable_device(pdev);
93 if (err) {
94 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
95 dev->name);
96 return err;
97 }
98 pci_restore_state(pdev);
99
100 pci_read_config_dword(pdev, 0x40, &val);
101 if ((val & 0x0000ff00) != 0)
102 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
103
104 pci_enable_wake(pdev, PCI_D0, 0);
105
106 if (priv->polling_timer_on == 0)
107 check_rfctrl_gpio_timer((unsigned long)dev);
108
109 if (!netif_running(dev)) {
110 printk(KERN_INFO "RTL819XE:UI is open out of resume "
111 "function\n");
112 goto out;
113 }
114
115 netif_device_attach(dev);
116 if (dev->netdev_ops->ndo_open)
117 dev->netdev_ops->ndo_open(dev);
118
119 if (!priv->rtllib->bSupportRemoteWakeUp)
120 MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_INIT, true);
121
122 out:
123 RT_TRACE(COMP_POWER, "<================r8192E resume call.\n");
124 return 0;
125 }
126
127
128 int rtl8192E_enable_wake(struct pci_dev *dev, pm_message_t state, int enable)
129 {
130 printk(KERN_NOTICE "r8192E enable wake call (state %u, enable %d).\n",
131 state.event, enable);
132 return -EAGAIN;
133 }
134
This page took 0.034267 seconds and 6 git commands to generate.