2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
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.
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.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 static struct ieee80211_rate vnt_rates_bg[] = {
30 { .bitrate = 10, .hw_value = RATE_1M },
31 { .bitrate = 20, .hw_value = RATE_2M },
32 { .bitrate = 55, .hw_value = RATE_5M },
33 { .bitrate = 110, .hw_value = RATE_11M },
34 { .bitrate = 60, .hw_value = RATE_6M },
35 { .bitrate = 90, .hw_value = RATE_9M },
36 { .bitrate = 120, .hw_value = RATE_12M },
37 { .bitrate = 180, .hw_value = RATE_18M },
38 { .bitrate = 240, .hw_value = RATE_24M },
39 { .bitrate = 360, .hw_value = RATE_36M },
40 { .bitrate = 480, .hw_value = RATE_48M },
41 { .bitrate = 540, .hw_value = RATE_54M },
44 static struct ieee80211_rate vnt_rates_a[] = {
45 { .bitrate = 60, .hw_value = RATE_6M },
46 { .bitrate = 90, .hw_value = RATE_9M },
47 { .bitrate = 120, .hw_value = RATE_12M },
48 { .bitrate = 180, .hw_value = RATE_18M },
49 { .bitrate = 240, .hw_value = RATE_24M },
50 { .bitrate = 360, .hw_value = RATE_36M },
51 { .bitrate = 480, .hw_value = RATE_48M },
52 { .bitrate = 540, .hw_value = RATE_54M },
55 static struct ieee80211_channel vnt_channels_2ghz[] = {
56 { .center_freq = 2412, .hw_value = 1 },
57 { .center_freq = 2417, .hw_value = 2 },
58 { .center_freq = 2422, .hw_value = 3 },
59 { .center_freq = 2427, .hw_value = 4 },
60 { .center_freq = 2432, .hw_value = 5 },
61 { .center_freq = 2437, .hw_value = 6 },
62 { .center_freq = 2442, .hw_value = 7 },
63 { .center_freq = 2447, .hw_value = 8 },
64 { .center_freq = 2452, .hw_value = 9 },
65 { .center_freq = 2457, .hw_value = 10 },
66 { .center_freq = 2462, .hw_value = 11 },
67 { .center_freq = 2467, .hw_value = 12 },
68 { .center_freq = 2472, .hw_value = 13 },
69 { .center_freq = 2484, .hw_value = 14 }
72 static struct ieee80211_channel vnt_channels_5ghz[] = {
73 { .center_freq = 4915, .hw_value = 15 },
74 { .center_freq = 4920, .hw_value = 16 },
75 { .center_freq = 4925, .hw_value = 17 },
76 { .center_freq = 4935, .hw_value = 18 },
77 { .center_freq = 4940, .hw_value = 19 },
78 { .center_freq = 4945, .hw_value = 20 },
79 { .center_freq = 4960, .hw_value = 21 },
80 { .center_freq = 4980, .hw_value = 22 },
81 { .center_freq = 5035, .hw_value = 23 },
82 { .center_freq = 5040, .hw_value = 24 },
83 { .center_freq = 5045, .hw_value = 25 },
84 { .center_freq = 5055, .hw_value = 26 },
85 { .center_freq = 5060, .hw_value = 27 },
86 { .center_freq = 5080, .hw_value = 28 },
87 { .center_freq = 5170, .hw_value = 29 },
88 { .center_freq = 5180, .hw_value = 30 },
89 { .center_freq = 5190, .hw_value = 31 },
90 { .center_freq = 5200, .hw_value = 32 },
91 { .center_freq = 5210, .hw_value = 33 },
92 { .center_freq = 5220, .hw_value = 34 },
93 { .center_freq = 5230, .hw_value = 35 },
94 { .center_freq = 5240, .hw_value = 36 },
95 { .center_freq = 5260, .hw_value = 37 },
96 { .center_freq = 5280, .hw_value = 38 },
97 { .center_freq = 5300, .hw_value = 39 },
98 { .center_freq = 5320, .hw_value = 40 },
99 { .center_freq = 5500, .hw_value = 41 },
100 { .center_freq = 5520, .hw_value = 42 },
101 { .center_freq = 5540, .hw_value = 43 },
102 { .center_freq = 5560, .hw_value = 44 },
103 { .center_freq = 5580, .hw_value = 45 },
104 { .center_freq = 5600, .hw_value = 46 },
105 { .center_freq = 5620, .hw_value = 47 },
106 { .center_freq = 5640, .hw_value = 48 },
107 { .center_freq = 5660, .hw_value = 49 },
108 { .center_freq = 5680, .hw_value = 50 },
109 { .center_freq = 5700, .hw_value = 51 },
110 { .center_freq = 5745, .hw_value = 52 },
111 { .center_freq = 5765, .hw_value = 53 },
112 { .center_freq = 5785, .hw_value = 54 },
113 { .center_freq = 5805, .hw_value = 55 },
114 { .center_freq = 5825, .hw_value = 56 }
117 static struct ieee80211_supported_band vnt_supported_2ghz_band = {
118 .channels = vnt_channels_2ghz,
119 .n_channels = ARRAY_SIZE(vnt_channels_2ghz),
120 .bitrates = vnt_rates_bg,
121 .n_bitrates = ARRAY_SIZE(vnt_rates_bg),
124 static struct ieee80211_supported_band vnt_supported_5ghz_band = {
125 .channels = vnt_channels_5ghz,
126 .n_channels = ARRAY_SIZE(vnt_channels_5ghz),
127 .bitrates = vnt_rates_a,
128 .n_bitrates = ARRAY_SIZE(vnt_rates_a),
131 void vnt_init_bands(struct vnt_private *priv)
133 struct ieee80211_channel *ch;
136 switch (priv->byRFType) {
141 ch = vnt_channels_5ghz;
143 for (i = 0; i < ARRAY_SIZE(vnt_channels_5ghz); i++) {
144 ch[i].max_power = 0x3f;
145 ch[i].flags = IEEE80211_CHAN_NO_HT40;
148 priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
149 &vnt_supported_5ghz_band;
156 ch = vnt_channels_2ghz;
158 for (i = 0; i < ARRAY_SIZE(vnt_channels_2ghz); i++) {
159 ch[i].max_power = 0x3f;
160 ch[i].flags = IEEE80211_CHAN_NO_HT40;
163 priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
164 &vnt_supported_2ghz_band;
170 * is_channel_valid() - Is Country Channel Valid
171 * @ChanneIndex: defined as VT3253 MAC channel:
175 * 14 = 2.4G channel 14
176 * 15 = 4.9G channel 183
177 * 16 = 4.9G channel 184
179 * Output: true if the specified 5GHz band is allowed to be used,
181 * 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22)
183 * 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
184 * 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 (Value 23 ~ 56)
187 bool is_channel_valid(unsigned int ChannelIndex)
192 /* If Channel Index is invalid, return invalid */
193 if ((ChannelIndex > CB_MAX_CHANNEL) ||
194 (ChannelIndex == 0)) {
203 * channel_get_list() - Get Available Channel List for a given country
204 * @CountryCode: The country code defined in country.h
207 * pbyChannelTable: (QWORD *) correspondent bit mask
208 * of available channels
209 * 0x0000000000000001 means channel 1 is supported
210 * 0x0000000000000003 means channel 1,2 are supported
211 * 0x000000000000000F means channel 1,2,..15 are supported
214 bool channel_get_list(unsigned int uCountryCodeIdx, unsigned char *pbyChannelTable)
219 unsigned char get_channel_mapping(void *pDeviceHandler, unsigned char byChannelNumber, CARD_PHY_TYPE ePhyType)
224 unsigned char get_channel_number(void *pDeviceHandler, unsigned char byChannelIndex)
230 * set_channel() - Set NIC media channel
232 * @pDeviceHandler: The adapter to be set
233 * @uConnectionChannel: Channel to be set
235 * Return Value: true if succeeded; false if failed.
238 bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel)
240 struct vnt_private *pDevice = pDeviceHandler;
243 if (pDevice->byCurrentCh == uConnectionChannel)
247 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MACCR, MACCR_CLRNAV);
249 /* TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput */
251 if (pDevice->byRFType == RF_AIROHA7230)
252 RFbAL7230SelectChannelPostProcess(pDevice->PortOffset, pDevice->byCurrentCh, (unsigned char)uConnectionChannel);
254 pDevice->byCurrentCh = (unsigned char)uConnectionChannel;
255 bResult &= RFbSelectChannel(pDevice->PortOffset, pDevice->byRFType, (unsigned char)uConnectionChannel);
257 /* Init Synthesizer Table */
258 if (pDevice->bEnablePSMode)
259 RFvWriteWakeProgSyn(pDevice->PortOffset, pDevice->byRFType, uConnectionChannel);
261 BBvSoftwareReset(pDevice->PortOffset);
263 if (pDevice->byLocalID > REV_ID_VT3253_B1) {
264 /* set HW default power register */
265 MACvSelectPage1(pDevice->PortOffset);
266 RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh);
267 VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWRCCK, pDevice->byCurPwr);
268 RFbSetPower(pDevice, RATE_6M, pDevice->byCurrentCh);
269 VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWROFDM, pDevice->byCurPwr);
270 MACvSelectPage0(pDevice->PortOffset);
273 if (pDevice->byBBType == BB_TYPE_11B)
274 RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh);
276 RFbSetPower(pDevice, RATE_6M, pDevice->byCurrentCh);
282 * set_country_info() - Set Channel Info of Country
284 * Return Value: none.
288 void set_country_info(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, void *pIE)
294 * set_support_channels() - Set Support Channels IE defined in 802.11h
296 * @hDeviceContext: device structure point
298 * Return Value: none.
302 unsigned char set_support_channels(void *pDeviceHandler, unsigned char *pbyIEs)
304 unsigned char byLen = 0;
308 void set_country_IE(void *pDeviceHandler, void *pIE)
312 bool get_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex,
313 unsigned char *pbyChannelNumber, unsigned char *pbyMap)
318 void set_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex,
323 void clear_channel_map_info(void *pDeviceHandler)
328 unsigned char auto_channel_select(void *pDeviceHandler, CARD_PHY_TYPE ePHYType)
330 unsigned char byOptionChannel = 0;
331 return byOptionChannel;