blob: d1fd1cdb29c23923e4818bc6e6afb9426303ac0e [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"
Assaf Krauss34cf6ff2008-03-06 10:40:20 -080078
Assaf Kraussbf85ea42008-03-14 10:38:49 -070079/************************** EEPROM BANDS ****************************
80 *
81 * The iwl_eeprom_band definitions below provide the mapping from the
82 * EEPROM contents to the specific channel number supported for each
83 * band.
84 *
85 * For example, iwl_priv->eeprom.band_3_channels[4] from the band_3
86 * definition below maps to physical channel 42 in the 5.2GHz spectrum.
87 * The specific geography and calibration information for that channel
88 * is contained in the eeprom map itself.
89 *
90 * During init, we copy the eeprom information and channel map
91 * information into priv->channel_info_24/52 and priv->channel_map_24/52
92 *
93 * channel_map_24/52 provides the index in the channel_info array for a
94 * given channel. We have to have two separate maps as there is channel
95 * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and
96 * band_2
97 *
98 * A value of 0xff stored in the channel_map indicates that the channel
99 * is not supported by the hardware at all.
100 *
101 * A value of 0xfe in the channel_map indicates that the channel is not
102 * valid for Tx with the current hardware. This means that
103 * while the system can tune and receive on a given channel, it may not
104 * be able to associate or transmit any frames on that
105 * channel. There is no corresponding channel information for that
106 * entry.
107 *
108 *********************************************************************/
109
110/* 2.4 GHz */
111const u8 iwl_eeprom_band_1[14] = {
112 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
113};
114
115/* 5.2 GHz bands */
116static const u8 iwl_eeprom_band_2[] = { /* 4915-5080MHz */
117 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16
118};
119
120static const u8 iwl_eeprom_band_3[] = { /* 5170-5320MHz */
121 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
122};
123
124static const u8 iwl_eeprom_band_4[] = { /* 5500-5700MHz */
125 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
126};
127
128static const u8 iwl_eeprom_band_5[] = { /* 5725-5825MHz */
129 145, 149, 153, 157, 161, 165
130};
131
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700132static const u8 iwl_eeprom_band_6[] = { /* 2.4 ht40 channel */
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700133 1, 2, 3, 4, 5, 6, 7
134};
135
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700136static const u8 iwl_eeprom_band_7[] = { /* 5.2 ht40 channel */
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700137 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157
138};
139
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800140/******************************************************************************
141 *
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700142 * generic NVM functions
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800143 *
144******************************************************************************/
145
Don Fry16b80b72011-04-20 15:25:14 -0700146/*
147 * The device's EEPROM semaphore prevents conflicts between driver and uCode
148 * when accessing the EEPROM; each access is a series of pulses to/from the
149 * EEPROM chip, not a single event, so even reads could conflict if they
150 * weren't arbitrated by the semaphore.
151 */
Don Fry1431b212011-11-10 06:55:26 -0800152static int iwl_eeprom_acquire_semaphore(struct iwl_bus *bus)
Don Fry16b80b72011-04-20 15:25:14 -0700153{
154 u16 count;
155 int ret;
156
157 for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) {
158 /* Request semaphore */
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200159 iwl_set_bit(trans(bus), CSR_HW_IF_CONFIG_REG,
Don Fry16b80b72011-04-20 15:25:14 -0700160 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
161
162 /* See if we got it */
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200163 ret = iwl_poll_bit(trans(bus), CSR_HW_IF_CONFIG_REG,
Don Fry16b80b72011-04-20 15:25:14 -0700164 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
165 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
166 EEPROM_SEM_TIMEOUT);
167 if (ret >= 0) {
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200168 IWL_DEBUG_EEPROM(trans(bus),
Don Fry16b80b72011-04-20 15:25:14 -0700169 "Acquired semaphore after %d tries.\n",
170 count+1);
171 return ret;
172 }
173 }
174
175 return ret;
176}
177
Don Fry1431b212011-11-10 06:55:26 -0800178static void iwl_eeprom_release_semaphore(struct iwl_bus *bus)
Don Fry16b80b72011-04-20 15:25:14 -0700179{
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200180 iwl_clear_bit(trans(bus), CSR_HW_IF_CONFIG_REG,
Don Fry16b80b72011-04-20 15:25:14 -0700181 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
182
183}
184
Don Fry97b52cf2011-11-10 06:55:27 -0800185static int iwl_eeprom_verify_signature(struct iwl_trans *trans)
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800186{
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200187 u32 gp = iwl_read32(trans, CSR_EEPROM_GP) &
188 CSR_EEPROM_GP_VALID_MSK;
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700189 int ret = 0;
190
Don Fry97b52cf2011-11-10 06:55:27 -0800191 IWL_DEBUG_EEPROM(trans, "EEPROM signature=0x%08x\n", gp);
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700192 switch (gp) {
193 case CSR_EEPROM_GP_BAD_SIG_EEP_GOOD_SIG_OTP:
Don Fry97b52cf2011-11-10 06:55:27 -0800194 if (trans->nvm_device_type != NVM_DEVICE_TYPE_OTP) {
195 IWL_ERR(trans, "EEPROM with bad signature: 0x%08x\n",
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700196 gp);
197 ret = -ENOENT;
198 }
199 break;
200 case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K:
201 case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K:
Don Fry97b52cf2011-11-10 06:55:27 -0800202 if (trans->nvm_device_type != NVM_DEVICE_TYPE_EEPROM) {
203 IWL_ERR(trans, "OTP with bad signature: 0x%08x\n", gp);
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700204 ret = -ENOENT;
205 }
206 break;
207 case CSR_EEPROM_GP_BAD_SIGNATURE_BOTH_EEP_AND_OTP:
208 default:
Don Fry97b52cf2011-11-10 06:55:27 -0800209 IWL_ERR(trans, "bad EEPROM/OTP signature, type=%s, "
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700210 "EEPROM_GP=0x%08x\n",
Don Fry97b52cf2011-11-10 06:55:27 -0800211 (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP)
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700212 ? "OTP" : "EEPROM", gp);
213 ret = -ENOENT;
214 break;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800215 }
Wey-Yi Guyf41bb892009-10-02 13:44:06 -0700216 return ret;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800217}
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800218
Don Fryab36eab2011-11-30 15:37:32 -0800219u16 iwl_eeprom_query16(const struct iwl_shared *shrd, size_t offset)
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700220{
Don Fryab36eab2011-11-30 15:37:32 -0800221 if (!shrd->eeprom)
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700222 return 0;
Don Fryab36eab2011-11-30 15:37:32 -0800223 return (u16)shrd->eeprom[offset] | ((u16)shrd->eeprom[offset + 1] << 8);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700224}
225
226int iwl_eeprom_check_version(struct iwl_priv *priv)
227{
228 u16 eeprom_ver;
229 u16 calib_ver;
230
Don Fryab36eab2011-11-30 15:37:32 -0800231 eeprom_ver = iwl_eeprom_query16(priv->shrd, EEPROM_VERSION);
232 calib_ver = iwl_eeprom_calib_version(priv->shrd);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700233
Don Fry38622412011-12-16 07:07:36 -0800234 if (eeprom_ver < cfg(priv)->eeprom_ver ||
235 calib_ver < cfg(priv)->eeprom_calib_ver)
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700236 goto err;
237
238 IWL_INFO(priv, "device EEPROM VER=0x%x, CALIB=0x%x\n",
239 eeprom_ver, calib_ver);
240
241 return 0;
242err:
243 IWL_ERR(priv, "Unsupported (too old) EEPROM VER=0x%x < 0x%x "
244 "CALIB=0x%x < 0x%x\n",
Don Fry38622412011-12-16 07:07:36 -0800245 eeprom_ver, cfg(priv)->eeprom_ver,
246 calib_ver, cfg(priv)->eeprom_calib_ver);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700247 return -EINVAL;
248
249}
250
251int iwl_eeprom_check_sku(struct iwl_priv *priv)
252{
Don Fryab36eab2011-11-30 15:37:32 -0800253 struct iwl_shared *shrd = priv->shrd;
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700254 u16 radio_cfg;
255
Don Fry38622412011-12-16 07:07:36 -0800256 if (!cfg(priv)->sku) {
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700257 /* not using sku overwrite */
Don Fry38622412011-12-16 07:07:36 -0800258 cfg(priv)->sku = iwl_eeprom_query16(shrd, EEPROM_SKU_CAP);
259 if (cfg(priv)->sku & EEPROM_SKU_CAP_11N_ENABLE &&
260 !cfg(priv)->ht_params) {
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700261 IWL_ERR(priv, "Invalid 11n configuration\n");
262 return -EINVAL;
263 }
264 }
Don Fry38622412011-12-16 07:07:36 -0800265 if (!cfg(priv)->sku) {
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700266 IWL_ERR(priv, "Invalid device sku\n");
267 return -EINVAL;
268 }
269
Don Fry38622412011-12-16 07:07:36 -0800270 IWL_INFO(priv, "Device SKU: 0x%X\n", cfg(priv)->sku);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700271
Don Fry38622412011-12-16 07:07:36 -0800272 if (!cfg(priv)->valid_tx_ant && !cfg(priv)->valid_rx_ant) {
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700273 /* not using .cfg overwrite */
Don Fryab36eab2011-11-30 15:37:32 -0800274 radio_cfg = iwl_eeprom_query16(shrd, EEPROM_RADIO_CONFIG);
Don Fry38622412011-12-16 07:07:36 -0800275 cfg(priv)->valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg);
276 cfg(priv)->valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg);
277 if (!cfg(priv)->valid_tx_ant || !cfg(priv)->valid_rx_ant) {
278 IWL_ERR(priv, "Invalid chain (0x%X, 0x%X)\n",
279 cfg(priv)->valid_tx_ant,
280 cfg(priv)->valid_rx_ant);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700281 return -EINVAL;
282 }
Don Fry38622412011-12-16 07:07:36 -0800283 IWL_INFO(priv, "Valid Tx ant: 0x%X, Valid Rx ant: 0x%X\n",
284 cfg(priv)->valid_tx_ant, cfg(priv)->valid_rx_ant);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700285 }
286 /*
287 * for some special cases,
288 * EEPROM did not reflect the correct antenna setting
289 * so overwrite the valid tx/rx antenna from .cfg
290 */
291 return 0;
292}
293
Don Fryab36eab2011-11-30 15:37:32 -0800294void iwl_eeprom_get_mac(const struct iwl_shared *shrd, u8 *mac)
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700295{
Don Fryab36eab2011-11-30 15:37:32 -0800296 const u8 *addr = iwl_eeprom_query_addr(shrd,
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700297 EEPROM_MAC_ADDRESS);
298 memcpy(mac, addr, ETH_ALEN);
299}
300
301/******************************************************************************
302 *
303 * OTP related functions
304 *
305******************************************************************************/
306
Don Fry1431b212011-11-10 06:55:26 -0800307static void iwl_set_otp_access(struct iwl_bus *bus, enum iwl_access_mode mode)
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700308{
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200309 iwl_read32(trans(bus), CSR_OTP_GP_REG);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700310
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700311 if (mode == IWL_OTP_ACCESS_ABSOLUTE)
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200312 iwl_clear_bit(trans(bus), CSR_OTP_GP_REG,
Johannes Berg70817b52011-05-11 03:29:25 -0700313 CSR_OTP_GP_REG_OTP_ACCESS_MODE);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700314 else
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200315 iwl_set_bit(trans(bus), CSR_OTP_GP_REG,
Johannes Berg70817b52011-05-11 03:29:25 -0700316 CSR_OTP_GP_REG_OTP_ACCESS_MODE);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700317}
318
Don Fry1431b212011-11-10 06:55:26 -0800319static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev)
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700320{
321 u32 otpgp;
322 int nvm_type;
323
324 /* OTP only valid for CP/PP and after */
Johannes Berge98a1302011-04-05 09:42:08 -0700325 switch (hw_rev & CSR_HW_REV_TYPE_MSK) {
Wey-Yi Guyb23a0522009-07-17 09:30:21 -0700326 case CSR_HW_REV_TYPE_NONE:
Don Fry1431b212011-11-10 06:55:26 -0800327 IWL_ERR(bus, "Unknown hardware type\n");
Wey-Yi Guyb23a0522009-07-17 09:30:21 -0700328 return -ENOENT;
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700329 case CSR_HW_REV_TYPE_5300:
330 case CSR_HW_REV_TYPE_5350:
331 case CSR_HW_REV_TYPE_5100:
332 case CSR_HW_REV_TYPE_5150:
333 nvm_type = NVM_DEVICE_TYPE_EEPROM;
334 break;
335 default:
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200336 otpgp = iwl_read32(trans(bus), CSR_OTP_GP_REG);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700337 if (otpgp & CSR_OTP_GP_REG_DEVICE_SELECT)
338 nvm_type = NVM_DEVICE_TYPE_OTP;
339 else
340 nvm_type = NVM_DEVICE_TYPE_EEPROM;
341 break;
342 }
343 return nvm_type;
344}
345
Don Fry1431b212011-11-10 06:55:26 -0800346static int iwl_init_otp_access(struct iwl_bus *bus)
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700347{
348 int ret;
349
350 /* Enable 40MHz radio clock */
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200351 iwl_write32(trans(bus), CSR_GP_CNTRL,
352 iwl_read32(trans(bus), CSR_GP_CNTRL) |
Johannes Berg02a7fa02011-04-05 09:42:12 -0700353 CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700354
355 /* wait for clock to be ready */
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200356 ret = iwl_poll_bit(trans(bus), CSR_GP_CNTRL,
Johannes Berg02a7fa02011-04-05 09:42:12 -0700357 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
358 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
359 25000);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700360 if (ret < 0)
Don Fry1431b212011-11-10 06:55:26 -0800361 IWL_ERR(bus, "Time out access OTP\n");
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700362 else {
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200363 iwl_set_bits_prph(trans(bus), APMG_PS_CTRL_REG,
Reinette Chatred77b0342009-05-22 14:37:55 -0700364 APMG_PS_CTRL_VAL_RESET_REQ);
365 udelay(5);
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200366 iwl_clear_bits_prph(trans(bus), APMG_PS_CTRL_REG,
Reinette Chatred77b0342009-05-22 14:37:55 -0700367 APMG_PS_CTRL_VAL_RESET_REQ);
Wey-Yi Guy32004ee2009-10-16 14:25:56 -0700368
369 /*
370 * CSR auto clock gate disable bit -
371 * this is only applicable for HW with OTP shadow RAM
372 */
Don Fry38622412011-12-16 07:07:36 -0800373 if (cfg(bus)->base_params->shadow_ram_support)
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200374 iwl_set_bit(trans(bus), CSR_DBG_LINK_PWR_MGMT_REG,
Wey-Yi Guy32004ee2009-10-16 14:25:56 -0700375 CSR_RESET_LINK_PWR_MGMT_DISABLED);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700376 }
377 return ret;
378}
379
Don Fry1431b212011-11-10 06:55:26 -0800380static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data)
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700381{
382 int ret = 0;
383 u32 r;
384 u32 otpgp;
385
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200386 iwl_write32(trans(bus), CSR_EEPROM_REG,
Johannes Berg02a7fa02011-04-05 09:42:12 -0700387 CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200388 ret = iwl_poll_bit(trans(bus), CSR_EEPROM_REG,
Johannes Berg02a7fa02011-04-05 09:42:12 -0700389 CSR_EEPROM_REG_READ_VALID_MSK,
390 CSR_EEPROM_REG_READ_VALID_MSK,
391 IWL_EEPROM_ACCESS_TIMEOUT);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700392 if (ret < 0) {
Don Fry1431b212011-11-10 06:55:26 -0800393 IWL_ERR(bus, "Time out reading OTP[%d]\n", addr);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700394 return ret;
395 }
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200396 r = iwl_read32(trans(bus), CSR_EEPROM_REG);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700397 /* check for ECC errors: */
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200398 otpgp = iwl_read32(trans(bus), CSR_OTP_GP_REG);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700399 if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) {
400 /* stop in this case */
401 /* set the uncorrectable OTP ECC bit for acknowledgement */
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200402 iwl_set_bit(trans(bus), CSR_OTP_GP_REG,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700403 CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK);
Don Fry1431b212011-11-10 06:55:26 -0800404 IWL_ERR(bus, "Uncorrectable OTP ECC error, abort OTP read\n");
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700405 return -EINVAL;
406 }
407 if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) {
408 /* continue in this case */
409 /* set the correctable OTP ECC bit for acknowledgement */
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200410 iwl_set_bit(trans(bus), CSR_OTP_GP_REG,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700411 CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK);
Don Fry1431b212011-11-10 06:55:26 -0800412 IWL_ERR(bus, "Correctable OTP ECC error, continue read\n");
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700413 }
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800414 *eeprom_data = cpu_to_le16(r >> 16);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700415 return 0;
416}
417
418/*
419 * iwl_is_otp_empty: check for empty OTP
420 */
Don Fry1431b212011-11-10 06:55:26 -0800421static bool iwl_is_otp_empty(struct iwl_bus *bus)
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700422{
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800423 u16 next_link_addr = 0;
424 __le16 link_value;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700425 bool is_empty = false;
426
427 /* locate the beginning of OTP link list */
Don Fry1431b212011-11-10 06:55:26 -0800428 if (!iwl_read_otp_word(bus, next_link_addr, &link_value)) {
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700429 if (!link_value) {
Don Fry1431b212011-11-10 06:55:26 -0800430 IWL_ERR(bus, "OTP is empty\n");
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700431 is_empty = true;
432 }
433 } else {
Don Fry1431b212011-11-10 06:55:26 -0800434 IWL_ERR(bus, "Unable to read first block of OTP list.\n");
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700435 is_empty = true;
436 }
437
438 return is_empty;
439}
440
441
442/*
443 * iwl_find_otp_image: find EEPROM image in OTP
444 * finding the OTP block that contains the EEPROM image.
445 * the last valid block on the link list (the block _before_ the last block)
446 * is the block we should read and used to configure the device.
447 * If all the available OTP blocks are full, the last block will be the block
448 * we should read and used to configure the device.
449 * only perform this operation if shadow RAM is disabled
450 */
Don Fry1431b212011-11-10 06:55:26 -0800451static int iwl_find_otp_image(struct iwl_bus *bus,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700452 u16 *validblockaddr)
453{
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800454 u16 next_link_addr = 0, valid_addr;
455 __le16 link_value = 0;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700456 int usedblocks = 0;
457
458 /* set addressing mode to absolute to traverse the link list */
Don Fry1431b212011-11-10 06:55:26 -0800459 iwl_set_otp_access(bus, IWL_OTP_ACCESS_ABSOLUTE);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700460
461 /* checking for empty OTP or error */
Don Fry1431b212011-11-10 06:55:26 -0800462 if (iwl_is_otp_empty(bus))
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700463 return -EINVAL;
464
465 /*
466 * start traverse link list
467 * until reach the max number of OTP blocks
468 * different devices have different number of OTP blocks
469 */
470 do {
471 /* save current valid block address
472 * check for more block on the link list
473 */
474 valid_addr = next_link_addr;
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800475 next_link_addr = le16_to_cpu(link_value) * sizeof(u16);
Don Fry1431b212011-11-10 06:55:26 -0800476 IWL_DEBUG_EEPROM(bus, "OTP blocks %d addr 0x%x\n",
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700477 usedblocks, next_link_addr);
Don Fry1431b212011-11-10 06:55:26 -0800478 if (iwl_read_otp_word(bus, next_link_addr, &link_value))
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700479 return -EINVAL;
480 if (!link_value) {
481 /*
Jay Sternberg2facba72009-10-02 13:43:55 -0700482 * reach the end of link list, return success and
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700483 * set address point to the starting address
484 * of the image
485 */
Jay Sternberg2facba72009-10-02 13:43:55 -0700486 *validblockaddr = valid_addr;
487 /* skip first 2 bytes (link list pointer) */
488 *validblockaddr += 2;
489 return 0;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700490 }
491 /* more in the link list, continue */
492 usedblocks++;
Don Fry38622412011-12-16 07:07:36 -0800493 } while (usedblocks <= cfg(bus)->base_params->max_ll_items);
Jay Sternberg2facba72009-10-02 13:43:55 -0700494
495 /* OTP has no valid blocks */
Don Fry1431b212011-11-10 06:55:26 -0800496 IWL_DEBUG_EEPROM(bus, "OTP has no valid blocks\n");
Jay Sternberg2facba72009-10-02 13:43:55 -0700497 return -EINVAL;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700498}
499
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700500/******************************************************************************
501 *
502 * Tx Power related functions
503 *
504******************************************************************************/
505/**
506 * iwl_get_max_txpower_avg - get the highest tx power from all chains.
507 * find the highest tx power from all chains for the channel
508 */
Don Fry1431b212011-11-10 06:55:26 -0800509static s8 iwl_get_max_txpower_avg(struct iwl_cfg *cfg,
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700510 struct iwl_eeprom_enhanced_txpwr *enhanced_txpower,
511 int element, s8 *max_txpower_in_half_dbm)
Wey-Yi Guy3be63ff2010-10-08 16:05:19 -0700512{
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700513 s8 max_txpower_avg = 0; /* (dBm) */
514
515 /* Take the highest tx power from any valid chains */
Don Fry1431b212011-11-10 06:55:26 -0800516 if ((cfg->valid_tx_ant & ANT_A) &&
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700517 (enhanced_txpower[element].chain_a_max > max_txpower_avg))
518 max_txpower_avg = enhanced_txpower[element].chain_a_max;
Don Fry1431b212011-11-10 06:55:26 -0800519 if ((cfg->valid_tx_ant & ANT_B) &&
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700520 (enhanced_txpower[element].chain_b_max > max_txpower_avg))
521 max_txpower_avg = enhanced_txpower[element].chain_b_max;
Don Fry1431b212011-11-10 06:55:26 -0800522 if ((cfg->valid_tx_ant & ANT_C) &&
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700523 (enhanced_txpower[element].chain_c_max > max_txpower_avg))
524 max_txpower_avg = enhanced_txpower[element].chain_c_max;
Don Fry1431b212011-11-10 06:55:26 -0800525 if (((cfg->valid_tx_ant == ANT_AB) |
526 (cfg->valid_tx_ant == ANT_BC) |
527 (cfg->valid_tx_ant == ANT_AC)) &&
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700528 (enhanced_txpower[element].mimo2_max > max_txpower_avg))
529 max_txpower_avg = enhanced_txpower[element].mimo2_max;
Don Fry1431b212011-11-10 06:55:26 -0800530 if ((cfg->valid_tx_ant == ANT_ABC) &&
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700531 (enhanced_txpower[element].mimo3_max > max_txpower_avg))
532 max_txpower_avg = enhanced_txpower[element].mimo3_max;
533
534 /*
535 * max. tx power in EEPROM is in 1/2 dBm format
536 * convert from 1/2 dBm to dBm (round-up convert)
537 * but we also do not want to loss 1/2 dBm resolution which
538 * will impact performance
539 */
540 *max_txpower_in_half_dbm = max_txpower_avg;
541 return (max_txpower_avg & 0x01) + (max_txpower_avg >> 1);
542}
543
544static void
545iwl_eeprom_enh_txp_read_element(struct iwl_priv *priv,
546 struct iwl_eeprom_enhanced_txpwr *txp,
547 s8 max_txpower_avg)
548{
549 int ch_idx;
550 bool is_ht40 = txp->flags & IWL_EEPROM_ENH_TXP_FL_40MHZ;
551 enum ieee80211_band band;
552
553 band = txp->flags & IWL_EEPROM_ENH_TXP_FL_BAND_52G ?
554 IEEE80211_BAND_5GHZ : IEEE80211_BAND_2GHZ;
555
556 for (ch_idx = 0; ch_idx < priv->channel_count; ch_idx++) {
557 struct iwl_channel_info *ch_info = &priv->channel_info[ch_idx];
558
559 /* update matching channel or from common data only */
560 if (txp->channel != 0 && ch_info->channel != txp->channel)
561 continue;
562
563 /* update matching band only */
564 if (band != ch_info->band)
565 continue;
566
567 if (ch_info->max_power_avg < max_txpower_avg && !is_ht40) {
568 ch_info->max_power_avg = max_txpower_avg;
569 ch_info->curr_txpow = max_txpower_avg;
570 ch_info->scan_power = max_txpower_avg;
571 }
572
573 if (is_ht40 && ch_info->ht40_max_power_avg < max_txpower_avg)
574 ch_info->ht40_max_power_avg = max_txpower_avg;
575 }
576}
577
578#define EEPROM_TXP_OFFS (0x00 | INDIRECT_ADDRESS | INDIRECT_TXP_LIMIT)
579#define EEPROM_TXP_ENTRY_LEN sizeof(struct iwl_eeprom_enhanced_txpwr)
580#define EEPROM_TXP_SZ_OFFS (0x00 | INDIRECT_ADDRESS | INDIRECT_TXP_LIMIT_SIZE)
581
582#define TXP_CHECK_AND_PRINT(x) ((txp->flags & IWL_EEPROM_ENH_TXP_FL_##x) \
583 ? # x " " : "")
584
585void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv)
586{
Don Fryab36eab2011-11-30 15:37:32 -0800587 struct iwl_shared *shrd = priv->shrd;
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700588 struct iwl_eeprom_enhanced_txpwr *txp_array, *txp;
589 int idx, entries;
590 __le16 *txp_len;
591 s8 max_txp_avg, max_txp_avg_halfdbm;
592
593 BUILD_BUG_ON(sizeof(struct iwl_eeprom_enhanced_txpwr) != 8);
594
595 /* the length is in 16-bit words, but we want entries */
Don Fryab36eab2011-11-30 15:37:32 -0800596 txp_len = (__le16 *) iwl_eeprom_query_addr(shrd, EEPROM_TXP_SZ_OFFS);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700597 entries = le16_to_cpup(txp_len) * 2 / EEPROM_TXP_ENTRY_LEN;
598
Don Fryab36eab2011-11-30 15:37:32 -0800599 txp_array = (void *) iwl_eeprom_query_addr(shrd, EEPROM_TXP_OFFS);
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700600
601 for (idx = 0; idx < entries; idx++) {
602 txp = &txp_array[idx];
603 /* skip invalid entries */
604 if (!(txp->flags & IWL_EEPROM_ENH_TXP_FL_VALID))
605 continue;
606
607 IWL_DEBUG_EEPROM(priv, "%s %d:\t %s%s%s%s%s%s%s%s (0x%02x)\n",
608 (txp->channel && (txp->flags &
609 IWL_EEPROM_ENH_TXP_FL_COMMON_TYPE)) ?
610 "Common " : (txp->channel) ?
611 "Channel" : "Common",
612 (txp->channel),
613 TXP_CHECK_AND_PRINT(VALID),
614 TXP_CHECK_AND_PRINT(BAND_52G),
615 TXP_CHECK_AND_PRINT(OFDM),
616 TXP_CHECK_AND_PRINT(40MHZ),
617 TXP_CHECK_AND_PRINT(HT_AP),
618 TXP_CHECK_AND_PRINT(RES1),
619 TXP_CHECK_AND_PRINT(RES2),
620 TXP_CHECK_AND_PRINT(COMMON_TYPE),
621 txp->flags);
622 IWL_DEBUG_EEPROM(priv, "\t\t chain_A: 0x%02x "
623 "chain_B: 0X%02x chain_C: 0X%02x\n",
624 txp->chain_a_max, txp->chain_b_max,
625 txp->chain_c_max);
626 IWL_DEBUG_EEPROM(priv, "\t\t MIMO2: 0x%02x "
627 "MIMO3: 0x%02x High 20_on_40: 0x%02x "
628 "Low 20_on_40: 0x%02x\n",
629 txp->mimo2_max, txp->mimo3_max,
630 ((txp->delta_20_in_40 & 0xf0) >> 4),
631 (txp->delta_20_in_40 & 0x0f));
632
Don Fry38622412011-12-16 07:07:36 -0800633 max_txp_avg = iwl_get_max_txpower_avg(cfg(priv), txp_array, idx,
Wey-Yi Guy701cb092011-09-15 11:46:41 -0700634 &max_txp_avg_halfdbm);
635
636 /*
637 * Update the user limit values values to the highest
638 * power supported by any channel
639 */
640 if (max_txp_avg > priv->tx_power_user_lmt)
641 priv->tx_power_user_lmt = max_txp_avg;
642 if (max_txp_avg_halfdbm > priv->tx_power_lmt_in_half_dbm)
643 priv->tx_power_lmt_in_half_dbm = max_txp_avg_halfdbm;
644
645 iwl_eeprom_enh_txp_read_element(priv, txp, max_txp_avg);
646 }
Wey-Yi Guy3be63ff2010-10-08 16:05:19 -0700647}
Wey-Yi Guy3be63ff2010-10-08 16:05:19 -0700648
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800649/**
650 * iwl_eeprom_init - read EEPROM contents
651 *
Don Fryab36eab2011-11-30 15:37:32 -0800652 * Load the EEPROM contents from adapter into shrd->eeprom
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800653 *
654 * NOTE: This routine uses the non-debug IO access functions.
655 */
Johannes Berge98a1302011-04-05 09:42:08 -0700656int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800657{
Don Fryab36eab2011-11-30 15:37:32 -0800658 struct iwl_shared *shrd = priv->shrd;
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800659 __le16 *e;
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200660 u32 gp = iwl_read32(trans(priv), CSR_EEPROM_GP);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700661 int sz;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800662 int ret;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800663 u16 addr;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700664 u16 validblockaddr = 0;
665 u16 cache_addr = 0;
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700666
Don Fry97b52cf2011-11-10 06:55:27 -0800667 trans(priv)->nvm_device_type = iwl_get_nvm_type(bus(priv), hw_rev);
668 if (trans(priv)->nvm_device_type == -ENOENT)
Wey-Yi Guyb23a0522009-07-17 09:30:21 -0700669 return -ENOENT;
Tomas Winkler073d3f52008-04-21 15:41:52 -0700670 /* allocate eeprom */
Don Fry38622412011-12-16 07:07:36 -0800671 sz = cfg(priv)->base_params->eeprom_size;
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800672 IWL_DEBUG_EEPROM(priv, "NVM size = %d\n", sz);
Don Fryab36eab2011-11-30 15:37:32 -0800673 shrd->eeprom = kzalloc(sz, GFP_KERNEL);
674 if (!shrd->eeprom) {
Tomas Winkler073d3f52008-04-21 15:41:52 -0700675 ret = -ENOMEM;
676 goto alloc_err;
677 }
Don Fryab36eab2011-11-30 15:37:32 -0800678 e = (__le16 *)shrd->eeprom;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800679
Don Fry97b52cf2011-11-10 06:55:27 -0800680 ret = iwl_eeprom_verify_signature(trans(priv));
Tomas Winkler073d3f52008-04-21 15:41:52 -0700681 if (ret < 0) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800682 IWL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700683 ret = -ENOENT;
684 goto err;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800685 }
686
687 /* Make sure driver (instead of uCode) is allowed to read EEPROM */
Don Fry1431b212011-11-10 06:55:26 -0800688 ret = iwl_eeprom_acquire_semaphore(bus(priv));
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800689 if (ret < 0) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800690 IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n");
Tomas Winkler073d3f52008-04-21 15:41:52 -0700691 ret = -ENOENT;
692 goto err;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800693 }
Ben Cahill88521362009-10-30 14:36:06 -0700694
Don Fry97b52cf2011-11-10 06:55:27 -0800695 if (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) {
Ben Cahill88521362009-10-30 14:36:06 -0700696
Don Fry1431b212011-11-10 06:55:26 -0800697 ret = iwl_init_otp_access(bus(priv));
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700698 if (ret) {
699 IWL_ERR(priv, "Failed to initialize OTP access.\n");
700 ret = -ENOENT;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700701 goto done;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800702 }
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200703 iwl_write32(trans(priv), CSR_EEPROM_GP,
704 iwl_read32(trans(priv), CSR_EEPROM_GP) &
Johannes Berg02a7fa02011-04-05 09:42:12 -0700705 ~CSR_EEPROM_GP_IF_OWNER_MSK);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700706
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200707 iwl_set_bit(trans(priv), CSR_OTP_GP_REG,
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700708 CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK |
709 CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700710 /* traversing the linked list if no shadow ram supported */
Don Fry38622412011-12-16 07:07:36 -0800711 if (!cfg(priv)->base_params->shadow_ram_support) {
Don Fry1431b212011-11-10 06:55:26 -0800712 if (iwl_find_otp_image(bus(priv), &validblockaddr)) {
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700713 ret = -ENOENT;
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700714 goto done;
715 }
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700716 }
717 for (addr = validblockaddr; addr < validblockaddr + sz;
718 addr += sizeof(u16)) {
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800719 __le16 eeprom_data;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700720
Don Fry1431b212011-11-10 06:55:26 -0800721 ret = iwl_read_otp_word(bus(priv), addr, &eeprom_data);
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700722 if (ret)
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700723 goto done;
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700724 e[cache_addr / 2] = eeprom_data;
725 cache_addr += sizeof(u16);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700726 }
727 } else {
728 /* eeprom is an array of 16bit values */
729 for (addr = 0; addr < sz; addr += sizeof(u16)) {
730 u32 r;
731
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200732 iwl_write32(trans(priv), CSR_EEPROM_REG,
Johannes Berg02a7fa02011-04-05 09:42:12 -0700733 CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700734
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200735 ret = iwl_poll_bit(trans(priv), CSR_EEPROM_REG,
Abhijeet Kolekar1739d332009-10-02 13:44:05 -0700736 CSR_EEPROM_REG_READ_VALID_MSK,
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700737 CSR_EEPROM_REG_READ_VALID_MSK,
738 IWL_EEPROM_ACCESS_TIMEOUT);
739 if (ret < 0) {
740 IWL_ERR(priv, "Time out reading EEPROM[%d]\n", addr);
741 goto done;
742 }
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200743 r = iwl_read32(trans(priv), CSR_EEPROM_REG);
Johannes Bergaf6b8ee2009-12-14 14:12:08 -0800744 e[addr / 2] = cpu_to_le16(r >> 16);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700745 }
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800746 }
Johannes Bergd1358f62010-04-28 12:09:15 -0700747
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800748 IWL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n",
Don Fry97b52cf2011-11-10 06:55:27 -0800749 (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP)
Johannes Bergd1358f62010-04-28 12:09:15 -0700750 ? "OTP" : "EEPROM",
Don Fryab36eab2011-11-30 15:37:32 -0800751 iwl_eeprom_query16(shrd, EEPROM_VERSION));
Johannes Bergd1358f62010-04-28 12:09:15 -0700752
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800753 ret = 0;
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800754done:
Don Fry1431b212011-11-10 06:55:26 -0800755 iwl_eeprom_release_semaphore(bus(priv));
Johannes Bergd1358f62010-04-28 12:09:15 -0700756
Tomas Winkler073d3f52008-04-21 15:41:52 -0700757err:
758 if (ret)
Don Fryab36eab2011-11-30 15:37:32 -0800759 iwl_eeprom_free(priv->shrd);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700760alloc_err:
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800761 return ret;
762}
Assaf Krauss34cf6ff2008-03-06 10:40:20 -0800763
Don Fryab36eab2011-11-30 15:37:32 -0800764void iwl_eeprom_free(struct iwl_shared *shrd)
Tomas Winkler073d3f52008-04-21 15:41:52 -0700765{
Don Fryab36eab2011-11-30 15:37:32 -0800766 kfree(shrd->eeprom);
767 shrd->eeprom = NULL;
Tomas Winkler073d3f52008-04-21 15:41:52 -0700768}
Tomas Winkler073d3f52008-04-21 15:41:52 -0700769
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700770static void iwl_init_band_reference(const struct iwl_priv *priv,
Tomas Winkler073d3f52008-04-21 15:41:52 -0700771 int eep_band, int *eeprom_ch_count,
772 const struct iwl_eeprom_channel **eeprom_ch_info,
773 const u8 **eeprom_ch_index)
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700774{
Don Fryab36eab2011-11-30 15:37:32 -0800775 struct iwl_shared *shrd = priv->shrd;
Don Fry38622412011-12-16 07:07:36 -0800776 u32 offset = cfg(priv)->lib->
Tomas Winkler073d3f52008-04-21 15:41:52 -0700777 eeprom_ops.regulatory_bands[eep_band - 1];
778 switch (eep_band) {
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700779 case 1: /* 2.4GHz band */
780 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_1);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700781 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800782 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700783 *eeprom_ch_index = iwl_eeprom_band_1;
784 break;
785 case 2: /* 4.9GHz band */
786 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_2);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700787 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800788 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700789 *eeprom_ch_index = iwl_eeprom_band_2;
790 break;
791 case 3: /* 5.2GHz band */
792 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_3);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700793 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800794 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700795 *eeprom_ch_index = iwl_eeprom_band_3;
796 break;
797 case 4: /* 5.5GHz band */
798 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_4);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700799 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800800 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700801 *eeprom_ch_index = iwl_eeprom_band_4;
802 break;
803 case 5: /* 5.7GHz band */
804 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_5);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700805 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800806 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700807 *eeprom_ch_index = iwl_eeprom_band_5;
808 break;
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700809 case 6: /* 2.4GHz ht40 channels */
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700810 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_6);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700811 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800812 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700813 *eeprom_ch_index = iwl_eeprom_band_6;
814 break;
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700815 case 7: /* 5 GHz ht40 channels */
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700816 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_7);
Tomas Winkler073d3f52008-04-21 15:41:52 -0700817 *eeprom_ch_info = (struct iwl_eeprom_channel *)
Don Fryab36eab2011-11-30 15:37:32 -0800818 iwl_eeprom_query_addr(shrd, offset);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700819 *eeprom_ch_index = iwl_eeprom_band_7;
820 break;
821 default:
822 BUG();
823 return;
824 }
825}
826
827#define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \
828 ? # x " " : "")
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700829/**
Zhu Yi3b247162009-08-13 13:30:53 -0700830 * iwl_mod_ht40_chan_info - Copy ht40 channel info into driver's priv.
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700831 *
832 * Does not set up a command, or touch hardware.
833 */
Zhu Yi3b247162009-08-13 13:30:53 -0700834static int iwl_mod_ht40_chan_info(struct iwl_priv *priv,
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700835 enum ieee80211_band band, u16 channel,
Tomas Winkler073d3f52008-04-21 15:41:52 -0700836 const struct iwl_eeprom_channel *eeprom_ch,
Zhu Yi3b247162009-08-13 13:30:53 -0700837 u8 clear_ht40_extension_channel)
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700838{
839 struct iwl_channel_info *ch_info;
840
841 ch_info = (struct iwl_channel_info *)
Assaf Krauss8622e702008-03-21 13:53:43 -0700842 iwl_get_channel_info(priv, band, channel);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700843
844 if (!is_channel_valid(ch_info))
845 return -1;
846
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800847 IWL_DEBUG_EEPROM(priv, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):"
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800848 " Ad-Hoc %ssupported\n",
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700849 ch_info->channel,
850 is_channel_a_band(ch_info) ?
851 "5.2" : "2.4",
852 CHECK_AND_PRINT(IBSS),
853 CHECK_AND_PRINT(ACTIVE),
854 CHECK_AND_PRINT(RADAR),
855 CHECK_AND_PRINT(WIDE),
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700856 CHECK_AND_PRINT(DFS),
857 eeprom_ch->flags,
858 eeprom_ch->max_power_avg,
859 ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS)
860 && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ?
861 "" : "not ");
862
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700863 ch_info->ht40_eeprom = *eeprom_ch;
864 ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg;
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700865 ch_info->ht40_flags = eeprom_ch->flags;
Reinette Chatre6c3069b2009-12-14 14:12:13 -0800866 if (eeprom_ch->flags & EEPROM_CHANNEL_VALID)
867 ch_info->ht40_extension_channel &= ~clear_ht40_extension_channel;
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700868
869 return 0;
870}
871
872#define CHECK_AND_PRINT_I(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \
873 ? # x " " : "")
874
875/**
876 * iwl_init_channel_map - Set up driver's info for all possible channels
877 */
878int iwl_init_channel_map(struct iwl_priv *priv)
879{
880 int eeprom_ch_count = 0;
881 const u8 *eeprom_ch_index = NULL;
Tomas Winkler073d3f52008-04-21 15:41:52 -0700882 const struct iwl_eeprom_channel *eeprom_ch_info = NULL;
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700883 int band, ch;
884 struct iwl_channel_info *ch_info;
885
886 if (priv->channel_count) {
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800887 IWL_DEBUG_EEPROM(priv, "Channel map already initialized.\n");
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700888 return 0;
889 }
890
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800891 IWL_DEBUG_EEPROM(priv, "Initializing regulatory info from EEPROM\n");
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700892
893 priv->channel_count =
894 ARRAY_SIZE(iwl_eeprom_band_1) +
895 ARRAY_SIZE(iwl_eeprom_band_2) +
896 ARRAY_SIZE(iwl_eeprom_band_3) +
897 ARRAY_SIZE(iwl_eeprom_band_4) +
898 ARRAY_SIZE(iwl_eeprom_band_5);
899
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800900 IWL_DEBUG_EEPROM(priv, "Parsing data for %d channels.\n",
901 priv->channel_count);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700902
Emmanuel Grumbach7f90dce2011-09-22 15:14:53 -0700903 priv->channel_info = kcalloc(priv->channel_count,
904 sizeof(struct iwl_channel_info),
905 GFP_KERNEL);
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700906 if (!priv->channel_info) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800907 IWL_ERR(priv, "Could not allocate channel_info\n");
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700908 priv->channel_count = 0;
909 return -ENOMEM;
910 }
911
912 ch_info = priv->channel_info;
913
914 /* Loop through the 5 EEPROM bands adding them in order to the
915 * channel map we maintain (that contains additional information than
916 * what just in the EEPROM) */
917 for (band = 1; band <= 5; band++) {
918
919 iwl_init_band_reference(priv, band, &eeprom_ch_count,
920 &eeprom_ch_info, &eeprom_ch_index);
921
922 /* Loop through each band adding each of the channels */
923 for (ch = 0; ch < eeprom_ch_count; ch++) {
924 ch_info->channel = eeprom_ch_index[ch];
925 ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ :
926 IEEE80211_BAND_5GHZ;
927
928 /* permanently store EEPROM's channel regulatory flags
929 * and max power in channel info database. */
930 ch_info->eeprom = eeprom_ch_info[ch];
931
932 /* Copy the run-time flags so they are there even on
933 * invalid channels */
934 ch_info->flags = eeprom_ch_info[ch].flags;
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700935 /* First write that ht40 is not enabled, and then enable
Emmanuel Grumbach963f5512008-06-12 09:47:00 +0800936 * one by one */
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700937 ch_info->ht40_extension_channel =
Zhu Yi3b247162009-08-13 13:30:53 -0700938 IEEE80211_CHAN_NO_HT40;
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700939
940 if (!(is_channel_valid(ch_info))) {
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800941 IWL_DEBUG_EEPROM(priv,
942 "Ch. %d Flags %x [%sGHz] - "
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700943 "No traffic\n",
944 ch_info->channel,
945 ch_info->flags,
946 is_channel_a_band(ch_info) ?
947 "5.2" : "2.4");
948 ch_info++;
949 continue;
950 }
951
952 /* Initialize regulatory-based run-time data */
953 ch_info->max_power_avg = ch_info->curr_txpow =
954 eeprom_ch_info[ch].max_power_avg;
955 ch_info->scan_power = eeprom_ch_info[ch].max_power_avg;
956 ch_info->min_power = 0;
957
Wey-Yi Guyd058ff82010-12-03 10:33:35 -0800958 IWL_DEBUG_EEPROM(priv, "Ch. %d [%sGHz] "
959 "%s%s%s%s%s%s(0x%02x %ddBm):"
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800960 " Ad-Hoc %ssupported\n",
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700961 ch_info->channel,
962 is_channel_a_band(ch_info) ?
963 "5.2" : "2.4",
964 CHECK_AND_PRINT_I(VALID),
965 CHECK_AND_PRINT_I(IBSS),
966 CHECK_AND_PRINT_I(ACTIVE),
967 CHECK_AND_PRINT_I(RADAR),
968 CHECK_AND_PRINT_I(WIDE),
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700969 CHECK_AND_PRINT_I(DFS),
970 eeprom_ch_info[ch].flags,
971 eeprom_ch_info[ch].max_power_avg,
972 ((eeprom_ch_info[ch].
973 flags & EEPROM_CHANNEL_IBSS)
974 && !(eeprom_ch_info[ch].
975 flags & EEPROM_CHANNEL_RADAR))
976 ? "" : "not ");
977
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700978 ch_info++;
979 }
980 }
981
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700982 /* Check if we do have HT40 channels */
Don Fry38622412011-12-16 07:07:36 -0800983 if (cfg(priv)->lib->eeprom_ops.regulatory_bands[5] ==
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700984 EEPROM_REGULATORY_BAND_NO_HT40 &&
Don Fry38622412011-12-16 07:07:36 -0800985 cfg(priv)->lib->eeprom_ops.regulatory_bands[6] ==
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700986 EEPROM_REGULATORY_BAND_NO_HT40)
Samuel Ortize6148912009-01-23 13:45:15 -0800987 return 0;
988
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700989 /* Two additional EEPROM bands for 2.4 and 5 GHz HT40 channels */
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700990 for (band = 6; band <= 7; band++) {
991 enum ieee80211_band ieeeband;
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700992
993 iwl_init_band_reference(priv, band, &eeprom_ch_count,
994 &eeprom_ch_info, &eeprom_ch_index);
995
996 /* EEPROM band 6 is 2.4, band 7 is 5 GHz */
997 ieeeband =
998 (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
999
1000 /* Loop through each band adding each of the channels */
1001 for (ch = 0; ch < eeprom_ch_count; ch++) {
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001002 /* Set up driver's info for lower half */
Zhu Yi3b247162009-08-13 13:30:53 -07001003 iwl_mod_ht40_chan_info(priv, ieeeband,
Tomas Winklerda6833c2008-05-15 13:54:15 +08001004 eeprom_ch_index[ch],
Zhu Yi3b247162009-08-13 13:30:53 -07001005 &eeprom_ch_info[ch],
1006 IEEE80211_CHAN_NO_HT40PLUS);
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001007
1008 /* Set up driver's info for upper half */
Zhu Yi3b247162009-08-13 13:30:53 -07001009 iwl_mod_ht40_chan_info(priv, ieeeband,
1010 eeprom_ch_index[ch] + 4,
1011 &eeprom_ch_info[ch],
1012 IEEE80211_CHAN_NO_HT40MINUS);
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001013 }
1014 }
1015
Wey-Yi Guyab9fd1b2009-08-21 13:34:23 -07001016 /* for newer device (6000 series and up)
1017 * EEPROM contain enhanced tx power information
1018 * driver need to process addition information
1019 * to determine the max channel tx power limits
1020 */
Don Fry38622412011-12-16 07:07:36 -08001021 if (cfg(priv)->lib->eeprom_ops.update_enhanced_txpower)
1022 cfg(priv)->lib->eeprom_ops.update_enhanced_txpower(priv);
Wey-Yi Guyab9fd1b2009-08-21 13:34:23 -07001023
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001024 return 0;
1025}
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001026
1027/*
Tomas Winklerda6833c2008-05-15 13:54:15 +08001028 * iwl_free_channel_map - undo allocations in iwl_init_channel_map
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001029 */
1030void iwl_free_channel_map(struct iwl_priv *priv)
1031{
1032 kfree(priv->channel_info);
1033 priv->channel_count = 0;
1034}
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001035
1036/**
1037 * iwl_get_channel_info - Find driver's private channel info
1038 *
1039 * Based on band and channel number.
1040 */
Tomas Winkler82a66bb2008-05-29 16:35:28 +08001041const struct iwl_channel_info *iwl_get_channel_info(const struct iwl_priv *priv,
1042 enum ieee80211_band band, u16 channel)
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001043{
1044 int i;
1045
1046 switch (band) {
1047 case IEEE80211_BAND_5GHZ:
1048 for (i = 14; i < priv->channel_count; i++) {
1049 if (priv->channel_info[i].channel == channel)
1050 return &priv->channel_info[i];
1051 }
1052 break;
1053 case IEEE80211_BAND_2GHZ:
1054 if (channel >= 1 && channel <= 14)
1055 return &priv->channel_info[channel - 1];
1056 break;
1057 default:
1058 BUG();
1059 }
1060
1061 return NULL;
1062}
Wey-Yi Guy86cb3b42011-06-14 15:23:39 -07001063
1064void iwl_rf_config(struct iwl_priv *priv)
1065{
1066 u16 radio_cfg;
1067
Don Fryab36eab2011-11-30 15:37:32 -08001068 radio_cfg = iwl_eeprom_query16(priv->shrd, EEPROM_RADIO_CONFIG);
Wey-Yi Guy86cb3b42011-06-14 15:23:39 -07001069
1070 /* write radio config values to register */
1071 if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX) {
Emmanuel Grumbach1042db22012-01-03 16:56:15 +02001072 iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG,
Wey-Yi Guy86cb3b42011-06-14 15:23:39 -07001073 EEPROM_RF_CFG_TYPE_MSK(radio_cfg) |
1074 EEPROM_RF_CFG_STEP_MSK(radio_cfg) |
1075 EEPROM_RF_CFG_DASH_MSK(radio_cfg));
1076 IWL_INFO(priv, "Radio type=0x%x-0x%x-0x%x\n",
1077 EEPROM_RF_CFG_TYPE_MSK(radio_cfg),
1078 EEPROM_RF_CFG_STEP_MSK(radio_cfg),
1079 EEPROM_RF_CFG_DASH_MSK(radio_cfg));
1080 } else
1081 WARN_ON(1);
1082
1083 /* set CSR_HW_CONFIG_REG for uCode use */
Emmanuel Grumbach1042db22012-01-03 16:56:15 +02001084 iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG,
Wey-Yi Guy86cb3b42011-06-14 15:23:39 -07001085 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
1086 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
1087}