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 * vnt_enable_power_saving - Enable Power Saving Mode
16 * PSvDiasblePowerSaving - Disable Power Saving Mode
17 * vnt_next_tbtt_wakeup - Decide if we need to wake up at next Beacon
33 * Routine Description:
34 * Enable hw power saving functions
41 void vnt_enable_power_saving(struct vnt_private
*priv
, u16 listen_interval
)
43 u16 aid
= priv
->current_aid
| BIT(14) | BIT(15);
45 /* set period of power up before TBTT */
46 vnt_mac_write_word(priv
, MAC_REG_PWBT
, C_PWBT
);
48 if (priv
->op_mode
!= NL80211_IFTYPE_ADHOC
)
50 vnt_mac_write_word(priv
, MAC_REG_AIDATIM
, aid
);
52 /* Warren:06-18-2004,the sequence must follow
53 * PSEN->AUTOSLEEP->GO2DOZE
55 /* enable power saving hw function */
56 vnt_mac_reg_bits_on(priv
, MAC_REG_PSCTL
, PSCTL_PSEN
);
59 vnt_mac_reg_bits_on(priv
, MAC_REG_PSCFG
, PSCFG_AUTOSLEEP
);
61 /* Warren:MUST turn on this once before turn on AUTOSLEEP ,or the
62 * AUTOSLEEP doesn't work
64 vnt_mac_reg_bits_on(priv
, MAC_REG_PSCTL
, PSCTL_GO2DOZE
);
66 /* always listen beacon */
67 vnt_mac_reg_bits_on(priv
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
69 dev_dbg(&priv
->usb
->dev
, "PS:Power Saving Mode Enable...\n");
72 int vnt_disable_power_saving(struct vnt_private
*priv
)
76 /* disable power saving hw function */
77 ret
= vnt_control_out(priv
, MESSAGE_TYPE_DISABLE_PS
, 0,
83 vnt_mac_reg_bits_off(priv
, MAC_REG_PSCFG
, PSCFG_AUTOSLEEP
);
85 /* set always listen beacon */
86 vnt_mac_reg_bits_on(priv
, MAC_REG_PSCTL
, PSCTL_ALBCN
);
93 * Routine Description:
94 * Check if Next TBTT must wake up
101 int vnt_next_tbtt_wakeup(struct vnt_private
*priv
)
103 struct ieee80211_hw
*hw
= priv
->hw
;
104 struct ieee80211_conf
*conf
= &hw
->conf
;
107 if (conf
->listen_interval
> 1) {
108 /* Turn on wake up to listen next beacon */
109 vnt_mac_reg_bits_on(priv
, MAC_REG_PSCTL
, PSCTL_LNBCN
);