1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
6 * Purpose: Handles 802.11 power management functions
13 * vnt_enable_power_saving - Enable Power Saving Mode
14 * PSvDiasblePowerSaving - Disable Power Saving Mode
15 * vnt_next_tbtt_wakeup - Decide if we need to wake up at next Beacon
31 * Routine Description:
32 * Enable hw power saving functions
39 void vnt_enable_power_saving(struct vnt_private *priv, u16 listen_interval)
41 u16 aid = priv->current_aid | BIT(14) | BIT(15);
43 /* set period of power up before TBTT */
44 vnt_mac_write_word(priv, MAC_REG_PWBT, C_PWBT);
46 if (priv->op_mode != NL80211_IFTYPE_ADHOC)
48 vnt_mac_write_word(priv, MAC_REG_AIDATIM, aid);
50 /* Warren:06-18-2004,the sequence must follow
51 * PSEN->AUTOSLEEP->GO2DOZE
53 /* enable power saving hw function */
54 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_PSEN);
57 vnt_mac_reg_bits_on(priv, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
59 /* Warren:MUST turn on this once before turn on AUTOSLEEP ,or the
60 * AUTOSLEEP doesn't work
62 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_GO2DOZE);
64 /* always listen beacon */
65 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
67 dev_dbg(&priv->usb->dev, "PS:Power Saving Mode Enable...\n");
70 int vnt_disable_power_saving(struct vnt_private *priv)
74 /* disable power saving hw function */
75 ret = vnt_control_out(priv, MESSAGE_TYPE_DISABLE_PS, 0,
81 vnt_mac_reg_bits_off(priv, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
83 /* set always listen beacon */
84 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
91 * Routine Description:
92 * Check if Next TBTT must wake up
99 int vnt_next_tbtt_wakeup(struct vnt_private *priv)
101 struct ieee80211_hw *hw = priv->hw;
102 struct ieee80211_conf *conf = &hw->conf;
105 if (conf->listen_interval > 1) {
106 /* Turn on wake up to listen next beacon */
107 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_LNBCN);