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
);
64 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCFG
, PSCFG_AUTOSLEEP
);
67 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_TFTCTL
, TFTCTL_HWUTSF
);
69 if (wListenInterval
>= 2) {
70 /* clear always listen beacon */
71 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
72 /* first time set listen next beacon */
73 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_LNBCN
);
75 /* always listen beacon */
76 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
79 /* enable power saving hw function */
80 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_PSEN
);
81 priv
->bEnablePSMode
= true;
83 priv
->bPWBitOn
= true;
84 pr_debug("PS:Power Saving Mode Enable...\n");
89 * Routine Description:
90 * Disable hw power saving functions
97 void PSvDisablePowerSaving(struct vnt_private
*priv
)
99 /* disable power saving hw function */
102 /* clear AutoSleep */
103 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_PSCFG
, PSCFG_AUTOSLEEP
);
106 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_TFTCTL
, TFTCTL_HWUTSF
);
108 /* set always listen beacon */
109 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
111 priv
->bEnablePSMode
= false;
113 priv
->bPWBitOn
= false;
118 * Routine Description:
119 * Check if Next TBTT must wake up
126 bool PSbIsNextTBTTWakeUp(struct vnt_private
*priv
)
128 struct ieee80211_hw
*hw
= priv
->hw
;
129 struct ieee80211_conf
*conf
= &hw
->conf
;
130 bool wake_up
= false;
132 if (conf
->listen_interval
> 1) {
133 if (!priv
->wake_up_count
)
134 priv
->wake_up_count
= conf
->listen_interval
;
136 --priv
->wake_up_count
;
138 if (priv
->wake_up_count
== 1) {
139 /* Turn on wake up to listen next beacon */
140 MACvRegBitsOn(priv
->PortOffset
,
141 MAC_REG_PSCTL
, PSCTL_LNBCN
);