iwlegacy: rename iwl to il
[deliverable/linux.git] / drivers / net / wireless / iwlegacy / iwl-eeprom.c
CommitLineData
be663ab6
WYG
1/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called LICENSE.GPL.
26 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *****************************************************************************/
62
63
64#include <linux/kernel.h>
65#include <linux/module.h>
66#include <linux/slab.h>
67#include <linux/init.h>
68
69#include <net/mac80211.h>
70
71#include "iwl-commands.h"
72#include "iwl-dev.h"
73#include "iwl-core.h"
74#include "iwl-debug.h"
75#include "iwl-eeprom.h"
76#include "iwl-io.h"
77
78/************************** EEPROM BANDS ****************************
79 *
ef33417d 80 * The iwlegacy_eeprom_band definitions below provide the mapping from the
be663ab6
WYG
81 * EEPROM contents to the specific channel number supported for each
82 * band.
83 *
e2ebc833 84 * For example, il_priv->eeprom.band_3_channels[4] from the band_3
be663ab6
WYG
85 * definition below maps to physical channel 42 in the 5.2GHz spectrum.
86 * The specific geography and calibration information for that channel
87 * is contained in the eeprom map itself.
88 *
89 * During init, we copy the eeprom information and channel map
90 * information into priv->channel_info_24/52 and priv->channel_map_24/52
91 *
92 * channel_map_24/52 provides the index in the channel_info array for a
93 * given channel. We have to have two separate maps as there is channel
94 * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and
95 * band_2
96 *
97 * A value of 0xff stored in the channel_map indicates that the channel
98 * is not supported by the hardware at all.
99 *
100 * A value of 0xfe in the channel_map indicates that the channel is not
101 * valid for Tx with the current hardware. This means that
102 * while the system can tune and receive on a given channel, it may not
103 * be able to associate or transmit any frames on that
104 * channel. There is no corresponding channel information for that
105 * entry.
106 *
107 *********************************************************************/
108
109/* 2.4 GHz */
ef33417d 110const u8 iwlegacy_eeprom_band_1[14] = {
be663ab6
WYG
111 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
112};
113
114/* 5.2 GHz bands */
ef33417d 115static const u8 iwlegacy_eeprom_band_2[] = { /* 4915-5080MHz */
be663ab6
WYG
116 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16
117};
118
ef33417d 119static const u8 iwlegacy_eeprom_band_3[] = { /* 5170-5320MHz */
be663ab6
WYG
120 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
121};
122
ef33417d 123static const u8 iwlegacy_eeprom_band_4[] = { /* 5500-5700MHz */
be663ab6
WYG
124 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
125};
126
ef33417d 127static const u8 iwlegacy_eeprom_band_5[] = { /* 5725-5825MHz */
be663ab6
WYG
128 145, 149, 153, 157, 161, 165
129};
130
ef33417d 131static const u8 iwlegacy_eeprom_band_6[] = { /* 2.4 ht40 channel */
be663ab6
WYG
132 1, 2, 3, 4, 5, 6, 7
133};
134
ef33417d 135static const u8 iwlegacy_eeprom_band_7[] = { /* 5.2 ht40 channel */
be663ab6
WYG
136 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157
137};
138
139/******************************************************************************
140 *
141 * EEPROM related functions
142 *
143******************************************************************************/
144
e2ebc833 145static int il_eeprom_verify_signature(struct il_priv *priv)
be663ab6 146{
e2ebc833 147 u32 gp = il_read32(priv, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK;
be663ab6
WYG
148 int ret = 0;
149
e2ebc833 150 IL_DEBUG_EEPROM(priv, "EEPROM signature=0x%08x\n", gp);
be663ab6
WYG
151 switch (gp) {
152 case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K:
153 case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K:
154 break;
155 default:
e2ebc833 156 IL_ERR(priv, "bad EEPROM signature,"
be663ab6
WYG
157 "EEPROM_GP=0x%08x\n", gp);
158 ret = -ENOENT;
159 break;
160 }
161 return ret;
162}
163
164const u8
e2ebc833 165*il_eeprom_query_addr(const struct il_priv *priv, size_t offset)
be663ab6
WYG
166{
167 BUG_ON(offset >= priv->cfg->base_params->eeprom_size);
168 return &priv->eeprom[offset];
169}
e2ebc833 170EXPORT_SYMBOL(il_eeprom_query_addr);
be663ab6 171
e2ebc833 172u16 il_eeprom_query16(const struct il_priv *priv, size_t offset)
be663ab6
WYG
173{
174 if (!priv->eeprom)
175 return 0;
176 return (u16)priv->eeprom[offset] | ((u16)priv->eeprom[offset + 1] << 8);
177}
e2ebc833 178EXPORT_SYMBOL(il_eeprom_query16);
be663ab6
WYG
179
180/**
e2ebc833 181 * il_eeprom_init - read EEPROM contents
be663ab6
WYG
182 *
183 * Load the EEPROM contents from adapter into priv->eeprom
184 *
185 * NOTE: This routine uses the non-debug IO access functions.
186 */
e2ebc833 187int il_eeprom_init(struct il_priv *priv)
be663ab6
WYG
188{
189 __le16 *e;
e2ebc833 190 u32 gp = il_read32(priv, CSR_EEPROM_GP);
be663ab6
WYG
191 int sz;
192 int ret;
193 u16 addr;
194
195 /* allocate eeprom */
196 sz = priv->cfg->base_params->eeprom_size;
e2ebc833 197 IL_DEBUG_EEPROM(priv, "NVM size = %d\n", sz);
be663ab6
WYG
198 priv->eeprom = kzalloc(sz, GFP_KERNEL);
199 if (!priv->eeprom) {
200 ret = -ENOMEM;
201 goto alloc_err;
202 }
203 e = (__le16 *)priv->eeprom;
204
205 priv->cfg->ops->lib->apm_ops.init(priv);
206
e2ebc833 207 ret = il_eeprom_verify_signature(priv);
be663ab6 208 if (ret < 0) {
e2ebc833 209 IL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp);
be663ab6
WYG
210 ret = -ENOENT;
211 goto err;
212 }
213
214 /* Make sure driver (instead of uCode) is allowed to read EEPROM */
215 ret = priv->cfg->ops->lib->eeprom_ops.acquire_semaphore(priv);
216 if (ret < 0) {
e2ebc833 217 IL_ERR(priv, "Failed to acquire EEPROM semaphore.\n");
be663ab6
WYG
218 ret = -ENOENT;
219 goto err;
220 }
221
222 /* eeprom is an array of 16bit values */
223 for (addr = 0; addr < sz; addr += sizeof(u16)) {
224 u32 r;
225
e2ebc833 226 _il_write32(priv, CSR_EEPROM_REG,
be663ab6
WYG
227 CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
228
e2ebc833 229 ret = il_poll_bit(priv, CSR_EEPROM_REG,
be663ab6
WYG
230 CSR_EEPROM_REG_READ_VALID_MSK,
231 CSR_EEPROM_REG_READ_VALID_MSK,
e2ebc833 232 IL_EEPROM_ACCESS_TIMEOUT);
be663ab6 233 if (ret < 0) {
e2ebc833 234 IL_ERR(priv, "Time out reading EEPROM[%d]\n",
be663ab6
WYG
235 addr);
236 goto done;
237 }
e2ebc833 238 r = _il_read_direct32(priv, CSR_EEPROM_REG);
be663ab6
WYG
239 e[addr / 2] = cpu_to_le16(r >> 16);
240 }
241
e2ebc833 242 IL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n",
be663ab6 243 "EEPROM",
e2ebc833 244 il_eeprom_query16(priv, EEPROM_VERSION));
be663ab6
WYG
245
246 ret = 0;
247done:
248 priv->cfg->ops->lib->eeprom_ops.release_semaphore(priv);
249
250err:
251 if (ret)
e2ebc833 252 il_eeprom_free(priv);
be663ab6 253 /* Reset chip to save power until we load uCode during "up". */
e2ebc833 254 il_apm_stop(priv);
be663ab6
WYG
255alloc_err:
256 return ret;
257}
e2ebc833 258EXPORT_SYMBOL(il_eeprom_init);
be663ab6 259
e2ebc833 260void il_eeprom_free(struct il_priv *priv)
be663ab6
WYG
261{
262 kfree(priv->eeprom);
263 priv->eeprom = NULL;
264}
e2ebc833 265EXPORT_SYMBOL(il_eeprom_free);
be663ab6 266
e2ebc833 267static void il_init_band_reference(const struct il_priv *priv,
be663ab6 268 int eep_band, int *eeprom_ch_count,
e2ebc833 269 const struct il_eeprom_channel **eeprom_ch_info,
be663ab6
WYG
270 const u8 **eeprom_ch_index)
271{
272 u32 offset = priv->cfg->ops->lib->
273 eeprom_ops.regulatory_bands[eep_band - 1];
274 switch (eep_band) {
275 case 1: /* 2.4GHz band */
ef33417d 276 *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_1);
e2ebc833
SG
277 *eeprom_ch_info = (struct il_eeprom_channel *)
278 il_eeprom_query_addr(priv, offset);
ef33417d 279 *eeprom_ch_index = iwlegacy_eeprom_band_1;
be663ab6
WYG
280 break;
281 case 2: /* 4.9GHz band */
ef33417d 282 *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_2);
e2ebc833
SG
283 *eeprom_ch_info = (struct il_eeprom_channel *)
284 il_eeprom_query_addr(priv, offset);
ef33417d 285 *eeprom_ch_index = iwlegacy_eeprom_band_2;
be663ab6
WYG
286 break;
287 case 3: /* 5.2GHz band */
ef33417d 288 *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_3);
e2ebc833
SG
289 *eeprom_ch_info = (struct il_eeprom_channel *)
290 il_eeprom_query_addr(priv, offset);
ef33417d 291 *eeprom_ch_index = iwlegacy_eeprom_band_3;
be663ab6
WYG
292 break;
293 case 4: /* 5.5GHz band */
ef33417d 294 *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_4);
e2ebc833
SG
295 *eeprom_ch_info = (struct il_eeprom_channel *)
296 il_eeprom_query_addr(priv, offset);
ef33417d 297 *eeprom_ch_index = iwlegacy_eeprom_band_4;
be663ab6
WYG
298 break;
299 case 5: /* 5.7GHz band */
ef33417d 300 *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_5);
e2ebc833
SG
301 *eeprom_ch_info = (struct il_eeprom_channel *)
302 il_eeprom_query_addr(priv, offset);
ef33417d 303 *eeprom_ch_index = iwlegacy_eeprom_band_5;
be663ab6
WYG
304 break;
305 case 6: /* 2.4GHz ht40 channels */
ef33417d 306 *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_6);
e2ebc833
SG
307 *eeprom_ch_info = (struct il_eeprom_channel *)
308 il_eeprom_query_addr(priv, offset);
ef33417d 309 *eeprom_ch_index = iwlegacy_eeprom_band_6;
be663ab6
WYG
310 break;
311 case 7: /* 5 GHz ht40 channels */
ef33417d 312 *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_7);
e2ebc833
SG
313 *eeprom_ch_info = (struct il_eeprom_channel *)
314 il_eeprom_query_addr(priv, offset);
ef33417d 315 *eeprom_ch_index = iwlegacy_eeprom_band_7;
be663ab6
WYG
316 break;
317 default:
318 BUG();
be663ab6
WYG
319 }
320}
321
322#define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \
323 ? # x " " : "")
324/**
e2ebc833 325 * il_mod_ht40_chan_info - Copy ht40 channel info into driver's priv.
be663ab6
WYG
326 *
327 * Does not set up a command, or touch hardware.
328 */
e2ebc833 329static int il_mod_ht40_chan_info(struct il_priv *priv,
be663ab6 330 enum ieee80211_band band, u16 channel,
e2ebc833 331 const struct il_eeprom_channel *eeprom_ch,
be663ab6
WYG
332 u8 clear_ht40_extension_channel)
333{
e2ebc833 334 struct il_channel_info *ch_info;
be663ab6 335
e2ebc833
SG
336 ch_info = (struct il_channel_info *)
337 il_get_channel_info(priv, band, channel);
be663ab6 338
e2ebc833 339 if (!il_is_channel_valid(ch_info))
be663ab6
WYG
340 return -1;
341
e2ebc833 342 IL_DEBUG_EEPROM(priv, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):"
be663ab6
WYG
343 " Ad-Hoc %ssupported\n",
344 ch_info->channel,
e2ebc833 345 il_is_channel_a_band(ch_info) ?
be663ab6
WYG
346 "5.2" : "2.4",
347 CHECK_AND_PRINT(IBSS),
348 CHECK_AND_PRINT(ACTIVE),
349 CHECK_AND_PRINT(RADAR),
350 CHECK_AND_PRINT(WIDE),
351 CHECK_AND_PRINT(DFS),
352 eeprom_ch->flags,
353 eeprom_ch->max_power_avg,
354 ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS)
355 && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ?
356 "" : "not ");
357
358 ch_info->ht40_eeprom = *eeprom_ch;
359 ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg;
360 ch_info->ht40_flags = eeprom_ch->flags;
361 if (eeprom_ch->flags & EEPROM_CHANNEL_VALID)
362 ch_info->ht40_extension_channel &=
363 ~clear_ht40_extension_channel;
364
365 return 0;
366}
367
368#define CHECK_AND_PRINT_I(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \
369 ? # x " " : "")
370
371/**
e2ebc833 372 * il_init_channel_map - Set up driver's info for all possible channels
be663ab6 373 */
e2ebc833 374int il_init_channel_map(struct il_priv *priv)
be663ab6
WYG
375{
376 int eeprom_ch_count = 0;
377 const u8 *eeprom_ch_index = NULL;
e2ebc833 378 const struct il_eeprom_channel *eeprom_ch_info = NULL;
be663ab6 379 int band, ch;
e2ebc833 380 struct il_channel_info *ch_info;
be663ab6
WYG
381
382 if (priv->channel_count) {
e2ebc833 383 IL_DEBUG_EEPROM(priv, "Channel map already initialized.\n");
be663ab6
WYG
384 return 0;
385 }
386
e2ebc833 387 IL_DEBUG_EEPROM(priv, "Initializing regulatory info from EEPROM\n");
be663ab6
WYG
388
389 priv->channel_count =
ef33417d
JL
390 ARRAY_SIZE(iwlegacy_eeprom_band_1) +
391 ARRAY_SIZE(iwlegacy_eeprom_band_2) +
392 ARRAY_SIZE(iwlegacy_eeprom_band_3) +
393 ARRAY_SIZE(iwlegacy_eeprom_band_4) +
394 ARRAY_SIZE(iwlegacy_eeprom_band_5);
be663ab6 395
e2ebc833 396 IL_DEBUG_EEPROM(priv, "Parsing data for %d channels.\n",
be663ab6
WYG
397 priv->channel_count);
398
e2ebc833 399 priv->channel_info = kzalloc(sizeof(struct il_channel_info) *
be663ab6
WYG
400 priv->channel_count, GFP_KERNEL);
401 if (!priv->channel_info) {
e2ebc833 402 IL_ERR(priv, "Could not allocate channel_info\n");
be663ab6
WYG
403 priv->channel_count = 0;
404 return -ENOMEM;
405 }
406
407 ch_info = priv->channel_info;
408
409 /* Loop through the 5 EEPROM bands adding them in order to the
410 * channel map we maintain (that contains additional information than
411 * what just in the EEPROM) */
412 for (band = 1; band <= 5; band++) {
413
e2ebc833 414 il_init_band_reference(priv, band, &eeprom_ch_count,
be663ab6
WYG
415 &eeprom_ch_info, &eeprom_ch_index);
416
417 /* Loop through each band adding each of the channels */
418 for (ch = 0; ch < eeprom_ch_count; ch++) {
419 ch_info->channel = eeprom_ch_index[ch];
420 ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ :
421 IEEE80211_BAND_5GHZ;
422
423 /* permanently store EEPROM's channel regulatory flags
424 * and max power in channel info database. */
425 ch_info->eeprom = eeprom_ch_info[ch];
426
427 /* Copy the run-time flags so they are there even on
428 * invalid channels */
429 ch_info->flags = eeprom_ch_info[ch].flags;
430 /* First write that ht40 is not enabled, and then enable
431 * one by one */
432 ch_info->ht40_extension_channel =
433 IEEE80211_CHAN_NO_HT40;
434
e2ebc833
SG
435 if (!(il_is_channel_valid(ch_info))) {
436 IL_DEBUG_EEPROM(priv,
be663ab6
WYG
437 "Ch. %d Flags %x [%sGHz] - "
438 "No traffic\n",
439 ch_info->channel,
440 ch_info->flags,
e2ebc833 441 il_is_channel_a_band(ch_info) ?
be663ab6
WYG
442 "5.2" : "2.4");
443 ch_info++;
444 continue;
445 }
446
447 /* Initialize regulatory-based run-time data */
448 ch_info->max_power_avg = ch_info->curr_txpow =
449 eeprom_ch_info[ch].max_power_avg;
450 ch_info->scan_power = eeprom_ch_info[ch].max_power_avg;
451 ch_info->min_power = 0;
452
e2ebc833 453 IL_DEBUG_EEPROM(priv, "Ch. %d [%sGHz] "
be663ab6
WYG
454 "%s%s%s%s%s%s(0x%02x %ddBm):"
455 " Ad-Hoc %ssupported\n",
456 ch_info->channel,
e2ebc833 457 il_is_channel_a_band(ch_info) ?
be663ab6
WYG
458 "5.2" : "2.4",
459 CHECK_AND_PRINT_I(VALID),
460 CHECK_AND_PRINT_I(IBSS),
461 CHECK_AND_PRINT_I(ACTIVE),
462 CHECK_AND_PRINT_I(RADAR),
463 CHECK_AND_PRINT_I(WIDE),
464 CHECK_AND_PRINT_I(DFS),
465 eeprom_ch_info[ch].flags,
466 eeprom_ch_info[ch].max_power_avg,
467 ((eeprom_ch_info[ch].
468 flags & EEPROM_CHANNEL_IBSS)
469 && !(eeprom_ch_info[ch].
470 flags & EEPROM_CHANNEL_RADAR))
471 ? "" : "not ");
472
be663ab6
WYG
473 ch_info++;
474 }
475 }
476
477 /* Check if we do have HT40 channels */
478 if (priv->cfg->ops->lib->eeprom_ops.regulatory_bands[5] ==
479 EEPROM_REGULATORY_BAND_NO_HT40 &&
480 priv->cfg->ops->lib->eeprom_ops.regulatory_bands[6] ==
481 EEPROM_REGULATORY_BAND_NO_HT40)
482 return 0;
483
484 /* Two additional EEPROM bands for 2.4 and 5 GHz HT40 channels */
485 for (band = 6; band <= 7; band++) {
486 enum ieee80211_band ieeeband;
487
e2ebc833 488 il_init_band_reference(priv, band, &eeprom_ch_count,
be663ab6
WYG
489 &eeprom_ch_info, &eeprom_ch_index);
490
491 /* EEPROM band 6 is 2.4, band 7 is 5 GHz */
492 ieeeband =
493 (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
494
495 /* Loop through each band adding each of the channels */
496 for (ch = 0; ch < eeprom_ch_count; ch++) {
497 /* Set up driver's info for lower half */
e2ebc833 498 il_mod_ht40_chan_info(priv, ieeeband,
be663ab6
WYG
499 eeprom_ch_index[ch],
500 &eeprom_ch_info[ch],
501 IEEE80211_CHAN_NO_HT40PLUS);
502
503 /* Set up driver's info for upper half */
e2ebc833 504 il_mod_ht40_chan_info(priv, ieeeband,
be663ab6
WYG
505 eeprom_ch_index[ch] + 4,
506 &eeprom_ch_info[ch],
507 IEEE80211_CHAN_NO_HT40MINUS);
508 }
509 }
510
511 return 0;
512}
e2ebc833 513EXPORT_SYMBOL(il_init_channel_map);
be663ab6
WYG
514
515/*
e2ebc833 516 * il_free_channel_map - undo allocations in il_init_channel_map
be663ab6 517 */
e2ebc833 518void il_free_channel_map(struct il_priv *priv)
be663ab6
WYG
519{
520 kfree(priv->channel_info);
521 priv->channel_count = 0;
522}
e2ebc833 523EXPORT_SYMBOL(il_free_channel_map);
be663ab6
WYG
524
525/**
e2ebc833 526 * il_get_channel_info - Find driver's private channel info
be663ab6
WYG
527 *
528 * Based on band and channel number.
529 */
530const struct
e2ebc833 531il_channel_info *il_get_channel_info(const struct il_priv *priv,
be663ab6
WYG
532 enum ieee80211_band band, u16 channel)
533{
534 int i;
535
536 switch (band) {
537 case IEEE80211_BAND_5GHZ:
538 for (i = 14; i < priv->channel_count; i++) {
539 if (priv->channel_info[i].channel == channel)
540 return &priv->channel_info[i];
541 }
542 break;
543 case IEEE80211_BAND_2GHZ:
544 if (channel >= 1 && channel <= 14)
545 return &priv->channel_info[channel - 1];
546 break;
547 default:
548 BUG();
549 }
550
551 return NULL;
552}
e2ebc833 553EXPORT_SYMBOL(il_get_channel_info);
This page took 0.146899 seconds and 5 git commands to generate.