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
53 struct vnt_private
*priv
,
54 unsigned short wListenInterval
57 u16 wAID
= priv
->current_aid
| BIT(14) | BIT(15);
59 /* set period of power up before TBTT */
60 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_PWBT
, C_PWBT
);
61 if (priv
->op_mode
!= NL80211_IFTYPE_ADHOC
) {
63 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_AIDATIM
, wAID
);
66 #if 0 /* TODO atim window */
67 MACvWriteATIMW(priv
->PortOffset
, pMgmt
->wCurrATIMWindow
);
71 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCFG
, PSCFG_AUTOSLEEP
);
73 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_TFTCTL
, TFTCTL_HWUTSF
);
75 if (wListenInterval
>= 2) {
76 /* clear always listen beacon */
77 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
78 /* first time set listen next beacon */
79 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_LNBCN
);
81 /* always listen beacon */
82 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
85 /* enable power saving hw function */
86 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_PSEN
);
87 priv
->bEnablePSMode
= true;
89 priv
->bPWBitOn
= true;
90 pr_debug("PS:Power Saving Mode Enable...\n");
95 * Routine Description:
96 * Disable hw power saving functions
104 PSvDisablePowerSaving(
105 struct vnt_private
*priv
108 /* disable power saving hw function */
110 /* clear AutoSleep */
111 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_PSCFG
, PSCFG_AUTOSLEEP
);
113 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_TFTCTL
, TFTCTL_HWUTSF
);
114 /* set always listen beacon */
115 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
117 priv
->bEnablePSMode
= false;
119 priv
->bPWBitOn
= false;
124 * Routine Description:
125 * Check if Next TBTT must wake up
134 struct vnt_private
*priv
137 struct ieee80211_hw
*hw
= priv
->hw
;
138 struct ieee80211_conf
*conf
= &hw
->conf
;
139 bool wake_up
= false;
141 if (conf
->listen_interval
> 1) {
142 if (!priv
->wake_up_count
)
143 priv
->wake_up_count
= conf
->listen_interval
;
145 --priv
->wake_up_count
;
147 if (priv
->wake_up_count
== 1) {
148 /* Turn on wake up to listen next beacon */
149 MACvRegBitsOn(priv
->PortOffset
,
150 MAC_REG_PSCTL
, PSCTL_LNBCN
);