]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/staging/vt6655/power.c
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.
17 * Purpose: Handles 802.11 power management functions
24 * PSvEnablePowerSaving - Enable Power Saving Mode
25 * PSvDiasblePowerSaving - Disable Power Saving Mode
26 * PSbConsiderPowerDown - Decide if we can Power Down
27 * PSvSendPSPOLL - Send PS-POLL packet
28 * PSbSendNullPacket - Send Null packet
29 * PSbIsNextTBTTWakeUp - Decide if we need to wake up at next Beacon
40 /*--------------------- Static Definitions -------------------------*/
42 /*--------------------- Static Classes ----------------------------*/
44 /*--------------------- Static Functions --------------------------*/
46 /*--------------------- Export Variables --------------------------*/
48 /*--------------------- Export Functions --------------------------*/
52 * Routine Description:
53 * Enable hw power saving functions
62 struct vnt_private
*priv
,
63 unsigned short wListenInterval
66 u16 wAID
= priv
->current_aid
| BIT(14) | BIT(15);
68 /* set period of power up before TBTT */
69 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_PWBT
, C_PWBT
);
70 if (priv
->op_mode
!= NL80211_IFTYPE_ADHOC
) {
72 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_AIDATIM
, wAID
);
75 #if 0 /* TODO atim window */
76 MACvWriteATIMW(priv
->PortOffset
, pMgmt
->wCurrATIMWindow
);
80 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCFG
, PSCFG_AUTOSLEEP
);
82 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_TFTCTL
, TFTCTL_HWUTSF
);
84 if (wListenInterval
>= 2) {
85 /* clear always listen beacon */
86 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
87 /* first time set listen next beacon */
88 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_LNBCN
);
90 /* always listen beacon */
91 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
94 /* enable power saving hw function */
95 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_PSEN
);
96 priv
->bEnablePSMode
= true;
98 priv
->bPWBitOn
= true;
99 pr_debug("PS:Power Saving Mode Enable...\n");
104 * Routine Description:
105 * Disable hw power saving functions
113 PSvDisablePowerSaving(
114 struct vnt_private
*priv
117 /* disable power saving hw function */
119 /* clear AutoSleep */
120 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_PSCFG
, PSCFG_AUTOSLEEP
);
122 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_TFTCTL
, TFTCTL_HWUTSF
);
123 /* set always listen beacon */
124 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
126 priv
->bEnablePSMode
= false;
128 priv
->bPWBitOn
= false;
133 * Routine Description:
134 * Check if Next TBTT must wake up
143 struct vnt_private
*priv
146 struct ieee80211_hw
*hw
= priv
->hw
;
147 struct ieee80211_conf
*conf
= &hw
->conf
;
148 bool wake_up
= false;
150 if (conf
->listen_interval
> 1) {
151 if (!priv
->wake_up_count
)
152 priv
->wake_up_count
= conf
->listen_interval
;
154 --priv
->wake_up_count
;
156 if (priv
->wake_up_count
== 1) {
157 /* Turn on wake up to listen next beacon */
158 MACvRegBitsOn(priv
->PortOffset
,
159 MAC_REG_PSCTL
, PSCTL_LNBCN
);