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 |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of version 2 of the GNU General Public License as |
| 13 | * published by the Free Software Foundation. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, but |
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, |
| 23 | * USA |
| 24 | * |
| 25 | * The full GNU General Public License is included in this distribution |
Emmanuel Grumbach | 410dc5a | 2013-02-18 09:22:28 +0200 | [diff] [blame] | 26 | * in the file called COPYING. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 27 | * |
| 28 | * Contact Information: |
| 29 | * Intel Linux Wireless <ilw@linux.intel.com> |
| 30 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 31 | * |
| 32 | * BSD LICENSE |
| 33 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 34 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
Eran Harary | 8d193ca | 2015-04-27 10:29:31 +0300 | [diff] [blame] | 35 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 36 | * All rights reserved. |
| 37 | * |
| 38 | * Redistribution and use in source and binary forms, with or without |
| 39 | * modification, are permitted provided that the following conditions |
| 40 | * are met: |
| 41 | * |
| 42 | * * Redistributions of source code must retain the above copyright |
| 43 | * notice, this list of conditions and the following disclaimer. |
| 44 | * * Redistributions in binary form must reproduce the above copyright |
| 45 | * notice, this list of conditions and the following disclaimer in |
| 46 | * the documentation and/or other materials provided with the |
| 47 | * distribution. |
| 48 | * * Neither the name Intel Corporation nor the names of its |
| 49 | * contributors may be used to endorse or promote products derived |
| 50 | * from this software without specific prior written permission. |
| 51 | * |
| 52 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 53 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 54 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 55 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 56 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 57 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 58 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 59 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 60 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 61 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 62 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 63 | * |
| 64 | *****************************************************************************/ |
| 65 | #include <net/mac80211.h> |
| 66 | |
| 67 | #include "iwl-trans.h" |
| 68 | #include "iwl-op-mode.h" |
| 69 | #include "iwl-fw.h" |
| 70 | #include "iwl-debug.h" |
| 71 | #include "iwl-csr.h" /* for iwl_mvm_rx_card_state_notif */ |
| 72 | #include "iwl-io.h" /* for iwl_mvm_rx_card_state_notif */ |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 73 | #include "iwl-prph.h" |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 74 | #include "iwl-eeprom-parse.h" |
| 75 | |
| 76 | #include "mvm.h" |
| 77 | #include "iwl-phy-db.h" |
| 78 | |
| 79 | #define MVM_UCODE_ALIVE_TIMEOUT HZ |
| 80 | #define MVM_UCODE_CALIB_TIMEOUT (2*HZ) |
| 81 | |
| 82 | #define UCODE_VALID_OK cpu_to_le32(0x1) |
| 83 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 84 | struct iwl_mvm_alive_data { |
| 85 | bool valid; |
| 86 | u32 scd_base_addr; |
| 87 | }; |
| 88 | |
| 89 | static inline const struct fw_img * |
| 90 | iwl_get_ucode_image(struct iwl_mvm *mvm, enum iwl_ucode_type ucode_type) |
| 91 | { |
| 92 | if (ucode_type >= IWL_UCODE_TYPE_MAX) |
| 93 | return NULL; |
| 94 | |
| 95 | return &mvm->fw->img[ucode_type]; |
| 96 | } |
| 97 | |
| 98 | static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant) |
| 99 | { |
| 100 | struct iwl_tx_ant_cfg_cmd tx_ant_cmd = { |
| 101 | .valid = cpu_to_le32(valid_tx_ant), |
| 102 | }; |
| 103 | |
Emmanuel Grumbach | 3322354 | 2013-03-09 20:38:19 +0200 | [diff] [blame] | 104 | 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] | 105 | return iwl_mvm_send_cmd_pdu(mvm, TX_ANT_CONFIGURATION_CMD, 0, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 106 | sizeof(tx_ant_cmd), &tx_ant_cmd); |
| 107 | } |
| 108 | |
| 109 | static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait, |
| 110 | struct iwl_rx_packet *pkt, void *data) |
| 111 | { |
| 112 | struct iwl_mvm *mvm = |
| 113 | container_of(notif_wait, struct iwl_mvm, notif_wait); |
| 114 | struct iwl_mvm_alive_data *alive_data = data; |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 115 | struct mvm_alive_resp_ver1 *palive1; |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 116 | struct mvm_alive_resp_ver2 *palive2; |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 117 | struct mvm_alive_resp *palive; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 118 | |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 119 | if (iwl_rx_packet_payload_len(pkt) == sizeof(*palive1)) { |
| 120 | palive1 = (void *)pkt->data; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 121 | |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 122 | mvm->support_umac_log = false; |
| 123 | mvm->error_event_table = |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 124 | le32_to_cpu(palive1->error_event_table_ptr); |
| 125 | mvm->log_event_table = |
| 126 | le32_to_cpu(palive1->log_event_table_ptr); |
| 127 | alive_data->scd_base_addr = le32_to_cpu(palive1->scd_base_ptr); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 128 | |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 129 | alive_data->valid = le16_to_cpu(palive1->status) == |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 130 | IWL_ALIVE_STATUS_OK; |
| 131 | IWL_DEBUG_FW(mvm, |
| 132 | "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] | 133 | le16_to_cpu(palive1->status), palive1->ver_type, |
| 134 | palive1->ver_subtype, palive1->flags); |
| 135 | } else if (iwl_rx_packet_payload_len(pkt) == sizeof(*palive2)) { |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 136 | palive2 = (void *)pkt->data; |
| 137 | |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 138 | mvm->error_event_table = |
| 139 | le32_to_cpu(palive2->error_event_table_ptr); |
| 140 | mvm->log_event_table = |
| 141 | le32_to_cpu(palive2->log_event_table_ptr); |
| 142 | alive_data->scd_base_addr = le32_to_cpu(palive2->scd_base_ptr); |
| 143 | mvm->umac_error_event_table = |
| 144 | le32_to_cpu(palive2->error_info_addr); |
Eran Harary | 91479b6 | 2014-05-11 08:11:34 +0300 | [diff] [blame] | 145 | mvm->sf_space.addr = le32_to_cpu(palive2->st_fwrd_addr); |
| 146 | mvm->sf_space.size = le32_to_cpu(palive2->st_fwrd_size); |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 147 | |
| 148 | alive_data->valid = le16_to_cpu(palive2->status) == |
| 149 | IWL_ALIVE_STATUS_OK; |
Emmanuel Grumbach | ffa7026 | 2014-02-11 16:37:34 +0200 | [diff] [blame] | 150 | if (mvm->umac_error_event_table) |
| 151 | mvm->support_umac_log = true; |
| 152 | |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 153 | IWL_DEBUG_FW(mvm, |
| 154 | "Alive VER2 ucode status 0x%04x revision 0x%01X 0x%01X flags 0x%01X\n", |
| 155 | le16_to_cpu(palive2->status), palive2->ver_type, |
| 156 | palive2->ver_subtype, palive2->flags); |
| 157 | |
| 158 | IWL_DEBUG_FW(mvm, |
| 159 | "UMAC version: Major - 0x%x, Minor - 0x%x\n", |
| 160 | palive2->umac_major, palive2->umac_minor); |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 161 | } else if (iwl_rx_packet_payload_len(pkt) == sizeof(*palive)) { |
| 162 | palive = (void *)pkt->data; |
| 163 | |
| 164 | mvm->error_event_table = |
| 165 | le32_to_cpu(palive->error_event_table_ptr); |
| 166 | mvm->log_event_table = |
| 167 | le32_to_cpu(palive->log_event_table_ptr); |
| 168 | alive_data->scd_base_addr = le32_to_cpu(palive->scd_base_ptr); |
| 169 | mvm->umac_error_event_table = |
| 170 | le32_to_cpu(palive->error_info_addr); |
| 171 | mvm->sf_space.addr = le32_to_cpu(palive->st_fwrd_addr); |
| 172 | mvm->sf_space.size = le32_to_cpu(palive->st_fwrd_size); |
| 173 | |
| 174 | alive_data->valid = le16_to_cpu(palive->status) == |
| 175 | IWL_ALIVE_STATUS_OK; |
| 176 | if (mvm->umac_error_event_table) |
| 177 | mvm->support_umac_log = true; |
| 178 | |
| 179 | IWL_DEBUG_FW(mvm, |
| 180 | "Alive VER3 ucode status 0x%04x revision 0x%01X 0x%01X flags 0x%01X\n", |
| 181 | le16_to_cpu(palive->status), palive->ver_type, |
| 182 | palive->ver_subtype, palive->flags); |
| 183 | |
| 184 | IWL_DEBUG_FW(mvm, |
| 185 | "UMAC version: Major - 0x%x, Minor - 0x%x\n", |
| 186 | le32_to_cpu(palive->umac_major), |
| 187 | le32_to_cpu(palive->umac_minor)); |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 188 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 189 | |
| 190 | return true; |
| 191 | } |
| 192 | |
| 193 | static bool iwl_wait_phy_db_entry(struct iwl_notif_wait_data *notif_wait, |
| 194 | struct iwl_rx_packet *pkt, void *data) |
| 195 | { |
| 196 | struct iwl_phy_db *phy_db = data; |
| 197 | |
| 198 | if (pkt->hdr.cmd != CALIB_RES_NOTIF_PHY_DB) { |
| 199 | WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF); |
| 200 | return true; |
| 201 | } |
| 202 | |
| 203 | WARN_ON(iwl_phy_db_set_section(phy_db, pkt, GFP_ATOMIC)); |
| 204 | |
| 205 | return false; |
| 206 | } |
| 207 | |
| 208 | static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm, |
| 209 | enum iwl_ucode_type ucode_type) |
| 210 | { |
| 211 | struct iwl_notification_wait alive_wait; |
| 212 | struct iwl_mvm_alive_data alive_data; |
| 213 | const struct fw_img *fw; |
| 214 | int ret, i; |
| 215 | enum iwl_ucode_type old_type = mvm->cur_ucode; |
Sara Sharon | 6eb031d | 2015-07-13 14:50:47 +0300 | [diff] [blame^] | 216 | static const u16 alive_cmd[] = { MVM_ALIVE }; |
Eran Harary | 91479b6 | 2014-05-11 08:11:34 +0300 | [diff] [blame] | 217 | struct iwl_sf_region st_fwrd_space; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 218 | |
Eran Harary | 61df750 | 2014-12-01 17:40:37 +0200 | [diff] [blame] | 219 | if (ucode_type == IWL_UCODE_REGULAR && |
Emmanuel Grumbach | d2709ad | 2015-01-29 14:58:06 +0200 | [diff] [blame] | 220 | iwl_fw_dbg_conf_usniffer(mvm->fw, FW_DBG_START_FROM_ALIVE)) |
Eran Harary | 61df750 | 2014-12-01 17:40:37 +0200 | [diff] [blame] | 221 | fw = iwl_get_ucode_image(mvm, IWL_UCODE_REGULAR_USNIFFER); |
| 222 | else |
| 223 | fw = iwl_get_ucode_image(mvm, ucode_type); |
Johannes Berg | befe9b6 | 2013-10-25 12:32:51 +0200 | [diff] [blame] | 224 | if (WARN_ON(!fw)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 225 | return -EINVAL; |
Johannes Berg | befe9b6 | 2013-10-25 12:32:51 +0200 | [diff] [blame] | 226 | mvm->cur_ucode = ucode_type; |
| 227 | mvm->ucode_loaded = false; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 228 | |
| 229 | iwl_init_notification_wait(&mvm->notif_wait, &alive_wait, |
| 230 | alive_cmd, ARRAY_SIZE(alive_cmd), |
| 231 | iwl_alive_fn, &alive_data); |
| 232 | |
| 233 | ret = iwl_trans_start_fw(mvm->trans, fw, ucode_type == IWL_UCODE_INIT); |
| 234 | if (ret) { |
| 235 | mvm->cur_ucode = old_type; |
| 236 | iwl_remove_notification(&mvm->notif_wait, &alive_wait); |
| 237 | return ret; |
| 238 | } |
| 239 | |
| 240 | /* |
| 241 | * Some things may run in the background now, but we |
| 242 | * just wait for the ALIVE notification here. |
| 243 | */ |
| 244 | ret = iwl_wait_notification(&mvm->notif_wait, &alive_wait, |
| 245 | MVM_UCODE_ALIVE_TIMEOUT); |
| 246 | if (ret) { |
| 247 | mvm->cur_ucode = old_type; |
| 248 | return ret; |
| 249 | } |
| 250 | |
| 251 | if (!alive_data.valid) { |
| 252 | IWL_ERR(mvm, "Loaded ucode is not valid!\n"); |
| 253 | mvm->cur_ucode = old_type; |
| 254 | return -EIO; |
| 255 | } |
| 256 | |
Eran Harary | 91479b6 | 2014-05-11 08:11:34 +0300 | [diff] [blame] | 257 | /* |
| 258 | * update the sdio allocation according to the pointer we get in the |
| 259 | * alive notification. |
| 260 | */ |
| 261 | st_fwrd_space.addr = mvm->sf_space.addr; |
| 262 | st_fwrd_space.size = mvm->sf_space.size; |
| 263 | ret = iwl_trans_update_sf(mvm->trans, &st_fwrd_space); |
Eyal Shapira | 82e8aea | 2014-10-19 14:56:40 +0300 | [diff] [blame] | 264 | if (ret) { |
| 265 | IWL_ERR(mvm, "Failed to update SF size. ret %d\n", ret); |
| 266 | return ret; |
| 267 | } |
Eran Harary | 91479b6 | 2014-05-11 08:11:34 +0300 | [diff] [blame] | 268 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 269 | iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr); |
| 270 | |
| 271 | /* |
| 272 | * Note: all the queues are enabled as part of the interface |
| 273 | * initialization, but in firmware restart scenarios they |
| 274 | * could be stopped, so wake them up. In firmware restart, |
| 275 | * mac80211 will have the queues stopped as well until the |
| 276 | * reconfiguration completes. During normal startup, they |
| 277 | * will be empty. |
| 278 | */ |
| 279 | |
| 280 | for (i = 0; i < IWL_MAX_HW_QUEUES; i++) { |
Eytan Lifshitz | 19e737c | 2013-09-09 13:30:15 +0200 | [diff] [blame] | 281 | if (i < mvm->first_agg_queue && i != IWL_MVM_CMD_QUEUE) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 282 | mvm->queue_to_mac80211[i] = i; |
| 283 | else |
| 284 | mvm->queue_to_mac80211[i] = IWL_INVALID_MAC80211_QUEUE; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 285 | } |
| 286 | |
Johannes Berg | df197c0 | 2014-08-01 18:14:45 +0200 | [diff] [blame] | 287 | for (i = 0; i < IEEE80211_MAX_QUEUES; i++) |
| 288 | atomic_set(&mvm->mac80211_queue_stop_count[i], 0); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 289 | |
| 290 | mvm->ucode_loaded = true; |
| 291 | |
| 292 | return 0; |
| 293 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 294 | |
| 295 | static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm) |
| 296 | { |
| 297 | struct iwl_phy_cfg_cmd phy_cfg_cmd; |
| 298 | enum iwl_ucode_type ucode_type = mvm->cur_ucode; |
| 299 | |
| 300 | /* Set parameters */ |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 301 | 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] | 302 | phy_cfg_cmd.calib_control.event_trigger = |
| 303 | mvm->fw->default_calib[ucode_type].event_trigger; |
| 304 | phy_cfg_cmd.calib_control.flow_trigger = |
| 305 | mvm->fw->default_calib[ucode_type].flow_trigger; |
| 306 | |
| 307 | IWL_DEBUG_INFO(mvm, "Sending Phy CFG command: 0x%x\n", |
| 308 | phy_cfg_cmd.phy_cfg); |
| 309 | |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 310 | return iwl_mvm_send_cmd_pdu(mvm, PHY_CONFIGURATION_CMD, 0, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 311 | sizeof(phy_cfg_cmd), &phy_cfg_cmd); |
| 312 | } |
| 313 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 314 | int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) |
| 315 | { |
| 316 | struct iwl_notification_wait calib_wait; |
Sara Sharon | 6eb031d | 2015-07-13 14:50:47 +0300 | [diff] [blame^] | 317 | static const u16 init_complete[] = { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 318 | INIT_COMPLETE_NOTIF, |
| 319 | CALIB_RES_NOTIF_PHY_DB |
| 320 | }; |
| 321 | int ret; |
| 322 | |
| 323 | lockdep_assert_held(&mvm->mutex); |
| 324 | |
Eran Harary | 8d193ca | 2015-04-27 10:29:31 +0300 | [diff] [blame] | 325 | if (WARN_ON_ONCE(mvm->calibrating)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 326 | return 0; |
| 327 | |
| 328 | iwl_init_notification_wait(&mvm->notif_wait, |
| 329 | &calib_wait, |
| 330 | init_complete, |
| 331 | ARRAY_SIZE(init_complete), |
| 332 | iwl_wait_phy_db_entry, |
| 333 | mvm->phy_db); |
| 334 | |
| 335 | /* Will also start the device */ |
| 336 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_INIT); |
| 337 | if (ret) { |
| 338 | IWL_ERR(mvm, "Failed to start INIT ucode: %d\n", ret); |
| 339 | goto error; |
| 340 | } |
| 341 | |
Emmanuel Grumbach | ae39747 | 2014-03-30 16:55:18 +0300 | [diff] [blame] | 342 | ret = iwl_send_bt_init_conf(mvm); |
Emmanuel Grumbach | 931d416 | 2013-01-17 09:42:25 +0200 | [diff] [blame] | 343 | if (ret) |
| 344 | goto error; |
| 345 | |
Eytan Lifshitz | 81a67e3 | 2013-09-11 12:39:18 +0200 | [diff] [blame] | 346 | /* 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] | 347 | if (read_nvm) { |
| 348 | /* Read nvm */ |
Eran Harary | 14b485f | 2014-04-23 10:46:09 +0300 | [diff] [blame] | 349 | ret = iwl_nvm_init(mvm, true); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 350 | if (ret) { |
| 351 | IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); |
| 352 | goto error; |
| 353 | } |
| 354 | } |
| 355 | |
Eytan Lifshitz | 81a67e3 | 2013-09-11 12:39:18 +0200 | [diff] [blame] | 356 | /* 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] | 357 | if (mvm->nvm_file_name) |
Eytan Lifshitz | 81a67e3 | 2013-09-11 12:39:18 +0200 | [diff] [blame] | 358 | iwl_mvm_load_nvm_to_nic(mvm); |
| 359 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 360 | ret = iwl_nvm_check_version(mvm->nvm_data, mvm->trans); |
| 361 | WARN_ON(ret); |
| 362 | |
Eran Harary | 4f59334 | 2013-05-13 07:53:26 +0300 | [diff] [blame] | 363 | /* |
| 364 | * abort after reading the nvm in case RF Kill is on, we will complete |
| 365 | * the init seq later when RF kill will switch to off |
| 366 | */ |
Eytan Lifshitz | 9ee718a | 2013-05-19 19:14:41 +0300 | [diff] [blame] | 367 | if (iwl_mvm_is_radio_killed(mvm)) { |
Eran Harary | 4f59334 | 2013-05-13 07:53:26 +0300 | [diff] [blame] | 368 | IWL_DEBUG_RF_KILL(mvm, |
| 369 | "jump over all phy activities due to RF kill\n"); |
| 370 | iwl_remove_notification(&mvm->notif_wait, &calib_wait); |
Arik Nemtsov | a408284 | 2013-11-24 19:10:46 +0200 | [diff] [blame] | 371 | ret = 1; |
| 372 | goto out; |
Eran Harary | 4f59334 | 2013-05-13 07:53:26 +0300 | [diff] [blame] | 373 | } |
| 374 | |
Emmanuel Grumbach | 31b8b34 | 2014-11-02 15:48:09 +0200 | [diff] [blame] | 375 | mvm->calibrating = true; |
| 376 | |
Dor Shaish | e07cbb5 | 2013-02-27 23:00:27 +0200 | [diff] [blame] | 377 | /* Send TX valid antennas before triggering calibrations */ |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 378 | 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] | 379 | if (ret) |
| 380 | goto error; |
| 381 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 382 | /* |
| 383 | * Send phy configurations command to init uCode |
| 384 | * to start the 16.0 uCode init image internal calibrations. |
| 385 | */ |
| 386 | ret = iwl_send_phy_cfg_cmd(mvm); |
| 387 | if (ret) { |
| 388 | IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n", |
| 389 | ret); |
| 390 | goto error; |
| 391 | } |
| 392 | |
| 393 | /* |
| 394 | * Some things may run in the background now, but we |
| 395 | * just wait for the calibration complete notification. |
| 396 | */ |
| 397 | ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait, |
| 398 | MVM_UCODE_CALIB_TIMEOUT); |
Emmanuel Grumbach | 31b8b34 | 2014-11-02 15:48:09 +0200 | [diff] [blame] | 399 | |
| 400 | if (ret && iwl_mvm_is_radio_killed(mvm)) { |
| 401 | IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n"); |
| 402 | ret = 1; |
| 403 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 404 | goto out; |
| 405 | |
| 406 | error: |
| 407 | iwl_remove_notification(&mvm->notif_wait, &calib_wait); |
| 408 | out: |
Emmanuel Grumbach | 31b8b34 | 2014-11-02 15:48:09 +0200 | [diff] [blame] | 409 | mvm->calibrating = false; |
Arik Nemtsov | a408284 | 2013-11-24 19:10:46 +0200 | [diff] [blame] | 410 | if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 411 | /* we want to debug INIT and we have no NVM - fake */ |
| 412 | mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) + |
| 413 | sizeof(struct ieee80211_channel) + |
| 414 | sizeof(struct ieee80211_rate), |
| 415 | GFP_KERNEL); |
| 416 | if (!mvm->nvm_data) |
| 417 | return -ENOMEM; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 418 | mvm->nvm_data->bands[0].channels = mvm->nvm_data->channels; |
| 419 | mvm->nvm_data->bands[0].n_channels = 1; |
| 420 | mvm->nvm_data->bands[0].n_bitrates = 1; |
| 421 | mvm->nvm_data->bands[0].bitrates = |
| 422 | (void *)mvm->nvm_data->channels + 1; |
| 423 | mvm->nvm_data->bands[0].bitrates->hw_value = 10; |
| 424 | } |
| 425 | |
| 426 | return ret; |
| 427 | } |
| 428 | |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 429 | static void iwl_mvm_get_shared_mem_conf(struct iwl_mvm *mvm) |
| 430 | { |
| 431 | struct iwl_host_cmd cmd = { |
| 432 | .id = SHARED_MEM_CFG, |
| 433 | .flags = CMD_WANT_SKB, |
| 434 | .data = { NULL, }, |
| 435 | .len = { 0, }, |
| 436 | }; |
| 437 | struct iwl_rx_packet *pkt; |
| 438 | struct iwl_shared_mem_cfg *mem_cfg; |
| 439 | u32 i; |
| 440 | |
| 441 | lockdep_assert_held(&mvm->mutex); |
| 442 | |
| 443 | if (WARN_ON(iwl_mvm_send_cmd(mvm, &cmd))) |
| 444 | return; |
| 445 | |
| 446 | pkt = cmd.resp_pkt; |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 447 | mem_cfg = (void *)pkt->data; |
| 448 | |
| 449 | mvm->shared_mem_cfg.shared_mem_addr = |
| 450 | le32_to_cpu(mem_cfg->shared_mem_addr); |
| 451 | mvm->shared_mem_cfg.shared_mem_size = |
| 452 | le32_to_cpu(mem_cfg->shared_mem_size); |
| 453 | mvm->shared_mem_cfg.sample_buff_addr = |
| 454 | le32_to_cpu(mem_cfg->sample_buff_addr); |
| 455 | mvm->shared_mem_cfg.sample_buff_size = |
| 456 | le32_to_cpu(mem_cfg->sample_buff_size); |
| 457 | mvm->shared_mem_cfg.txfifo_addr = le32_to_cpu(mem_cfg->txfifo_addr); |
| 458 | for (i = 0; i < ARRAY_SIZE(mvm->shared_mem_cfg.txfifo_size); i++) |
| 459 | mvm->shared_mem_cfg.txfifo_size[i] = |
| 460 | le32_to_cpu(mem_cfg->txfifo_size[i]); |
| 461 | for (i = 0; i < ARRAY_SIZE(mvm->shared_mem_cfg.rxfifo_size); i++) |
| 462 | mvm->shared_mem_cfg.rxfifo_size[i] = |
| 463 | le32_to_cpu(mem_cfg->rxfifo_size[i]); |
| 464 | mvm->shared_mem_cfg.page_buff_addr = |
| 465 | le32_to_cpu(mem_cfg->page_buff_addr); |
| 466 | mvm->shared_mem_cfg.page_buff_size = |
| 467 | le32_to_cpu(mem_cfg->page_buff_size); |
| 468 | IWL_DEBUG_INFO(mvm, "SHARED MEM CFG: got memory offsets/sizes\n"); |
| 469 | |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 470 | iwl_free_resp(&cmd); |
| 471 | } |
| 472 | |
Emmanuel Grumbach | b6eaa45 | 2015-01-29 14:58:20 +0200 | [diff] [blame] | 473 | int iwl_mvm_fw_dbg_collect_desc(struct iwl_mvm *mvm, |
| 474 | struct iwl_mvm_dump_desc *desc, |
| 475 | unsigned int delay) |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 476 | { |
Emmanuel Grumbach | d2709ad | 2015-01-29 14:58:06 +0200 | [diff] [blame] | 477 | if (test_and_set_bit(IWL_MVM_STATUS_DUMPING_FW_LOG, &mvm->status)) |
| 478 | return -EBUSY; |
| 479 | |
Emmanuel Grumbach | b6eaa45 | 2015-01-29 14:58:20 +0200 | [diff] [blame] | 480 | if (WARN_ON(mvm->fw_dump_desc)) |
| 481 | iwl_mvm_free_fw_dump_desc(mvm); |
| 482 | |
| 483 | IWL_WARN(mvm, "Collecting data: trigger %d fired.\n", |
| 484 | le32_to_cpu(desc->trig_desc.type)); |
| 485 | |
| 486 | mvm->fw_dump_desc = desc; |
Emmanuel Grumbach | d2709ad | 2015-01-29 14:58:06 +0200 | [diff] [blame] | 487 | |
Emmanuel Grumbach | d2709ad | 2015-01-29 14:58:06 +0200 | [diff] [blame] | 488 | queue_delayed_work(system_wq, &mvm->fw_dump_wk, delay); |
| 489 | |
| 490 | return 0; |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 491 | } |
| 492 | |
Emmanuel Grumbach | b6eaa45 | 2015-01-29 14:58:20 +0200 | [diff] [blame] | 493 | int iwl_mvm_fw_dbg_collect(struct iwl_mvm *mvm, enum iwl_fw_dbg_trigger trig, |
| 494 | const char *str, size_t len, unsigned int delay) |
| 495 | { |
| 496 | struct iwl_mvm_dump_desc *desc; |
| 497 | |
| 498 | desc = kzalloc(sizeof(*desc) + len, GFP_ATOMIC); |
| 499 | if (!desc) |
| 500 | return -ENOMEM; |
| 501 | |
| 502 | desc->len = len; |
| 503 | desc->trig_desc.type = cpu_to_le32(trig); |
| 504 | memcpy(desc->trig_desc.data, str, len); |
| 505 | |
| 506 | return iwl_mvm_fw_dbg_collect_desc(mvm, desc, delay); |
| 507 | } |
| 508 | |
Emmanuel Grumbach | d2709ad | 2015-01-29 14:58:06 +0200 | [diff] [blame] | 509 | int iwl_mvm_fw_dbg_collect_trig(struct iwl_mvm *mvm, |
Emmanuel Grumbach | b6eaa45 | 2015-01-29 14:58:20 +0200 | [diff] [blame] | 510 | struct iwl_fw_dbg_trigger_tlv *trigger, |
Johannes Berg | 5d4f929 | 2015-03-31 09:12:54 +0200 | [diff] [blame] | 511 | const char *fmt, ...) |
Emmanuel Grumbach | d2709ad | 2015-01-29 14:58:06 +0200 | [diff] [blame] | 512 | { |
| 513 | unsigned int delay = msecs_to_jiffies(le32_to_cpu(trigger->stop_delay)); |
| 514 | u16 occurrences = le16_to_cpu(trigger->occurrences); |
Johannes Berg | 5d4f929 | 2015-03-31 09:12:54 +0200 | [diff] [blame] | 515 | int ret, len = 0; |
| 516 | char buf[64]; |
Emmanuel Grumbach | d2709ad | 2015-01-29 14:58:06 +0200 | [diff] [blame] | 517 | |
| 518 | if (!occurrences) |
| 519 | return 0; |
| 520 | |
Johannes Berg | 5d4f929 | 2015-03-31 09:12:54 +0200 | [diff] [blame] | 521 | if (fmt) { |
| 522 | va_list ap; |
| 523 | |
| 524 | buf[sizeof(buf) - 1] = '\0'; |
| 525 | |
| 526 | va_start(ap, fmt); |
| 527 | vsnprintf(buf, sizeof(buf), fmt, ap); |
| 528 | va_end(ap); |
| 529 | |
| 530 | /* check for truncation */ |
| 531 | if (WARN_ON_ONCE(buf[sizeof(buf) - 1])) |
| 532 | buf[sizeof(buf) - 1] = '\0'; |
| 533 | |
| 534 | len = strlen(buf) + 1; |
| 535 | } |
| 536 | |
| 537 | ret = iwl_mvm_fw_dbg_collect(mvm, le32_to_cpu(trigger->id), buf, |
Emmanuel Grumbach | b6eaa45 | 2015-01-29 14:58:20 +0200 | [diff] [blame] | 538 | len, delay); |
Emmanuel Grumbach | d2709ad | 2015-01-29 14:58:06 +0200 | [diff] [blame] | 539 | if (ret) |
| 540 | return ret; |
| 541 | |
| 542 | trigger->occurrences = cpu_to_le16(occurrences - 1); |
| 543 | return 0; |
| 544 | } |
| 545 | |
Emmanuel Grumbach | 945d420 | 2015-02-15 17:16:16 +0200 | [diff] [blame] | 546 | static inline void iwl_mvm_restart_early_start(struct iwl_mvm *mvm) |
| 547 | { |
| 548 | if (mvm->cfg->device_family == IWL_DEVICE_FAMILY_7000) |
| 549 | iwl_clear_bits_prph(mvm->trans, MON_BUFF_SAMPLE_CTL, 0x100); |
| 550 | else |
| 551 | iwl_write_prph(mvm->trans, DBGC_IN_SAMPLE, 1); |
| 552 | } |
| 553 | |
Emmanuel Grumbach | d2709ad | 2015-01-29 14:58:06 +0200 | [diff] [blame] | 554 | int iwl_mvm_start_fw_dbg_conf(struct iwl_mvm *mvm, u8 conf_id) |
Liad Kaufman | 6a95126 | 2014-11-17 11:36:21 +0200 | [diff] [blame] | 555 | { |
| 556 | u8 *ptr; |
| 557 | int ret; |
| 558 | int i; |
| 559 | |
| 560 | if (WARN_ONCE(conf_id >= ARRAY_SIZE(mvm->fw->dbg_conf_tlv), |
| 561 | "Invalid configuration %d\n", conf_id)) |
| 562 | return -EINVAL; |
| 563 | |
Emmanuel Grumbach | 945d420 | 2015-02-15 17:16:16 +0200 | [diff] [blame] | 564 | /* EARLY START - firmware's configuration is hard coded */ |
| 565 | if ((!mvm->fw->dbg_conf_tlv[conf_id] || |
| 566 | !mvm->fw->dbg_conf_tlv[conf_id]->num_of_hcmds) && |
| 567 | conf_id == FW_DBG_START_FROM_ALIVE) { |
| 568 | iwl_mvm_restart_early_start(mvm); |
| 569 | return 0; |
| 570 | } |
| 571 | |
Liad Kaufman | 6a95126 | 2014-11-17 11:36:21 +0200 | [diff] [blame] | 572 | if (!mvm->fw->dbg_conf_tlv[conf_id]) |
| 573 | return -EINVAL; |
| 574 | |
| 575 | if (mvm->fw_dbg_conf != FW_DBG_INVALID) |
| 576 | IWL_WARN(mvm, "FW already configured (%d) - re-configuring\n", |
| 577 | mvm->fw_dbg_conf); |
| 578 | |
| 579 | /* Send all HCMDs for configuring the FW debug */ |
| 580 | ptr = (void *)&mvm->fw->dbg_conf_tlv[conf_id]->hcmd; |
| 581 | for (i = 0; i < mvm->fw->dbg_conf_tlv[conf_id]->num_of_hcmds; i++) { |
| 582 | struct iwl_fw_dbg_conf_hcmd *cmd = (void *)ptr; |
| 583 | |
| 584 | ret = iwl_mvm_send_cmd_pdu(mvm, cmd->id, 0, |
| 585 | le16_to_cpu(cmd->len), cmd->data); |
| 586 | if (ret) |
| 587 | return ret; |
| 588 | |
| 589 | ptr += sizeof(*cmd); |
| 590 | ptr += le16_to_cpu(cmd->len); |
| 591 | } |
| 592 | |
| 593 | mvm->fw_dbg_conf = conf_id; |
| 594 | return ret; |
| 595 | } |
| 596 | |
Emmanuel Grumbach | 84bfffa | 2015-01-13 10:16:30 +0200 | [diff] [blame] | 597 | static int iwl_mvm_config_ltr_v1(struct iwl_mvm *mvm) |
| 598 | { |
| 599 | struct iwl_ltr_config_cmd_v1 cmd_v1 = { |
| 600 | .flags = cpu_to_le32(LTR_CFG_FLAG_FEATURE_ENABLE), |
| 601 | }; |
| 602 | |
| 603 | if (!mvm->trans->ltr_enabled) |
| 604 | return 0; |
| 605 | |
| 606 | return iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0, |
| 607 | sizeof(cmd_v1), &cmd_v1); |
| 608 | } |
| 609 | |
| 610 | static int iwl_mvm_config_ltr(struct iwl_mvm *mvm) |
| 611 | { |
| 612 | struct iwl_ltr_config_cmd cmd = { |
| 613 | .flags = cpu_to_le32(LTR_CFG_FLAG_FEATURE_ENABLE), |
| 614 | }; |
| 615 | |
| 616 | if (!mvm->trans->ltr_enabled) |
| 617 | return 0; |
| 618 | |
Johannes Berg | 859d914 | 2015-06-01 17:11:11 +0200 | [diff] [blame] | 619 | if (!fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_HDC_PHASE_0)) |
Emmanuel Grumbach | 84bfffa | 2015-01-13 10:16:30 +0200 | [diff] [blame] | 620 | return iwl_mvm_config_ltr_v1(mvm); |
| 621 | |
| 622 | return iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0, |
| 623 | sizeof(cmd), &cmd); |
| 624 | } |
| 625 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 626 | int iwl_mvm_up(struct iwl_mvm *mvm) |
| 627 | { |
| 628 | int ret, i; |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 629 | struct ieee80211_channel *chan; |
| 630 | struct cfg80211_chan_def chandef; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 631 | |
| 632 | lockdep_assert_held(&mvm->mutex); |
| 633 | |
| 634 | ret = iwl_trans_start_hw(mvm->trans); |
| 635 | if (ret) |
| 636 | return ret; |
| 637 | |
Eytan Lifshitz | ff11637 | 2013-09-03 12:06:11 +0300 | [diff] [blame] | 638 | /* |
| 639 | * If we haven't completed the run of the init ucode during |
| 640 | * module loading, load init ucode now |
| 641 | * (for example, if we were in RFKILL) |
| 642 | */ |
Eran Harary | 8d193ca | 2015-04-27 10:29:31 +0300 | [diff] [blame] | 643 | ret = iwl_run_init_mvm_ucode(mvm, false); |
| 644 | if (ret && !iwlmvm_mod_params.init_dbg) { |
| 645 | IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret); |
| 646 | /* this can't happen */ |
| 647 | if (WARN_ON(ret > 0)) |
| 648 | ret = -ERFKILL; |
| 649 | goto error; |
| 650 | } |
| 651 | if (!iwlmvm_mod_params.init_dbg) { |
| 652 | /* |
| 653 | * Stop and start the transport without entering low power |
| 654 | * mode. This will save the state of other components on the |
| 655 | * device that are triggered by the INIT firwmare (MFUART). |
| 656 | */ |
| 657 | _iwl_trans_stop_device(mvm->trans, false); |
Johannes Berg | d643c43 | 2015-05-07 14:47:50 +0200 | [diff] [blame] | 658 | ret = _iwl_trans_start_hw(mvm->trans, false); |
Eran Harary | 8d193ca | 2015-04-27 10:29:31 +0300 | [diff] [blame] | 659 | if (ret) |
Johannes Berg | d643c43 | 2015-05-07 14:47:50 +0200 | [diff] [blame] | 660 | goto error; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | if (iwlmvm_mod_params.init_dbg) |
| 664 | return 0; |
| 665 | |
| 666 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR); |
| 667 | if (ret) { |
| 668 | IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret); |
| 669 | goto error; |
| 670 | } |
| 671 | |
Sara Sharon | 6c7d32c | 2015-06-07 09:34:57 +0300 | [diff] [blame] | 672 | iwl_mvm_get_shared_mem_conf(mvm); |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 673 | |
Lilach Edelstein | 1f3b0ff | 2013-10-06 13:03:32 +0200 | [diff] [blame] | 674 | ret = iwl_mvm_sf_update(mvm, NULL, false); |
| 675 | if (ret) |
| 676 | IWL_ERR(mvm, "Failed to initialize Smart Fifo\n"); |
| 677 | |
Liad Kaufman | 6a95126 | 2014-11-17 11:36:21 +0200 | [diff] [blame] | 678 | mvm->fw_dbg_conf = FW_DBG_INVALID; |
Emmanuel Grumbach | 945d420 | 2015-02-15 17:16:16 +0200 | [diff] [blame] | 679 | /* if we have a destination, assume EARLY START */ |
| 680 | if (mvm->fw->dbg_dest_tlv) |
| 681 | mvm->fw_dbg_conf = FW_DBG_START_FROM_ALIVE; |
Emmanuel Grumbach | d2709ad | 2015-01-29 14:58:06 +0200 | [diff] [blame] | 682 | iwl_mvm_start_fw_dbg_conf(mvm, FW_DBG_START_FROM_ALIVE); |
Liad Kaufman | 6a95126 | 2014-11-17 11:36:21 +0200 | [diff] [blame] | 683 | |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 684 | 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] | 685 | if (ret) |
| 686 | goto error; |
| 687 | |
Emmanuel Grumbach | 931d416 | 2013-01-17 09:42:25 +0200 | [diff] [blame] | 688 | ret = iwl_send_bt_init_conf(mvm); |
| 689 | if (ret) |
| 690 | goto error; |
| 691 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 692 | /* Send phy db control command and then phy db calibration*/ |
| 693 | ret = iwl_send_phy_db_data(mvm->phy_db); |
| 694 | if (ret) |
| 695 | goto error; |
| 696 | |
| 697 | ret = iwl_send_phy_cfg_cmd(mvm); |
| 698 | if (ret) |
| 699 | goto error; |
| 700 | |
| 701 | /* init the fw <-> mac80211 STA mapping */ |
| 702 | for (i = 0; i < IWL_MVM_STATION_COUNT; i++) |
| 703 | RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); |
| 704 | |
Arik Nemtsov | 1d3c3f6 | 2014-10-23 18:03:10 +0300 | [diff] [blame] | 705 | mvm->tdls_cs.peer.sta_id = IWL_MVM_STATION_COUNT; |
| 706 | |
Johannes Berg | b2b7875 | 2014-09-08 16:42:54 +0200 | [diff] [blame] | 707 | /* reset quota debouncing buffer - 0xff will yield invalid data */ |
| 708 | memset(&mvm->last_quota_cmd, 0xff, sizeof(mvm->last_quota_cmd)); |
| 709 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 710 | /* Add auxiliary station for scanning */ |
| 711 | ret = iwl_mvm_add_aux_sta(mvm); |
| 712 | if (ret) |
| 713 | goto error; |
| 714 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 715 | /* Add all the PHY contexts */ |
| 716 | chan = &mvm->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->channels[0]; |
| 717 | cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT); |
| 718 | for (i = 0; i < NUM_PHY_CTX; i++) { |
| 719 | /* |
| 720 | * The channel used here isn't relevant as it's |
| 721 | * going to be overwritten in the other flows. |
| 722 | * For now use the first channel we have. |
| 723 | */ |
| 724 | ret = iwl_mvm_phy_ctxt_add(mvm, &mvm->phy_ctxts[i], |
| 725 | &chandef, 1, 1); |
| 726 | if (ret) |
| 727 | goto error; |
| 728 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 729 | |
Ido Yariv | 0c0e2c7 | 2014-01-16 21:12:02 -0500 | [diff] [blame] | 730 | /* Initialize tx backoffs to the minimal possible */ |
| 731 | iwl_mvm_tt_tx_backoff(mvm, 0); |
| 732 | |
Emmanuel Grumbach | 84bfffa | 2015-01-13 10:16:30 +0200 | [diff] [blame] | 733 | WARN_ON(iwl_mvm_config_ltr(mvm)); |
Emmanuel Grumbach | 9180ac5 | 2014-09-23 23:02:41 +0300 | [diff] [blame] | 734 | |
Emmanuel Grumbach | c1cb92f | 2014-01-28 10:17:18 +0200 | [diff] [blame] | 735 | ret = iwl_mvm_power_update_device(mvm); |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 736 | if (ret) |
| 737 | goto error; |
| 738 | |
Arik Nemtsov | 35af15d | 2015-03-04 15:08:00 +0200 | [diff] [blame] | 739 | /* |
| 740 | * RTNL is not taken during Ct-kill, but we don't need to scan/Tx |
| 741 | * anyway, so don't init MCC. |
| 742 | */ |
| 743 | if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) { |
| 744 | ret = iwl_mvm_init_mcc(mvm); |
| 745 | if (ret) |
| 746 | goto error; |
| 747 | } |
Arik Nemtsov | 90d4f7d | 2014-03-04 19:58:46 +0200 | [diff] [blame] | 748 | |
Johannes Berg | 859d914 | 2015-06-01 17:11:11 +0200 | [diff] [blame] | 749 | if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 750 | ret = iwl_mvm_config_scan(mvm); |
| 751 | if (ret) |
| 752 | goto error; |
| 753 | } |
| 754 | |
Avri Altman | 93190fb | 2014-12-27 09:09:47 +0200 | [diff] [blame] | 755 | if (iwl_mvm_is_csum_supported(mvm) && |
| 756 | mvm->cfg->features & NETIF_F_RXCSUM) |
| 757 | iwl_trans_write_prph(mvm->trans, RX_EN_CSUM, 0x3); |
| 758 | |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 759 | /* allow FW/transport low power modes if not during restart */ |
| 760 | if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
| 761 | iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN); |
| 762 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 763 | IWL_DEBUG_INFO(mvm, "RT uCode started.\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 764 | return 0; |
| 765 | error: |
| 766 | iwl_trans_stop_device(mvm->trans); |
| 767 | return ret; |
| 768 | } |
| 769 | |
| 770 | int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm) |
| 771 | { |
| 772 | int ret, i; |
| 773 | |
| 774 | lockdep_assert_held(&mvm->mutex); |
| 775 | |
| 776 | ret = iwl_trans_start_hw(mvm->trans); |
| 777 | if (ret) |
| 778 | return ret; |
| 779 | |
| 780 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_WOWLAN); |
| 781 | if (ret) { |
| 782 | IWL_ERR(mvm, "Failed to start WoWLAN firmware: %d\n", ret); |
| 783 | goto error; |
| 784 | } |
| 785 | |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 786 | 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] | 787 | if (ret) |
| 788 | goto error; |
| 789 | |
| 790 | /* Send phy db control command and then phy db calibration*/ |
| 791 | ret = iwl_send_phy_db_data(mvm->phy_db); |
| 792 | if (ret) |
| 793 | goto error; |
| 794 | |
| 795 | ret = iwl_send_phy_cfg_cmd(mvm); |
| 796 | if (ret) |
| 797 | goto error; |
| 798 | |
| 799 | /* init the fw <-> mac80211 STA mapping */ |
| 800 | for (i = 0; i < IWL_MVM_STATION_COUNT; i++) |
| 801 | RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); |
| 802 | |
| 803 | /* Add auxiliary station for scanning */ |
| 804 | ret = iwl_mvm_add_aux_sta(mvm); |
| 805 | if (ret) |
| 806 | goto error; |
| 807 | |
| 808 | return 0; |
| 809 | error: |
| 810 | iwl_trans_stop_device(mvm->trans); |
| 811 | return ret; |
| 812 | } |
| 813 | |
Johannes Berg | 0416841 | 2015-06-23 21:22:09 +0200 | [diff] [blame] | 814 | void iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm, |
| 815 | struct iwl_rx_cmd_buffer *rxb) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 816 | { |
| 817 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 818 | struct iwl_card_state_notif *card_state_notif = (void *)pkt->data; |
| 819 | u32 flags = le32_to_cpu(card_state_notif->flags); |
| 820 | |
| 821 | IWL_DEBUG_RF_KILL(mvm, "Card state received: HW:%s SW:%s CT:%s\n", |
| 822 | (flags & HW_CARD_DISABLED) ? "Kill" : "On", |
| 823 | (flags & SW_CARD_DISABLED) ? "Kill" : "On", |
| 824 | (flags & CT_KILL_CARD_DISABLED) ? |
| 825 | "Reached" : "Not reached"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 826 | } |
| 827 | |
Johannes Berg | 0416841 | 2015-06-23 21:22:09 +0200 | [diff] [blame] | 828 | void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm, |
| 829 | struct iwl_rx_cmd_buffer *rxb) |
Chaya Rachel Ivgy | 30269c1 | 2014-11-15 21:08:29 +0200 | [diff] [blame] | 830 | { |
| 831 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 832 | struct iwl_mfuart_load_notif *mfuart_notif = (void *)pkt->data; |
| 833 | |
| 834 | IWL_DEBUG_INFO(mvm, |
| 835 | "MFUART: installed ver: 0x%08x, external ver: 0x%08x, status: 0x%08x, duration: 0x%08x\n", |
| 836 | le32_to_cpu(mfuart_notif->installed_ver), |
| 837 | le32_to_cpu(mfuart_notif->external_ver), |
| 838 | le32_to_cpu(mfuart_notif->status), |
| 839 | le32_to_cpu(mfuart_notif->duration)); |
Chaya Rachel Ivgy | 30269c1 | 2014-11-15 21:08:29 +0200 | [diff] [blame] | 840 | } |