1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#include "mac.h"
34#include "device.h"
35#include "power.h"
36#include "wcmd.h"
37#include "rxtx.h"
38#include "card.h"
39#include "usbpipe.h"
40
41
42
43
44
45
46
47
48
49
50
51void vnt_enable_power_saving(struct vnt_private *priv, u16 listen_interval)
52{
53 u16 aid = priv->current_aid | BIT(14) | BIT(15);
54
55
56 vnt_mac_write_word(priv, MAC_REG_PWBT, C_PWBT);
57
58 if (priv->op_mode != NL80211_IFTYPE_ADHOC)
59
60 vnt_mac_write_word(priv, MAC_REG_AIDATIM, aid);
61
62
63
64
65
66 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_PSEN);
67
68
69 vnt_mac_reg_bits_on(priv, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
70
71
72
73
74 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_GO2DOZE);
75
76 if (listen_interval >= 2) {
77
78
79 vnt_mac_reg_bits_off(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
80
81
82 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_LNBCN);
83 } else
84
85
86 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
87
88 dev_dbg(&priv->usb->dev, "PS:Power Saving Mode Enable...\n");
89}
90
91
92
93
94
95
96
97
98
99
100
101void vnt_disable_power_saving(struct vnt_private *priv)
102{
103
104
105 vnt_control_out(priv, MESSAGE_TYPE_DISABLE_PS, 0,
106 0, 0, NULL);
107
108
109 vnt_mac_reg_bits_off(priv, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
110
111
112 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
113}
114
115
116
117
118
119
120
121
122
123
124
125int vnt_next_tbtt_wakeup(struct vnt_private *priv)
126{
127 struct ieee80211_hw *hw = priv->hw;
128 struct ieee80211_conf *conf = &hw->conf;
129 int wake_up = false;
130
131 if (conf->listen_interval > 1) {
132
133 vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_LNBCN);
134 wake_up = true;
135 }
136
137 return wake_up;
138}
139