0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include "mac.h"
0022 #include "device.h"
0023 #include "power.h"
0024 #include "wcmd.h"
0025 #include "rxtx.h"
0026 #include "card.h"
0027 #include "usbpipe.h"
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 void vnt_enable_power_saving(struct vnt_private *priv, u16 listen_interval)
0040 {
0041 u16 aid = priv->current_aid | BIT(14) | BIT(15);
0042
0043
0044 vnt_mac_write_word(priv, MAC_REG_PWBT, C_PWBT);
0045
0046 if (priv->op_mode != NL80211_IFTYPE_ADHOC)
0047
0048 vnt_mac_write_word(priv, MAC_REG_AIDATIM, aid);
0049
0050
0051
0052
0053
0054 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_PSEN);
0055
0056
0057 vnt_mac_reg_bits_on(priv, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
0058
0059
0060
0061
0062 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_GO2DOZE);
0063
0064
0065 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
0066
0067 dev_dbg(&priv->usb->dev, "PS:Power Saving Mode Enable...\n");
0068 }
0069
0070 int vnt_disable_power_saving(struct vnt_private *priv)
0071 {
0072 int ret;
0073
0074
0075 ret = vnt_control_out(priv, MESSAGE_TYPE_DISABLE_PS, 0,
0076 0, 0, NULL);
0077 if (ret)
0078 return ret;
0079
0080
0081 vnt_mac_reg_bits_off(priv, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
0082
0083
0084 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
0085
0086 return 0;
0087 }
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 int vnt_next_tbtt_wakeup(struct vnt_private *priv)
0100 {
0101 struct ieee80211_hw *hw = priv->hw;
0102 struct ieee80211_conf *conf = &hw->conf;
0103 int wake_up = false;
0104
0105 if (conf->listen_interval > 1) {
0106
0107 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_LNBCN);
0108 wake_up = true;
0109 }
0110
0111 return wake_up;
0112 }