Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * File: channel.c
16 *
17 */
18
19#include "baseband.h"
20#include "channel.h"
21#include "device.h"
22#include "rf.h"
23
24static struct ieee80211_rate vnt_rates_bg[] = {
25 { .bitrate = 10, .hw_value = RATE_1M },
26 { .bitrate = 20, .hw_value = RATE_2M },
27 { .bitrate = 55, .hw_value = RATE_5M },
28 { .bitrate = 110, .hw_value = RATE_11M },
29 { .bitrate = 60, .hw_value = RATE_6M },
30 { .bitrate = 90, .hw_value = RATE_9M },
31 { .bitrate = 120, .hw_value = RATE_12M },
32 { .bitrate = 180, .hw_value = RATE_18M },
33 { .bitrate = 240, .hw_value = RATE_24M },
34 { .bitrate = 360, .hw_value = RATE_36M },
35 { .bitrate = 480, .hw_value = RATE_48M },
36 { .bitrate = 540, .hw_value = RATE_54M },
37};
38
39static struct ieee80211_rate vnt_rates_a[] = {
40 { .bitrate = 60, .hw_value = RATE_6M },
41 { .bitrate = 90, .hw_value = RATE_9M },
42 { .bitrate = 120, .hw_value = RATE_12M },
43 { .bitrate = 180, .hw_value = RATE_18M },
44 { .bitrate = 240, .hw_value = RATE_24M },
45 { .bitrate = 360, .hw_value = RATE_36M },
46 { .bitrate = 480, .hw_value = RATE_48M },
47 { .bitrate = 540, .hw_value = RATE_54M },
48};
49
50static struct ieee80211_channel vnt_channels_2ghz[] = {
51 { .center_freq = 2412, .hw_value = 1 },
52 { .center_freq = 2417, .hw_value = 2 },
53 { .center_freq = 2422, .hw_value = 3 },
54 { .center_freq = 2427, .hw_value = 4 },
55 { .center_freq = 2432, .hw_value = 5 },
56 { .center_freq = 2437, .hw_value = 6 },
57 { .center_freq = 2442, .hw_value = 7 },
58 { .center_freq = 2447, .hw_value = 8 },
59 { .center_freq = 2452, .hw_value = 9 },
60 { .center_freq = 2457, .hw_value = 10 },
61 { .center_freq = 2462, .hw_value = 11 },
62 { .center_freq = 2467, .hw_value = 12 },
63 { .center_freq = 2472, .hw_value = 13 },
64 { .center_freq = 2484, .hw_value = 14 }
65};
66
67static struct ieee80211_channel vnt_channels_5ghz[] = {
68 { .center_freq = 4915, .hw_value = 15 },
69 { .center_freq = 4920, .hw_value = 16 },
70 { .center_freq = 4925, .hw_value = 17 },
71 { .center_freq = 4935, .hw_value = 18 },
72 { .center_freq = 4940, .hw_value = 19 },
73 { .center_freq = 4945, .hw_value = 20 },
74 { .center_freq = 4960, .hw_value = 21 },
75 { .center_freq = 4980, .hw_value = 22 },
76 { .center_freq = 5035, .hw_value = 23 },
77 { .center_freq = 5040, .hw_value = 24 },
78 { .center_freq = 5045, .hw_value = 25 },
79 { .center_freq = 5055, .hw_value = 26 },
80 { .center_freq = 5060, .hw_value = 27 },
81 { .center_freq = 5080, .hw_value = 28 },
82 { .center_freq = 5170, .hw_value = 29 },
83 { .center_freq = 5180, .hw_value = 30 },
84 { .center_freq = 5190, .hw_value = 31 },
85 { .center_freq = 5200, .hw_value = 32 },
86 { .center_freq = 5210, .hw_value = 33 },
87 { .center_freq = 5220, .hw_value = 34 },
88 { .center_freq = 5230, .hw_value = 35 },
89 { .center_freq = 5240, .hw_value = 36 },
90 { .center_freq = 5260, .hw_value = 37 },
91 { .center_freq = 5280, .hw_value = 38 },
92 { .center_freq = 5300, .hw_value = 39 },
93 { .center_freq = 5320, .hw_value = 40 },
94 { .center_freq = 5500, .hw_value = 41 },
95 { .center_freq = 5520, .hw_value = 42 },
96 { .center_freq = 5540, .hw_value = 43 },
97 { .center_freq = 5560, .hw_value = 44 },
98 { .center_freq = 5580, .hw_value = 45 },
99 { .center_freq = 5600, .hw_value = 46 },
100 { .center_freq = 5620, .hw_value = 47 },
101 { .center_freq = 5640, .hw_value = 48 },
102 { .center_freq = 5660, .hw_value = 49 },
103 { .center_freq = 5680, .hw_value = 50 },
104 { .center_freq = 5700, .hw_value = 51 },
105 { .center_freq = 5745, .hw_value = 52 },
106 { .center_freq = 5765, .hw_value = 53 },
107 { .center_freq = 5785, .hw_value = 54 },
108 { .center_freq = 5805, .hw_value = 55 },
109 { .center_freq = 5825, .hw_value = 56 }
110};
111
112static struct ieee80211_supported_band vnt_supported_2ghz_band = {
113 .channels = vnt_channels_2ghz,
114 .n_channels = ARRAY_SIZE(vnt_channels_2ghz),
115 .bitrates = vnt_rates_bg,
116 .n_bitrates = ARRAY_SIZE(vnt_rates_bg),
117};
118
119static struct ieee80211_supported_band vnt_supported_5ghz_band = {
120 .channels = vnt_channels_5ghz,
121 .n_channels = ARRAY_SIZE(vnt_channels_5ghz),
122 .bitrates = vnt_rates_a,
123 .n_bitrates = ARRAY_SIZE(vnt_rates_a),
124};
125
126void vnt_init_bands(struct vnt_private *priv)
127{
128 struct ieee80211_channel *ch;
129 int i;
130
131 switch (priv->byRFType) {
132 case RF_AIROHA7230:
133 case RF_UW2452:
134 case RF_NOTHING:
135 default:
136 ch = vnt_channels_5ghz;
137
138 for (i = 0; i < ARRAY_SIZE(vnt_channels_5ghz); i++) {
139 ch[i].max_power = 0x3f;
140 ch[i].flags = IEEE80211_CHAN_NO_HT40;
141 }
142
143 priv->hw->wiphy->bands[NL80211_BAND_5GHZ] =
144 &vnt_supported_5ghz_band;
145 /* fallthrough */
146 case RF_RFMD2959:
147 case RF_AIROHA:
148 case RF_AL2230S:
149 case RF_UW2451:
150 case RF_VT3226:
151 ch = vnt_channels_2ghz;
152
153 for (i = 0; i < ARRAY_SIZE(vnt_channels_2ghz); i++) {
154 ch[i].max_power = 0x3f;
155 ch[i].flags = IEEE80211_CHAN_NO_HT40;
156 }
157
158 priv->hw->wiphy->bands[NL80211_BAND_2GHZ] =
159 &vnt_supported_2ghz_band;
160 break;
161 }
162}
163
164/**
165 * set_channel() - Set NIC media channel
166 *
167 * @pDeviceHandler: The adapter to be set
168 * @uConnectionChannel: Channel to be set
169 *
170 * Return Value: true if succeeded; false if failed.
171 *
172 */
173bool set_channel(struct vnt_private *priv, struct ieee80211_channel *ch)
174{
175 bool ret = true;
176
177 if (priv->byCurrentCh == ch->hw_value)
178 return ret;
179
180 /* Set VGA to max sensitivity */
181 if (priv->bUpdateBBVGA &&
182 priv->byBBVGACurrent != priv->abyBBVGA[0]) {
183 priv->byBBVGACurrent = priv->abyBBVGA[0];
184
185 BBvSetVGAGainOffset(priv, priv->byBBVGACurrent);
186 }
187
188 /* clear NAV */
189 MACvRegBitsOn(priv->PortOffset, MAC_REG_MACCR, MACCR_CLRNAV);
190
191 /* TX_PE will reserve 3 us for MAX2829 A mode only,
192 * it is for better TX throughput
193 */
194
195 if (priv->byRFType == RF_AIROHA7230)
196 RFbAL7230SelectChannelPostProcess(priv, priv->byCurrentCh,
197 ch->hw_value);
198
199 priv->byCurrentCh = ch->hw_value;
200 ret &= RFbSelectChannel(priv, priv->byRFType,
201 ch->hw_value);
202
203 /* Init Synthesizer Table */
204 if (priv->bEnablePSMode)
205 RFvWriteWakeProgSyn(priv, priv->byRFType, ch->hw_value);
206
207 BBvSoftwareReset(priv);
208
209 if (priv->byLocalID > REV_ID_VT3253_B1) {
210 unsigned long flags;
211
212 spin_lock_irqsave(&priv->lock, flags);
213
214 /* set HW default power register */
215 MACvSelectPage1(priv->PortOffset);
216 RFbSetPower(priv, RATE_1M, priv->byCurrentCh);
217 VNSvOutPortB(priv->PortOffset + MAC_REG_PWRCCK,
218 priv->byCurPwr);
219 RFbSetPower(priv, RATE_6M, priv->byCurrentCh);
220 VNSvOutPortB(priv->PortOffset + MAC_REG_PWROFDM,
221 priv->byCurPwr);
222 MACvSelectPage0(priv->PortOffset);
223
224 spin_unlock_irqrestore(&priv->lock, flags);
225 }
226
227 if (priv->byBBType == BB_TYPE_11B)
228 RFbSetPower(priv, RATE_1M, priv->byCurrentCh);
229 else
230 RFbSetPower(priv, RATE_6M, priv->byCurrentCh);
231
232 return ret;
233}