2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * Purpose: Handles 802.11 power management functions
29 * PSvEnablePowerSaving - Enable Power Saving Mode
30 * PSvDiasblePowerSaving - Disable Power Saving Mode
31 * PSbConsiderPowerDown - Decide if we can Power Down
32 * PSvSendPSPOLL - Send PS-POLL packet
33 * PSbSendNullPacket - Send Null packet
34 * PSbIsNextTBTTWakeUp - Decide if we need to wake up at next Beacon
45 /*--------------------- Static Definitions -------------------------*/
47 /*--------------------- Static Classes ----------------------------*/
49 /*--------------------- Static Functions --------------------------*/
51 /*--------------------- Export Variables --------------------------*/
53 /*--------------------- Export Functions --------------------------*/
57 * Routine Description:
58 * Enable hw power saving functions
68 unsigned short wListenInterval
71 struct vnt_private *pDevice = hDeviceContext;
72 u16 wAID = pDevice->current_aid | BIT(14) | BIT(15);
74 // set period of power up before TBTT
75 VNSvOutPortW(pDevice->PortOffset + MAC_REG_PWBT, C_PWBT);
76 if (pDevice->op_mode != NL80211_IFTYPE_ADHOC) {
78 VNSvOutPortW(pDevice->PortOffset + MAC_REG_AIDATIM, wAID);
81 #if 0 /* TODO atim window */
82 MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow);
86 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
88 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_HWUTSF);
90 if (wListenInterval >= 2) {
91 // clear always listen beacon
92 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN);
93 // first time set listen next beacon
94 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN);
96 // always listen beacon
97 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN);
100 // enable power saving hw function
101 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN);
102 pDevice->bEnablePSMode = true;
104 pDevice->bPWBitOn = true;
105 pr_debug("PS:Power Saving Mode Enable...\n");
110 * Routine Description:
111 * Disable hw power saving functions
119 PSvDisablePowerSaving(
123 struct vnt_private *pDevice = hDeviceContext;
125 // disable power saving hw function
126 MACbPSWakeup(pDevice->PortOffset);
128 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
130 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_HWUTSF);
131 // set always listen beacon
132 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN);
134 pDevice->bEnablePSMode = false;
136 pDevice->bPWBitOn = false;
142 * Routine Description:
143 * Check if Next TBTT must wake up
155 struct vnt_private *pDevice = hDeviceContext;
156 struct ieee80211_hw *hw = pDevice->hw;
157 struct ieee80211_conf *conf = &hw->conf;
158 bool bWakeUp = false;
160 if (conf->listen_interval == 1) {
161 /* Turn on wake up to listen next beacon */
162 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN);