blob: e2d80849001f5c9f4ac673ffa1bd30a387018a08 [file] [log] [blame]
Assaf Krauss34cf6ff2008-03-06 10:40:20 -08001/******************************************************************************
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 *
Wey-Yi Guy4e318262011-12-27 11:21:32 -08008 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
Assaf Krauss34cf6ff2008-03-06 10:40:20 -08009 *
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:
Winkler, Tomas759ef892008-12-09 11:28:58 -080028 * Intel Linux Wireless <ilw@linux.intel.com>
Assaf Krauss34cf6ff2008-03-06 10:40:20 -080029 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
Wey-Yi Guy4e318262011-12-27 11:21:32 -080033 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
Assaf Krauss34cf6ff2008-03-06 10:40:20 -080034 * 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>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090066#include <linux/slab.h>
Assaf Krauss34cf6ff2008-03-06 10:40:20 -080067#include <linux/init.h>
68
69#include <net/mac80211.h>
70
Tomas Winkler5a36ba02008-04-24 11:55:37 -070071#include "iwl-commands.h"
Tomas Winkler3e0d4cb2008-04-24 11:55:38 -070072#include "iwl-dev.h"
Assaf Krauss34cf6ff2008-03-06 10:40:20 -080073#include "iwl-core.h"
Tomas Winkler0a6857e2008-03-12 16:58:49 -070074#include "iwl-debug.h"
Wey-Yi Guy701cb092011-09-15 11:46:41 -070075#include "iwl-agn.h"
Assaf Krauss34cf6ff2008-03-06 10:40:20 -080076#include "iwl-eeprom.h"
Tomas Winkler3395f6e2008-03-25 16:33:37 -070077#include "iwl-io.h"
Johannes Bergeae63b82012-03-06 13:31:06 -080078#include "iwl-prph.h"
Assaf Krauss34cf6ff2008-03-06 10:40:20 -080079
Assaf Kraussbf85ea42008-03-14 10:38:49 -070080/************************** EEPROM BANDS ****************************
81 *
82 * The iwl_eeprom_band definitions below provide the mapping from the
83 * EEPROM contents to the specific channel number supported for each
84 * band.
85 *
86 * For example, iwl_priv->eeprom.band_3_channels[4] from the band_3
87 * definition below maps to physical channel 42 in the 5.2GHz spectrum.
88 * The specific geography and calibration information for that channel
89 * is contained in the eeprom map itself.
90 *
91 * During init, we copy the eeprom information and channel map
92 * information into priv->channel_info_24/52 and priv->channel_map_24/52
93 *
94 * channel_map_24/52 provides the index in the channel_info array for a
95 * given channel. We have to have two separate maps as there is channel
96 * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and
97 * band_2
98 *
99 * A value of 0xff stored in the channel_map indicates that the channel
100 * is not supported by the hardware at all.
101 *
102 * A value of 0xfe in the channel_map indicates that the channel is not
103 * valid for Tx with the current hardware. This means that
104 * while the system can tune and receive on a given channel, it may not
105 * be able to associate or transmit any frames on that
106 * channel. There is no corresponding channel information for that
107 * entry.
108 *
109 *********************************************************************/
110
111/* 2.4 GHz */
112const u8 iwl_eeprom_band_1[14] = {
113 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
114};
115
116/* 5.2 GHz bands */
117static const u8 iwl_eeprom_band_2[] = { /* 4915-5080MHz */
118 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16
119};
120
121static const u8 iwl_eeprom_band_3[] = { /* 5170-5320MHz */
122 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
123};
124
125static const u8 iwl_eeprom_band_4[] = { /* 5500-5700MHz */
126 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
127};
128
129static const u8 iwl_eeprom_band_5[] = { /* 5725-5825MHz */
130 145, 149, 153, 157, 161, 165
131};
132
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700133static const u8 iwl_eeprom_band_6[] = { /* 2.4 ht40 channel */
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700134 1, 2, 3, 4, 5, 6, 7
135};
136
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700137static const u8 iwl_eeprom_band_7[] = { /* 5.2 ht40 channel */
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700138 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157
139};
140
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800141/******************************************************************************
142 *
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700143 * generic NVM functions
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800144 *
145******************************************************************************/
146
Don Fry16b80b72011-04-20 15:25:14 -0700147/*
148 * The device's EEPROM semaphore prevents conflicts between driver and uCode
149 * when accessing the EEPROM; each access is a series of pulses to/from the
150 * EEPROM chip, not a single event, so even reads could conflict if they
151 * weren't arbitrated by the semaphore.
152 */
Emmanuel Grumbach90304742012-02-13 11:17:57 +0200153
154#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
155#define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
156
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200157static int iwl_eeprom_acquire_semaphore(struct iwl_trans *trans)
Don Fry16b80b72011-04-20 15:25:14 -0700158{
159 u16 count;
160 int ret;
161
162 for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) {
163 /* Request semaphore */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200164 iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG,
Don Fry16b80b72011-04-20 15:25:14 -0700165 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
166
167 /* See if we got it */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200168 ret = iwl_poll_bit(trans, CSR_HW_IF_CONFIG_REG,
Don Fry16b80b72011-04-20 15:25:14 -0700169 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
170 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
171 EEPROM_SEM_TIMEOUT);
172 if (ret >= 0) {
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200173 IWL_DEBUG_EEPROM(trans,
Don Fry16b80b72011-04-20 15:25:14 -0700174 "Acquired semaphore after %d tries.\n",
175 count+1);
176 return ret;
177 }
178 }
179
180 return ret;
181}
182
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200183static void iwl_eeprom_release_semaphore(struct iwl_trans *trans)
Don Fry16b80b72011-04-20 15:25:14 -0700184{
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200185 iwl_clear_bit(trans, CSR_HW_IF_CONFIG_REG,
Don Fry16b80b72011-04-20 15:25:14 -0700186 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
187
188}
189
Don Fry97b52cf2011-11-10 06:55:27 -0800190static int iwl_eeprom_verify_signature(struct iwl_trans *trans)
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800191{
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200192 u32 gp = iwl_read32(trans, CSR_EEPROM_GP) &
193 CSR_EEPROM_GP_VALID_MSK;
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700194 int ret = 0;
195
Don Fry97b52cf2011-11-10 06:55:27 -0800196 IWL_DEBUG_EEPROM(trans, "EEPROM signature=0x%08x\n", gp);
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700197 switch (gp) {
198 case CSR_EEPROM_GP_BAD_SIG_EEP_GOOD_SIG_OTP:
Don Fry97b52cf2011-11-10 06:55:27 -0800199 if (trans->nvm_device_type != NVM_DEVICE_TYPE_OTP) {
200 IWL_ERR(trans, "EEPROM with bad signature: 0x%08x\n",
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700201 gp);
202 ret = -ENOENT;
203 }
204 break;
205 case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K:
206 case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K:
Don Fry97b52cf2011-11-10 06:55:27 -0800207 if (trans->nvm_device_type != NVM_DEVICE_TYPE_EEPROM) {
208 IWL_ERR(trans, "OTP with bad signature: 0x%08x\n", gp);
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700209 ret = -ENOENT;
210 }
211 break;
212 case CSR_EEPROM_GP_BAD_SIGNATURE_BOTH_EEP_AND_OTP:
213 default:
Don Fry97b52cf2011-11-10 06:55:27 -0800214 IWL_ERR(trans, "bad EEPROM/OTP signature, type=%s, "
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700215 "EEPROM_GP=0x%08x\n",
Don Fry97b52cf2011-11-10 06:55:27 -0800216 (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP)
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700217 ? "OTP" : "EEPROM", gp);
218 ret = -ENOENT;
219 break;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800220 }
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700221 return ret;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800222}
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800223
Don Fryab36eab2011-11-30 15:37:32 -0800224u16 iwl_eeprom_query16(const struct iwl_shared *shrd, size_t offset)
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700225{
Don Fryab36eab2011-11-30 15:37:32 -0800226 if (!shrd->eeprom)
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700227 return 0;
Don Fryab36eab2011-11-30 15:37:32 -0800228 return (u16)shrd->eeprom[offset] | ((u16)shrd->eeprom[offset + 1] << 8);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700229}
230
231int iwl_eeprom_check_version(struct iwl_priv *priv)
232{
233 u16 eeprom_ver;
234 u16 calib_ver;
235
Don Fryab36eab2011-11-30 15:37:32 -0800236 eeprom_ver = iwl_eeprom_query16(priv->shrd, EEPROM_VERSION);
237 calib_ver = iwl_eeprom_calib_version(priv->shrd);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700238
Don Fry38622412011-12-16 07:07:36 -0800239 if (eeprom_ver < cfg(priv)->eeprom_ver ||
240 calib_ver < cfg(priv)->eeprom_calib_ver)
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700241 goto err;
242
243 IWL_INFO(priv, "device EEPROM VER=0x%x, CALIB=0x%x\n",
244 eeprom_ver, calib_ver);
245
246 return 0;
247err:
248 IWL_ERR(priv, "Unsupported (too old) EEPROM VER=0x%x < 0x%x "
249 "CALIB=0x%x < 0x%x\n",
Don Fry38622412011-12-16 07:07:36 -0800250 eeprom_ver, cfg(priv)->eeprom_ver,
251 calib_ver, cfg(priv)->eeprom_calib_ver);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700252 return -EINVAL;
253
254}
255
Johannes Berg54708d82012-03-05 11:24:31 -0800256int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700257{
Don Fryab36eab2011-11-30 15:37:32 -0800258 struct iwl_shared *shrd = priv->shrd;
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700259 u16 radio_cfg;
260
Johannes Berg54708d82012-03-05 11:24:31 -0800261 hw_params(priv).sku = iwl_eeprom_query16(shrd, EEPROM_SKU_CAP);
262 if (hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE &&
263 !cfg(priv)->ht_params) {
264 IWL_ERR(priv, "Invalid 11n configuration\n");
265 return -EINVAL;
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700266 }
Johannes Berg54708d82012-03-05 11:24:31 -0800267
268 if (!hw_params(priv).sku) {
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700269 IWL_ERR(priv, "Invalid device sku\n");
270 return -EINVAL;
271 }
272
Johannes Berg54708d82012-03-05 11:24:31 -0800273 IWL_INFO(priv, "Device SKU: 0x%X\n", hw_params(priv).sku);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700274
Johannes Berg7e79a392012-03-05 11:24:32 -0800275 radio_cfg = iwl_eeprom_query16(shrd, EEPROM_RADIO_CONFIG);
276
277 hw_params(priv).valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg);
278 hw_params(priv).valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg);
279
280 /* check overrides (some devices have wrong EEPROM) */
281 if (cfg(priv)->valid_tx_ant)
282 hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
283 if (cfg(priv)->valid_rx_ant)
284 hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
285
286 if (!hw_params(priv).valid_tx_ant || !hw_params(priv).valid_rx_ant) {
287 IWL_ERR(priv, "Invalid chain (0x%X, 0x%X)\n",
288 hw_params(priv).valid_tx_ant,
289 hw_params(priv).valid_rx_ant);
290 return -EINVAL;
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700291 }
Johannes Berg7e79a392012-03-05 11:24:32 -0800292
293 IWL_INFO(priv, "Valid Tx ant: 0x%X, Valid Rx ant: 0x%X\n",
294 hw_params(priv).valid_tx_ant, hw_params(priv).valid_rx_ant);
295
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700296 return 0;
297}
298
Don Fryab36eab2011-11-30 15:37:32 -0800299void iwl_eeprom_get_mac(const struct iwl_shared *shrd, u8 *mac)
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700300{
Don Fryab36eab2011-11-30 15:37:32 -0800301 const u8 *addr = iwl_eeprom_query_addr(shrd,
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700302 EEPROM_MAC_ADDRESS);
303 memcpy(mac, addr, ETH_ALEN);
304}
305
306/******************************************************************************
307 *
308 * OTP related functions
309 *
310******************************************************************************/
311
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200312static void iwl_set_otp_access(struct iwl_trans *trans,
313 enum iwl_access_mode mode)
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700314{
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200315 iwl_read32(trans, CSR_OTP_GP_REG);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700316
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700317 if (mode == IWL_OTP_ACCESS_ABSOLUTE)
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200318 iwl_clear_bit(trans, CSR_OTP_GP_REG,
Johannes Berg70817b52011-05-11 03:29:25 -0700319 CSR_OTP_GP_REG_OTP_ACCESS_MODE);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700320 else
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200321 iwl_set_bit(trans, CSR_OTP_GP_REG,
Johannes Berg70817b52011-05-11 03:29:25 -0700322 CSR_OTP_GP_REG_OTP_ACCESS_MODE);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700323}
324
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200325static int iwl_get_nvm_type(struct iwl_trans *trans, u32 hw_rev)
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700326{
327 u32 otpgp;
328 int nvm_type;
329
330 /* OTP only valid for CP/PP and after */
Johannes Berge98a1302011-04-05 09:42:08 -0700331 switch (hw_rev & CSR_HW_REV_TYPE_MSK) {
Wey-Yi Guyb23a0522009-07-17 09:30:21 -0700332 case CSR_HW_REV_TYPE_NONE:
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200333 IWL_ERR(trans, "Unknown hardware type\n");
Wey-Yi Guyb23a0522009-07-17 09:30:21 -0700334 return -ENOENT;
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700335 case CSR_HW_REV_TYPE_5300:
336 case CSR_HW_REV_TYPE_5350:
337 case CSR_HW_REV_TYPE_5100:
338 case CSR_HW_REV_TYPE_5150:
339 nvm_type = NVM_DEVICE_TYPE_EEPROM;
340 break;
341 default:
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200342 otpgp = iwl_read32(trans, CSR_OTP_GP_REG);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700343 if (otpgp & CSR_OTP_GP_REG_DEVICE_SELECT)
344 nvm_type = NVM_DEVICE_TYPE_OTP;
345 else
346 nvm_type = NVM_DEVICE_TYPE_EEPROM;
347 break;
348 }
349 return nvm_type;
350}
351
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200352static int iwl_init_otp_access(struct iwl_trans *trans)
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700353{
354 int ret;
355
356 /* Enable 40MHz radio clock */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200357 iwl_write32(trans, CSR_GP_CNTRL,
358 iwl_read32(trans, CSR_GP_CNTRL) |
Johannes Berg02a7fa02011-04-05 09:42:12 -0700359 CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700360
361 /* wait for clock to be ready */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200362 ret = iwl_poll_bit(trans, CSR_GP_CNTRL,
Johannes Berg02a7fa02011-04-05 09:42:12 -0700363 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
364 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
365 25000);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700366 if (ret < 0)
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200367 IWL_ERR(trans, "Time out access OTP\n");
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700368 else {
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200369 iwl_set_bits_prph(trans, APMG_PS_CTRL_REG,
Reinette Chatred77b0342009-05-22 14:37:55 -0700370 APMG_PS_CTRL_VAL_RESET_REQ);
371 udelay(5);
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200372 iwl_clear_bits_prph(trans, APMG_PS_CTRL_REG,
Reinette Chatred77b0342009-05-22 14:37:55 -0700373 APMG_PS_CTRL_VAL_RESET_REQ);
Wey-Yi Guy32004ee2009-10-16 14:25:56 -0700374
375 /*
376 * CSR auto clock gate disable bit -
377 * this is only applicable for HW with OTP shadow RAM
378 */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200379 if (cfg(trans)->base_params->shadow_ram_support)
380 iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG,
Wey-Yi Guy32004ee2009-10-16 14:25:56 -0700381 CSR_RESET_LINK_PWR_MGMT_DISABLED);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700382 }
383 return ret;
384}
385
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200386static int iwl_read_otp_word(struct iwl_trans *trans, u16 addr,
387 __le16 *eeprom_data)
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700388{
389 int ret = 0;
390 u32 r;
391 u32 otpgp;
392
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200393 iwl_write32(trans, CSR_EEPROM_REG,
Johannes Berg02a7fa02011-04-05 09:42:12 -0700394 CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200395 ret = iwl_poll_bit(trans, CSR_EEPROM_REG,
Johannes Berg02a7fa02011-04-05 09:42:12 -0700396 CSR_EEPROM_REG_READ_VALID_MSK,
397 CSR_EEPROM_REG_READ_VALID_MSK,
398 IWL_EEPROM_ACCESS_TIMEOUT);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700399 if (ret < 0) {
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200400 IWL_ERR(trans, "Time out reading OTP[%d]\n", addr);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700401 return ret;
402 }
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200403 r = iwl_read32(trans, CSR_EEPROM_REG);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700404 /* check for ECC errors: */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200405 otpgp = iwl_read32(trans, CSR_OTP_GP_REG);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700406 if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) {
407 /* stop in this case */
408 /* set the uncorrectable OTP ECC bit for acknowledgement */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200409 iwl_set_bit(trans, CSR_OTP_GP_REG,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700410 CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK);
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200411 IWL_ERR(trans, "Uncorrectable OTP ECC error, abort OTP read\n");
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700412 return -EINVAL;
413 }
414 if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) {
415 /* continue in this case */
416 /* set the correctable OTP ECC bit for acknowledgement */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200417 iwl_set_bit(trans, CSR_OTP_GP_REG,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700418 CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK);
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200419 IWL_ERR(trans, "Correctable OTP ECC error, continue read\n");
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700420 }
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800421 *eeprom_data = cpu_to_le16(r >> 16);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700422 return 0;
423}
424
425/*
426 * iwl_is_otp_empty: check for empty OTP
427 */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200428static bool iwl_is_otp_empty(struct iwl_trans *trans)
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700429{
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800430 u16 next_link_addr = 0;
431 __le16 link_value;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700432 bool is_empty = false;
433
434 /* locate the beginning of OTP link list */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200435 if (!iwl_read_otp_word(trans, next_link_addr, &link_value)) {
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700436 if (!link_value) {
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200437 IWL_ERR(trans, "OTP is empty\n");
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700438 is_empty = true;
439 }
440 } else {
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200441 IWL_ERR(trans, "Unable to read first block of OTP list.\n");
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700442 is_empty = true;
443 }
444
445 return is_empty;
446}
447
448
449/*
450 * iwl_find_otp_image: find EEPROM image in OTP
451 * finding the OTP block that contains the EEPROM image.
452 * the last valid block on the link list (the block _before_ the last block)
453 * is the block we should read and used to configure the device.
454 * If all the available OTP blocks are full, the last block will be the block
455 * we should read and used to configure the device.
456 * only perform this operation if shadow RAM is disabled
457 */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200458static int iwl_find_otp_image(struct iwl_trans *trans,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700459 u16 *validblockaddr)
460{
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800461 u16 next_link_addr = 0, valid_addr;
462 __le16 link_value = 0;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700463 int usedblocks = 0;
464
465 /* set addressing mode to absolute to traverse the link list */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200466 iwl_set_otp_access(trans, IWL_OTP_ACCESS_ABSOLUTE);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700467
468 /* checking for empty OTP or error */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200469 if (iwl_is_otp_empty(trans))
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700470 return -EINVAL;
471
472 /*
473 * start traverse link list
474 * until reach the max number of OTP blocks
475 * different devices have different number of OTP blocks
476 */
477 do {
478 /* save current valid block address
479 * check for more block on the link list
480 */
481 valid_addr = next_link_addr;
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800482 next_link_addr = le16_to_cpu(link_value) * sizeof(u16);
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200483 IWL_DEBUG_EEPROM(trans, "OTP blocks %d addr 0x%x\n",
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700484 usedblocks, next_link_addr);
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200485 if (iwl_read_otp_word(trans, next_link_addr, &link_value))
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700486 return -EINVAL;
487 if (!link_value) {
488 /*
Jay Sternberg2facba72009-10-02 13:43:55 -0700489 * reach the end of link list, return success and
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700490 * set address point to the starting address
491 * of the image
492 */
Jay Sternberg2facba72009-10-02 13:43:55 -0700493 *validblockaddr = valid_addr;
494 /* skip first 2 bytes (link list pointer) */
495 *validblockaddr += 2;
496 return 0;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700497 }
498 /* more in the link list, continue */
499 usedblocks++;
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200500 } while (usedblocks <= cfg(trans)->base_params->max_ll_items);
Jay Sternberg2facba72009-10-02 13:43:55 -0700501
502 /* OTP has no valid blocks */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200503 IWL_DEBUG_EEPROM(trans, "OTP has no valid blocks\n");
Jay Sternberg2facba72009-10-02 13:43:55 -0700504 return -EINVAL;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700505}
506
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700507/******************************************************************************
508 *
509 * Tx Power related functions
510 *
511******************************************************************************/
512/**
513 * iwl_get_max_txpower_avg - get the highest tx power from all chains.
514 * find the highest tx power from all chains for the channel
515 */
Johannes Berg706c4ff2012-03-05 11:24:33 -0800516static s8 iwl_get_max_txpower_avg(const struct iwl_cfg *cfg,
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700517 struct iwl_eeprom_enhanced_txpwr *enhanced_txpower,
518 int element, s8 *max_txpower_in_half_dbm)
Wey-Yi Guy3be63ff2010-10-08 16:05:19 -0700519{
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700520 s8 max_txpower_avg = 0; /* (dBm) */
521
522 /* Take the highest tx power from any valid chains */
Don Fry1431b212011-11-10 06:55:26 -0800523 if ((cfg->valid_tx_ant & ANT_A) &&
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700524 (enhanced_txpower[element].chain_a_max > max_txpower_avg))
525 max_txpower_avg = enhanced_txpower[element].chain_a_max;
Don Fry1431b212011-11-10 06:55:26 -0800526 if ((cfg->valid_tx_ant & ANT_B) &&
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700527 (enhanced_txpower[element].chain_b_max > max_txpower_avg))
528 max_txpower_avg = enhanced_txpower[element].chain_b_max;
Don Fry1431b212011-11-10 06:55:26 -0800529 if ((cfg->valid_tx_ant & ANT_C) &&
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700530 (enhanced_txpower[element].chain_c_max > max_txpower_avg))
531 max_txpower_avg = enhanced_txpower[element].chain_c_max;
Don Fry1431b212011-11-10 06:55:26 -0800532 if (((cfg->valid_tx_ant == ANT_AB) |
533 (cfg->valid_tx_ant == ANT_BC) |
534 (cfg->valid_tx_ant == ANT_AC)) &&
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700535 (enhanced_txpower[element].mimo2_max > max_txpower_avg))
536 max_txpower_avg = enhanced_txpower[element].mimo2_max;
Don Fry1431b212011-11-10 06:55:26 -0800537 if ((cfg->valid_tx_ant == ANT_ABC) &&
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700538 (enhanced_txpower[element].mimo3_max > max_txpower_avg))
539 max_txpower_avg = enhanced_txpower[element].mimo3_max;
540
541 /*
542 * max. tx power in EEPROM is in 1/2 dBm format
543 * convert from 1/2 dBm to dBm (round-up convert)
544 * but we also do not want to loss 1/2 dBm resolution which
545 * will impact performance
546 */
547 *max_txpower_in_half_dbm = max_txpower_avg;
548 return (max_txpower_avg & 0x01) + (max_txpower_avg >> 1);
549}
550
551static void
552iwl_eeprom_enh_txp_read_element(struct iwl_priv *priv,
553 struct iwl_eeprom_enhanced_txpwr *txp,
554 s8 max_txpower_avg)
555{
556 int ch_idx;
557 bool is_ht40 = txp->flags & IWL_EEPROM_ENH_TXP_FL_40MHZ;
558 enum ieee80211_band band;
559
560 band = txp->flags & IWL_EEPROM_ENH_TXP_FL_BAND_52G ?
561 IEEE80211_BAND_5GHZ : IEEE80211_BAND_2GHZ;
562
563 for (ch_idx = 0; ch_idx < priv->channel_count; ch_idx++) {
564 struct iwl_channel_info *ch_info = &priv->channel_info[ch_idx];
565
566 /* update matching channel or from common data only */
567 if (txp->channel != 0 && ch_info->channel != txp->channel)
568 continue;
569
570 /* update matching band only */
571 if (band != ch_info->band)
572 continue;
573
574 if (ch_info->max_power_avg < max_txpower_avg && !is_ht40) {
575 ch_info->max_power_avg = max_txpower_avg;
576 ch_info->curr_txpow = max_txpower_avg;
577 ch_info->scan_power = max_txpower_avg;
578 }
579
580 if (is_ht40 && ch_info->ht40_max_power_avg < max_txpower_avg)
581 ch_info->ht40_max_power_avg = max_txpower_avg;
582 }
583}
584
585#define EEPROM_TXP_OFFS (0x00 | INDIRECT_ADDRESS | INDIRECT_TXP_LIMIT)
586#define EEPROM_TXP_ENTRY_LEN sizeof(struct iwl_eeprom_enhanced_txpwr)
587#define EEPROM_TXP_SZ_OFFS (0x00 | INDIRECT_ADDRESS | INDIRECT_TXP_LIMIT_SIZE)
588
589#define TXP_CHECK_AND_PRINT(x) ((txp->flags & IWL_EEPROM_ENH_TXP_FL_##x) \
590 ? # x " " : "")
591
592void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv)
593{
Don Fryab36eab2011-11-30 15:37:32 -0800594 struct iwl_shared *shrd = priv->shrd;
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700595 struct iwl_eeprom_enhanced_txpwr *txp_array, *txp;
596 int idx, entries;
597 __le16 *txp_len;
598 s8 max_txp_avg, max_txp_avg_halfdbm;
599
600 BUILD_BUG_ON(sizeof(struct iwl_eeprom_enhanced_txpwr) != 8);
601
602 /* the length is in 16-bit words, but we want entries */
Don Fryab36eab2011-11-30 15:37:32 -0800603 txp_len = (__le16 *) iwl_eeprom_query_addr(shrd, EEPROM_TXP_SZ_OFFS);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700604 entries = le16_to_cpup(txp_len) * 2 / EEPROM_TXP_ENTRY_LEN;
605
Don Fryab36eab2011-11-30 15:37:32 -0800606 txp_array = (void *) iwl_eeprom_query_addr(shrd, EEPROM_TXP_OFFS);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700607
608 for (idx = 0; idx < entries; idx++) {
609 txp = &txp_array[idx];
610 /* skip invalid entries */
611 if (!(txp->flags & IWL_EEPROM_ENH_TXP_FL_VALID))
612 continue;
613
614 IWL_DEBUG_EEPROM(priv, "%s %d:\t %s%s%s%s%s%s%s%s (0x%02x)\n",
615 (txp->channel && (txp->flags &
616 IWL_EEPROM_ENH_TXP_FL_COMMON_TYPE)) ?
617 "Common " : (txp->channel) ?
618 "Channel" : "Common",
619 (txp->channel),
620 TXP_CHECK_AND_PRINT(VALID),
621 TXP_CHECK_AND_PRINT(BAND_52G),
622 TXP_CHECK_AND_PRINT(OFDM),
623 TXP_CHECK_AND_PRINT(40MHZ),
624 TXP_CHECK_AND_PRINT(HT_AP),
625 TXP_CHECK_AND_PRINT(RES1),
626 TXP_CHECK_AND_PRINT(RES2),
627 TXP_CHECK_AND_PRINT(COMMON_TYPE),
628 txp->flags);
629 IWL_DEBUG_EEPROM(priv, "\t\t chain_A: 0x%02x "
630 "chain_B: 0X%02x chain_C: 0X%02x\n",
631 txp->chain_a_max, txp->chain_b_max,
632 txp->chain_c_max);
633 IWL_DEBUG_EEPROM(priv, "\t\t MIMO2: 0x%02x "
634 "MIMO3: 0x%02x High 20_on_40: 0x%02x "
635 "Low 20_on_40: 0x%02x\n",
636 txp->mimo2_max, txp->mimo3_max,
637 ((txp->delta_20_in_40 & 0xf0) >> 4),
638 (txp->delta_20_in_40 & 0x0f));
639
Don Fry38622412011-12-16 07:07:36 -0800640 max_txp_avg = iwl_get_max_txpower_avg(cfg(priv), txp_array, idx,
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700641 &max_txp_avg_halfdbm);
642
643 /*
644 * Update the user limit values values to the highest
645 * power supported by any channel
646 */
647 if (max_txp_avg > priv->tx_power_user_lmt)
648 priv->tx_power_user_lmt = max_txp_avg;
649 if (max_txp_avg_halfdbm > priv->tx_power_lmt_in_half_dbm)
650 priv->tx_power_lmt_in_half_dbm = max_txp_avg_halfdbm;
651
652 iwl_eeprom_enh_txp_read_element(priv, txp, max_txp_avg);
653 }
Wey-Yi Guy3be63ff2010-10-08 16:05:19 -0700654}
Wey-Yi Guy3be63ff2010-10-08 16:05:19 -0700655
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800656/**
657 * iwl_eeprom_init - read EEPROM contents
658 *
Don Fryab36eab2011-11-30 15:37:32 -0800659 * Load the EEPROM contents from adapter into shrd->eeprom
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800660 *
661 * NOTE: This routine uses the non-debug IO access functions.
662 */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200663int iwl_eeprom_init(struct iwl_trans *trans, u32 hw_rev)
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800664{
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800665 __le16 *e;
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200666 u32 gp = iwl_read32(trans, CSR_EEPROM_GP);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700667 int sz;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800668 int ret;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800669 u16 addr;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700670 u16 validblockaddr = 0;
671 u16 cache_addr = 0;
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700672
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200673 trans->nvm_device_type = iwl_get_nvm_type(trans, hw_rev);
674 if (trans->nvm_device_type == -ENOENT)
Wey-Yi Guyb23a0522009-07-17 09:30:21 -0700675 return -ENOENT;
Tomas Winkler073d3f52008-04-21 15:41:52 -0700676 /* allocate eeprom */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200677 sz = cfg(trans)->base_params->eeprom_size;
678 IWL_DEBUG_EEPROM(trans, "NVM size = %d\n", sz);
679 trans->shrd->eeprom = kzalloc(sz, GFP_KERNEL);
680 if (!trans->shrd->eeprom) {
Tomas Winkler073d3f52008-04-21 15:41:52 -0700681 ret = -ENOMEM;
682 goto alloc_err;
683 }
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200684 e = (__le16 *)trans->shrd->eeprom;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800685
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200686 ret = iwl_eeprom_verify_signature(trans);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700687 if (ret < 0) {
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200688 IWL_ERR(trans, "EEPROM not found, EEPROM_GP=0x%08x\n", gp);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700689 ret = -ENOENT;
690 goto err;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800691 }
692
693 /* Make sure driver (instead of uCode) is allowed to read EEPROM */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200694 ret = iwl_eeprom_acquire_semaphore(trans);
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800695 if (ret < 0) {
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200696 IWL_ERR(trans, "Failed to acquire EEPROM semaphore.\n");
Tomas Winkler073d3f52008-04-21 15:41:52 -0700697 ret = -ENOENT;
698 goto err;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800699 }
Ben Cahill88521362009-10-30 14:36:06 -0700700
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200701 if (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP) {
Ben Cahill88521362009-10-30 14:36:06 -0700702
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200703 ret = iwl_init_otp_access(trans);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700704 if (ret) {
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200705 IWL_ERR(trans, "Failed to initialize OTP access.\n");
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700706 ret = -ENOENT;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700707 goto done;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800708 }
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200709 iwl_write32(trans, CSR_EEPROM_GP,
710 iwl_read32(trans, CSR_EEPROM_GP) &
Johannes Berg02a7fa02011-04-05 09:42:12 -0700711 ~CSR_EEPROM_GP_IF_OWNER_MSK);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700712
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200713 iwl_set_bit(trans, CSR_OTP_GP_REG,
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700714 CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK |
715 CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700716 /* traversing the linked list if no shadow ram supported */
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200717 if (!cfg(trans)->base_params->shadow_ram_support) {
718 if (iwl_find_otp_image(trans, &validblockaddr)) {
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700719 ret = -ENOENT;
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700720 goto done;
721 }
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700722 }
723 for (addr = validblockaddr; addr < validblockaddr + sz;
724 addr += sizeof(u16)) {
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800725 __le16 eeprom_data;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700726
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200727 ret = iwl_read_otp_word(trans, addr, &eeprom_data);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700728 if (ret)
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700729 goto done;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700730 e[cache_addr / 2] = eeprom_data;
731 cache_addr += sizeof(u16);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700732 }
733 } else {
734 /* eeprom is an array of 16bit values */
735 for (addr = 0; addr < sz; addr += sizeof(u16)) {
736 u32 r;
737
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200738 iwl_write32(trans, CSR_EEPROM_REG,
Johannes Berg02a7fa02011-04-05 09:42:12 -0700739 CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700740
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200741 ret = iwl_poll_bit(trans, CSR_EEPROM_REG,
Abhijeet Kolekar1739d332009-10-02 13:44:05 -0700742 CSR_EEPROM_REG_READ_VALID_MSK,
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700743 CSR_EEPROM_REG_READ_VALID_MSK,
744 IWL_EEPROM_ACCESS_TIMEOUT);
745 if (ret < 0) {
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200746 IWL_ERR(trans,
747 "Time out reading EEPROM[%d]\n", addr);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700748 goto done;
749 }
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200750 r = iwl_read32(trans, CSR_EEPROM_REG);
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800751 e[addr / 2] = cpu_to_le16(r >> 16);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700752 }
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800753 }
Johannes Bergd1358f62010-04-28 12:09:15 -0700754
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200755 IWL_DEBUG_EEPROM(trans, "NVM Type: %s, version: 0x%x\n",
756 (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP)
Johannes Bergd1358f62010-04-28 12:09:15 -0700757 ? "OTP" : "EEPROM",
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200758 iwl_eeprom_query16(trans->shrd, EEPROM_VERSION));
Johannes Bergd1358f62010-04-28 12:09:15 -0700759
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800760 ret = 0;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800761done:
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200762 iwl_eeprom_release_semaphore(trans);
Johannes Bergd1358f62010-04-28 12:09:15 -0700763
Tomas Winkler073d3f52008-04-21 15:41:52 -0700764err:
765 if (ret)
Emmanuel Grumbachca77d532012-02-13 11:24:47 +0200766 iwl_eeprom_free(trans->shrd);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700767alloc_err:
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800768 return ret;
769}
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800770
Don Fryab36eab2011-11-30 15:37:32 -0800771void iwl_eeprom_free(struct iwl_shared *shrd)
Tomas Winkler073d3f52008-04-21 15:41:52 -0700772{
Don Fryab36eab2011-11-30 15:37:32 -0800773 kfree(shrd->eeprom);
774 shrd->eeprom = NULL;
Tomas Winkler073d3f52008-04-21 15:41:52 -0700775}
Tomas Winkler073d3f52008-04-21 15:41:52 -0700776
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700777static void iwl_init_band_reference(const struct iwl_priv *priv,
Tomas Winkler073d3f52008-04-21 15:41:52 -0700778 int eep_band, int *eeprom_ch_count,
779 const struct iwl_eeprom_channel **eeprom_ch_info,
780 const u8 **eeprom_ch_index)
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700781{
Don Fryab36eab2011-11-30 15:37:32 -0800782 struct iwl_shared *shrd = priv->shrd;
Don Fry38622412011-12-16 07:07:36 -0800783 u32 offset = cfg(priv)->lib->
Tomas Winkler073d3f52008-04-21 15:41:52 -0700784 eeprom_ops.regulatory_bands[eep_band - 1];
785 switch (eep_band) {
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700786 case 1: /* 2.4GHz band */
787 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_1);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700788 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800789 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700790 *eeprom_ch_index = iwl_eeprom_band_1;
791 break;
792 case 2: /* 4.9GHz band */
793 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_2);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700794 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800795 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700796 *eeprom_ch_index = iwl_eeprom_band_2;
797 break;
798 case 3: /* 5.2GHz band */
799 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_3);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700800 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800801 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700802 *eeprom_ch_index = iwl_eeprom_band_3;
803 break;
804 case 4: /* 5.5GHz band */
805 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_4);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700806 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800807 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700808 *eeprom_ch_index = iwl_eeprom_band_4;
809 break;
810 case 5: /* 5.7GHz band */
811 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_5);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700812 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800813 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700814 *eeprom_ch_index = iwl_eeprom_band_5;
815 break;
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700816 case 6: /* 2.4GHz ht40 channels */
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700817 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_6);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700818 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800819 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700820 *eeprom_ch_index = iwl_eeprom_band_6;
821 break;
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700822 case 7: /* 5 GHz ht40 channels */
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700823 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_7);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700824 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800825 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700826 *eeprom_ch_index = iwl_eeprom_band_7;
827 break;
828 default:
829 BUG();
830 return;
831 }
832}
833
834#define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \
835 ? # x " " : "")
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700836/**
Zhu Yi3b247162009-08-13 13:30:53 -0700837 * iwl_mod_ht40_chan_info - Copy ht40 channel info into driver's priv.
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700838 *
839 * Does not set up a command, or touch hardware.
840 */
Zhu Yi3b247162009-08-13 13:30:53 -0700841static int iwl_mod_ht40_chan_info(struct iwl_priv *priv,
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700842 enum ieee80211_band band, u16 channel,
Tomas Winkler073d3f52008-04-21 15:41:52 -0700843 const struct iwl_eeprom_channel *eeprom_ch,
Zhu Yi3b247162009-08-13 13:30:53 -0700844 u8 clear_ht40_extension_channel)
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700845{
846 struct iwl_channel_info *ch_info;
847
848 ch_info = (struct iwl_channel_info *)
Assaf Krauss8622e702008-03-21 13:53:43 -0700849 iwl_get_channel_info(priv, band, channel);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700850
851 if (!is_channel_valid(ch_info))
852 return -1;
853
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800854 IWL_DEBUG_EEPROM(priv, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):"
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800855 " Ad-Hoc %ssupported\n",
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700856 ch_info->channel,
857 is_channel_a_band(ch_info) ?
858 "5.2" : "2.4",
859 CHECK_AND_PRINT(IBSS),
860 CHECK_AND_PRINT(ACTIVE),
861 CHECK_AND_PRINT(RADAR),
862 CHECK_AND_PRINT(WIDE),
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700863 CHECK_AND_PRINT(DFS),
864 eeprom_ch->flags,
865 eeprom_ch->max_power_avg,
866 ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS)
867 && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ?
868 "" : "not ");
869
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700870 ch_info->ht40_eeprom = *eeprom_ch;
871 ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg;
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700872 ch_info->ht40_flags = eeprom_ch->flags;
Reinette Chatre6c3069b2009-12-14 14:12:13 -0800873 if (eeprom_ch->flags & EEPROM_CHANNEL_VALID)
874 ch_info->ht40_extension_channel &= ~clear_ht40_extension_channel;
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700875
876 return 0;
877}
878
879#define CHECK_AND_PRINT_I(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \
880 ? # x " " : "")
881
882/**
883 * iwl_init_channel_map - Set up driver's info for all possible channels
884 */
885int iwl_init_channel_map(struct iwl_priv *priv)
886{
887 int eeprom_ch_count = 0;
888 const u8 *eeprom_ch_index = NULL;
Tomas Winkler073d3f52008-04-21 15:41:52 -0700889 const struct iwl_eeprom_channel *eeprom_ch_info = NULL;
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700890 int band, ch;
891 struct iwl_channel_info *ch_info;
892
893 if (priv->channel_count) {
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800894 IWL_DEBUG_EEPROM(priv, "Channel map already initialized.\n");
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700895 return 0;
896 }
897
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800898 IWL_DEBUG_EEPROM(priv, "Initializing regulatory info from EEPROM\n");
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700899
900 priv->channel_count =
901 ARRAY_SIZE(iwl_eeprom_band_1) +
902 ARRAY_SIZE(iwl_eeprom_band_2) +
903 ARRAY_SIZE(iwl_eeprom_band_3) +
904 ARRAY_SIZE(iwl_eeprom_band_4) +
905 ARRAY_SIZE(iwl_eeprom_band_5);
906
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800907 IWL_DEBUG_EEPROM(priv, "Parsing data for %d channels.\n",
908 priv->channel_count);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700909
Emmanuel Grumbach7f90dce2011-09-22 15:14:53 -0700910 priv->channel_info = kcalloc(priv->channel_count,
911 sizeof(struct iwl_channel_info),
912 GFP_KERNEL);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700913 if (!priv->channel_info) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800914 IWL_ERR(priv, "Could not allocate channel_info\n");
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700915 priv->channel_count = 0;
916 return -ENOMEM;
917 }
918
919 ch_info = priv->channel_info;
920
921 /* Loop through the 5 EEPROM bands adding them in order to the
922 * channel map we maintain (that contains additional information than
923 * what just in the EEPROM) */
924 for (band = 1; band <= 5; band++) {
925
926 iwl_init_band_reference(priv, band, &eeprom_ch_count,
927 &eeprom_ch_info, &eeprom_ch_index);
928
929 /* Loop through each band adding each of the channels */
930 for (ch = 0; ch < eeprom_ch_count; ch++) {
931 ch_info->channel = eeprom_ch_index[ch];
932 ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ :
933 IEEE80211_BAND_5GHZ;
934
935 /* permanently store EEPROM's channel regulatory flags
936 * and max power in channel info database. */
937 ch_info->eeprom = eeprom_ch_info[ch];
938
939 /* Copy the run-time flags so they are there even on
940 * invalid channels */
941 ch_info->flags = eeprom_ch_info[ch].flags;
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700942 /* First write that ht40 is not enabled, and then enable
Emmanuel Grumbach963f5512008-06-12 09:47:00 +0800943 * one by one */
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700944 ch_info->ht40_extension_channel =
Zhu Yi3b247162009-08-13 13:30:53 -0700945 IEEE80211_CHAN_NO_HT40;
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700946
947 if (!(is_channel_valid(ch_info))) {
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800948 IWL_DEBUG_EEPROM(priv,
949 "Ch. %d Flags %x [%sGHz] - "
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700950 "No traffic\n",
951 ch_info->channel,
952 ch_info->flags,
953 is_channel_a_band(ch_info) ?
954 "5.2" : "2.4");
955 ch_info++;
956 continue;
957 }
958
959 /* Initialize regulatory-based run-time data */
960 ch_info->max_power_avg = ch_info->curr_txpow =
961 eeprom_ch_info[ch].max_power_avg;
962 ch_info->scan_power = eeprom_ch_info[ch].max_power_avg;
963 ch_info->min_power = 0;
964
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800965 IWL_DEBUG_EEPROM(priv, "Ch. %d [%sGHz] "
966 "%s%s%s%s%s%s(0x%02x %ddBm):"
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800967 " Ad-Hoc %ssupported\n",
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700968 ch_info->channel,
969 is_channel_a_band(ch_info) ?
970 "5.2" : "2.4",
971 CHECK_AND_PRINT_I(VALID),
972 CHECK_AND_PRINT_I(IBSS),
973 CHECK_AND_PRINT_I(ACTIVE),
974 CHECK_AND_PRINT_I(RADAR),
975 CHECK_AND_PRINT_I(WIDE),
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700976 CHECK_AND_PRINT_I(DFS),
977 eeprom_ch_info[ch].flags,
978 eeprom_ch_info[ch].max_power_avg,
979 ((eeprom_ch_info[ch].
980 flags & EEPROM_CHANNEL_IBSS)
981 && !(eeprom_ch_info[ch].
982 flags & EEPROM_CHANNEL_RADAR))
983 ? "" : "not ");
984
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700985 ch_info++;
986 }
987 }
988
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700989 /* Check if we do have HT40 channels */
Don Fry38622412011-12-16 07:07:36 -0800990 if (cfg(priv)->lib->eeprom_ops.regulatory_bands[5] ==
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700991 EEPROM_REGULATORY_BAND_NO_HT40 &&
Don Fry38622412011-12-16 07:07:36 -0800992 cfg(priv)->lib->eeprom_ops.regulatory_bands[6] ==
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700993 EEPROM_REGULATORY_BAND_NO_HT40)
Samuel Ortize6148912009-01-23 13:45:15 -0800994 return 0;
995
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700996 /* Two additional EEPROM bands for 2.4 and 5 GHz HT40 channels */
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700997 for (band = 6; band <= 7; band++) {
998 enum ieee80211_band ieeeband;
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700999
1000 iwl_init_band_reference(priv, band, &eeprom_ch_count,
1001 &eeprom_ch_info, &eeprom_ch_index);
1002
1003 /* EEPROM band 6 is 2.4, band 7 is 5 GHz */
1004 ieeeband =
1005 (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
1006
1007 /* Loop through each band adding each of the channels */
1008 for (ch = 0; ch < eeprom_ch_count; ch++) {
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001009 /* Set up driver's info for lower half */
Zhu Yi3b247162009-08-13 13:30:53 -07001010 iwl_mod_ht40_chan_info(priv, ieeeband,
Tomas Winklerda6833c2008-05-15 13:54:15 +08001011 eeprom_ch_index[ch],
Zhu Yi3b247162009-08-13 13:30:53 -07001012 &eeprom_ch_info[ch],
1013 IEEE80211_CHAN_NO_HT40PLUS);
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001014
1015 /* Set up driver's info for upper half */
Zhu Yi3b247162009-08-13 13:30:53 -07001016 iwl_mod_ht40_chan_info(priv, ieeeband,
1017 eeprom_ch_index[ch] + 4,
1018 &eeprom_ch_info[ch],
1019 IEEE80211_CHAN_NO_HT40MINUS);
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001020 }
1021 }
1022
Wey-Yi Guyab9fd1b2009-08-21 13:34:23 -07001023 /* for newer device (6000 series and up)
1024 * EEPROM contain enhanced tx power information
1025 * driver need to process addition information
1026 * to determine the max channel tx power limits
1027 */
Don Fry38622412011-12-16 07:07:36 -08001028 if (cfg(priv)->lib->eeprom_ops.update_enhanced_txpower)
1029 cfg(priv)->lib->eeprom_ops.update_enhanced_txpower(priv);
Wey-Yi Guyab9fd1b2009-08-21 13:34:23 -07001030
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001031 return 0;
1032}
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001033
1034/*
Tomas Winklerda6833c2008-05-15 13:54:15 +08001035 * iwl_free_channel_map - undo allocations in iwl_init_channel_map
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001036 */
1037void iwl_free_channel_map(struct iwl_priv *priv)
1038{
1039 kfree(priv->channel_info);
1040 priv->channel_count = 0;
1041}
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001042
1043/**
1044 * iwl_get_channel_info - Find driver's private channel info
1045 *
1046 * Based on band and channel number.
1047 */
Tomas Winkler82a66bb2008-05-29 16:35:28 +08001048const struct iwl_channel_info *iwl_get_channel_info(const struct iwl_priv *priv,
1049 enum ieee80211_band band, u16 channel)
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001050{
1051 int i;
1052
1053 switch (band) {
1054 case IEEE80211_BAND_5GHZ:
1055 for (i = 14; i < priv->channel_count; i++) {
1056 if (priv->channel_info[i].channel == channel)
1057 return &priv->channel_info[i];
1058 }
1059 break;
1060 case IEEE80211_BAND_2GHZ:
1061 if (channel >= 1 && channel <= 14)
1062 return &priv->channel_info[channel - 1];
1063 break;
1064 default:
1065 BUG();
1066 }
1067
1068 return NULL;
1069}
Wey-Yi Guy86cb3b42011-06-14 15:23:39 -07001070
1071void iwl_rf_config(struct iwl_priv *priv)
1072{
1073 u16 radio_cfg;
1074
Don Fryab36eab2011-11-30 15:37:32 -08001075 radio_cfg = iwl_eeprom_query16(priv->shrd, EEPROM_RADIO_CONFIG);
Wey-Yi Guy86cb3b42011-06-14 15:23:39 -07001076
1077 /* write radio config values to register */
1078 if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX) {
Emmanuel Grumbach1042db22012-01-03 16:56:15 +02001079 iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG,
Wey-Yi Guy86cb3b42011-06-14 15:23:39 -07001080 EEPROM_RF_CFG_TYPE_MSK(radio_cfg) |
1081 EEPROM_RF_CFG_STEP_MSK(radio_cfg) |
1082 EEPROM_RF_CFG_DASH_MSK(radio_cfg));
1083 IWL_INFO(priv, "Radio type=0x%x-0x%x-0x%x\n",
1084 EEPROM_RF_CFG_TYPE_MSK(radio_cfg),
1085 EEPROM_RF_CFG_STEP_MSK(radio_cfg),
1086 EEPROM_RF_CFG_DASH_MSK(radio_cfg));
1087 } else
1088 WARN_ON(1);
1089
1090 /* set CSR_HW_CONFIG_REG for uCode use */
Emmanuel Grumbach1042db22012-01-03 16:56:15 +02001091 iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG,
Wey-Yi Guy86cb3b42011-06-14 15:23:39 -07001092 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
1093 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
1094}