1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
8 * Purpose: Handles 802.11 power management functions
15 * PSvEnablePowerSaving - Enable Power Saving Mode
16 * PSvDiasblePowerSaving - Disable Power Saving Mode
17 * PSbConsiderPowerDown - Decide if we can Power Down
18 * PSvSendPSPOLL - Send PS-POLL packet
19 * PSbSendNullPacket - Send Null packet
20 * PSbIsNextTBTTWakeUp - Decide if we need to wake up at next Beacon
31 /*--------------------- Static Definitions -------------------------*/
33 /*--------------------- Static Classes ----------------------------*/
35 /*--------------------- Static Functions --------------------------*/
37 /*--------------------- Export Variables --------------------------*/
39 /*--------------------- Export Functions --------------------------*/
43 * Routine Description:
44 * Enable hw power saving functions
51 void PSvEnablePowerSaving(struct vnt_private
*priv
,
52 unsigned short wListenInterval
)
54 u16 wAID
= priv
->current_aid
| BIT(14) | BIT(15);
56 /* set period of power up before TBTT */
57 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_PWBT
, C_PWBT
);
58 if (priv
->op_mode
!= NL80211_IFTYPE_ADHOC
) {
60 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_AIDATIM
, wAID
);
63 #if 0 /* TODO atim window */
64 MACvWriteATIMW(priv
->PortOffset
, pMgmt
->wCurrATIMWindow
);
68 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCFG
, PSCFG_AUTOSLEEP
);
70 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_TFTCTL
, TFTCTL_HWUTSF
);
72 if (wListenInterval
>= 2) {
73 /* clear always listen beacon */
74 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
75 /* first time set listen next beacon */
76 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_LNBCN
);
78 /* always listen beacon */
79 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
82 /* enable power saving hw function */
83 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_PSEN
);
84 priv
->bEnablePSMode
= true;
86 priv
->bPWBitOn
= true;
87 pr_debug("PS:Power Saving Mode Enable...\n");
92 * Routine Description:
93 * Disable hw power saving functions
101 PSvDisablePowerSaving(
102 struct vnt_private
*priv
105 /* disable power saving hw function */
107 /* clear AutoSleep */
108 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_PSCFG
, PSCFG_AUTOSLEEP
);
110 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_TFTCTL
, TFTCTL_HWUTSF
);
111 /* set always listen beacon */
112 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
114 priv
->bEnablePSMode
= false;
116 priv
->bPWBitOn
= false;
121 * Routine Description:
122 * Check if Next TBTT must wake up
131 struct vnt_private
*priv
134 struct ieee80211_hw
*hw
= priv
->hw
;
135 struct ieee80211_conf
*conf
= &hw
->conf
;
136 bool wake_up
= false;
138 if (conf
->listen_interval
> 1) {
139 if (!priv
->wake_up_count
)
140 priv
->wake_up_count
= conf
->listen_interval
;
142 --priv
->wake_up_count
;
144 if (priv
->wake_up_count
== 1) {
145 /* Turn on wake up to listen next beacon */
146 MACvRegBitsOn(priv
->PortOffset
,
147 MAC_REG_PSCTL
, PSCTL_LNBCN
);