Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * This file is provided under a dual BSD/GPLv2 license. When using or |
| 4 | * redistributing this file, you may do so under either license. |
| 5 | * |
| 6 | * GPL LICENSE SUMMARY |
| 7 | * |
Wey-Yi Guy | 4e31826 | 2011-12-27 11:21:32 -0800 | [diff] [blame] | 8 | * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of version 2 of the GNU General Public License as |
| 12 | * published by the Free Software Foundation. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, |
| 22 | * USA |
| 23 | * |
| 24 | * The full GNU General Public License is included in this distribution |
| 25 | * in the file called LICENSE.GPL. |
| 26 | * |
| 27 | * Contact Information: |
Winkler, Tomas | 759ef89 | 2008-12-09 11:28:58 -0800 | [diff] [blame] | 28 | * Intel Linux Wireless <ilw@linux.intel.com> |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 29 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 30 | * |
| 31 | * BSD LICENSE |
| 32 | * |
Wey-Yi Guy | 4e31826 | 2011-12-27 11:21:32 -0800 | [diff] [blame] | 33 | * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 34 | * All rights reserved. |
| 35 | * |
| 36 | * Redistribution and use in source and binary forms, with or without |
| 37 | * modification, are permitted provided that the following conditions |
| 38 | * are met: |
| 39 | * |
| 40 | * * Redistributions of source code must retain the above copyright |
| 41 | * notice, this list of conditions and the following disclaimer. |
| 42 | * * Redistributions in binary form must reproduce the above copyright |
| 43 | * notice, this list of conditions and the following disclaimer in |
| 44 | * the documentation and/or other materials provided with the |
| 45 | * distribution. |
| 46 | * * Neither the name Intel Corporation nor the names of its |
| 47 | * contributors may be used to endorse or promote products derived |
| 48 | * from this software without specific prior written permission. |
| 49 | * |
| 50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 51 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 52 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 53 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 54 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 55 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 56 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 57 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 58 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 59 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 61 | *****************************************************************************/ |
| 62 | |
| 63 | |
| 64 | #include <linux/kernel.h> |
| 65 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 66 | #include <linux/slab.h> |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 67 | #include <linux/init.h> |
| 68 | |
| 69 | #include <net/mac80211.h> |
| 70 | |
Tomas Winkler | 5a36ba0 | 2008-04-24 11:55:37 -0700 | [diff] [blame] | 71 | #include "iwl-commands.h" |
Tomas Winkler | 3e0d4cb | 2008-04-24 11:55:38 -0700 | [diff] [blame] | 72 | #include "iwl-dev.h" |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 73 | #include "iwl-core.h" |
Tomas Winkler | 0a6857e | 2008-03-12 16:58:49 -0700 | [diff] [blame] | 74 | #include "iwl-debug.h" |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 75 | #include "iwl-agn.h" |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 76 | #include "iwl-eeprom.h" |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 77 | #include "iwl-io.h" |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 78 | |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 79 | /************************** 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 */ |
| 111 | const 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 */ |
| 116 | static const u8 iwl_eeprom_band_2[] = { /* 4915-5080MHz */ |
| 117 | 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 |
| 118 | }; |
| 119 | |
| 120 | static const u8 iwl_eeprom_band_3[] = { /* 5170-5320MHz */ |
| 121 | 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 |
| 122 | }; |
| 123 | |
| 124 | static const u8 iwl_eeprom_band_4[] = { /* 5500-5700MHz */ |
| 125 | 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 |
| 126 | }; |
| 127 | |
| 128 | static const u8 iwl_eeprom_band_5[] = { /* 5725-5825MHz */ |
| 129 | 145, 149, 153, 157, 161, 165 |
| 130 | }; |
| 131 | |
Wey-Yi Guy | 7aafef1 | 2009-08-07 15:41:38 -0700 | [diff] [blame] | 132 | static const u8 iwl_eeprom_band_6[] = { /* 2.4 ht40 channel */ |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 133 | 1, 2, 3, 4, 5, 6, 7 |
| 134 | }; |
| 135 | |
Wey-Yi Guy | 7aafef1 | 2009-08-07 15:41:38 -0700 | [diff] [blame] | 136 | static const u8 iwl_eeprom_band_7[] = { /* 5.2 ht40 channel */ |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 137 | 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157 |
| 138 | }; |
| 139 | |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 140 | /****************************************************************************** |
| 141 | * |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 142 | * generic NVM functions |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 143 | * |
| 144 | ******************************************************************************/ |
| 145 | |
Don Fry | 16b80b7 | 2011-04-20 15:25:14 -0700 | [diff] [blame] | 146 | /* |
| 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 | */ |
Emmanuel Grumbach | 9030474 | 2012-02-13 11:17:57 +0200 | [diff] [blame] | 152 | |
| 153 | #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ |
| 154 | #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ |
| 155 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 156 | static int iwl_eeprom_acquire_semaphore(struct iwl_trans *trans) |
Don Fry | 16b80b7 | 2011-04-20 15:25:14 -0700 | [diff] [blame] | 157 | { |
| 158 | u16 count; |
| 159 | int ret; |
| 160 | |
| 161 | for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { |
| 162 | /* Request semaphore */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 163 | iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, |
Don Fry | 16b80b7 | 2011-04-20 15:25:14 -0700 | [diff] [blame] | 164 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); |
| 165 | |
| 166 | /* See if we got it */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 167 | ret = iwl_poll_bit(trans, CSR_HW_IF_CONFIG_REG, |
Don Fry | 16b80b7 | 2011-04-20 15:25:14 -0700 | [diff] [blame] | 168 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, |
| 169 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, |
| 170 | EEPROM_SEM_TIMEOUT); |
| 171 | if (ret >= 0) { |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 172 | IWL_DEBUG_EEPROM(trans, |
Don Fry | 16b80b7 | 2011-04-20 15:25:14 -0700 | [diff] [blame] | 173 | "Acquired semaphore after %d tries.\n", |
| 174 | count+1); |
| 175 | return ret; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | return ret; |
| 180 | } |
| 181 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 182 | static void iwl_eeprom_release_semaphore(struct iwl_trans *trans) |
Don Fry | 16b80b7 | 2011-04-20 15:25:14 -0700 | [diff] [blame] | 183 | { |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 184 | iwl_clear_bit(trans, CSR_HW_IF_CONFIG_REG, |
Don Fry | 16b80b7 | 2011-04-20 15:25:14 -0700 | [diff] [blame] | 185 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); |
| 186 | |
| 187 | } |
| 188 | |
Don Fry | 97b52cf | 2011-11-10 06:55:27 -0800 | [diff] [blame] | 189 | static int iwl_eeprom_verify_signature(struct iwl_trans *trans) |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 190 | { |
Emmanuel Grumbach | 1042db2 | 2012-01-03 16:56:15 +0200 | [diff] [blame] | 191 | u32 gp = iwl_read32(trans, CSR_EEPROM_GP) & |
| 192 | CSR_EEPROM_GP_VALID_MSK; |
Wey-Yi Guy | f41bb89 | 2009-10-02 13:44:06 -0700 | [diff] [blame] | 193 | int ret = 0; |
| 194 | |
Don Fry | 97b52cf | 2011-11-10 06:55:27 -0800 | [diff] [blame] | 195 | IWL_DEBUG_EEPROM(trans, "EEPROM signature=0x%08x\n", gp); |
Wey-Yi Guy | f41bb89 | 2009-10-02 13:44:06 -0700 | [diff] [blame] | 196 | switch (gp) { |
| 197 | case CSR_EEPROM_GP_BAD_SIG_EEP_GOOD_SIG_OTP: |
Don Fry | 97b52cf | 2011-11-10 06:55:27 -0800 | [diff] [blame] | 198 | if (trans->nvm_device_type != NVM_DEVICE_TYPE_OTP) { |
| 199 | IWL_ERR(trans, "EEPROM with bad signature: 0x%08x\n", |
Wey-Yi Guy | f41bb89 | 2009-10-02 13:44:06 -0700 | [diff] [blame] | 200 | gp); |
| 201 | ret = -ENOENT; |
| 202 | } |
| 203 | break; |
| 204 | case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: |
| 205 | case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: |
Don Fry | 97b52cf | 2011-11-10 06:55:27 -0800 | [diff] [blame] | 206 | if (trans->nvm_device_type != NVM_DEVICE_TYPE_EEPROM) { |
| 207 | IWL_ERR(trans, "OTP with bad signature: 0x%08x\n", gp); |
Wey-Yi Guy | f41bb89 | 2009-10-02 13:44:06 -0700 | [diff] [blame] | 208 | ret = -ENOENT; |
| 209 | } |
| 210 | break; |
| 211 | case CSR_EEPROM_GP_BAD_SIGNATURE_BOTH_EEP_AND_OTP: |
| 212 | default: |
Don Fry | 97b52cf | 2011-11-10 06:55:27 -0800 | [diff] [blame] | 213 | IWL_ERR(trans, "bad EEPROM/OTP signature, type=%s, " |
Wey-Yi Guy | f41bb89 | 2009-10-02 13:44:06 -0700 | [diff] [blame] | 214 | "EEPROM_GP=0x%08x\n", |
Don Fry | 97b52cf | 2011-11-10 06:55:27 -0800 | [diff] [blame] | 215 | (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP) |
Wey-Yi Guy | f41bb89 | 2009-10-02 13:44:06 -0700 | [diff] [blame] | 216 | ? "OTP" : "EEPROM", gp); |
| 217 | ret = -ENOENT; |
| 218 | break; |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 219 | } |
Wey-Yi Guy | f41bb89 | 2009-10-02 13:44:06 -0700 | [diff] [blame] | 220 | return ret; |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 221 | } |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 222 | |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 223 | u16 iwl_eeprom_query16(const struct iwl_shared *shrd, size_t offset) |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 224 | { |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 225 | if (!shrd->eeprom) |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 226 | return 0; |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 227 | return (u16)shrd->eeprom[offset] | ((u16)shrd->eeprom[offset + 1] << 8); |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | int iwl_eeprom_check_version(struct iwl_priv *priv) |
| 231 | { |
| 232 | u16 eeprom_ver; |
| 233 | u16 calib_ver; |
| 234 | |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 235 | eeprom_ver = iwl_eeprom_query16(priv->shrd, EEPROM_VERSION); |
| 236 | calib_ver = iwl_eeprom_calib_version(priv->shrd); |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 237 | |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 238 | if (eeprom_ver < cfg(priv)->eeprom_ver || |
| 239 | calib_ver < cfg(priv)->eeprom_calib_ver) |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 240 | goto err; |
| 241 | |
| 242 | IWL_INFO(priv, "device EEPROM VER=0x%x, CALIB=0x%x\n", |
| 243 | eeprom_ver, calib_ver); |
| 244 | |
| 245 | return 0; |
| 246 | err: |
| 247 | IWL_ERR(priv, "Unsupported (too old) EEPROM VER=0x%x < 0x%x " |
| 248 | "CALIB=0x%x < 0x%x\n", |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 249 | eeprom_ver, cfg(priv)->eeprom_ver, |
| 250 | calib_ver, cfg(priv)->eeprom_calib_ver); |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 251 | return -EINVAL; |
| 252 | |
| 253 | } |
| 254 | |
Johannes Berg | 54708d8 | 2012-03-05 11:24:31 -0800 | [diff] [blame] | 255 | int iwl_eeprom_init_hw_params(struct iwl_priv *priv) |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 256 | { |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 257 | struct iwl_shared *shrd = priv->shrd; |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 258 | u16 radio_cfg; |
| 259 | |
Johannes Berg | 54708d8 | 2012-03-05 11:24:31 -0800 | [diff] [blame] | 260 | hw_params(priv).sku = iwl_eeprom_query16(shrd, EEPROM_SKU_CAP); |
| 261 | if (hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE && |
| 262 | !cfg(priv)->ht_params) { |
| 263 | IWL_ERR(priv, "Invalid 11n configuration\n"); |
| 264 | return -EINVAL; |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 265 | } |
Johannes Berg | 54708d8 | 2012-03-05 11:24:31 -0800 | [diff] [blame] | 266 | |
| 267 | if (!hw_params(priv).sku) { |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 268 | IWL_ERR(priv, "Invalid device sku\n"); |
| 269 | return -EINVAL; |
| 270 | } |
| 271 | |
Johannes Berg | 54708d8 | 2012-03-05 11:24:31 -0800 | [diff] [blame] | 272 | IWL_INFO(priv, "Device SKU: 0x%X\n", hw_params(priv).sku); |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 273 | |
Johannes Berg | 7e79a39 | 2012-03-05 11:24:32 -0800 | [diff] [blame] | 274 | radio_cfg = iwl_eeprom_query16(shrd, EEPROM_RADIO_CONFIG); |
| 275 | |
| 276 | hw_params(priv).valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg); |
| 277 | hw_params(priv).valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg); |
| 278 | |
| 279 | /* check overrides (some devices have wrong EEPROM) */ |
| 280 | if (cfg(priv)->valid_tx_ant) |
| 281 | hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant; |
| 282 | if (cfg(priv)->valid_rx_ant) |
| 283 | hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant; |
| 284 | |
| 285 | if (!hw_params(priv).valid_tx_ant || !hw_params(priv).valid_rx_ant) { |
| 286 | IWL_ERR(priv, "Invalid chain (0x%X, 0x%X)\n", |
| 287 | hw_params(priv).valid_tx_ant, |
| 288 | hw_params(priv).valid_rx_ant); |
| 289 | return -EINVAL; |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 290 | } |
Johannes Berg | 7e79a39 | 2012-03-05 11:24:32 -0800 | [diff] [blame] | 291 | |
| 292 | IWL_INFO(priv, "Valid Tx ant: 0x%X, Valid Rx ant: 0x%X\n", |
| 293 | hw_params(priv).valid_tx_ant, hw_params(priv).valid_rx_ant); |
| 294 | |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 295 | return 0; |
| 296 | } |
| 297 | |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 298 | void iwl_eeprom_get_mac(const struct iwl_shared *shrd, u8 *mac) |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 299 | { |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 300 | const u8 *addr = iwl_eeprom_query_addr(shrd, |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 301 | EEPROM_MAC_ADDRESS); |
| 302 | memcpy(mac, addr, ETH_ALEN); |
| 303 | } |
| 304 | |
| 305 | /****************************************************************************** |
| 306 | * |
| 307 | * OTP related functions |
| 308 | * |
| 309 | ******************************************************************************/ |
| 310 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 311 | static void iwl_set_otp_access(struct iwl_trans *trans, |
| 312 | enum iwl_access_mode mode) |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 313 | { |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 314 | iwl_read32(trans, CSR_OTP_GP_REG); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 315 | |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 316 | if (mode == IWL_OTP_ACCESS_ABSOLUTE) |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 317 | iwl_clear_bit(trans, CSR_OTP_GP_REG, |
Johannes Berg | 70817b5 | 2011-05-11 03:29:25 -0700 | [diff] [blame] | 318 | CSR_OTP_GP_REG_OTP_ACCESS_MODE); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 319 | else |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 320 | iwl_set_bit(trans, CSR_OTP_GP_REG, |
Johannes Berg | 70817b5 | 2011-05-11 03:29:25 -0700 | [diff] [blame] | 321 | CSR_OTP_GP_REG_OTP_ACCESS_MODE); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 322 | } |
| 323 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 324 | static int iwl_get_nvm_type(struct iwl_trans *trans, u32 hw_rev) |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 325 | { |
| 326 | u32 otpgp; |
| 327 | int nvm_type; |
| 328 | |
| 329 | /* OTP only valid for CP/PP and after */ |
Johannes Berg | e98a130 | 2011-04-05 09:42:08 -0700 | [diff] [blame] | 330 | switch (hw_rev & CSR_HW_REV_TYPE_MSK) { |
Wey-Yi Guy | b23a052 | 2009-07-17 09:30:21 -0700 | [diff] [blame] | 331 | case CSR_HW_REV_TYPE_NONE: |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 332 | IWL_ERR(trans, "Unknown hardware type\n"); |
Wey-Yi Guy | b23a052 | 2009-07-17 09:30:21 -0700 | [diff] [blame] | 333 | return -ENOENT; |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 334 | case CSR_HW_REV_TYPE_5300: |
| 335 | case CSR_HW_REV_TYPE_5350: |
| 336 | case CSR_HW_REV_TYPE_5100: |
| 337 | case CSR_HW_REV_TYPE_5150: |
| 338 | nvm_type = NVM_DEVICE_TYPE_EEPROM; |
| 339 | break; |
| 340 | default: |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 341 | otpgp = iwl_read32(trans, CSR_OTP_GP_REG); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 342 | if (otpgp & CSR_OTP_GP_REG_DEVICE_SELECT) |
| 343 | nvm_type = NVM_DEVICE_TYPE_OTP; |
| 344 | else |
| 345 | nvm_type = NVM_DEVICE_TYPE_EEPROM; |
| 346 | break; |
| 347 | } |
| 348 | return nvm_type; |
| 349 | } |
| 350 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 351 | static int iwl_init_otp_access(struct iwl_trans *trans) |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 352 | { |
| 353 | int ret; |
| 354 | |
| 355 | /* Enable 40MHz radio clock */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 356 | iwl_write32(trans, CSR_GP_CNTRL, |
| 357 | iwl_read32(trans, CSR_GP_CNTRL) | |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 358 | CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 359 | |
| 360 | /* wait for clock to be ready */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 361 | ret = iwl_poll_bit(trans, CSR_GP_CNTRL, |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 362 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, |
| 363 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, |
| 364 | 25000); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 365 | if (ret < 0) |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 366 | IWL_ERR(trans, "Time out access OTP\n"); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 367 | else { |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 368 | iwl_set_bits_prph(trans, APMG_PS_CTRL_REG, |
Reinette Chatre | d77b034 | 2009-05-22 14:37:55 -0700 | [diff] [blame] | 369 | APMG_PS_CTRL_VAL_RESET_REQ); |
| 370 | udelay(5); |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 371 | iwl_clear_bits_prph(trans, APMG_PS_CTRL_REG, |
Reinette Chatre | d77b034 | 2009-05-22 14:37:55 -0700 | [diff] [blame] | 372 | APMG_PS_CTRL_VAL_RESET_REQ); |
Wey-Yi Guy | 32004ee | 2009-10-16 14:25:56 -0700 | [diff] [blame] | 373 | |
| 374 | /* |
| 375 | * CSR auto clock gate disable bit - |
| 376 | * this is only applicable for HW with OTP shadow RAM |
| 377 | */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 378 | if (cfg(trans)->base_params->shadow_ram_support) |
| 379 | iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, |
Wey-Yi Guy | 32004ee | 2009-10-16 14:25:56 -0700 | [diff] [blame] | 380 | CSR_RESET_LINK_PWR_MGMT_DISABLED); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 381 | } |
| 382 | return ret; |
| 383 | } |
| 384 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 385 | static int iwl_read_otp_word(struct iwl_trans *trans, u16 addr, |
| 386 | __le16 *eeprom_data) |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 387 | { |
| 388 | int ret = 0; |
| 389 | u32 r; |
| 390 | u32 otpgp; |
| 391 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 392 | iwl_write32(trans, CSR_EEPROM_REG, |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 393 | CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 394 | ret = iwl_poll_bit(trans, CSR_EEPROM_REG, |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 395 | CSR_EEPROM_REG_READ_VALID_MSK, |
| 396 | CSR_EEPROM_REG_READ_VALID_MSK, |
| 397 | IWL_EEPROM_ACCESS_TIMEOUT); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 398 | if (ret < 0) { |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 399 | IWL_ERR(trans, "Time out reading OTP[%d]\n", addr); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 400 | return ret; |
| 401 | } |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 402 | r = iwl_read32(trans, CSR_EEPROM_REG); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 403 | /* check for ECC errors: */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 404 | otpgp = iwl_read32(trans, CSR_OTP_GP_REG); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 405 | if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) { |
| 406 | /* stop in this case */ |
| 407 | /* set the uncorrectable OTP ECC bit for acknowledgement */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 408 | iwl_set_bit(trans, CSR_OTP_GP_REG, |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 409 | CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 410 | IWL_ERR(trans, "Uncorrectable OTP ECC error, abort OTP read\n"); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 411 | return -EINVAL; |
| 412 | } |
| 413 | if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) { |
| 414 | /* continue in this case */ |
| 415 | /* set the correctable OTP ECC bit for acknowledgement */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 416 | iwl_set_bit(trans, CSR_OTP_GP_REG, |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 417 | CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK); |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 418 | IWL_ERR(trans, "Correctable OTP ECC error, continue read\n"); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 419 | } |
Johannes Berg | af6b8ee | 2009-12-14 14:12:08 -0800 | [diff] [blame] | 420 | *eeprom_data = cpu_to_le16(r >> 16); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 421 | return 0; |
| 422 | } |
| 423 | |
| 424 | /* |
| 425 | * iwl_is_otp_empty: check for empty OTP |
| 426 | */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 427 | static bool iwl_is_otp_empty(struct iwl_trans *trans) |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 428 | { |
Johannes Berg | af6b8ee | 2009-12-14 14:12:08 -0800 | [diff] [blame] | 429 | u16 next_link_addr = 0; |
| 430 | __le16 link_value; |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 431 | bool is_empty = false; |
| 432 | |
| 433 | /* locate the beginning of OTP link list */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 434 | if (!iwl_read_otp_word(trans, next_link_addr, &link_value)) { |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 435 | if (!link_value) { |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 436 | IWL_ERR(trans, "OTP is empty\n"); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 437 | is_empty = true; |
| 438 | } |
| 439 | } else { |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 440 | IWL_ERR(trans, "Unable to read first block of OTP list.\n"); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 441 | is_empty = true; |
| 442 | } |
| 443 | |
| 444 | return is_empty; |
| 445 | } |
| 446 | |
| 447 | |
| 448 | /* |
| 449 | * iwl_find_otp_image: find EEPROM image in OTP |
| 450 | * finding the OTP block that contains the EEPROM image. |
| 451 | * the last valid block on the link list (the block _before_ the last block) |
| 452 | * is the block we should read and used to configure the device. |
| 453 | * If all the available OTP blocks are full, the last block will be the block |
| 454 | * we should read and used to configure the device. |
| 455 | * only perform this operation if shadow RAM is disabled |
| 456 | */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 457 | static int iwl_find_otp_image(struct iwl_trans *trans, |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 458 | u16 *validblockaddr) |
| 459 | { |
Johannes Berg | af6b8ee | 2009-12-14 14:12:08 -0800 | [diff] [blame] | 460 | u16 next_link_addr = 0, valid_addr; |
| 461 | __le16 link_value = 0; |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 462 | int usedblocks = 0; |
| 463 | |
| 464 | /* set addressing mode to absolute to traverse the link list */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 465 | iwl_set_otp_access(trans, IWL_OTP_ACCESS_ABSOLUTE); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 466 | |
| 467 | /* checking for empty OTP or error */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 468 | if (iwl_is_otp_empty(trans)) |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 469 | return -EINVAL; |
| 470 | |
| 471 | /* |
| 472 | * start traverse link list |
| 473 | * until reach the max number of OTP blocks |
| 474 | * different devices have different number of OTP blocks |
| 475 | */ |
| 476 | do { |
| 477 | /* save current valid block address |
| 478 | * check for more block on the link list |
| 479 | */ |
| 480 | valid_addr = next_link_addr; |
Johannes Berg | af6b8ee | 2009-12-14 14:12:08 -0800 | [diff] [blame] | 481 | next_link_addr = le16_to_cpu(link_value) * sizeof(u16); |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 482 | IWL_DEBUG_EEPROM(trans, "OTP blocks %d addr 0x%x\n", |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 483 | usedblocks, next_link_addr); |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 484 | if (iwl_read_otp_word(trans, next_link_addr, &link_value)) |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 485 | return -EINVAL; |
| 486 | if (!link_value) { |
| 487 | /* |
Jay Sternberg | 2facba7 | 2009-10-02 13:43:55 -0700 | [diff] [blame] | 488 | * reach the end of link list, return success and |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 489 | * set address point to the starting address |
| 490 | * of the image |
| 491 | */ |
Jay Sternberg | 2facba7 | 2009-10-02 13:43:55 -0700 | [diff] [blame] | 492 | *validblockaddr = valid_addr; |
| 493 | /* skip first 2 bytes (link list pointer) */ |
| 494 | *validblockaddr += 2; |
| 495 | return 0; |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 496 | } |
| 497 | /* more in the link list, continue */ |
| 498 | usedblocks++; |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 499 | } while (usedblocks <= cfg(trans)->base_params->max_ll_items); |
Jay Sternberg | 2facba7 | 2009-10-02 13:43:55 -0700 | [diff] [blame] | 500 | |
| 501 | /* OTP has no valid blocks */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 502 | IWL_DEBUG_EEPROM(trans, "OTP has no valid blocks\n"); |
Jay Sternberg | 2facba7 | 2009-10-02 13:43:55 -0700 | [diff] [blame] | 503 | return -EINVAL; |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 504 | } |
| 505 | |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 506 | /****************************************************************************** |
| 507 | * |
| 508 | * Tx Power related functions |
| 509 | * |
| 510 | ******************************************************************************/ |
| 511 | /** |
| 512 | * iwl_get_max_txpower_avg - get the highest tx power from all chains. |
| 513 | * find the highest tx power from all chains for the channel |
| 514 | */ |
Johannes Berg | 706c4ff | 2012-03-05 11:24:33 -0800 | [diff] [blame^] | 515 | static s8 iwl_get_max_txpower_avg(const struct iwl_cfg *cfg, |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 516 | struct iwl_eeprom_enhanced_txpwr *enhanced_txpower, |
| 517 | int element, s8 *max_txpower_in_half_dbm) |
Wey-Yi Guy | 3be63ff | 2010-10-08 16:05:19 -0700 | [diff] [blame] | 518 | { |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 519 | s8 max_txpower_avg = 0; /* (dBm) */ |
| 520 | |
| 521 | /* Take the highest tx power from any valid chains */ |
Don Fry | 1431b21 | 2011-11-10 06:55:26 -0800 | [diff] [blame] | 522 | if ((cfg->valid_tx_ant & ANT_A) && |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 523 | (enhanced_txpower[element].chain_a_max > max_txpower_avg)) |
| 524 | max_txpower_avg = enhanced_txpower[element].chain_a_max; |
Don Fry | 1431b21 | 2011-11-10 06:55:26 -0800 | [diff] [blame] | 525 | if ((cfg->valid_tx_ant & ANT_B) && |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 526 | (enhanced_txpower[element].chain_b_max > max_txpower_avg)) |
| 527 | max_txpower_avg = enhanced_txpower[element].chain_b_max; |
Don Fry | 1431b21 | 2011-11-10 06:55:26 -0800 | [diff] [blame] | 528 | if ((cfg->valid_tx_ant & ANT_C) && |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 529 | (enhanced_txpower[element].chain_c_max > max_txpower_avg)) |
| 530 | max_txpower_avg = enhanced_txpower[element].chain_c_max; |
Don Fry | 1431b21 | 2011-11-10 06:55:26 -0800 | [diff] [blame] | 531 | if (((cfg->valid_tx_ant == ANT_AB) | |
| 532 | (cfg->valid_tx_ant == ANT_BC) | |
| 533 | (cfg->valid_tx_ant == ANT_AC)) && |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 534 | (enhanced_txpower[element].mimo2_max > max_txpower_avg)) |
| 535 | max_txpower_avg = enhanced_txpower[element].mimo2_max; |
Don Fry | 1431b21 | 2011-11-10 06:55:26 -0800 | [diff] [blame] | 536 | if ((cfg->valid_tx_ant == ANT_ABC) && |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 537 | (enhanced_txpower[element].mimo3_max > max_txpower_avg)) |
| 538 | max_txpower_avg = enhanced_txpower[element].mimo3_max; |
| 539 | |
| 540 | /* |
| 541 | * max. tx power in EEPROM is in 1/2 dBm format |
| 542 | * convert from 1/2 dBm to dBm (round-up convert) |
| 543 | * but we also do not want to loss 1/2 dBm resolution which |
| 544 | * will impact performance |
| 545 | */ |
| 546 | *max_txpower_in_half_dbm = max_txpower_avg; |
| 547 | return (max_txpower_avg & 0x01) + (max_txpower_avg >> 1); |
| 548 | } |
| 549 | |
| 550 | static void |
| 551 | iwl_eeprom_enh_txp_read_element(struct iwl_priv *priv, |
| 552 | struct iwl_eeprom_enhanced_txpwr *txp, |
| 553 | s8 max_txpower_avg) |
| 554 | { |
| 555 | int ch_idx; |
| 556 | bool is_ht40 = txp->flags & IWL_EEPROM_ENH_TXP_FL_40MHZ; |
| 557 | enum ieee80211_band band; |
| 558 | |
| 559 | band = txp->flags & IWL_EEPROM_ENH_TXP_FL_BAND_52G ? |
| 560 | IEEE80211_BAND_5GHZ : IEEE80211_BAND_2GHZ; |
| 561 | |
| 562 | for (ch_idx = 0; ch_idx < priv->channel_count; ch_idx++) { |
| 563 | struct iwl_channel_info *ch_info = &priv->channel_info[ch_idx]; |
| 564 | |
| 565 | /* update matching channel or from common data only */ |
| 566 | if (txp->channel != 0 && ch_info->channel != txp->channel) |
| 567 | continue; |
| 568 | |
| 569 | /* update matching band only */ |
| 570 | if (band != ch_info->band) |
| 571 | continue; |
| 572 | |
| 573 | if (ch_info->max_power_avg < max_txpower_avg && !is_ht40) { |
| 574 | ch_info->max_power_avg = max_txpower_avg; |
| 575 | ch_info->curr_txpow = max_txpower_avg; |
| 576 | ch_info->scan_power = max_txpower_avg; |
| 577 | } |
| 578 | |
| 579 | if (is_ht40 && ch_info->ht40_max_power_avg < max_txpower_avg) |
| 580 | ch_info->ht40_max_power_avg = max_txpower_avg; |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | #define EEPROM_TXP_OFFS (0x00 | INDIRECT_ADDRESS | INDIRECT_TXP_LIMIT) |
| 585 | #define EEPROM_TXP_ENTRY_LEN sizeof(struct iwl_eeprom_enhanced_txpwr) |
| 586 | #define EEPROM_TXP_SZ_OFFS (0x00 | INDIRECT_ADDRESS | INDIRECT_TXP_LIMIT_SIZE) |
| 587 | |
| 588 | #define TXP_CHECK_AND_PRINT(x) ((txp->flags & IWL_EEPROM_ENH_TXP_FL_##x) \ |
| 589 | ? # x " " : "") |
| 590 | |
| 591 | void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv) |
| 592 | { |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 593 | struct iwl_shared *shrd = priv->shrd; |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 594 | struct iwl_eeprom_enhanced_txpwr *txp_array, *txp; |
| 595 | int idx, entries; |
| 596 | __le16 *txp_len; |
| 597 | s8 max_txp_avg, max_txp_avg_halfdbm; |
| 598 | |
| 599 | BUILD_BUG_ON(sizeof(struct iwl_eeprom_enhanced_txpwr) != 8); |
| 600 | |
| 601 | /* the length is in 16-bit words, but we want entries */ |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 602 | txp_len = (__le16 *) iwl_eeprom_query_addr(shrd, EEPROM_TXP_SZ_OFFS); |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 603 | entries = le16_to_cpup(txp_len) * 2 / EEPROM_TXP_ENTRY_LEN; |
| 604 | |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 605 | txp_array = (void *) iwl_eeprom_query_addr(shrd, EEPROM_TXP_OFFS); |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 606 | |
| 607 | for (idx = 0; idx < entries; idx++) { |
| 608 | txp = &txp_array[idx]; |
| 609 | /* skip invalid entries */ |
| 610 | if (!(txp->flags & IWL_EEPROM_ENH_TXP_FL_VALID)) |
| 611 | continue; |
| 612 | |
| 613 | IWL_DEBUG_EEPROM(priv, "%s %d:\t %s%s%s%s%s%s%s%s (0x%02x)\n", |
| 614 | (txp->channel && (txp->flags & |
| 615 | IWL_EEPROM_ENH_TXP_FL_COMMON_TYPE)) ? |
| 616 | "Common " : (txp->channel) ? |
| 617 | "Channel" : "Common", |
| 618 | (txp->channel), |
| 619 | TXP_CHECK_AND_PRINT(VALID), |
| 620 | TXP_CHECK_AND_PRINT(BAND_52G), |
| 621 | TXP_CHECK_AND_PRINT(OFDM), |
| 622 | TXP_CHECK_AND_PRINT(40MHZ), |
| 623 | TXP_CHECK_AND_PRINT(HT_AP), |
| 624 | TXP_CHECK_AND_PRINT(RES1), |
| 625 | TXP_CHECK_AND_PRINT(RES2), |
| 626 | TXP_CHECK_AND_PRINT(COMMON_TYPE), |
| 627 | txp->flags); |
| 628 | IWL_DEBUG_EEPROM(priv, "\t\t chain_A: 0x%02x " |
| 629 | "chain_B: 0X%02x chain_C: 0X%02x\n", |
| 630 | txp->chain_a_max, txp->chain_b_max, |
| 631 | txp->chain_c_max); |
| 632 | IWL_DEBUG_EEPROM(priv, "\t\t MIMO2: 0x%02x " |
| 633 | "MIMO3: 0x%02x High 20_on_40: 0x%02x " |
| 634 | "Low 20_on_40: 0x%02x\n", |
| 635 | txp->mimo2_max, txp->mimo3_max, |
| 636 | ((txp->delta_20_in_40 & 0xf0) >> 4), |
| 637 | (txp->delta_20_in_40 & 0x0f)); |
| 638 | |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 639 | max_txp_avg = iwl_get_max_txpower_avg(cfg(priv), txp_array, idx, |
Wey-Yi Guy | 701cb09 | 2011-09-15 11:46:41 -0700 | [diff] [blame] | 640 | &max_txp_avg_halfdbm); |
| 641 | |
| 642 | /* |
| 643 | * Update the user limit values values to the highest |
| 644 | * power supported by any channel |
| 645 | */ |
| 646 | if (max_txp_avg > priv->tx_power_user_lmt) |
| 647 | priv->tx_power_user_lmt = max_txp_avg; |
| 648 | if (max_txp_avg_halfdbm > priv->tx_power_lmt_in_half_dbm) |
| 649 | priv->tx_power_lmt_in_half_dbm = max_txp_avg_halfdbm; |
| 650 | |
| 651 | iwl_eeprom_enh_txp_read_element(priv, txp, max_txp_avg); |
| 652 | } |
Wey-Yi Guy | 3be63ff | 2010-10-08 16:05:19 -0700 | [diff] [blame] | 653 | } |
Wey-Yi Guy | 3be63ff | 2010-10-08 16:05:19 -0700 | [diff] [blame] | 654 | |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 655 | /** |
| 656 | * iwl_eeprom_init - read EEPROM contents |
| 657 | * |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 658 | * Load the EEPROM contents from adapter into shrd->eeprom |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 659 | * |
| 660 | * NOTE: This routine uses the non-debug IO access functions. |
| 661 | */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 662 | int iwl_eeprom_init(struct iwl_trans *trans, u32 hw_rev) |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 663 | { |
Johannes Berg | af6b8ee | 2009-12-14 14:12:08 -0800 | [diff] [blame] | 664 | __le16 *e; |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 665 | u32 gp = iwl_read32(trans, CSR_EEPROM_GP); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 666 | int sz; |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 667 | int ret; |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 668 | u16 addr; |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 669 | u16 validblockaddr = 0; |
| 670 | u16 cache_addr = 0; |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 671 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 672 | trans->nvm_device_type = iwl_get_nvm_type(trans, hw_rev); |
| 673 | if (trans->nvm_device_type == -ENOENT) |
Wey-Yi Guy | b23a052 | 2009-07-17 09:30:21 -0700 | [diff] [blame] | 674 | return -ENOENT; |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 675 | /* allocate eeprom */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 676 | sz = cfg(trans)->base_params->eeprom_size; |
| 677 | IWL_DEBUG_EEPROM(trans, "NVM size = %d\n", sz); |
| 678 | trans->shrd->eeprom = kzalloc(sz, GFP_KERNEL); |
| 679 | if (!trans->shrd->eeprom) { |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 680 | ret = -ENOMEM; |
| 681 | goto alloc_err; |
| 682 | } |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 683 | e = (__le16 *)trans->shrd->eeprom; |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 684 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 685 | ret = iwl_eeprom_verify_signature(trans); |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 686 | if (ret < 0) { |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 687 | IWL_ERR(trans, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 688 | ret = -ENOENT; |
| 689 | goto err; |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | /* Make sure driver (instead of uCode) is allowed to read EEPROM */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 693 | ret = iwl_eeprom_acquire_semaphore(trans); |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 694 | if (ret < 0) { |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 695 | IWL_ERR(trans, "Failed to acquire EEPROM semaphore.\n"); |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 696 | ret = -ENOENT; |
| 697 | goto err; |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 698 | } |
Ben Cahill | 8852136 | 2009-10-30 14:36:06 -0700 | [diff] [blame] | 699 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 700 | if (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP) { |
Ben Cahill | 8852136 | 2009-10-30 14:36:06 -0700 | [diff] [blame] | 701 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 702 | ret = iwl_init_otp_access(trans); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 703 | if (ret) { |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 704 | IWL_ERR(trans, "Failed to initialize OTP access.\n"); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 705 | ret = -ENOENT; |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 706 | goto done; |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 707 | } |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 708 | iwl_write32(trans, CSR_EEPROM_GP, |
| 709 | iwl_read32(trans, CSR_EEPROM_GP) & |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 710 | ~CSR_EEPROM_GP_IF_OWNER_MSK); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 711 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 712 | iwl_set_bit(trans, CSR_OTP_GP_REG, |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 713 | CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK | |
| 714 | CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 715 | /* traversing the linked list if no shadow ram supported */ |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 716 | if (!cfg(trans)->base_params->shadow_ram_support) { |
| 717 | if (iwl_find_otp_image(trans, &validblockaddr)) { |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 718 | ret = -ENOENT; |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 719 | goto done; |
| 720 | } |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 721 | } |
| 722 | for (addr = validblockaddr; addr < validblockaddr + sz; |
| 723 | addr += sizeof(u16)) { |
Johannes Berg | af6b8ee | 2009-12-14 14:12:08 -0800 | [diff] [blame] | 724 | __le16 eeprom_data; |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 725 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 726 | ret = iwl_read_otp_word(trans, addr, &eeprom_data); |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 727 | if (ret) |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 728 | goto done; |
Wey-Yi Guy | 415e499 | 2009-08-13 13:30:54 -0700 | [diff] [blame] | 729 | e[cache_addr / 2] = eeprom_data; |
| 730 | cache_addr += sizeof(u16); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 731 | } |
| 732 | } else { |
| 733 | /* eeprom is an array of 16bit values */ |
| 734 | for (addr = 0; addr < sz; addr += sizeof(u16)) { |
| 735 | u32 r; |
| 736 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 737 | iwl_write32(trans, CSR_EEPROM_REG, |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 738 | CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 739 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 740 | ret = iwl_poll_bit(trans, CSR_EEPROM_REG, |
Abhijeet Kolekar | 1739d33 | 2009-10-02 13:44:05 -0700 | [diff] [blame] | 741 | CSR_EEPROM_REG_READ_VALID_MSK, |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 742 | CSR_EEPROM_REG_READ_VALID_MSK, |
| 743 | IWL_EEPROM_ACCESS_TIMEOUT); |
| 744 | if (ret < 0) { |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 745 | IWL_ERR(trans, |
| 746 | "Time out reading EEPROM[%d]\n", addr); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 747 | goto done; |
| 748 | } |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 749 | r = iwl_read32(trans, CSR_EEPROM_REG); |
Johannes Berg | af6b8ee | 2009-12-14 14:12:08 -0800 | [diff] [blame] | 750 | e[addr / 2] = cpu_to_le16(r >> 16); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 751 | } |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 752 | } |
Johannes Berg | d1358f6 | 2010-04-28 12:09:15 -0700 | [diff] [blame] | 753 | |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 754 | IWL_DEBUG_EEPROM(trans, "NVM Type: %s, version: 0x%x\n", |
| 755 | (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP) |
Johannes Berg | d1358f6 | 2010-04-28 12:09:15 -0700 | [diff] [blame] | 756 | ? "OTP" : "EEPROM", |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 757 | iwl_eeprom_query16(trans->shrd, EEPROM_VERSION)); |
Johannes Berg | d1358f6 | 2010-04-28 12:09:15 -0700 | [diff] [blame] | 758 | |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 759 | ret = 0; |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 760 | done: |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 761 | iwl_eeprom_release_semaphore(trans); |
Johannes Berg | d1358f6 | 2010-04-28 12:09:15 -0700 | [diff] [blame] | 762 | |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 763 | err: |
| 764 | if (ret) |
Emmanuel Grumbach | ca77d53 | 2012-02-13 11:24:47 +0200 | [diff] [blame] | 765 | iwl_eeprom_free(trans->shrd); |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 766 | alloc_err: |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 767 | return ret; |
| 768 | } |
Assaf Krauss | 34cf6ff | 2008-03-06 10:40:20 -0800 | [diff] [blame] | 769 | |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 770 | void iwl_eeprom_free(struct iwl_shared *shrd) |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 771 | { |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 772 | kfree(shrd->eeprom); |
| 773 | shrd->eeprom = NULL; |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 774 | } |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 775 | |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 776 | static void iwl_init_band_reference(const struct iwl_priv *priv, |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 777 | int eep_band, int *eeprom_ch_count, |
| 778 | const struct iwl_eeprom_channel **eeprom_ch_info, |
| 779 | const u8 **eeprom_ch_index) |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 780 | { |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 781 | struct iwl_shared *shrd = priv->shrd; |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 782 | u32 offset = cfg(priv)->lib-> |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 783 | eeprom_ops.regulatory_bands[eep_band - 1]; |
| 784 | switch (eep_band) { |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 785 | case 1: /* 2.4GHz band */ |
| 786 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_1); |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 787 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 788 | iwl_eeprom_query_addr(shrd, offset); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 789 | *eeprom_ch_index = iwl_eeprom_band_1; |
| 790 | break; |
| 791 | case 2: /* 4.9GHz band */ |
| 792 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_2); |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 793 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 794 | iwl_eeprom_query_addr(shrd, offset); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 795 | *eeprom_ch_index = iwl_eeprom_band_2; |
| 796 | break; |
| 797 | case 3: /* 5.2GHz band */ |
| 798 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_3); |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 799 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 800 | iwl_eeprom_query_addr(shrd, offset); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 801 | *eeprom_ch_index = iwl_eeprom_band_3; |
| 802 | break; |
| 803 | case 4: /* 5.5GHz band */ |
| 804 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_4); |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 805 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 806 | iwl_eeprom_query_addr(shrd, offset); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 807 | *eeprom_ch_index = iwl_eeprom_band_4; |
| 808 | break; |
| 809 | case 5: /* 5.7GHz band */ |
| 810 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_5); |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 811 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 812 | iwl_eeprom_query_addr(shrd, offset); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 813 | *eeprom_ch_index = iwl_eeprom_band_5; |
| 814 | break; |
Wey-Yi Guy | 7aafef1 | 2009-08-07 15:41:38 -0700 | [diff] [blame] | 815 | case 6: /* 2.4GHz ht40 channels */ |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 816 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_6); |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 817 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 818 | iwl_eeprom_query_addr(shrd, offset); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 819 | *eeprom_ch_index = iwl_eeprom_band_6; |
| 820 | break; |
Wey-Yi Guy | 7aafef1 | 2009-08-07 15:41:38 -0700 | [diff] [blame] | 821 | case 7: /* 5 GHz ht40 channels */ |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 822 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_7); |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 823 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 824 | iwl_eeprom_query_addr(shrd, offset); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 825 | *eeprom_ch_index = iwl_eeprom_band_7; |
| 826 | break; |
| 827 | default: |
| 828 | BUG(); |
| 829 | return; |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | #define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \ |
| 834 | ? # x " " : "") |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 835 | /** |
Zhu Yi | 3b24716 | 2009-08-13 13:30:53 -0700 | [diff] [blame] | 836 | * iwl_mod_ht40_chan_info - Copy ht40 channel info into driver's priv. |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 837 | * |
| 838 | * Does not set up a command, or touch hardware. |
| 839 | */ |
Zhu Yi | 3b24716 | 2009-08-13 13:30:53 -0700 | [diff] [blame] | 840 | static int iwl_mod_ht40_chan_info(struct iwl_priv *priv, |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 841 | enum ieee80211_band band, u16 channel, |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 842 | const struct iwl_eeprom_channel *eeprom_ch, |
Zhu Yi | 3b24716 | 2009-08-13 13:30:53 -0700 | [diff] [blame] | 843 | u8 clear_ht40_extension_channel) |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 844 | { |
| 845 | struct iwl_channel_info *ch_info; |
| 846 | |
| 847 | ch_info = (struct iwl_channel_info *) |
Assaf Krauss | 8622e70 | 2008-03-21 13:53:43 -0700 | [diff] [blame] | 848 | iwl_get_channel_info(priv, band, channel); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 849 | |
| 850 | if (!is_channel_valid(ch_info)) |
| 851 | return -1; |
| 852 | |
Wey-Yi Guy | d058ff8 | 2010-12-03 10:33:35 -0800 | [diff] [blame] | 853 | IWL_DEBUG_EEPROM(priv, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" |
Tomas Winkler | 630fe9b | 2008-06-12 09:47:08 +0800 | [diff] [blame] | 854 | " Ad-Hoc %ssupported\n", |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 855 | ch_info->channel, |
| 856 | is_channel_a_band(ch_info) ? |
| 857 | "5.2" : "2.4", |
| 858 | CHECK_AND_PRINT(IBSS), |
| 859 | CHECK_AND_PRINT(ACTIVE), |
| 860 | CHECK_AND_PRINT(RADAR), |
| 861 | CHECK_AND_PRINT(WIDE), |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 862 | CHECK_AND_PRINT(DFS), |
| 863 | eeprom_ch->flags, |
| 864 | eeprom_ch->max_power_avg, |
| 865 | ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS) |
| 866 | && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ? |
| 867 | "" : "not "); |
| 868 | |
Wey-Yi Guy | 7aafef1 | 2009-08-07 15:41:38 -0700 | [diff] [blame] | 869 | ch_info->ht40_eeprom = *eeprom_ch; |
| 870 | ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg; |
Wey-Yi Guy | 7aafef1 | 2009-08-07 15:41:38 -0700 | [diff] [blame] | 871 | ch_info->ht40_flags = eeprom_ch->flags; |
Reinette Chatre | 6c3069b | 2009-12-14 14:12:13 -0800 | [diff] [blame] | 872 | if (eeprom_ch->flags & EEPROM_CHANNEL_VALID) |
| 873 | ch_info->ht40_extension_channel &= ~clear_ht40_extension_channel; |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 874 | |
| 875 | return 0; |
| 876 | } |
| 877 | |
| 878 | #define CHECK_AND_PRINT_I(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \ |
| 879 | ? # x " " : "") |
| 880 | |
| 881 | /** |
| 882 | * iwl_init_channel_map - Set up driver's info for all possible channels |
| 883 | */ |
| 884 | int iwl_init_channel_map(struct iwl_priv *priv) |
| 885 | { |
| 886 | int eeprom_ch_count = 0; |
| 887 | const u8 *eeprom_ch_index = NULL; |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 888 | const struct iwl_eeprom_channel *eeprom_ch_info = NULL; |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 889 | int band, ch; |
| 890 | struct iwl_channel_info *ch_info; |
| 891 | |
| 892 | if (priv->channel_count) { |
Wey-Yi Guy | d058ff8 | 2010-12-03 10:33:35 -0800 | [diff] [blame] | 893 | IWL_DEBUG_EEPROM(priv, "Channel map already initialized.\n"); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 894 | return 0; |
| 895 | } |
| 896 | |
Wey-Yi Guy | d058ff8 | 2010-12-03 10:33:35 -0800 | [diff] [blame] | 897 | IWL_DEBUG_EEPROM(priv, "Initializing regulatory info from EEPROM\n"); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 898 | |
| 899 | priv->channel_count = |
| 900 | ARRAY_SIZE(iwl_eeprom_band_1) + |
| 901 | ARRAY_SIZE(iwl_eeprom_band_2) + |
| 902 | ARRAY_SIZE(iwl_eeprom_band_3) + |
| 903 | ARRAY_SIZE(iwl_eeprom_band_4) + |
| 904 | ARRAY_SIZE(iwl_eeprom_band_5); |
| 905 | |
Wey-Yi Guy | d058ff8 | 2010-12-03 10:33:35 -0800 | [diff] [blame] | 906 | IWL_DEBUG_EEPROM(priv, "Parsing data for %d channels.\n", |
| 907 | priv->channel_count); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 908 | |
Emmanuel Grumbach | 7f90dce | 2011-09-22 15:14:53 -0700 | [diff] [blame] | 909 | priv->channel_info = kcalloc(priv->channel_count, |
| 910 | sizeof(struct iwl_channel_info), |
| 911 | GFP_KERNEL); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 912 | if (!priv->channel_info) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 913 | IWL_ERR(priv, "Could not allocate channel_info\n"); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 914 | priv->channel_count = 0; |
| 915 | return -ENOMEM; |
| 916 | } |
| 917 | |
| 918 | ch_info = priv->channel_info; |
| 919 | |
| 920 | /* Loop through the 5 EEPROM bands adding them in order to the |
| 921 | * channel map we maintain (that contains additional information than |
| 922 | * what just in the EEPROM) */ |
| 923 | for (band = 1; band <= 5; band++) { |
| 924 | |
| 925 | iwl_init_band_reference(priv, band, &eeprom_ch_count, |
| 926 | &eeprom_ch_info, &eeprom_ch_index); |
| 927 | |
| 928 | /* Loop through each band adding each of the channels */ |
| 929 | for (ch = 0; ch < eeprom_ch_count; ch++) { |
| 930 | ch_info->channel = eeprom_ch_index[ch]; |
| 931 | ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : |
| 932 | IEEE80211_BAND_5GHZ; |
| 933 | |
| 934 | /* permanently store EEPROM's channel regulatory flags |
| 935 | * and max power in channel info database. */ |
| 936 | ch_info->eeprom = eeprom_ch_info[ch]; |
| 937 | |
| 938 | /* Copy the run-time flags so they are there even on |
| 939 | * invalid channels */ |
| 940 | ch_info->flags = eeprom_ch_info[ch].flags; |
Wey-Yi Guy | 7aafef1 | 2009-08-07 15:41:38 -0700 | [diff] [blame] | 941 | /* First write that ht40 is not enabled, and then enable |
Emmanuel Grumbach | 963f551 | 2008-06-12 09:47:00 +0800 | [diff] [blame] | 942 | * one by one */ |
Wey-Yi Guy | 7aafef1 | 2009-08-07 15:41:38 -0700 | [diff] [blame] | 943 | ch_info->ht40_extension_channel = |
Zhu Yi | 3b24716 | 2009-08-13 13:30:53 -0700 | [diff] [blame] | 944 | IEEE80211_CHAN_NO_HT40; |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 945 | |
| 946 | if (!(is_channel_valid(ch_info))) { |
Wey-Yi Guy | d058ff8 | 2010-12-03 10:33:35 -0800 | [diff] [blame] | 947 | IWL_DEBUG_EEPROM(priv, |
| 948 | "Ch. %d Flags %x [%sGHz] - " |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 949 | "No traffic\n", |
| 950 | ch_info->channel, |
| 951 | ch_info->flags, |
| 952 | is_channel_a_band(ch_info) ? |
| 953 | "5.2" : "2.4"); |
| 954 | ch_info++; |
| 955 | continue; |
| 956 | } |
| 957 | |
| 958 | /* Initialize regulatory-based run-time data */ |
| 959 | ch_info->max_power_avg = ch_info->curr_txpow = |
| 960 | eeprom_ch_info[ch].max_power_avg; |
| 961 | ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; |
| 962 | ch_info->min_power = 0; |
| 963 | |
Wey-Yi Guy | d058ff8 | 2010-12-03 10:33:35 -0800 | [diff] [blame] | 964 | IWL_DEBUG_EEPROM(priv, "Ch. %d [%sGHz] " |
| 965 | "%s%s%s%s%s%s(0x%02x %ddBm):" |
Tomas Winkler | 630fe9b | 2008-06-12 09:47:08 +0800 | [diff] [blame] | 966 | " Ad-Hoc %ssupported\n", |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 967 | ch_info->channel, |
| 968 | is_channel_a_band(ch_info) ? |
| 969 | "5.2" : "2.4", |
| 970 | CHECK_AND_PRINT_I(VALID), |
| 971 | CHECK_AND_PRINT_I(IBSS), |
| 972 | CHECK_AND_PRINT_I(ACTIVE), |
| 973 | CHECK_AND_PRINT_I(RADAR), |
| 974 | CHECK_AND_PRINT_I(WIDE), |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 975 | CHECK_AND_PRINT_I(DFS), |
| 976 | eeprom_ch_info[ch].flags, |
| 977 | eeprom_ch_info[ch].max_power_avg, |
| 978 | ((eeprom_ch_info[ch]. |
| 979 | flags & EEPROM_CHANNEL_IBSS) |
| 980 | && !(eeprom_ch_info[ch]. |
| 981 | flags & EEPROM_CHANNEL_RADAR)) |
| 982 | ? "" : "not "); |
| 983 | |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 984 | ch_info++; |
| 985 | } |
| 986 | } |
| 987 | |
Wey-Yi Guy | 7aafef1 | 2009-08-07 15:41:38 -0700 | [diff] [blame] | 988 | /* Check if we do have HT40 channels */ |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 989 | if (cfg(priv)->lib->eeprom_ops.regulatory_bands[5] == |
Wey-Yi Guy | 7aafef1 | 2009-08-07 15:41:38 -0700 | [diff] [blame] | 990 | EEPROM_REGULATORY_BAND_NO_HT40 && |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 991 | cfg(priv)->lib->eeprom_ops.regulatory_bands[6] == |
Wey-Yi Guy | 7aafef1 | 2009-08-07 15:41:38 -0700 | [diff] [blame] | 992 | EEPROM_REGULATORY_BAND_NO_HT40) |
Samuel Ortiz | e614891 | 2009-01-23 13:45:15 -0800 | [diff] [blame] | 993 | return 0; |
| 994 | |
Wey-Yi Guy | 7aafef1 | 2009-08-07 15:41:38 -0700 | [diff] [blame] | 995 | /* Two additional EEPROM bands for 2.4 and 5 GHz HT40 channels */ |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 996 | for (band = 6; band <= 7; band++) { |
| 997 | enum ieee80211_band ieeeband; |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 998 | |
| 999 | iwl_init_band_reference(priv, band, &eeprom_ch_count, |
| 1000 | &eeprom_ch_info, &eeprom_ch_index); |
| 1001 | |
| 1002 | /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ |
| 1003 | ieeeband = |
| 1004 | (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; |
| 1005 | |
| 1006 | /* Loop through each band adding each of the channels */ |
| 1007 | for (ch = 0; ch < eeprom_ch_count; ch++) { |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 1008 | /* Set up driver's info for lower half */ |
Zhu Yi | 3b24716 | 2009-08-13 13:30:53 -0700 | [diff] [blame] | 1009 | iwl_mod_ht40_chan_info(priv, ieeeband, |
Tomas Winkler | da6833c | 2008-05-15 13:54:15 +0800 | [diff] [blame] | 1010 | eeprom_ch_index[ch], |
Zhu Yi | 3b24716 | 2009-08-13 13:30:53 -0700 | [diff] [blame] | 1011 | &eeprom_ch_info[ch], |
| 1012 | IEEE80211_CHAN_NO_HT40PLUS); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 1013 | |
| 1014 | /* Set up driver's info for upper half */ |
Zhu Yi | 3b24716 | 2009-08-13 13:30:53 -0700 | [diff] [blame] | 1015 | iwl_mod_ht40_chan_info(priv, ieeeband, |
| 1016 | eeprom_ch_index[ch] + 4, |
| 1017 | &eeprom_ch_info[ch], |
| 1018 | IEEE80211_CHAN_NO_HT40MINUS); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 1019 | } |
| 1020 | } |
| 1021 | |
Wey-Yi Guy | ab9fd1b | 2009-08-21 13:34:23 -0700 | [diff] [blame] | 1022 | /* for newer device (6000 series and up) |
| 1023 | * EEPROM contain enhanced tx power information |
| 1024 | * driver need to process addition information |
| 1025 | * to determine the max channel tx power limits |
| 1026 | */ |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 1027 | if (cfg(priv)->lib->eeprom_ops.update_enhanced_txpower) |
| 1028 | cfg(priv)->lib->eeprom_ops.update_enhanced_txpower(priv); |
Wey-Yi Guy | ab9fd1b | 2009-08-21 13:34:23 -0700 | [diff] [blame] | 1029 | |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 1030 | return 0; |
| 1031 | } |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 1032 | |
| 1033 | /* |
Tomas Winkler | da6833c | 2008-05-15 13:54:15 +0800 | [diff] [blame] | 1034 | * iwl_free_channel_map - undo allocations in iwl_init_channel_map |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 1035 | */ |
| 1036 | void iwl_free_channel_map(struct iwl_priv *priv) |
| 1037 | { |
| 1038 | kfree(priv->channel_info); |
| 1039 | priv->channel_count = 0; |
| 1040 | } |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 1041 | |
| 1042 | /** |
| 1043 | * iwl_get_channel_info - Find driver's private channel info |
| 1044 | * |
| 1045 | * Based on band and channel number. |
| 1046 | */ |
Tomas Winkler | 82a66bb | 2008-05-29 16:35:28 +0800 | [diff] [blame] | 1047 | const struct iwl_channel_info *iwl_get_channel_info(const struct iwl_priv *priv, |
| 1048 | enum ieee80211_band band, u16 channel) |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 1049 | { |
| 1050 | int i; |
| 1051 | |
| 1052 | switch (band) { |
| 1053 | case IEEE80211_BAND_5GHZ: |
| 1054 | for (i = 14; i < priv->channel_count; i++) { |
| 1055 | if (priv->channel_info[i].channel == channel) |
| 1056 | return &priv->channel_info[i]; |
| 1057 | } |
| 1058 | break; |
| 1059 | case IEEE80211_BAND_2GHZ: |
| 1060 | if (channel >= 1 && channel <= 14) |
| 1061 | return &priv->channel_info[channel - 1]; |
| 1062 | break; |
| 1063 | default: |
| 1064 | BUG(); |
| 1065 | } |
| 1066 | |
| 1067 | return NULL; |
| 1068 | } |
Wey-Yi Guy | 86cb3b4 | 2011-06-14 15:23:39 -0700 | [diff] [blame] | 1069 | |
| 1070 | void iwl_rf_config(struct iwl_priv *priv) |
| 1071 | { |
| 1072 | u16 radio_cfg; |
| 1073 | |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 1074 | radio_cfg = iwl_eeprom_query16(priv->shrd, EEPROM_RADIO_CONFIG); |
Wey-Yi Guy | 86cb3b4 | 2011-06-14 15:23:39 -0700 | [diff] [blame] | 1075 | |
| 1076 | /* write radio config values to register */ |
| 1077 | if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX) { |
Emmanuel Grumbach | 1042db2 | 2012-01-03 16:56:15 +0200 | [diff] [blame] | 1078 | iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG, |
Wey-Yi Guy | 86cb3b4 | 2011-06-14 15:23:39 -0700 | [diff] [blame] | 1079 | EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | |
| 1080 | EEPROM_RF_CFG_STEP_MSK(radio_cfg) | |
| 1081 | EEPROM_RF_CFG_DASH_MSK(radio_cfg)); |
| 1082 | IWL_INFO(priv, "Radio type=0x%x-0x%x-0x%x\n", |
| 1083 | EEPROM_RF_CFG_TYPE_MSK(radio_cfg), |
| 1084 | EEPROM_RF_CFG_STEP_MSK(radio_cfg), |
| 1085 | EEPROM_RF_CFG_DASH_MSK(radio_cfg)); |
| 1086 | } else |
| 1087 | WARN_ON(1); |
| 1088 | |
| 1089 | /* set CSR_HW_CONFIG_REG for uCode use */ |
Emmanuel Grumbach | 1042db2 | 2012-01-03 16:56:15 +0200 | [diff] [blame] | 1090 | iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG, |
Wey-Yi Guy | 86cb3b4 | 2011-06-14 15:23:39 -0700 | [diff] [blame] | 1091 | CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | |
| 1092 | CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); |
| 1093 | } |