2 Power management interface routines.
3 Written by Mariusz Matuszek.
4 This code is currently just a placeholder for later work and
5 does not do anything useful.
7 This is part of rtl8180 OpenSource driver.
8 Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it>
9 Released under the terms of GPL (General Public Licence)
15 #include "r8192E_hw.h"
17 #include "r8190_rtl8256.h"
19 int rtl8192E_save_state (struct pci_dev
*dev
, pm_message_t state
)
21 printk(KERN_NOTICE
"r8192E save state call (state %u).\n", state
.event
);
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
= ieee80211_priv(dev
);
33 RT_TRACE(COMP_POWER
, "============> r8192E suspend call.\n");
34 if (!netif_running(dev
))
37 if (dev
->netdev_ops
->ndo_stop
)
38 dev
->netdev_ops
->ndo_stop(dev
);
42 netif_carrier_off(dev
);
44 ieee80211_softmac_stop_protocol(priv
->ieee80211
);
46 write_nic_byte(dev
,MSR
,(read_nic_byte(dev
,MSR
)&0xfc)|MSR_LINK_NONE
);
47 if(!priv
->ieee80211
->bSupportRemoteWakeUp
) {
48 /* disable tx/rx. In 8185 we write 0x10 (Reset bit),
49 * but here we make reference to WMAC and wirte 0x0.
52 write_nic_byte(dev
, CMDR
, 0);
55 write_nic_dword(dev
,INTA_MASK
,0);
56 priv
->irq_enabled
= 0;
57 write_nic_dword(dev
,ISR
,read_nic_dword(dev
, ISR
));
59 /* need to free DM related functions */
60 cancel_work_sync(&priv
->reset_wq
);
61 del_timer_sync(&priv
->fsync_timer
);
62 del_timer_sync(&priv
->watch_dog_timer
);
63 cancel_delayed_work(&priv
->watch_dog_wq
);
64 cancel_delayed_work(&priv
->update_beacon_wq
);
65 cancel_work_sync(&priv
->qos_activate
);
68 #if ((DEV_BUS_TYPE == PCI_INTERFACE) && (HAL_CODE_BASE == RTL8192))
69 pHalData->bHwRfOffAction = 2;
73 // Call MgntActSet_RF_State instead to prevent RF config race condition.
74 // By Bruce, 2008-01-17.
76 if(!priv
->ieee80211
->bSupportRemoteWakeUp
) {
77 MgntActSet_RF_State(dev
, eRfOff
, RF_CHANGE_BY_INIT
);
78 // 2006.11.30. System reset bit
79 ulRegRead
= read_nic_dword(dev
, CPU_GEN
);
80 ulRegRead
|=CPU_GEN_SYSTEM_RESET
;
81 write_nic_dword(dev
, CPU_GEN
, ulRegRead
);
84 write_nic_dword(dev
, WFCRC0
, 0xffffffff);
85 write_nic_dword(dev
, WFCRC1
, 0xffffffff);
86 write_nic_dword(dev
, WFCRC2
, 0xffffffff);
89 ucRegRead
= read_nic_byte(dev
, GPO
);
91 write_nic_byte(dev
, GPO
, ucRegRead
);
94 write_nic_byte(dev
, PMR
, 0x5);
95 //Disable tx, enanble rx
96 write_nic_byte(dev
, MacBlkCtrl
, 0xa);
100 RT_TRACE(COMP_POWER
, "r8192E support WOL call??????????????????????\n");
101 if(priv
->ieee80211
->bSupportRemoteWakeUp
) {
102 RT_TRACE(COMP_POWER
, "r8192E support WOL call!!!!!!!!!!!!!!!!!!.\n");
104 netif_device_detach(dev
);
105 pci_save_state(pdev
);
106 pci_disable_device(pdev
);
107 pci_enable_wake(pdev
, pci_choose_state(pdev
,state
),\
108 priv
->ieee80211
->bSupportRemoteWakeUp
?1:0);
109 pci_set_power_state(pdev
,pci_choose_state(pdev
,state
));
114 int rtl8192E_resume (struct pci_dev
*pdev
)
116 struct net_device
*dev
= pci_get_drvdata(pdev
);
117 //struct r8192_priv *priv = ieee80211_priv(dev);
118 //union iwreq_data wrqu;
122 RT_TRACE(COMP_POWER
, "================>r8192E resume call.");
124 pci_set_power_state(pdev
, PCI_D0
);
126 err
= pci_enable_device(pdev
);
128 printk(KERN_ERR
"%s: pci_enable_device failed on resume\n",
133 pci_restore_state(pdev
);
136 * Suspend/Resume resets the PCI configuration space, so we have to
137 * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries
138 * from interfering with C3 CPU state. pci_restore_state won't help
139 * here since it only restores the first 64 bytes pci config header.
141 pci_read_config_dword(pdev
, 0x40, &val
);
142 if ((val
& 0x0000ff00) != 0) {
143 pci_write_config_dword(pdev
, 0x40, val
& 0xffff00ff);
148 pci_enable_wake(pdev
, PCI_D0
, 0);
150 if(!netif_running(dev
))
153 netif_device_attach(dev
);
155 if (dev
->netdev_ops
->ndo_open
)
156 dev
->netdev_ops
->ndo_open(dev
);
160 RT_TRACE(COMP_POWER
, "<================r8192E resume call.\n");
165 int rtl8192E_enable_wake (struct pci_dev
*dev
, pm_message_t state
, int enable
)
167 printk(KERN_NOTICE
"r8192E enable wake call (state %u, enable %d).\n",
168 state
.event
, enable
);
172 #endif //CONFIG_PM_RTL