1
2
3
4
5
6
7
8
9
10#include "baseband.h"
11#include "channel.h"
12#include "device.h"
13#include "rf.h"
14
15static struct ieee80211_rate vnt_rates_bg[] = {
16 { .bitrate = 10, .hw_value = RATE_1M },
17 { .bitrate = 20, .hw_value = RATE_2M },
18 { .bitrate = 55, .hw_value = RATE_5M },
19 { .bitrate = 110, .hw_value = RATE_11M },
20 { .bitrate = 60, .hw_value = RATE_6M },
21 { .bitrate = 90, .hw_value = RATE_9M },
22 { .bitrate = 120, .hw_value = RATE_12M },
23 { .bitrate = 180, .hw_value = RATE_18M },
24 { .bitrate = 240, .hw_value = RATE_24M },
25 { .bitrate = 360, .hw_value = RATE_36M },
26 { .bitrate = 480, .hw_value = RATE_48M },
27 { .bitrate = 540, .hw_value = RATE_54M },
28};
29
30static struct ieee80211_rate vnt_rates_a[] = {
31 { .bitrate = 60, .hw_value = RATE_6M },
32 { .bitrate = 90, .hw_value = RATE_9M },
33 { .bitrate = 120, .hw_value = RATE_12M },
34 { .bitrate = 180, .hw_value = RATE_18M },
35 { .bitrate = 240, .hw_value = RATE_24M },
36 { .bitrate = 360, .hw_value = RATE_36M },
37 { .bitrate = 480, .hw_value = RATE_48M },
38 { .bitrate = 540, .hw_value = RATE_54M },
39};
40
41static struct ieee80211_channel vnt_channels_2ghz[] = {
42 { .center_freq = 2412, .hw_value = 1 },
43 { .center_freq = 2417, .hw_value = 2 },
44 { .center_freq = 2422, .hw_value = 3 },
45 { .center_freq = 2427, .hw_value = 4 },
46 { .center_freq = 2432, .hw_value = 5 },
47 { .center_freq = 2437, .hw_value = 6 },
48 { .center_freq = 2442, .hw_value = 7 },
49 { .center_freq = 2447, .hw_value = 8 },
50 { .center_freq = 2452, .hw_value = 9 },
51 { .center_freq = 2457, .hw_value = 10 },
52 { .center_freq = 2462, .hw_value = 11 },
53 { .center_freq = 2467, .hw_value = 12 },
54 { .center_freq = 2472, .hw_value = 13 },
55 { .center_freq = 2484, .hw_value = 14 }
56};
57
58static struct ieee80211_channel vnt_channels_5ghz[] = {
59 { .center_freq = 4915, .hw_value = 15 },
60 { .center_freq = 4920, .hw_value = 16 },
61 { .center_freq = 4925, .hw_value = 17 },
62 { .center_freq = 4935, .hw_value = 18 },
63 { .center_freq = 4940, .hw_value = 19 },
64 { .center_freq = 4945, .hw_value = 20 },
65 { .center_freq = 4960, .hw_value = 21 },
66 { .center_freq = 4980, .hw_value = 22 },
67 { .center_freq = 5035, .hw_value = 23 },
68 { .center_freq = 5040, .hw_value = 24 },
69 { .center_freq = 5045, .hw_value = 25 },
70 { .center_freq = 5055, .hw_value = 26 },
71 { .center_freq = 5060, .hw_value = 27 },
72 { .center_freq = 5080, .hw_value = 28 },
73 { .center_freq = 5170, .hw_value = 29 },
74 { .center_freq = 5180, .hw_value = 30 },
75 { .center_freq = 5190, .hw_value = 31 },
76 { .center_freq = 5200, .hw_value = 32 },
77 { .center_freq = 5210, .hw_value = 33 },
78 { .center_freq = 5220, .hw_value = 34 },
79 { .center_freq = 5230, .hw_value = 35 },
80 { .center_freq = 5240, .hw_value = 36 },
81 { .center_freq = 5260, .hw_value = 37 },
82 { .center_freq = 5280, .hw_value = 38 },
83 { .center_freq = 5300, .hw_value = 39 },
84 { .center_freq = 5320, .hw_value = 40 },
85 { .center_freq = 5500, .hw_value = 41 },
86 { .center_freq = 5520, .hw_value = 42 },
87 { .center_freq = 5540, .hw_value = 43 },
88 { .center_freq = 5560, .hw_value = 44 },
89 { .center_freq = 5580, .hw_value = 45 },
90 { .center_freq = 5600, .hw_value = 46 },
91 { .center_freq = 5620, .hw_value = 47 },
92 { .center_freq = 5640, .hw_value = 48 },
93 { .center_freq = 5660, .hw_value = 49 },
94 { .center_freq = 5680, .hw_value = 50 },
95 { .center_freq = 5700, .hw_value = 51 },
96 { .center_freq = 5745, .hw_value = 52 },
97 { .center_freq = 5765, .hw_value = 53 },
98 { .center_freq = 5785, .hw_value = 54 },
99 { .center_freq = 5805, .hw_value = 55 },
100 { .center_freq = 5825, .hw_value = 56 }
101};
102
103static struct ieee80211_supported_band vnt_supported_2ghz_band = {
104 .channels = vnt_channels_2ghz,
105 .n_channels = ARRAY_SIZE(vnt_channels_2ghz),
106 .bitrates = vnt_rates_bg,
107 .n_bitrates = ARRAY_SIZE(vnt_rates_bg),
108};
109
110static struct ieee80211_supported_band vnt_supported_5ghz_band = {
111 .channels = vnt_channels_5ghz,
112 .n_channels = ARRAY_SIZE(vnt_channels_5ghz),
113 .bitrates = vnt_rates_a,
114 .n_bitrates = ARRAY_SIZE(vnt_rates_a),
115};
116
117void vnt_init_bands(struct vnt_private *priv)
118{
119 struct ieee80211_channel *ch;
120 int i;
121
122 switch (priv->byRFType) {
123 case RF_AIROHA7230:
124 case RF_UW2452:
125 case RF_NOTHING:
126 default:
127 ch = vnt_channels_5ghz;
128
129 for (i = 0; i < ARRAY_SIZE(vnt_channels_5ghz); i++) {
130 ch[i].max_power = 0x3f;
131 ch[i].flags = IEEE80211_CHAN_NO_HT40;
132 }
133
134 priv->hw->wiphy->bands[NL80211_BAND_5GHZ] =
135 &vnt_supported_5ghz_band;
136
137 case RF_RFMD2959:
138 case RF_AIROHA:
139 case RF_AL2230S:
140 case RF_UW2451:
141 case RF_VT3226:
142 ch = vnt_channels_2ghz;
143
144 for (i = 0; i < ARRAY_SIZE(vnt_channels_2ghz); i++) {
145 ch[i].max_power = 0x3f;
146 ch[i].flags = IEEE80211_CHAN_NO_HT40;
147 }
148
149 priv->hw->wiphy->bands[NL80211_BAND_2GHZ] =
150 &vnt_supported_2ghz_band;
151 break;
152 }
153}
154
155
156
157
158
159
160
161
162
163
164bool set_channel(struct vnt_private *priv, struct ieee80211_channel *ch)
165{
166 bool ret = true;
167
168 if (priv->byCurrentCh == ch->hw_value)
169 return ret;
170
171
172 if (priv->bUpdateBBVGA &&
173 priv->byBBVGACurrent != priv->abyBBVGA[0]) {
174 priv->byBBVGACurrent = priv->abyBBVGA[0];
175
176 BBvSetVGAGainOffset(priv, priv->byBBVGACurrent);
177 }
178
179
180 MACvRegBitsOn(priv->PortOffset, MAC_REG_MACCR, MACCR_CLRNAV);
181
182
183
184
185
186 if (priv->byRFType == RF_AIROHA7230)
187 RFbAL7230SelectChannelPostProcess(priv, priv->byCurrentCh,
188 ch->hw_value);
189
190 priv->byCurrentCh = ch->hw_value;
191 ret &= RFbSelectChannel(priv, priv->byRFType,
192 ch->hw_value);
193
194
195 if (priv->bEnablePSMode)
196 RFvWriteWakeProgSyn(priv, priv->byRFType, ch->hw_value);
197
198 BBvSoftwareReset(priv);
199
200 if (priv->byLocalID > REV_ID_VT3253_B1) {
201 unsigned long flags;
202
203 spin_lock_irqsave(&priv->lock, flags);
204
205
206 MACvSelectPage1(priv->PortOffset);
207 RFbSetPower(priv, RATE_1M, priv->byCurrentCh);
208 VNSvOutPortB(priv->PortOffset + MAC_REG_PWRCCK,
209 priv->byCurPwr);
210 RFbSetPower(priv, RATE_6M, priv->byCurrentCh);
211 VNSvOutPortB(priv->PortOffset + MAC_REG_PWROFDM,
212 priv->byCurPwr);
213 MACvSelectPage0(priv->PortOffset);
214
215 spin_unlock_irqrestore(&priv->lock, flags);
216 }
217
218 if (priv->byBBType == BB_TYPE_11B)
219 RFbSetPower(priv, RATE_1M, priv->byCurrentCh);
220 else
221 RFbSetPower(priv, RATE_6M, priv->byCurrentCh);
222
223 return ret;
224}
225