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
67 struct vnt_private
*priv
,
68 unsigned short wListenInterval
71 u16 wAID
= priv
->current_aid
| BIT(14) | BIT(15);
73 /* set period of power up before TBTT */
74 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_PWBT
, C_PWBT
);
75 if (priv
->op_mode
!= NL80211_IFTYPE_ADHOC
) {
77 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_AIDATIM
, wAID
);
80 #if 0 /* TODO atim window */
81 MACvWriteATIMW(priv
->PortOffset
, pMgmt
->wCurrATIMWindow
);
85 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCFG
, PSCFG_AUTOSLEEP
);
87 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_TFTCTL
, TFTCTL_HWUTSF
);
89 if (wListenInterval
>= 2) {
90 /* clear always listen beacon */
91 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
92 /* first time set listen next beacon */
93 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_LNBCN
);
95 /* always listen beacon */
96 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
99 /* enable power saving hw function */
100 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_PSEN
);
101 priv
->bEnablePSMode
= true;
103 priv
->bPWBitOn
= true;
104 pr_debug("PS:Power Saving Mode Enable...\n");
109 * Routine Description:
110 * Disable hw power saving functions
118 PSvDisablePowerSaving(
119 struct vnt_private
*priv
122 /* disable power saving hw function */
124 /* clear AutoSleep */
125 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_PSCFG
, PSCFG_AUTOSLEEP
);
127 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_TFTCTL
, TFTCTL_HWUTSF
);
128 /* set always listen beacon */
129 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
131 priv
->bEnablePSMode
= false;
133 priv
->bPWBitOn
= false;
139 * Routine Description:
140 * Check if Next TBTT must wake up
149 struct vnt_private
*priv
152 struct ieee80211_hw
*hw
= priv
->hw
;
153 struct ieee80211_conf
*conf
= &hw
->conf
;
154 bool wake_up
= false;
156 if (conf
->listen_interval
> 1) {
157 if (!priv
->wake_up_count
)
158 priv
->wake_up_count
= conf
->listen_interval
;
160 --priv
->wake_up_count
;
162 if (priv
->wake_up_count
== 1) {
163 /* Turn on wake up to listen next beacon */
164 MACvRegBitsOn(priv
->PortOffset
,
165 MAC_REG_PSCTL
, PSCTL_LNBCN
);