Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [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 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 8 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
Eran Harary | 8d193ca | 2015-04-27 10:29:31 +0300 | [diff] [blame] | 9 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 10 | * Copyright(c) 2016 Intel Deutschland GmbH |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of version 2 of the GNU General Public License as |
| 14 | * published by the Free Software Foundation. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, but |
| 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 | * General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, |
| 24 | * USA |
| 25 | * |
| 26 | * The full GNU General Public License is included in this distribution |
Emmanuel Grumbach | 410dc5a | 2013-02-18 09:22:28 +0200 | [diff] [blame] | 27 | * in the file called COPYING. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 28 | * |
| 29 | * Contact Information: |
Emmanuel Grumbach | cb2f827 | 2015-11-17 15:39:56 +0200 | [diff] [blame] | 30 | * Intel Linux Wireless <linuxwifi@intel.com> |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 31 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 32 | * |
| 33 | * BSD LICENSE |
| 34 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 35 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
Eran Harary | 8d193ca | 2015-04-27 10:29:31 +0300 | [diff] [blame] | 36 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 37 | * All rights reserved. |
| 38 | * |
| 39 | * Redistribution and use in source and binary forms, with or without |
| 40 | * modification, are permitted provided that the following conditions |
| 41 | * are met: |
| 42 | * |
| 43 | * * Redistributions of source code must retain the above copyright |
| 44 | * notice, this list of conditions and the following disclaimer. |
| 45 | * * Redistributions in binary form must reproduce the above copyright |
| 46 | * notice, this list of conditions and the following disclaimer in |
| 47 | * the documentation and/or other materials provided with the |
| 48 | * distribution. |
| 49 | * * Neither the name Intel Corporation nor the names of its |
| 50 | * contributors may be used to endorse or promote products derived |
| 51 | * from this software without specific prior written permission. |
| 52 | * |
| 53 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 54 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 55 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 56 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 57 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 58 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 59 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 60 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 61 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 62 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 63 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 64 | * |
| 65 | *****************************************************************************/ |
| 66 | #include <net/mac80211.h> |
| 67 | |
| 68 | #include "iwl-trans.h" |
| 69 | #include "iwl-op-mode.h" |
| 70 | #include "iwl-fw.h" |
| 71 | #include "iwl-debug.h" |
| 72 | #include "iwl-csr.h" /* for iwl_mvm_rx_card_state_notif */ |
| 73 | #include "iwl-io.h" /* for iwl_mvm_rx_card_state_notif */ |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 74 | #include "iwl-prph.h" |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 75 | #include "iwl-eeprom-parse.h" |
| 76 | |
| 77 | #include "mvm.h" |
Golan Ben-Ami | 2f89a5d | 2015-10-27 19:17:14 +0200 | [diff] [blame] | 78 | #include "fw-dbg.h" |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 79 | #include "iwl-phy-db.h" |
| 80 | |
| 81 | #define MVM_UCODE_ALIVE_TIMEOUT HZ |
| 82 | #define MVM_UCODE_CALIB_TIMEOUT (2*HZ) |
| 83 | |
| 84 | #define UCODE_VALID_OK cpu_to_le32(0x1) |
| 85 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 86 | struct iwl_mvm_alive_data { |
| 87 | bool valid; |
| 88 | u32 scd_base_addr; |
| 89 | }; |
| 90 | |
| 91 | static inline const struct fw_img * |
| 92 | iwl_get_ucode_image(struct iwl_mvm *mvm, enum iwl_ucode_type ucode_type) |
| 93 | { |
| 94 | if (ucode_type >= IWL_UCODE_TYPE_MAX) |
| 95 | return NULL; |
| 96 | |
| 97 | return &mvm->fw->img[ucode_type]; |
| 98 | } |
| 99 | |
| 100 | static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant) |
| 101 | { |
| 102 | struct iwl_tx_ant_cfg_cmd tx_ant_cmd = { |
| 103 | .valid = cpu_to_le32(valid_tx_ant), |
| 104 | }; |
| 105 | |
Emmanuel Grumbach | 3322354 | 2013-03-09 20:38:19 +0200 | [diff] [blame] | 106 | IWL_DEBUG_FW(mvm, "select valid tx ant: %u\n", valid_tx_ant); |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 107 | return iwl_mvm_send_cmd_pdu(mvm, TX_ANT_CONFIGURATION_CMD, 0, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 108 | sizeof(tx_ant_cmd), &tx_ant_cmd); |
| 109 | } |
| 110 | |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 111 | static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm) |
| 112 | { |
| 113 | int i; |
| 114 | struct iwl_rss_config_cmd cmd = { |
| 115 | .flags = cpu_to_le32(IWL_RSS_ENABLE), |
| 116 | .hash_mask = IWL_RSS_HASH_TYPE_IPV4_TCP | |
| 117 | IWL_RSS_HASH_TYPE_IPV4_PAYLOAD | |
| 118 | IWL_RSS_HASH_TYPE_IPV6_TCP | |
| 119 | IWL_RSS_HASH_TYPE_IPV6_PAYLOAD, |
| 120 | }; |
| 121 | |
| 122 | for (i = 0; i < ARRAY_SIZE(cmd.indirection_table); i++) |
| 123 | cmd.indirection_table[i] = i % mvm->trans->num_rx_queues; |
Sara Sharon | dd4d316 | 2016-02-07 12:50:35 +0200 | [diff] [blame] | 124 | memcpy(cmd.secret_key, mvm->secret_key, sizeof(cmd.secret_key)); |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 125 | |
| 126 | return iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0, sizeof(cmd), &cmd); |
| 127 | } |
| 128 | |
Matti Gottlieb | 905e36a | 2016-02-14 17:05:39 +0200 | [diff] [blame] | 129 | void iwl_free_fw_paging(struct iwl_mvm *mvm) |
Matti Gottlieb | a6c4fb4 | 2015-07-15 16:19:29 +0300 | [diff] [blame] | 130 | { |
| 131 | int i; |
| 132 | |
| 133 | if (!mvm->fw_paging_db[0].fw_paging_block) |
| 134 | return; |
| 135 | |
| 136 | for (i = 0; i < NUM_OF_FW_PAGING_BLOCKS; i++) { |
| 137 | if (!mvm->fw_paging_db[i].fw_paging_block) { |
| 138 | IWL_DEBUG_FW(mvm, |
| 139 | "Paging: block %d already freed, continue to next page\n", |
| 140 | i); |
| 141 | |
| 142 | continue; |
| 143 | } |
| 144 | |
| 145 | __free_pages(mvm->fw_paging_db[i].fw_paging_block, |
| 146 | get_order(mvm->fw_paging_db[i].fw_paging_size)); |
| 147 | } |
Matti Gottlieb | e112018 | 2015-07-19 11:15:07 +0300 | [diff] [blame] | 148 | kfree(mvm->trans->paging_download_buf); |
Matti Gottlieb | 905e36a | 2016-02-14 17:05:39 +0200 | [diff] [blame] | 149 | mvm->trans->paging_download_buf = NULL; |
| 150 | |
Matti Gottlieb | a6c4fb4 | 2015-07-15 16:19:29 +0300 | [diff] [blame] | 151 | memset(mvm->fw_paging_db, 0, sizeof(mvm->fw_paging_db)); |
| 152 | } |
| 153 | |
| 154 | static int iwl_fill_paging_mem(struct iwl_mvm *mvm, const struct fw_img *image) |
| 155 | { |
| 156 | int sec_idx, idx; |
| 157 | u32 offset = 0; |
| 158 | |
| 159 | /* |
| 160 | * find where is the paging image start point: |
| 161 | * if CPU2 exist and it's in paging format, then the image looks like: |
| 162 | * CPU1 sections (2 or more) |
| 163 | * CPU1_CPU2_SEPARATOR_SECTION delimiter - separate between CPU1 to CPU2 |
| 164 | * CPU2 sections (not paged) |
| 165 | * PAGING_SEPARATOR_SECTION delimiter - separate between CPU2 |
| 166 | * non paged to CPU2 paging sec |
| 167 | * CPU2 paging CSS |
| 168 | * CPU2 paging image (including instruction and data) |
| 169 | */ |
| 170 | for (sec_idx = 0; sec_idx < IWL_UCODE_SECTION_MAX; sec_idx++) { |
| 171 | if (image->sec[sec_idx].offset == PAGING_SEPARATOR_SECTION) { |
| 172 | sec_idx++; |
| 173 | break; |
| 174 | } |
| 175 | } |
| 176 | |
Matti Gottlieb | cd47a3d | 2016-03-10 16:18:26 +0200 | [diff] [blame] | 177 | /* |
| 178 | * If paging is enabled there should be at least 2 more sections left |
| 179 | * (one for CSS and one for Paging data) |
| 180 | */ |
| 181 | if (sec_idx >= ARRAY_SIZE(image->sec) - 1) { |
| 182 | IWL_ERR(mvm, "Paging: Missing CSS and/or paging sections\n"); |
Matti Gottlieb | a6c4fb4 | 2015-07-15 16:19:29 +0300 | [diff] [blame] | 183 | iwl_free_fw_paging(mvm); |
| 184 | return -EINVAL; |
| 185 | } |
| 186 | |
| 187 | /* copy the CSS block to the dram */ |
| 188 | IWL_DEBUG_FW(mvm, "Paging: load paging CSS to FW, sec = %d\n", |
| 189 | sec_idx); |
| 190 | |
| 191 | memcpy(page_address(mvm->fw_paging_db[0].fw_paging_block), |
| 192 | image->sec[sec_idx].data, |
| 193 | mvm->fw_paging_db[0].fw_paging_size); |
| 194 | |
| 195 | IWL_DEBUG_FW(mvm, |
| 196 | "Paging: copied %d CSS bytes to first block\n", |
| 197 | mvm->fw_paging_db[0].fw_paging_size); |
| 198 | |
| 199 | sec_idx++; |
| 200 | |
| 201 | /* |
| 202 | * copy the paging blocks to the dram |
| 203 | * loop index start from 1 since that CSS block already copied to dram |
| 204 | * and CSS index is 0. |
| 205 | * loop stop at num_of_paging_blk since that last block is not full. |
| 206 | */ |
| 207 | for (idx = 1; idx < mvm->num_of_paging_blk; idx++) { |
| 208 | memcpy(page_address(mvm->fw_paging_db[idx].fw_paging_block), |
| 209 | image->sec[sec_idx].data + offset, |
| 210 | mvm->fw_paging_db[idx].fw_paging_size); |
| 211 | |
| 212 | IWL_DEBUG_FW(mvm, |
| 213 | "Paging: copied %d paging bytes to block %d\n", |
| 214 | mvm->fw_paging_db[idx].fw_paging_size, |
| 215 | idx); |
| 216 | |
| 217 | offset += mvm->fw_paging_db[idx].fw_paging_size; |
| 218 | } |
| 219 | |
| 220 | /* copy the last paging block */ |
| 221 | if (mvm->num_of_pages_in_last_blk > 0) { |
| 222 | memcpy(page_address(mvm->fw_paging_db[idx].fw_paging_block), |
| 223 | image->sec[sec_idx].data + offset, |
| 224 | FW_PAGING_SIZE * mvm->num_of_pages_in_last_blk); |
| 225 | |
| 226 | IWL_DEBUG_FW(mvm, |
| 227 | "Paging: copied %d pages in the last block %d\n", |
| 228 | mvm->num_of_pages_in_last_blk, idx); |
| 229 | } |
| 230 | |
| 231 | return 0; |
| 232 | } |
| 233 | |
| 234 | static int iwl_alloc_fw_paging_mem(struct iwl_mvm *mvm, |
| 235 | const struct fw_img *image) |
| 236 | { |
| 237 | struct page *block; |
| 238 | dma_addr_t phys = 0; |
| 239 | int blk_idx = 0; |
| 240 | int order, num_of_pages; |
| 241 | int dma_enabled; |
| 242 | |
| 243 | if (mvm->fw_paging_db[0].fw_paging_block) |
| 244 | return 0; |
| 245 | |
| 246 | dma_enabled = is_device_dma_capable(mvm->trans->dev); |
| 247 | |
| 248 | /* ensure BLOCK_2_EXP_SIZE is power of 2 of PAGING_BLOCK_SIZE */ |
| 249 | BUILD_BUG_ON(BIT(BLOCK_2_EXP_SIZE) != PAGING_BLOCK_SIZE); |
| 250 | |
| 251 | num_of_pages = image->paging_mem_size / FW_PAGING_SIZE; |
| 252 | mvm->num_of_paging_blk = ((num_of_pages - 1) / |
| 253 | NUM_OF_PAGE_PER_GROUP) + 1; |
| 254 | |
| 255 | mvm->num_of_pages_in_last_blk = |
| 256 | num_of_pages - |
| 257 | NUM_OF_PAGE_PER_GROUP * (mvm->num_of_paging_blk - 1); |
| 258 | |
| 259 | IWL_DEBUG_FW(mvm, |
| 260 | "Paging: allocating mem for %d paging blocks, each block holds 8 pages, last block holds %d pages\n", |
| 261 | mvm->num_of_paging_blk, |
| 262 | mvm->num_of_pages_in_last_blk); |
| 263 | |
| 264 | /* allocate block of 4Kbytes for paging CSS */ |
| 265 | order = get_order(FW_PAGING_SIZE); |
| 266 | block = alloc_pages(GFP_KERNEL, order); |
| 267 | if (!block) { |
| 268 | /* free all the previous pages since we failed */ |
| 269 | iwl_free_fw_paging(mvm); |
| 270 | return -ENOMEM; |
| 271 | } |
| 272 | |
| 273 | mvm->fw_paging_db[blk_idx].fw_paging_block = block; |
| 274 | mvm->fw_paging_db[blk_idx].fw_paging_size = FW_PAGING_SIZE; |
| 275 | |
| 276 | if (dma_enabled) { |
| 277 | phys = dma_map_page(mvm->trans->dev, block, 0, |
| 278 | PAGE_SIZE << order, DMA_BIDIRECTIONAL); |
| 279 | if (dma_mapping_error(mvm->trans->dev, phys)) { |
| 280 | /* |
| 281 | * free the previous pages and the current one since |
| 282 | * we failed to map_page. |
| 283 | */ |
| 284 | iwl_free_fw_paging(mvm); |
| 285 | return -ENOMEM; |
| 286 | } |
| 287 | mvm->fw_paging_db[blk_idx].fw_paging_phys = phys; |
Matti Gottlieb | e112018 | 2015-07-19 11:15:07 +0300 | [diff] [blame] | 288 | } else { |
| 289 | mvm->fw_paging_db[blk_idx].fw_paging_phys = PAGING_ADDR_SIG | |
| 290 | blk_idx << BLOCK_2_EXP_SIZE; |
Matti Gottlieb | a6c4fb4 | 2015-07-15 16:19:29 +0300 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | IWL_DEBUG_FW(mvm, |
| 294 | "Paging: allocated 4K(CSS) bytes (order %d) for firmware paging.\n", |
| 295 | order); |
| 296 | |
| 297 | /* |
| 298 | * allocate blocks in dram. |
| 299 | * since that CSS allocated in fw_paging_db[0] loop start from index 1 |
| 300 | */ |
| 301 | for (blk_idx = 1; blk_idx < mvm->num_of_paging_blk + 1; blk_idx++) { |
| 302 | /* allocate block of PAGING_BLOCK_SIZE (32K) */ |
| 303 | order = get_order(PAGING_BLOCK_SIZE); |
| 304 | block = alloc_pages(GFP_KERNEL, order); |
| 305 | if (!block) { |
| 306 | /* free all the previous pages since we failed */ |
| 307 | iwl_free_fw_paging(mvm); |
| 308 | return -ENOMEM; |
| 309 | } |
| 310 | |
| 311 | mvm->fw_paging_db[blk_idx].fw_paging_block = block; |
| 312 | mvm->fw_paging_db[blk_idx].fw_paging_size = PAGING_BLOCK_SIZE; |
| 313 | |
| 314 | if (dma_enabled) { |
| 315 | phys = dma_map_page(mvm->trans->dev, block, 0, |
| 316 | PAGE_SIZE << order, |
| 317 | DMA_BIDIRECTIONAL); |
| 318 | if (dma_mapping_error(mvm->trans->dev, phys)) { |
| 319 | /* |
| 320 | * free the previous pages and the current one |
| 321 | * since we failed to map_page. |
| 322 | */ |
| 323 | iwl_free_fw_paging(mvm); |
| 324 | return -ENOMEM; |
| 325 | } |
| 326 | mvm->fw_paging_db[blk_idx].fw_paging_phys = phys; |
Matti Gottlieb | e112018 | 2015-07-19 11:15:07 +0300 | [diff] [blame] | 327 | } else { |
| 328 | mvm->fw_paging_db[blk_idx].fw_paging_phys = |
| 329 | PAGING_ADDR_SIG | |
| 330 | blk_idx << BLOCK_2_EXP_SIZE; |
Matti Gottlieb | a6c4fb4 | 2015-07-15 16:19:29 +0300 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | IWL_DEBUG_FW(mvm, |
| 334 | "Paging: allocated 32K bytes (order %d) for firmware paging.\n", |
| 335 | order); |
| 336 | } |
| 337 | |
| 338 | return 0; |
| 339 | } |
| 340 | |
| 341 | static int iwl_save_fw_paging(struct iwl_mvm *mvm, |
| 342 | const struct fw_img *fw) |
| 343 | { |
| 344 | int ret; |
| 345 | |
| 346 | ret = iwl_alloc_fw_paging_mem(mvm, fw); |
| 347 | if (ret) |
| 348 | return ret; |
| 349 | |
| 350 | return iwl_fill_paging_mem(mvm, fw); |
| 351 | } |
| 352 | |
| 353 | /* send paging cmd to FW in case CPU2 has paging image */ |
| 354 | static int iwl_send_paging_cmd(struct iwl_mvm *mvm, const struct fw_img *fw) |
| 355 | { |
| 356 | int blk_idx; |
| 357 | __le32 dev_phy_addr; |
| 358 | struct iwl_fw_paging_cmd fw_paging_cmd = { |
| 359 | .flags = |
| 360 | cpu_to_le32(PAGING_CMD_IS_SECURED | |
| 361 | PAGING_CMD_IS_ENABLED | |
| 362 | (mvm->num_of_pages_in_last_blk << |
| 363 | PAGING_CMD_NUM_OF_PAGES_IN_LAST_GRP_POS)), |
| 364 | .block_size = cpu_to_le32(BLOCK_2_EXP_SIZE), |
| 365 | .block_num = cpu_to_le32(mvm->num_of_paging_blk), |
| 366 | }; |
| 367 | |
| 368 | /* loop for for all paging blocks + CSS block */ |
| 369 | for (blk_idx = 0; blk_idx < mvm->num_of_paging_blk + 1; blk_idx++) { |
| 370 | dev_phy_addr = |
| 371 | cpu_to_le32(mvm->fw_paging_db[blk_idx].fw_paging_phys >> |
| 372 | PAGE_2_EXP_SIZE); |
| 373 | fw_paging_cmd.device_phy_addr[blk_idx] = dev_phy_addr; |
| 374 | } |
| 375 | |
| 376 | return iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(FW_PAGING_BLOCK_CMD, |
| 377 | IWL_ALWAYS_LONG_GROUP, 0), |
| 378 | 0, sizeof(fw_paging_cmd), &fw_paging_cmd); |
| 379 | } |
| 380 | |
Matti Gottlieb | e112018 | 2015-07-19 11:15:07 +0300 | [diff] [blame] | 381 | /* |
| 382 | * Send paging item cmd to FW in case CPU2 has paging image |
| 383 | */ |
| 384 | static int iwl_trans_get_paging_item(struct iwl_mvm *mvm) |
| 385 | { |
| 386 | int ret; |
| 387 | struct iwl_fw_get_item_cmd fw_get_item_cmd = { |
| 388 | .item_id = cpu_to_le32(IWL_FW_ITEM_ID_PAGING), |
| 389 | }; |
| 390 | |
| 391 | struct iwl_fw_get_item_resp *item_resp; |
| 392 | struct iwl_host_cmd cmd = { |
| 393 | .id = iwl_cmd_id(FW_GET_ITEM_CMD, IWL_ALWAYS_LONG_GROUP, 0), |
| 394 | .flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL, |
| 395 | .data = { &fw_get_item_cmd, }, |
| 396 | }; |
| 397 | |
| 398 | cmd.len[0] = sizeof(struct iwl_fw_get_item_cmd); |
| 399 | |
| 400 | ret = iwl_mvm_send_cmd(mvm, &cmd); |
| 401 | if (ret) { |
| 402 | IWL_ERR(mvm, |
| 403 | "Paging: Failed to send FW_GET_ITEM_CMD cmd (err = %d)\n", |
| 404 | ret); |
| 405 | return ret; |
| 406 | } |
| 407 | |
| 408 | item_resp = (void *)((struct iwl_rx_packet *)cmd.resp_pkt)->data; |
| 409 | if (item_resp->item_id != cpu_to_le32(IWL_FW_ITEM_ID_PAGING)) { |
| 410 | IWL_ERR(mvm, |
| 411 | "Paging: got wrong item in FW_GET_ITEM_CMD resp (item_id = %u)\n", |
| 412 | le32_to_cpu(item_resp->item_id)); |
| 413 | ret = -EIO; |
| 414 | goto exit; |
| 415 | } |
| 416 | |
Matti Gottlieb | c94d799 | 2016-03-09 10:54:10 +0200 | [diff] [blame] | 417 | /* Add an extra page for headers */ |
| 418 | mvm->trans->paging_download_buf = kzalloc(PAGING_BLOCK_SIZE + |
| 419 | FW_PAGING_SIZE, |
Matti Gottlieb | e112018 | 2015-07-19 11:15:07 +0300 | [diff] [blame] | 420 | GFP_KERNEL); |
| 421 | if (!mvm->trans->paging_download_buf) { |
| 422 | ret = -ENOMEM; |
| 423 | goto exit; |
| 424 | } |
| 425 | mvm->trans->paging_req_addr = le32_to_cpu(item_resp->item_val); |
| 426 | mvm->trans->paging_db = mvm->fw_paging_db; |
| 427 | IWL_DEBUG_FW(mvm, |
| 428 | "Paging: got paging request address (paging_req_addr 0x%08x)\n", |
| 429 | mvm->trans->paging_req_addr); |
| 430 | |
| 431 | exit: |
| 432 | iwl_free_resp(&cmd); |
| 433 | |
| 434 | return ret; |
| 435 | } |
| 436 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 437 | static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait, |
| 438 | struct iwl_rx_packet *pkt, void *data) |
| 439 | { |
| 440 | struct iwl_mvm *mvm = |
| 441 | container_of(notif_wait, struct iwl_mvm, notif_wait); |
| 442 | struct iwl_mvm_alive_data *alive_data = data; |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 443 | struct mvm_alive_resp_ver1 *palive1; |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 444 | struct mvm_alive_resp_ver2 *palive2; |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 445 | struct mvm_alive_resp *palive; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 446 | |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 447 | if (iwl_rx_packet_payload_len(pkt) == sizeof(*palive1)) { |
| 448 | palive1 = (void *)pkt->data; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 449 | |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 450 | mvm->support_umac_log = false; |
| 451 | mvm->error_event_table = |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 452 | le32_to_cpu(palive1->error_event_table_ptr); |
| 453 | mvm->log_event_table = |
| 454 | le32_to_cpu(palive1->log_event_table_ptr); |
| 455 | alive_data->scd_base_addr = le32_to_cpu(palive1->scd_base_ptr); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 456 | |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 457 | alive_data->valid = le16_to_cpu(palive1->status) == |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 458 | IWL_ALIVE_STATUS_OK; |
| 459 | IWL_DEBUG_FW(mvm, |
| 460 | "Alive VER1 ucode status 0x%04x revision 0x%01X 0x%01X flags 0x%01X\n", |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 461 | le16_to_cpu(palive1->status), palive1->ver_type, |
| 462 | palive1->ver_subtype, palive1->flags); |
| 463 | } else if (iwl_rx_packet_payload_len(pkt) == sizeof(*palive2)) { |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 464 | palive2 = (void *)pkt->data; |
| 465 | |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 466 | mvm->error_event_table = |
| 467 | le32_to_cpu(palive2->error_event_table_ptr); |
| 468 | mvm->log_event_table = |
| 469 | le32_to_cpu(palive2->log_event_table_ptr); |
| 470 | alive_data->scd_base_addr = le32_to_cpu(palive2->scd_base_ptr); |
| 471 | mvm->umac_error_event_table = |
| 472 | le32_to_cpu(palive2->error_info_addr); |
Eran Harary | 91479b6 | 2014-05-11 08:11:34 +0300 | [diff] [blame] | 473 | mvm->sf_space.addr = le32_to_cpu(palive2->st_fwrd_addr); |
| 474 | mvm->sf_space.size = le32_to_cpu(palive2->st_fwrd_size); |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 475 | |
| 476 | alive_data->valid = le16_to_cpu(palive2->status) == |
| 477 | IWL_ALIVE_STATUS_OK; |
Emmanuel Grumbach | ffa7026 | 2014-02-11 16:37:34 +0200 | [diff] [blame] | 478 | if (mvm->umac_error_event_table) |
| 479 | mvm->support_umac_log = true; |
| 480 | |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 481 | IWL_DEBUG_FW(mvm, |
| 482 | "Alive VER2 ucode status 0x%04x revision 0x%01X 0x%01X flags 0x%01X\n", |
| 483 | le16_to_cpu(palive2->status), palive2->ver_type, |
| 484 | palive2->ver_subtype, palive2->flags); |
| 485 | |
| 486 | IWL_DEBUG_FW(mvm, |
| 487 | "UMAC version: Major - 0x%x, Minor - 0x%x\n", |
| 488 | palive2->umac_major, palive2->umac_minor); |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 489 | } else if (iwl_rx_packet_payload_len(pkt) == sizeof(*palive)) { |
| 490 | palive = (void *)pkt->data; |
| 491 | |
| 492 | mvm->error_event_table = |
| 493 | le32_to_cpu(palive->error_event_table_ptr); |
| 494 | mvm->log_event_table = |
| 495 | le32_to_cpu(palive->log_event_table_ptr); |
| 496 | alive_data->scd_base_addr = le32_to_cpu(palive->scd_base_ptr); |
| 497 | mvm->umac_error_event_table = |
| 498 | le32_to_cpu(palive->error_info_addr); |
| 499 | mvm->sf_space.addr = le32_to_cpu(palive->st_fwrd_addr); |
| 500 | mvm->sf_space.size = le32_to_cpu(palive->st_fwrd_size); |
| 501 | |
| 502 | alive_data->valid = le16_to_cpu(palive->status) == |
| 503 | IWL_ALIVE_STATUS_OK; |
| 504 | if (mvm->umac_error_event_table) |
| 505 | mvm->support_umac_log = true; |
| 506 | |
| 507 | IWL_DEBUG_FW(mvm, |
| 508 | "Alive VER3 ucode status 0x%04x revision 0x%01X 0x%01X flags 0x%01X\n", |
| 509 | le16_to_cpu(palive->status), palive->ver_type, |
| 510 | palive->ver_subtype, palive->flags); |
| 511 | |
| 512 | IWL_DEBUG_FW(mvm, |
| 513 | "UMAC version: Major - 0x%x, Minor - 0x%x\n", |
| 514 | le32_to_cpu(palive->umac_major), |
| 515 | le32_to_cpu(palive->umac_minor)); |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 516 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 517 | |
| 518 | return true; |
| 519 | } |
| 520 | |
| 521 | static bool iwl_wait_phy_db_entry(struct iwl_notif_wait_data *notif_wait, |
| 522 | struct iwl_rx_packet *pkt, void *data) |
| 523 | { |
| 524 | struct iwl_phy_db *phy_db = data; |
| 525 | |
| 526 | if (pkt->hdr.cmd != CALIB_RES_NOTIF_PHY_DB) { |
| 527 | WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF); |
| 528 | return true; |
| 529 | } |
| 530 | |
| 531 | WARN_ON(iwl_phy_db_set_section(phy_db, pkt, GFP_ATOMIC)); |
| 532 | |
| 533 | return false; |
| 534 | } |
| 535 | |
| 536 | static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm, |
| 537 | enum iwl_ucode_type ucode_type) |
| 538 | { |
| 539 | struct iwl_notification_wait alive_wait; |
| 540 | struct iwl_mvm_alive_data alive_data; |
| 541 | const struct fw_img *fw; |
| 542 | int ret, i; |
| 543 | enum iwl_ucode_type old_type = mvm->cur_ucode; |
Sara Sharon | 6eb031d | 2015-07-13 14:50:47 +0300 | [diff] [blame] | 544 | static const u16 alive_cmd[] = { MVM_ALIVE }; |
Eran Harary | 91479b6 | 2014-05-11 08:11:34 +0300 | [diff] [blame] | 545 | struct iwl_sf_region st_fwrd_space; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 546 | |
Eran Harary | 61df750 | 2014-12-01 17:40:37 +0200 | [diff] [blame] | 547 | if (ucode_type == IWL_UCODE_REGULAR && |
Golan Ben-Ami | 3d2d442 | 2016-02-23 10:34:48 +0200 | [diff] [blame] | 548 | iwl_fw_dbg_conf_usniffer(mvm->fw, FW_DBG_START_FROM_ALIVE) && |
| 549 | !(fw_has_capa(&mvm->fw->ucode_capa, |
| 550 | IWL_UCODE_TLV_CAPA_USNIFFER_UNIFIED))) |
Eran Harary | 61df750 | 2014-12-01 17:40:37 +0200 | [diff] [blame] | 551 | fw = iwl_get_ucode_image(mvm, IWL_UCODE_REGULAR_USNIFFER); |
| 552 | else |
| 553 | fw = iwl_get_ucode_image(mvm, ucode_type); |
Johannes Berg | befe9b6 | 2013-10-25 12:32:51 +0200 | [diff] [blame] | 554 | if (WARN_ON(!fw)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 555 | return -EINVAL; |
Johannes Berg | befe9b6 | 2013-10-25 12:32:51 +0200 | [diff] [blame] | 556 | mvm->cur_ucode = ucode_type; |
| 557 | mvm->ucode_loaded = false; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 558 | |
| 559 | iwl_init_notification_wait(&mvm->notif_wait, &alive_wait, |
| 560 | alive_cmd, ARRAY_SIZE(alive_cmd), |
| 561 | iwl_alive_fn, &alive_data); |
| 562 | |
| 563 | ret = iwl_trans_start_fw(mvm->trans, fw, ucode_type == IWL_UCODE_INIT); |
| 564 | if (ret) { |
| 565 | mvm->cur_ucode = old_type; |
| 566 | iwl_remove_notification(&mvm->notif_wait, &alive_wait); |
| 567 | return ret; |
| 568 | } |
| 569 | |
| 570 | /* |
| 571 | * Some things may run in the background now, but we |
| 572 | * just wait for the ALIVE notification here. |
| 573 | */ |
| 574 | ret = iwl_wait_notification(&mvm->notif_wait, &alive_wait, |
| 575 | MVM_UCODE_ALIVE_TIMEOUT); |
| 576 | if (ret) { |
Dor Shaish | 192de2b | 2015-07-15 11:41:21 +0300 | [diff] [blame] | 577 | if (mvm->trans->cfg->device_family == IWL_DEVICE_FAMILY_8000) |
| 578 | IWL_ERR(mvm, |
| 579 | "SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n", |
| 580 | iwl_read_prph(mvm->trans, SB_CPU_1_STATUS), |
| 581 | iwl_read_prph(mvm->trans, SB_CPU_2_STATUS)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 582 | mvm->cur_ucode = old_type; |
| 583 | return ret; |
| 584 | } |
| 585 | |
| 586 | if (!alive_data.valid) { |
| 587 | IWL_ERR(mvm, "Loaded ucode is not valid!\n"); |
| 588 | mvm->cur_ucode = old_type; |
| 589 | return -EIO; |
| 590 | } |
| 591 | |
Eran Harary | 91479b6 | 2014-05-11 08:11:34 +0300 | [diff] [blame] | 592 | /* |
| 593 | * update the sdio allocation according to the pointer we get in the |
| 594 | * alive notification. |
| 595 | */ |
| 596 | st_fwrd_space.addr = mvm->sf_space.addr; |
| 597 | st_fwrd_space.size = mvm->sf_space.size; |
| 598 | ret = iwl_trans_update_sf(mvm->trans, &st_fwrd_space); |
Eyal Shapira | 82e8aea | 2014-10-19 14:56:40 +0300 | [diff] [blame] | 599 | if (ret) { |
| 600 | IWL_ERR(mvm, "Failed to update SF size. ret %d\n", ret); |
| 601 | return ret; |
| 602 | } |
Eran Harary | 91479b6 | 2014-05-11 08:11:34 +0300 | [diff] [blame] | 603 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 604 | iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr); |
| 605 | |
| 606 | /* |
Matti Gottlieb | a6c4fb4 | 2015-07-15 16:19:29 +0300 | [diff] [blame] | 607 | * configure and operate fw paging mechanism. |
| 608 | * driver configures the paging flow only once, CPU2 paging image |
| 609 | * included in the IWL_UCODE_INIT image. |
| 610 | */ |
| 611 | if (fw->paging_mem_size) { |
Matti Gottlieb | e112018 | 2015-07-19 11:15:07 +0300 | [diff] [blame] | 612 | /* |
| 613 | * When dma is not enabled, the driver needs to copy / write |
| 614 | * the downloaded / uploaded page to / from the smem. |
| 615 | * This gets the location of the place were the pages are |
| 616 | * stored. |
| 617 | */ |
| 618 | if (!is_device_dma_capable(mvm->trans->dev)) { |
| 619 | ret = iwl_trans_get_paging_item(mvm); |
| 620 | if (ret) { |
| 621 | IWL_ERR(mvm, "failed to get FW paging item\n"); |
| 622 | return ret; |
| 623 | } |
| 624 | } |
| 625 | |
Matti Gottlieb | a6c4fb4 | 2015-07-15 16:19:29 +0300 | [diff] [blame] | 626 | ret = iwl_save_fw_paging(mvm, fw); |
| 627 | if (ret) { |
| 628 | IWL_ERR(mvm, "failed to save the FW paging image\n"); |
| 629 | return ret; |
| 630 | } |
| 631 | |
| 632 | ret = iwl_send_paging_cmd(mvm, fw); |
| 633 | if (ret) { |
| 634 | IWL_ERR(mvm, "failed to send the paging cmd\n"); |
| 635 | iwl_free_fw_paging(mvm); |
| 636 | return ret; |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | /* |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 641 | * Note: all the queues are enabled as part of the interface |
| 642 | * initialization, but in firmware restart scenarios they |
| 643 | * could be stopped, so wake them up. In firmware restart, |
| 644 | * mac80211 will have the queues stopped as well until the |
| 645 | * reconfiguration completes. During normal startup, they |
| 646 | * will be empty. |
| 647 | */ |
| 648 | |
Liad Kaufman | 4ecafae | 2015-07-14 13:36:18 +0300 | [diff] [blame] | 649 | memset(&mvm->queue_info, 0, sizeof(mvm->queue_info)); |
| 650 | mvm->queue_info[IWL_MVM_CMD_QUEUE].hw_queue_refcount = 1; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 651 | |
Johannes Berg | df197c0 | 2014-08-01 18:14:45 +0200 | [diff] [blame] | 652 | for (i = 0; i < IEEE80211_MAX_QUEUES; i++) |
| 653 | atomic_set(&mvm->mac80211_queue_stop_count[i], 0); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 654 | |
| 655 | mvm->ucode_loaded = true; |
| 656 | |
| 657 | return 0; |
| 658 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 659 | |
| 660 | static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm) |
| 661 | { |
| 662 | struct iwl_phy_cfg_cmd phy_cfg_cmd; |
| 663 | enum iwl_ucode_type ucode_type = mvm->cur_ucode; |
| 664 | |
| 665 | /* Set parameters */ |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 666 | phy_cfg_cmd.phy_cfg = cpu_to_le32(iwl_mvm_get_phy_config(mvm)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 667 | phy_cfg_cmd.calib_control.event_trigger = |
| 668 | mvm->fw->default_calib[ucode_type].event_trigger; |
| 669 | phy_cfg_cmd.calib_control.flow_trigger = |
| 670 | mvm->fw->default_calib[ucode_type].flow_trigger; |
| 671 | |
| 672 | IWL_DEBUG_INFO(mvm, "Sending Phy CFG command: 0x%x\n", |
| 673 | phy_cfg_cmd.phy_cfg); |
| 674 | |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 675 | return iwl_mvm_send_cmd_pdu(mvm, PHY_CONFIGURATION_CMD, 0, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 676 | sizeof(phy_cfg_cmd), &phy_cfg_cmd); |
| 677 | } |
| 678 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 679 | int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) |
| 680 | { |
| 681 | struct iwl_notification_wait calib_wait; |
Sara Sharon | 6eb031d | 2015-07-13 14:50:47 +0300 | [diff] [blame] | 682 | static const u16 init_complete[] = { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 683 | INIT_COMPLETE_NOTIF, |
| 684 | CALIB_RES_NOTIF_PHY_DB |
| 685 | }; |
| 686 | int ret; |
| 687 | |
| 688 | lockdep_assert_held(&mvm->mutex); |
| 689 | |
Eran Harary | 8d193ca | 2015-04-27 10:29:31 +0300 | [diff] [blame] | 690 | if (WARN_ON_ONCE(mvm->calibrating)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 691 | return 0; |
| 692 | |
| 693 | iwl_init_notification_wait(&mvm->notif_wait, |
| 694 | &calib_wait, |
| 695 | init_complete, |
| 696 | ARRAY_SIZE(init_complete), |
| 697 | iwl_wait_phy_db_entry, |
| 698 | mvm->phy_db); |
| 699 | |
| 700 | /* Will also start the device */ |
| 701 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_INIT); |
| 702 | if (ret) { |
| 703 | IWL_ERR(mvm, "Failed to start INIT ucode: %d\n", ret); |
| 704 | goto error; |
| 705 | } |
| 706 | |
Emmanuel Grumbach | ae39747 | 2014-03-30 16:55:18 +0300 | [diff] [blame] | 707 | ret = iwl_send_bt_init_conf(mvm); |
Emmanuel Grumbach | 931d416 | 2013-01-17 09:42:25 +0200 | [diff] [blame] | 708 | if (ret) |
| 709 | goto error; |
| 710 | |
Eytan Lifshitz | 81a67e3 | 2013-09-11 12:39:18 +0200 | [diff] [blame] | 711 | /* Read the NVM only at driver load time, no need to do this twice */ |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 712 | if (read_nvm) { |
| 713 | /* Read nvm */ |
Eran Harary | 14b485f | 2014-04-23 10:46:09 +0300 | [diff] [blame] | 714 | ret = iwl_nvm_init(mvm, true); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 715 | if (ret) { |
| 716 | IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); |
| 717 | goto error; |
| 718 | } |
| 719 | } |
| 720 | |
Eytan Lifshitz | 81a67e3 | 2013-09-11 12:39:18 +0200 | [diff] [blame] | 721 | /* In case we read the NVM from external file, load it to the NIC */ |
Eran Harary | e02a9d6 | 2014-05-07 12:27:10 +0300 | [diff] [blame] | 722 | if (mvm->nvm_file_name) |
Eytan Lifshitz | 81a67e3 | 2013-09-11 12:39:18 +0200 | [diff] [blame] | 723 | iwl_mvm_load_nvm_to_nic(mvm); |
| 724 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 725 | ret = iwl_nvm_check_version(mvm->nvm_data, mvm->trans); |
| 726 | WARN_ON(ret); |
| 727 | |
Eran Harary | 4f59334 | 2013-05-13 07:53:26 +0300 | [diff] [blame] | 728 | /* |
| 729 | * abort after reading the nvm in case RF Kill is on, we will complete |
| 730 | * the init seq later when RF kill will switch to off |
| 731 | */ |
Arik Nemtsov | 1a3fe0b | 2015-09-30 11:19:55 +0300 | [diff] [blame] | 732 | if (iwl_mvm_is_radio_hw_killed(mvm)) { |
Eran Harary | 4f59334 | 2013-05-13 07:53:26 +0300 | [diff] [blame] | 733 | IWL_DEBUG_RF_KILL(mvm, |
| 734 | "jump over all phy activities due to RF kill\n"); |
| 735 | iwl_remove_notification(&mvm->notif_wait, &calib_wait); |
Arik Nemtsov | a408284 | 2013-11-24 19:10:46 +0200 | [diff] [blame] | 736 | ret = 1; |
| 737 | goto out; |
Eran Harary | 4f59334 | 2013-05-13 07:53:26 +0300 | [diff] [blame] | 738 | } |
| 739 | |
Emmanuel Grumbach | 31b8b34 | 2014-11-02 15:48:09 +0200 | [diff] [blame] | 740 | mvm->calibrating = true; |
| 741 | |
Dor Shaish | e07cbb5 | 2013-02-27 23:00:27 +0200 | [diff] [blame] | 742 | /* Send TX valid antennas before triggering calibrations */ |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 743 | ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm)); |
Dor Shaish | e07cbb5 | 2013-02-27 23:00:27 +0200 | [diff] [blame] | 744 | if (ret) |
| 745 | goto error; |
| 746 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 747 | /* |
| 748 | * Send phy configurations command to init uCode |
| 749 | * to start the 16.0 uCode init image internal calibrations. |
| 750 | */ |
| 751 | ret = iwl_send_phy_cfg_cmd(mvm); |
| 752 | if (ret) { |
| 753 | IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n", |
| 754 | ret); |
| 755 | goto error; |
| 756 | } |
| 757 | |
| 758 | /* |
| 759 | * Some things may run in the background now, but we |
| 760 | * just wait for the calibration complete notification. |
| 761 | */ |
| 762 | ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait, |
| 763 | MVM_UCODE_CALIB_TIMEOUT); |
Emmanuel Grumbach | 31b8b34 | 2014-11-02 15:48:09 +0200 | [diff] [blame] | 764 | |
Arik Nemtsov | 1a3fe0b | 2015-09-30 11:19:55 +0300 | [diff] [blame] | 765 | if (ret && iwl_mvm_is_radio_hw_killed(mvm)) { |
Emmanuel Grumbach | 31b8b34 | 2014-11-02 15:48:09 +0200 | [diff] [blame] | 766 | IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n"); |
| 767 | ret = 1; |
| 768 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 769 | goto out; |
| 770 | |
| 771 | error: |
| 772 | iwl_remove_notification(&mvm->notif_wait, &calib_wait); |
| 773 | out: |
Emmanuel Grumbach | 31b8b34 | 2014-11-02 15:48:09 +0200 | [diff] [blame] | 774 | mvm->calibrating = false; |
Arik Nemtsov | a408284 | 2013-11-24 19:10:46 +0200 | [diff] [blame] | 775 | if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 776 | /* we want to debug INIT and we have no NVM - fake */ |
| 777 | mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) + |
| 778 | sizeof(struct ieee80211_channel) + |
| 779 | sizeof(struct ieee80211_rate), |
| 780 | GFP_KERNEL); |
| 781 | if (!mvm->nvm_data) |
| 782 | return -ENOMEM; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 783 | mvm->nvm_data->bands[0].channels = mvm->nvm_data->channels; |
| 784 | mvm->nvm_data->bands[0].n_channels = 1; |
| 785 | mvm->nvm_data->bands[0].n_bitrates = 1; |
| 786 | mvm->nvm_data->bands[0].bitrates = |
| 787 | (void *)mvm->nvm_data->channels + 1; |
| 788 | mvm->nvm_data->bands[0].bitrates->hw_value = 10; |
| 789 | } |
| 790 | |
| 791 | return ret; |
| 792 | } |
| 793 | |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 794 | static void iwl_mvm_get_shared_mem_conf(struct iwl_mvm *mvm) |
| 795 | { |
| 796 | struct iwl_host_cmd cmd = { |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 797 | .flags = CMD_WANT_SKB, |
| 798 | .data = { NULL, }, |
| 799 | .len = { 0, }, |
| 800 | }; |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 801 | struct iwl_shared_mem_cfg *mem_cfg; |
Golan Ben-Ami | 5b08641 | 2016-02-09 12:57:16 +0200 | [diff] [blame] | 802 | struct iwl_rx_packet *pkt; |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 803 | u32 i; |
| 804 | |
| 805 | lockdep_assert_held(&mvm->mutex); |
| 806 | |
Golan Ben-Ami | 5b08641 | 2016-02-09 12:57:16 +0200 | [diff] [blame] | 807 | if (fw_has_capa(&mvm->fw->ucode_capa, |
| 808 | IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG)) |
| 809 | cmd.id = iwl_cmd_id(SHARED_MEM_CFG_CMD, SYSTEM_GROUP, 0); |
| 810 | else |
| 811 | cmd.id = SHARED_MEM_CFG; |
| 812 | |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 813 | if (WARN_ON(iwl_mvm_send_cmd(mvm, &cmd))) |
| 814 | return; |
| 815 | |
| 816 | pkt = cmd.resp_pkt; |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 817 | mem_cfg = (void *)pkt->data; |
| 818 | |
| 819 | mvm->shared_mem_cfg.shared_mem_addr = |
| 820 | le32_to_cpu(mem_cfg->shared_mem_addr); |
| 821 | mvm->shared_mem_cfg.shared_mem_size = |
| 822 | le32_to_cpu(mem_cfg->shared_mem_size); |
| 823 | mvm->shared_mem_cfg.sample_buff_addr = |
| 824 | le32_to_cpu(mem_cfg->sample_buff_addr); |
| 825 | mvm->shared_mem_cfg.sample_buff_size = |
| 826 | le32_to_cpu(mem_cfg->sample_buff_size); |
| 827 | mvm->shared_mem_cfg.txfifo_addr = le32_to_cpu(mem_cfg->txfifo_addr); |
| 828 | for (i = 0; i < ARRAY_SIZE(mvm->shared_mem_cfg.txfifo_size); i++) |
| 829 | mvm->shared_mem_cfg.txfifo_size[i] = |
| 830 | le32_to_cpu(mem_cfg->txfifo_size[i]); |
| 831 | for (i = 0; i < ARRAY_SIZE(mvm->shared_mem_cfg.rxfifo_size); i++) |
| 832 | mvm->shared_mem_cfg.rxfifo_size[i] = |
| 833 | le32_to_cpu(mem_cfg->rxfifo_size[i]); |
| 834 | mvm->shared_mem_cfg.page_buff_addr = |
| 835 | le32_to_cpu(mem_cfg->page_buff_addr); |
| 836 | mvm->shared_mem_cfg.page_buff_size = |
| 837 | le32_to_cpu(mem_cfg->page_buff_size); |
Golan Ben-Ami | 5b08641 | 2016-02-09 12:57:16 +0200 | [diff] [blame] | 838 | |
| 839 | /* new API has more data */ |
| 840 | if (fw_has_capa(&mvm->fw->ucode_capa, |
| 841 | IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG)) { |
| 842 | mvm->shared_mem_cfg.rxfifo_addr = |
| 843 | le32_to_cpu(mem_cfg->rxfifo_addr); |
| 844 | mvm->shared_mem_cfg.internal_txfifo_addr = |
| 845 | le32_to_cpu(mem_cfg->internal_txfifo_addr); |
| 846 | |
| 847 | BUILD_BUG_ON(sizeof(mvm->shared_mem_cfg.internal_txfifo_size) != |
| 848 | sizeof(mem_cfg->internal_txfifo_size)); |
| 849 | |
| 850 | for (i = 0; |
| 851 | i < ARRAY_SIZE(mvm->shared_mem_cfg.internal_txfifo_size); |
| 852 | i++) |
| 853 | mvm->shared_mem_cfg.internal_txfifo_size[i] = |
| 854 | le32_to_cpu(mem_cfg->internal_txfifo_size[i]); |
| 855 | } |
| 856 | |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 857 | IWL_DEBUG_INFO(mvm, "SHARED MEM CFG: got memory offsets/sizes\n"); |
| 858 | |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 859 | iwl_free_resp(&cmd); |
| 860 | } |
| 861 | |
Emmanuel Grumbach | 84bfffa | 2015-01-13 10:16:30 +0200 | [diff] [blame] | 862 | static int iwl_mvm_config_ltr(struct iwl_mvm *mvm) |
| 863 | { |
| 864 | struct iwl_ltr_config_cmd cmd = { |
| 865 | .flags = cpu_to_le32(LTR_CFG_FLAG_FEATURE_ENABLE), |
| 866 | }; |
| 867 | |
| 868 | if (!mvm->trans->ltr_enabled) |
| 869 | return 0; |
| 870 | |
Emmanuel Grumbach | 84bfffa | 2015-01-13 10:16:30 +0200 | [diff] [blame] | 871 | return iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0, |
| 872 | sizeof(cmd), &cmd); |
| 873 | } |
| 874 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 875 | int iwl_mvm_up(struct iwl_mvm *mvm) |
| 876 | { |
| 877 | int ret, i; |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 878 | struct ieee80211_channel *chan; |
| 879 | struct cfg80211_chan_def chandef; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 880 | |
| 881 | lockdep_assert_held(&mvm->mutex); |
| 882 | |
| 883 | ret = iwl_trans_start_hw(mvm->trans); |
| 884 | if (ret) |
| 885 | return ret; |
| 886 | |
Eytan Lifshitz | ff11637 | 2013-09-03 12:06:11 +0300 | [diff] [blame] | 887 | /* |
| 888 | * If we haven't completed the run of the init ucode during |
| 889 | * module loading, load init ucode now |
| 890 | * (for example, if we were in RFKILL) |
| 891 | */ |
Eran Harary | 8d193ca | 2015-04-27 10:29:31 +0300 | [diff] [blame] | 892 | ret = iwl_run_init_mvm_ucode(mvm, false); |
| 893 | if (ret && !iwlmvm_mod_params.init_dbg) { |
| 894 | IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret); |
| 895 | /* this can't happen */ |
| 896 | if (WARN_ON(ret > 0)) |
| 897 | ret = -ERFKILL; |
| 898 | goto error; |
| 899 | } |
| 900 | if (!iwlmvm_mod_params.init_dbg) { |
| 901 | /* |
| 902 | * Stop and start the transport without entering low power |
| 903 | * mode. This will save the state of other components on the |
| 904 | * device that are triggered by the INIT firwmare (MFUART). |
| 905 | */ |
| 906 | _iwl_trans_stop_device(mvm->trans, false); |
Johannes Berg | d643c43 | 2015-05-07 14:47:50 +0200 | [diff] [blame] | 907 | ret = _iwl_trans_start_hw(mvm->trans, false); |
Eran Harary | 8d193ca | 2015-04-27 10:29:31 +0300 | [diff] [blame] | 908 | if (ret) |
Johannes Berg | d643c43 | 2015-05-07 14:47:50 +0200 | [diff] [blame] | 909 | goto error; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | if (iwlmvm_mod_params.init_dbg) |
| 913 | return 0; |
| 914 | |
| 915 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR); |
| 916 | if (ret) { |
| 917 | IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret); |
| 918 | goto error; |
| 919 | } |
| 920 | |
Sara Sharon | 6c7d32c | 2015-06-07 09:34:57 +0300 | [diff] [blame] | 921 | iwl_mvm_get_shared_mem_conf(mvm); |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 922 | |
Lilach Edelstein | 1f3b0ff | 2013-10-06 13:03:32 +0200 | [diff] [blame] | 923 | ret = iwl_mvm_sf_update(mvm, NULL, false); |
| 924 | if (ret) |
| 925 | IWL_ERR(mvm, "Failed to initialize Smart Fifo\n"); |
| 926 | |
Liad Kaufman | 6a95126 | 2014-11-17 11:36:21 +0200 | [diff] [blame] | 927 | mvm->fw_dbg_conf = FW_DBG_INVALID; |
Emmanuel Grumbach | 945d420 | 2015-02-15 17:16:16 +0200 | [diff] [blame] | 928 | /* if we have a destination, assume EARLY START */ |
| 929 | if (mvm->fw->dbg_dest_tlv) |
| 930 | mvm->fw_dbg_conf = FW_DBG_START_FROM_ALIVE; |
Emmanuel Grumbach | d2709ad | 2015-01-29 14:58:06 +0200 | [diff] [blame] | 931 | iwl_mvm_start_fw_dbg_conf(mvm, FW_DBG_START_FROM_ALIVE); |
Liad Kaufman | 6a95126 | 2014-11-17 11:36:21 +0200 | [diff] [blame] | 932 | |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 933 | ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 934 | if (ret) |
| 935 | goto error; |
| 936 | |
Emmanuel Grumbach | 931d416 | 2013-01-17 09:42:25 +0200 | [diff] [blame] | 937 | ret = iwl_send_bt_init_conf(mvm); |
| 938 | if (ret) |
| 939 | goto error; |
| 940 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 941 | /* Send phy db control command and then phy db calibration*/ |
| 942 | ret = iwl_send_phy_db_data(mvm->phy_db); |
| 943 | if (ret) |
| 944 | goto error; |
| 945 | |
| 946 | ret = iwl_send_phy_cfg_cmd(mvm); |
| 947 | if (ret) |
| 948 | goto error; |
| 949 | |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 950 | /* Init RSS configuration */ |
| 951 | if (iwl_mvm_has_new_rx_api(mvm)) { |
| 952 | ret = iwl_send_rss_cfg_cmd(mvm); |
| 953 | if (ret) { |
| 954 | IWL_ERR(mvm, "Failed to configure RSS queues: %d\n", |
| 955 | ret); |
| 956 | goto error; |
| 957 | } |
| 958 | } |
| 959 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 960 | /* init the fw <-> mac80211 STA mapping */ |
| 961 | for (i = 0; i < IWL_MVM_STATION_COUNT; i++) |
| 962 | RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); |
| 963 | |
Arik Nemtsov | 1d3c3f6 | 2014-10-23 18:03:10 +0300 | [diff] [blame] | 964 | mvm->tdls_cs.peer.sta_id = IWL_MVM_STATION_COUNT; |
| 965 | |
Johannes Berg | b2b7875 | 2014-09-08 16:42:54 +0200 | [diff] [blame] | 966 | /* reset quota debouncing buffer - 0xff will yield invalid data */ |
| 967 | memset(&mvm->last_quota_cmd, 0xff, sizeof(mvm->last_quota_cmd)); |
| 968 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 969 | /* Add auxiliary station for scanning */ |
| 970 | ret = iwl_mvm_add_aux_sta(mvm); |
| 971 | if (ret) |
| 972 | goto error; |
| 973 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 974 | /* Add all the PHY contexts */ |
| 975 | chan = &mvm->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->channels[0]; |
| 976 | cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT); |
| 977 | for (i = 0; i < NUM_PHY_CTX; i++) { |
| 978 | /* |
| 979 | * The channel used here isn't relevant as it's |
| 980 | * going to be overwritten in the other flows. |
| 981 | * For now use the first channel we have. |
| 982 | */ |
| 983 | ret = iwl_mvm_phy_ctxt_add(mvm, &mvm->phy_ctxts[i], |
| 984 | &chandef, 1, 1); |
| 985 | if (ret) |
| 986 | goto error; |
| 987 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 988 | |
Chaya Rachel Ivgi | c221daf | 2015-12-29 09:54:49 +0200 | [diff] [blame] | 989 | #ifdef CONFIG_THERMAL |
| 990 | if (iwl_mvm_is_tt_in_fw(mvm)) { |
| 991 | /* in order to give the responsibility of ct-kill and |
| 992 | * TX backoff to FW we need to send empty temperature reporting |
| 993 | * cmd during init time |
| 994 | */ |
| 995 | iwl_mvm_send_temp_report_ths_cmd(mvm); |
| 996 | } else { |
| 997 | /* Initialize tx backoffs to the minimal possible */ |
| 998 | iwl_mvm_tt_tx_backoff(mvm, 0); |
| 999 | } |
Chaya Rachel Ivgi | 5c89e7b | 2016-01-05 10:34:47 +0200 | [diff] [blame] | 1000 | |
| 1001 | /* TODO: read the budget from BIOS / Platform NVM */ |
| 1002 | if (iwl_mvm_is_ctdp_supported(mvm) && mvm->cooling_dev.cur_state > 0) |
| 1003 | ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START, |
| 1004 | mvm->cooling_dev.cur_state); |
Chaya Rachel Ivgi | c221daf | 2015-12-29 09:54:49 +0200 | [diff] [blame] | 1005 | #else |
Ido Yariv | 0c0e2c7 | 2014-01-16 21:12:02 -0500 | [diff] [blame] | 1006 | /* Initialize tx backoffs to the minimal possible */ |
| 1007 | iwl_mvm_tt_tx_backoff(mvm, 0); |
Chaya Rachel Ivgi | c221daf | 2015-12-29 09:54:49 +0200 | [diff] [blame] | 1008 | #endif |
Ido Yariv | 0c0e2c7 | 2014-01-16 21:12:02 -0500 | [diff] [blame] | 1009 | |
Emmanuel Grumbach | 84bfffa | 2015-01-13 10:16:30 +0200 | [diff] [blame] | 1010 | WARN_ON(iwl_mvm_config_ltr(mvm)); |
Emmanuel Grumbach | 9180ac5 | 2014-09-23 23:02:41 +0300 | [diff] [blame] | 1011 | |
Emmanuel Grumbach | c1cb92f | 2014-01-28 10:17:18 +0200 | [diff] [blame] | 1012 | ret = iwl_mvm_power_update_device(mvm); |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 1013 | if (ret) |
| 1014 | goto error; |
| 1015 | |
Arik Nemtsov | 35af15d | 2015-03-04 15:08:00 +0200 | [diff] [blame] | 1016 | /* |
| 1017 | * RTNL is not taken during Ct-kill, but we don't need to scan/Tx |
| 1018 | * anyway, so don't init MCC. |
| 1019 | */ |
| 1020 | if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) { |
| 1021 | ret = iwl_mvm_init_mcc(mvm); |
| 1022 | if (ret) |
| 1023 | goto error; |
| 1024 | } |
Arik Nemtsov | 90d4f7d | 2014-03-04 19:58:46 +0200 | [diff] [blame] | 1025 | |
Johannes Berg | 859d914 | 2015-06-01 17:11:11 +0200 | [diff] [blame] | 1026 | if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { |
Emmanuel Grumbach | 4ca87a5 | 2016-01-03 22:23:40 +0200 | [diff] [blame] | 1027 | mvm->scan_type = IWL_SCAN_TYPE_NOT_SET; |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1028 | ret = iwl_mvm_config_scan(mvm); |
| 1029 | if (ret) |
| 1030 | goto error; |
| 1031 | } |
| 1032 | |
Avri Altman | 93190fb | 2014-12-27 09:09:47 +0200 | [diff] [blame] | 1033 | if (iwl_mvm_is_csum_supported(mvm) && |
| 1034 | mvm->cfg->features & NETIF_F_RXCSUM) |
| 1035 | iwl_trans_write_prph(mvm->trans, RX_EN_CSUM, 0x3); |
| 1036 | |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 1037 | /* allow FW/transport low power modes if not during restart */ |
| 1038 | if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
| 1039 | iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN); |
| 1040 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1041 | IWL_DEBUG_INFO(mvm, "RT uCode started.\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1042 | return 0; |
| 1043 | error: |
Chaya Rachel Ivgi | fcb6b92 | 2016-02-22 10:21:41 +0200 | [diff] [blame] | 1044 | iwl_mvm_stop_device(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1045 | return ret; |
| 1046 | } |
| 1047 | |
| 1048 | int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm) |
| 1049 | { |
| 1050 | int ret, i; |
| 1051 | |
| 1052 | lockdep_assert_held(&mvm->mutex); |
| 1053 | |
| 1054 | ret = iwl_trans_start_hw(mvm->trans); |
| 1055 | if (ret) |
| 1056 | return ret; |
| 1057 | |
| 1058 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_WOWLAN); |
| 1059 | if (ret) { |
| 1060 | IWL_ERR(mvm, "Failed to start WoWLAN firmware: %d\n", ret); |
| 1061 | goto error; |
| 1062 | } |
| 1063 | |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 1064 | ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1065 | if (ret) |
| 1066 | goto error; |
| 1067 | |
| 1068 | /* Send phy db control command and then phy db calibration*/ |
| 1069 | ret = iwl_send_phy_db_data(mvm->phy_db); |
| 1070 | if (ret) |
| 1071 | goto error; |
| 1072 | |
| 1073 | ret = iwl_send_phy_cfg_cmd(mvm); |
| 1074 | if (ret) |
| 1075 | goto error; |
| 1076 | |
| 1077 | /* init the fw <-> mac80211 STA mapping */ |
| 1078 | for (i = 0; i < IWL_MVM_STATION_COUNT; i++) |
| 1079 | RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); |
| 1080 | |
| 1081 | /* Add auxiliary station for scanning */ |
| 1082 | ret = iwl_mvm_add_aux_sta(mvm); |
| 1083 | if (ret) |
| 1084 | goto error; |
| 1085 | |
| 1086 | return 0; |
| 1087 | error: |
Chaya Rachel Ivgi | fcb6b92 | 2016-02-22 10:21:41 +0200 | [diff] [blame] | 1088 | iwl_mvm_stop_device(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1089 | return ret; |
| 1090 | } |
| 1091 | |
Johannes Berg | 0416841 | 2015-06-23 21:22:09 +0200 | [diff] [blame] | 1092 | void iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm, |
| 1093 | struct iwl_rx_cmd_buffer *rxb) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1094 | { |
| 1095 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 1096 | struct iwl_card_state_notif *card_state_notif = (void *)pkt->data; |
| 1097 | u32 flags = le32_to_cpu(card_state_notif->flags); |
| 1098 | |
| 1099 | IWL_DEBUG_RF_KILL(mvm, "Card state received: HW:%s SW:%s CT:%s\n", |
| 1100 | (flags & HW_CARD_DISABLED) ? "Kill" : "On", |
| 1101 | (flags & SW_CARD_DISABLED) ? "Kill" : "On", |
| 1102 | (flags & CT_KILL_CARD_DISABLED) ? |
| 1103 | "Reached" : "Not reached"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1104 | } |
| 1105 | |
Johannes Berg | 0416841 | 2015-06-23 21:22:09 +0200 | [diff] [blame] | 1106 | void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm, |
| 1107 | struct iwl_rx_cmd_buffer *rxb) |
Chaya Rachel Ivgy | 30269c1 | 2014-11-15 21:08:29 +0200 | [diff] [blame] | 1108 | { |
| 1109 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 1110 | struct iwl_mfuart_load_notif *mfuart_notif = (void *)pkt->data; |
| 1111 | |
| 1112 | IWL_DEBUG_INFO(mvm, |
| 1113 | "MFUART: installed ver: 0x%08x, external ver: 0x%08x, status: 0x%08x, duration: 0x%08x\n", |
| 1114 | le32_to_cpu(mfuart_notif->installed_ver), |
| 1115 | le32_to_cpu(mfuart_notif->external_ver), |
| 1116 | le32_to_cpu(mfuart_notif->status), |
| 1117 | le32_to_cpu(mfuart_notif->duration)); |
Chaya Rachel Ivgy | 30269c1 | 2014-11-15 21:08:29 +0200 | [diff] [blame] | 1118 | } |