blob: ff44e1aa035e228082611cb33939105fdd46f8a9 [file] [log] [blame]
Johannes Berg8ca151b2013-01-24 14:25:36 +01001/******************************************************************************
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 Grumbach51368bf2013-12-30 13:15:54 +02008 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Eran Harary8d193ca2015-04-27 10:29:31 +03009 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
Golan Ben-Amibdccdb82016-11-15 14:45:29 +020010 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
Johannes Berg8ca151b2013-01-24 14:25:36 +010011 *
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 Grumbach410dc5a2013-02-18 09:22:28 +020027 * in the file called COPYING.
Johannes Berg8ca151b2013-01-24 14:25:36 +010028 *
29 * Contact Information:
Emmanuel Grumbachcb2f8272015-11-17 15:39:56 +020030 * Intel Linux Wireless <linuxwifi@intel.com>
Johannes Berg8ca151b2013-01-24 14:25:36 +010031 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
32 *
33 * BSD LICENSE
34 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +020035 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Eran Harary8d193ca2015-04-27 10:29:31 +030036 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
Golan Ben-Amibdccdb82016-11-15 14:45:29 +020037 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
Johannes Berg8ca151b2013-01-24 14:25:36 +010038 * All rights reserved.
39 *
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
42 * are met:
43 *
44 * * Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * * Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in
48 * the documentation and/or other materials provided with the
49 * distribution.
50 * * Neither the name Intel Corporation nor the names of its
51 * contributors may be used to endorse or promote products derived
52 * from this software without specific prior written permission.
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
55 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
56 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
57 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
58 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
59 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
60 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
61 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
62 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
63 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
64 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65 *
66 *****************************************************************************/
67#include <net/mac80211.h>
Sara Sharon854d7732016-03-22 15:55:58 +020068#include <linux/netdevice.h>
Luca Coelhoda2830a2016-05-30 13:00:44 +030069#include <linux/acpi.h>
Johannes Berg8ca151b2013-01-24 14:25:36 +010070
71#include "iwl-trans.h"
72#include "iwl-op-mode.h"
Johannes Bergd962f9b2017-06-01 10:22:09 +020073#include "fw/img.h"
Johannes Berg8ca151b2013-01-24 14:25:36 +010074#include "iwl-debug.h"
75#include "iwl-csr.h" /* for iwl_mvm_rx_card_state_notif */
76#include "iwl-io.h" /* for iwl_mvm_rx_card_state_notif */
Emmanuel Grumbach8c23f952014-12-04 10:07:47 +020077#include "iwl-prph.h"
Johannes Berg8ca151b2013-01-24 14:25:36 +010078#include "iwl-eeprom-parse.h"
79
80#include "mvm.h"
Johannes Berg7174beb2017-06-01 16:03:19 +020081#include "fw/dbg.h"
Johannes Berg8ca151b2013-01-24 14:25:36 +010082#include "iwl-phy-db.h"
83
84#define MVM_UCODE_ALIVE_TIMEOUT HZ
85#define MVM_UCODE_CALIB_TIMEOUT (2*HZ)
86
87#define UCODE_VALID_OK cpu_to_le32(0x1)
88
Johannes Berg8ca151b2013-01-24 14:25:36 +010089struct iwl_mvm_alive_data {
90 bool valid;
91 u32 scd_base_addr;
92};
93
Johannes Berg8ca151b2013-01-24 14:25:36 +010094static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant)
95{
96 struct iwl_tx_ant_cfg_cmd tx_ant_cmd = {
97 .valid = cpu_to_le32(valid_tx_ant),
98 };
99
Emmanuel Grumbach33223542013-03-09 20:38:19 +0200100 IWL_DEBUG_FW(mvm, "select valid tx ant: %u\n", valid_tx_ant);
Emmanuel Grumbacha1022922014-05-12 11:36:41 +0300101 return iwl_mvm_send_cmd_pdu(mvm, TX_ANT_CONFIGURATION_CMD, 0,
Johannes Berg8ca151b2013-01-24 14:25:36 +0100102 sizeof(tx_ant_cmd), &tx_ant_cmd);
103}
104
Sara Sharon43413a92015-12-31 11:49:18 +0200105static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm)
106{
107 int i;
108 struct iwl_rss_config_cmd cmd = {
109 .flags = cpu_to_le32(IWL_RSS_ENABLE),
110 .hash_mask = IWL_RSS_HASH_TYPE_IPV4_TCP |
Sara Sharon854d7732016-03-22 15:55:58 +0200111 IWL_RSS_HASH_TYPE_IPV4_UDP |
Sara Sharon43413a92015-12-31 11:49:18 +0200112 IWL_RSS_HASH_TYPE_IPV4_PAYLOAD |
113 IWL_RSS_HASH_TYPE_IPV6_TCP |
Sara Sharon854d7732016-03-22 15:55:58 +0200114 IWL_RSS_HASH_TYPE_IPV6_UDP |
Sara Sharon43413a92015-12-31 11:49:18 +0200115 IWL_RSS_HASH_TYPE_IPV6_PAYLOAD,
116 };
117
Sara Sharonf43495f2016-05-04 14:22:10 +0300118 if (mvm->trans->num_rx_queues == 1)
119 return 0;
120
Sara Sharon854d7732016-03-22 15:55:58 +0200121 /* Do not direct RSS traffic to Q 0 which is our fallback queue */
Sara Sharon43413a92015-12-31 11:49:18 +0200122 for (i = 0; i < ARRAY_SIZE(cmd.indirection_table); i++)
Sara Sharon854d7732016-03-22 15:55:58 +0200123 cmd.indirection_table[i] =
124 1 + (i % (mvm->trans->num_rx_queues - 1));
125 netdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));
Sara Sharon43413a92015-12-31 11:49:18 +0200126
127 return iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0, sizeof(cmd), &cmd);
128}
129
Liad Kaufman97d5be72015-08-31 14:33:23 +0300130static int iwl_mvm_send_dqa_cmd(struct iwl_mvm *mvm)
131{
132 struct iwl_dqa_enable_cmd dqa_cmd = {
133 .cmd_queue = cpu_to_le32(IWL_MVM_DQA_CMD_QUEUE),
134 };
135 u32 cmd_id = iwl_cmd_id(DQA_ENABLE_CMD, DATA_PATH_GROUP, 0);
136 int ret;
137
138 ret = iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, sizeof(dqa_cmd), &dqa_cmd);
139 if (ret)
140 IWL_ERR(mvm, "Failed to send DQA enabling command: %d\n", ret);
141 else
142 IWL_DEBUG_FW(mvm, "Working in DQA mode\n");
143
144 return ret;
145}
146
Golan Ben-Amibdccdb82016-11-15 14:45:29 +0200147void iwl_mvm_mfu_assert_dump_notif(struct iwl_mvm *mvm,
148 struct iwl_rx_cmd_buffer *rxb)
149{
150 struct iwl_rx_packet *pkt = rxb_addr(rxb);
151 struct iwl_mfu_assert_dump_notif *mfu_dump_notif = (void *)pkt->data;
152 __le32 *dump_data = mfu_dump_notif->data;
153 int n_words = le32_to_cpu(mfu_dump_notif->data_size) / sizeof(__le32);
154 int i;
155
156 if (mfu_dump_notif->index_num == 0)
157 IWL_INFO(mvm, "MFUART assert id 0x%x occurred\n",
158 le32_to_cpu(mfu_dump_notif->assert_id));
159
160 for (i = 0; i < n_words; i++)
161 IWL_DEBUG_INFO(mvm,
162 "MFUART assert dump, dword %u: 0x%08x\n",
163 le16_to_cpu(mfu_dump_notif->index_num) *
164 n_words + i,
165 le32_to_cpu(dump_data[i]));
166}
167
Johannes Berg8ca151b2013-01-24 14:25:36 +0100168static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait,
169 struct iwl_rx_packet *pkt, void *data)
170{
171 struct iwl_mvm *mvm =
172 container_of(notif_wait, struct iwl_mvm, notif_wait);
173 struct iwl_mvm_alive_data *alive_data = data;
Sara Sharon5c228d62016-11-24 13:48:27 +0200174 struct mvm_alive_resp_v3 *palive3;
Emmanuel Grumbach7e1223b2015-02-03 20:11:48 +0200175 struct mvm_alive_resp *palive;
Sara Sharon5c228d62016-11-24 13:48:27 +0200176 struct iwl_umac_alive *umac;
177 struct iwl_lmac_alive *lmac1;
178 struct iwl_lmac_alive *lmac2 = NULL;
179 u16 status;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100180
Sara Sharon5c228d62016-11-24 13:48:27 +0200181 if (iwl_rx_packet_payload_len(pkt) == sizeof(*palive)) {
Emmanuel Grumbach7e1223b2015-02-03 20:11:48 +0200182 palive = (void *)pkt->data;
Sara Sharon5c228d62016-11-24 13:48:27 +0200183 umac = &palive->umac_data;
184 lmac1 = &palive->lmac_data[0];
185 lmac2 = &palive->lmac_data[1];
186 status = le16_to_cpu(palive->status);
187 } else {
188 palive3 = (void *)pkt->data;
189 umac = &palive3->umac_data;
190 lmac1 = &palive3->lmac_data;
191 status = le16_to_cpu(palive3->status);
Eran Harary01a9ca52014-02-03 09:29:57 +0200192 }
Johannes Berg8ca151b2013-01-24 14:25:36 +0100193
Sara Sharon5c228d62016-11-24 13:48:27 +0200194 mvm->error_event_table[0] = le32_to_cpu(lmac1->error_event_table_ptr);
195 if (lmac2)
196 mvm->error_event_table[1] =
197 le32_to_cpu(lmac2->error_event_table_ptr);
198 mvm->log_event_table = le32_to_cpu(lmac1->log_event_table_ptr);
199 mvm->sf_space.addr = le32_to_cpu(lmac1->st_fwrd_addr);
200 mvm->sf_space.size = le32_to_cpu(lmac1->st_fwrd_size);
201
202 mvm->umac_error_event_table = le32_to_cpu(umac->error_info_addr);
203
204 alive_data->scd_base_addr = le32_to_cpu(lmac1->scd_base_ptr);
205 alive_data->valid = status == IWL_ALIVE_STATUS_OK;
206 if (mvm->umac_error_event_table)
207 mvm->support_umac_log = true;
208
209 IWL_DEBUG_FW(mvm,
210 "Alive ucode status 0x%04x revision 0x%01X 0x%01X\n",
211 status, lmac1->ver_type, lmac1->ver_subtype);
212
213 if (lmac2)
214 IWL_DEBUG_FW(mvm, "Alive ucode CDB\n");
215
216 IWL_DEBUG_FW(mvm,
217 "UMAC version: Major - 0x%x, Minor - 0x%x\n",
218 le32_to_cpu(umac->umac_major),
219 le32_to_cpu(umac->umac_minor));
220
Johannes Berg8ca151b2013-01-24 14:25:36 +0100221 return true;
222}
223
Sara Sharon1f370652016-08-31 18:13:57 +0300224static bool iwl_wait_init_complete(struct iwl_notif_wait_data *notif_wait,
225 struct iwl_rx_packet *pkt, void *data)
226{
227 WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF);
228
229 return true;
230}
231
Johannes Berg8ca151b2013-01-24 14:25:36 +0100232static bool iwl_wait_phy_db_entry(struct iwl_notif_wait_data *notif_wait,
233 struct iwl_rx_packet *pkt, void *data)
234{
235 struct iwl_phy_db *phy_db = data;
236
237 if (pkt->hdr.cmd != CALIB_RES_NOTIF_PHY_DB) {
238 WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF);
239 return true;
240 }
241
Sara Sharonce1f2772016-04-10 16:02:12 +0300242 WARN_ON(iwl_phy_db_set_section(phy_db, pkt));
Johannes Berg8ca151b2013-01-24 14:25:36 +0100243
244 return false;
245}
246
247static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
248 enum iwl_ucode_type ucode_type)
249{
250 struct iwl_notification_wait alive_wait;
251 struct iwl_mvm_alive_data alive_data;
252 const struct fw_img *fw;
253 int ret, i;
Johannes Berg702e9752017-06-02 11:56:58 +0200254 enum iwl_ucode_type old_type = mvm->fwrt.cur_fw_img;
Sara Sharon6eb031d2015-07-13 14:50:47 +0300255 static const u16 alive_cmd[] = { MVM_ALIVE };
Eran Harary91479b62014-05-11 08:11:34 +0300256 struct iwl_sf_region st_fwrd_space;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100257
Eran Harary61df7502014-12-01 17:40:37 +0200258 if (ucode_type == IWL_UCODE_REGULAR &&
Golan Ben-Ami3d2d4422016-02-23 10:34:48 +0200259 iwl_fw_dbg_conf_usniffer(mvm->fw, FW_DBG_START_FROM_ALIVE) &&
260 !(fw_has_capa(&mvm->fw->ucode_capa,
261 IWL_UCODE_TLV_CAPA_USNIFFER_UNIFIED)))
Sharon Dvir612da1e2016-08-03 10:55:45 +0300262 fw = iwl_get_ucode_image(mvm->fw, IWL_UCODE_REGULAR_USNIFFER);
Eran Harary61df7502014-12-01 17:40:37 +0200263 else
Sharon Dvir612da1e2016-08-03 10:55:45 +0300264 fw = iwl_get_ucode_image(mvm->fw, ucode_type);
Johannes Bergbefe9b62013-10-25 12:32:51 +0200265 if (WARN_ON(!fw))
Johannes Berg8ca151b2013-01-24 14:25:36 +0100266 return -EINVAL;
Johannes Berg702e9752017-06-02 11:56:58 +0200267 iwl_fw_set_current_image(&mvm->fwrt, ucode_type);
Johannes Berg65b280f2017-03-22 22:10:36 +0100268 clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100269
270 iwl_init_notification_wait(&mvm->notif_wait, &alive_wait,
271 alive_cmd, ARRAY_SIZE(alive_cmd),
272 iwl_alive_fn, &alive_data);
273
274 ret = iwl_trans_start_fw(mvm->trans, fw, ucode_type == IWL_UCODE_INIT);
275 if (ret) {
Johannes Berg702e9752017-06-02 11:56:58 +0200276 iwl_fw_set_current_image(&mvm->fwrt, old_type);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100277 iwl_remove_notification(&mvm->notif_wait, &alive_wait);
278 return ret;
279 }
280
281 /*
282 * Some things may run in the background now, but we
283 * just wait for the ALIVE notification here.
284 */
285 ret = iwl_wait_notification(&mvm->notif_wait, &alive_wait,
286 MVM_UCODE_ALIVE_TIMEOUT);
287 if (ret) {
Sara Sharond6be9c12017-01-12 11:31:25 +0200288 struct iwl_trans *trans = mvm->trans;
289
Sara Sharon6e584872017-03-22 14:07:50 +0200290 if (trans->cfg->device_family == IWL_DEVICE_FAMILY_A000)
Dor Shaish192de2b2015-07-15 11:41:21 +0300291 IWL_ERR(mvm,
292 "SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n",
Sara Sharond6be9c12017-01-12 11:31:25 +0200293 iwl_read_prph(trans, UMAG_SB_CPU_1_STATUS),
294 iwl_read_prph(trans, UMAG_SB_CPU_2_STATUS));
Sara Sharon6e584872017-03-22 14:07:50 +0200295 else if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_8000)
Sara Sharond6be9c12017-01-12 11:31:25 +0200296 IWL_ERR(mvm,
297 "SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n",
298 iwl_read_prph(trans, SB_CPU_1_STATUS),
299 iwl_read_prph(trans, SB_CPU_2_STATUS));
Johannes Berg702e9752017-06-02 11:56:58 +0200300 iwl_fw_set_current_image(&mvm->fwrt, old_type);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100301 return ret;
302 }
303
304 if (!alive_data.valid) {
305 IWL_ERR(mvm, "Loaded ucode is not valid!\n");
Johannes Berg702e9752017-06-02 11:56:58 +0200306 iwl_fw_set_current_image(&mvm->fwrt, old_type);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100307 return -EIO;
308 }
309
Eran Harary91479b62014-05-11 08:11:34 +0300310 /*
311 * update the sdio allocation according to the pointer we get in the
312 * alive notification.
313 */
314 st_fwrd_space.addr = mvm->sf_space.addr;
315 st_fwrd_space.size = mvm->sf_space.size;
316 ret = iwl_trans_update_sf(mvm->trans, &st_fwrd_space);
Eyal Shapira82e8aea2014-10-19 14:56:40 +0300317 if (ret) {
318 IWL_ERR(mvm, "Failed to update SF size. ret %d\n", ret);
319 return ret;
320 }
Eran Harary91479b62014-05-11 08:11:34 +0300321
Johannes Berg8ca151b2013-01-24 14:25:36 +0100322 iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr);
323
324 /*
325 * Note: all the queues are enabled as part of the interface
326 * initialization, but in firmware restart scenarios they
327 * could be stopped, so wake them up. In firmware restart,
328 * mac80211 will have the queues stopped as well until the
329 * reconfiguration completes. During normal startup, they
330 * will be empty.
331 */
332
Liad Kaufman4ecafae2015-07-14 13:36:18 +0300333 memset(&mvm->queue_info, 0, sizeof(mvm->queue_info));
Johannes Bergc8f54702017-06-19 23:50:31 +0200334 mvm->queue_info[IWL_MVM_DQA_CMD_QUEUE].hw_queue_refcount = 1;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100335
Johannes Bergdf197c02014-08-01 18:14:45 +0200336 for (i = 0; i < IEEE80211_MAX_QUEUES; i++)
337 atomic_set(&mvm->mac80211_queue_stop_count[i], 0);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100338
Johannes Berg65b280f2017-03-22 22:10:36 +0100339 set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100340
341 return 0;
342}
Johannes Berg8ca151b2013-01-24 14:25:36 +0100343
Johannes Berg8c5f47b2017-02-20 17:47:04 +0100344static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
345{
346 struct iwl_notification_wait init_wait;
347 struct iwl_nvm_access_complete_cmd nvm_complete = {};
348 struct iwl_init_extended_cfg_cmd init_cfg = {
349 .init_flags = cpu_to_le32(BIT(IWL_INIT_NVM)),
350 };
351 static const u16 init_complete[] = {
352 INIT_COMPLETE_NOTIF,
353 };
354 int ret;
355
356 lockdep_assert_held(&mvm->mutex);
357
358 iwl_init_notification_wait(&mvm->notif_wait,
359 &init_wait,
360 init_complete,
361 ARRAY_SIZE(init_complete),
362 iwl_wait_init_complete,
363 NULL);
364
365 /* Will also start the device */
366 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR);
367 if (ret) {
368 IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret);
369 goto error;
370 }
371
372 /* Send init config command to mark that we are sending NVM access
373 * commands
374 */
375 ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(SYSTEM_GROUP,
376 INIT_EXTENDED_CFG_CMD), 0,
377 sizeof(init_cfg), &init_cfg);
378 if (ret) {
379 IWL_ERR(mvm, "Failed to run init config command: %d\n",
380 ret);
381 goto error;
382 }
383
Sara Sharone9e1ba32017-01-08 16:46:14 +0200384 /* Load NVM to NIC if needed */
385 if (mvm->nvm_file_name) {
386 iwl_mvm_read_external_nvm(mvm);
Johannes Berg8c5f47b2017-02-20 17:47:04 +0100387 iwl_mvm_load_nvm_to_nic(mvm);
Sara Sharone9e1ba32017-01-08 16:46:14 +0200388 }
Johannes Berg8c5f47b2017-02-20 17:47:04 +0100389
Sara Sharond4f36952017-03-06 11:13:02 +0200390 if (IWL_MVM_PARSE_NVM && read_nvm) {
391 ret = iwl_nvm_init(mvm, true);
392 if (ret) {
393 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
394 goto error;
395 }
396 }
397
Johannes Berg8c5f47b2017-02-20 17:47:04 +0100398 ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(REGULATORY_AND_NVM_GROUP,
399 NVM_ACCESS_COMPLETE), 0,
400 sizeof(nvm_complete), &nvm_complete);
401 if (ret) {
402 IWL_ERR(mvm, "Failed to run complete NVM access: %d\n",
403 ret);
404 goto error;
405 }
406
407 /* We wait for the INIT complete notification */
Sara Sharone9e1ba32017-01-08 16:46:14 +0200408 ret = iwl_wait_notification(&mvm->notif_wait, &init_wait,
409 MVM_UCODE_ALIVE_TIMEOUT);
410 if (ret)
411 return ret;
412
413 /* Read the NVM only at driver load time, no need to do this twice */
Sara Sharond4f36952017-03-06 11:13:02 +0200414 if (!IWL_MVM_PARSE_NVM && read_nvm) {
Sara Sharone9e1ba32017-01-08 16:46:14 +0200415 ret = iwl_mvm_nvm_get_from_fw(mvm);
416 if (ret) {
417 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
418 return ret;
419 }
420 }
421
422 return 0;
Johannes Berg8c5f47b2017-02-20 17:47:04 +0100423
424error:
425 iwl_remove_notification(&mvm->notif_wait, &init_wait);
426 return ret;
427}
428
Johannes Berg8ca151b2013-01-24 14:25:36 +0100429static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm)
430{
431 struct iwl_phy_cfg_cmd phy_cfg_cmd;
Johannes Berg702e9752017-06-02 11:56:58 +0200432 enum iwl_ucode_type ucode_type = mvm->fwrt.cur_fw_img;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100433
434 /* Set parameters */
Moshe Harela0544272014-12-08 21:13:14 +0200435 phy_cfg_cmd.phy_cfg = cpu_to_le32(iwl_mvm_get_phy_config(mvm));
Johannes Berg8ca151b2013-01-24 14:25:36 +0100436 phy_cfg_cmd.calib_control.event_trigger =
437 mvm->fw->default_calib[ucode_type].event_trigger;
438 phy_cfg_cmd.calib_control.flow_trigger =
439 mvm->fw->default_calib[ucode_type].flow_trigger;
440
441 IWL_DEBUG_INFO(mvm, "Sending Phy CFG command: 0x%x\n",
442 phy_cfg_cmd.phy_cfg);
443
Emmanuel Grumbacha1022922014-05-12 11:36:41 +0300444 return iwl_mvm_send_cmd_pdu(mvm, PHY_CONFIGURATION_CMD, 0,
Johannes Berg8ca151b2013-01-24 14:25:36 +0100445 sizeof(phy_cfg_cmd), &phy_cfg_cmd);
446}
447
Johannes Berg8ca151b2013-01-24 14:25:36 +0100448int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
449{
450 struct iwl_notification_wait calib_wait;
Sara Sharon6eb031d2015-07-13 14:50:47 +0300451 static const u16 init_complete[] = {
Johannes Berg8ca151b2013-01-24 14:25:36 +0100452 INIT_COMPLETE_NOTIF,
453 CALIB_RES_NOTIF_PHY_DB
454 };
455 int ret;
456
Johannes Berg7d6222e22017-06-08 09:18:22 +0200457 if (iwl_mvm_has_unified_ucode(mvm))
Johannes Berg8c5f47b2017-02-20 17:47:04 +0100458 return iwl_run_unified_mvm_ucode(mvm, true);
459
Johannes Berg8ca151b2013-01-24 14:25:36 +0100460 lockdep_assert_held(&mvm->mutex);
461
Eran Harary8d193ca2015-04-27 10:29:31 +0300462 if (WARN_ON_ONCE(mvm->calibrating))
Johannes Berg8ca151b2013-01-24 14:25:36 +0100463 return 0;
464
465 iwl_init_notification_wait(&mvm->notif_wait,
466 &calib_wait,
467 init_complete,
468 ARRAY_SIZE(init_complete),
469 iwl_wait_phy_db_entry,
470 mvm->phy_db);
471
472 /* Will also start the device */
473 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_INIT);
474 if (ret) {
475 IWL_ERR(mvm, "Failed to start INIT ucode: %d\n", ret);
476 goto error;
477 }
478
Emmanuel Grumbachb3de3ef2017-05-29 14:01:06 +0300479 if (mvm->cfg->device_family < IWL_DEVICE_FAMILY_8000) {
480 ret = iwl_mvm_send_bt_init_conf(mvm);
481 if (ret)
482 goto error;
483 }
Emmanuel Grumbach931d4162013-01-17 09:42:25 +0200484
Eytan Lifshitz81a67e32013-09-11 12:39:18 +0200485 /* Read the NVM only at driver load time, no need to do this twice */
Johannes Berg8ca151b2013-01-24 14:25:36 +0100486 if (read_nvm) {
487 /* Read nvm */
Eran Harary14b485f2014-04-23 10:46:09 +0300488 ret = iwl_nvm_init(mvm, true);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100489 if (ret) {
490 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
491 goto error;
492 }
493 }
494
Eytan Lifshitz81a67e32013-09-11 12:39:18 +0200495 /* In case we read the NVM from external file, load it to the NIC */
Eran Hararye02a9d62014-05-07 12:27:10 +0300496 if (mvm->nvm_file_name)
Eytan Lifshitz81a67e32013-09-11 12:39:18 +0200497 iwl_mvm_load_nvm_to_nic(mvm);
498
Johannes Berg8ca151b2013-01-24 14:25:36 +0100499 ret = iwl_nvm_check_version(mvm->nvm_data, mvm->trans);
500 WARN_ON(ret);
501
Eran Harary4f593342013-05-13 07:53:26 +0300502 /*
503 * abort after reading the nvm in case RF Kill is on, we will complete
504 * the init seq later when RF kill will switch to off
505 */
Arik Nemtsov1a3fe0b2015-09-30 11:19:55 +0300506 if (iwl_mvm_is_radio_hw_killed(mvm)) {
Eran Harary4f593342013-05-13 07:53:26 +0300507 IWL_DEBUG_RF_KILL(mvm,
508 "jump over all phy activities due to RF kill\n");
509 iwl_remove_notification(&mvm->notif_wait, &calib_wait);
Arik Nemtsova4082842013-11-24 19:10:46 +0200510 ret = 1;
511 goto out;
Eran Harary4f593342013-05-13 07:53:26 +0300512 }
513
Emmanuel Grumbach31b8b342014-11-02 15:48:09 +0200514 mvm->calibrating = true;
515
Dor Shaishe07cbb52013-02-27 23:00:27 +0200516 /* Send TX valid antennas before triggering calibrations */
Moshe Harela0544272014-12-08 21:13:14 +0200517 ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm));
Dor Shaishe07cbb52013-02-27 23:00:27 +0200518 if (ret)
519 goto error;
520
Johannes Berg8ca151b2013-01-24 14:25:36 +0100521 /*
522 * Send phy configurations command to init uCode
523 * to start the 16.0 uCode init image internal calibrations.
524 */
525 ret = iwl_send_phy_cfg_cmd(mvm);
526 if (ret) {
527 IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n",
528 ret);
529 goto error;
530 }
531
532 /*
533 * Some things may run in the background now, but we
534 * just wait for the calibration complete notification.
535 */
536 ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait,
537 MVM_UCODE_CALIB_TIMEOUT);
Emmanuel Grumbach31b8b342014-11-02 15:48:09 +0200538
Arik Nemtsov1a3fe0b2015-09-30 11:19:55 +0300539 if (ret && iwl_mvm_is_radio_hw_killed(mvm)) {
Emmanuel Grumbach31b8b342014-11-02 15:48:09 +0200540 IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n");
541 ret = 1;
542 }
Johannes Berg8ca151b2013-01-24 14:25:36 +0100543 goto out;
544
545error:
546 iwl_remove_notification(&mvm->notif_wait, &calib_wait);
547out:
Emmanuel Grumbach31b8b342014-11-02 15:48:09 +0200548 mvm->calibrating = false;
Arik Nemtsova4082842013-11-24 19:10:46 +0200549 if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) {
Johannes Berg8ca151b2013-01-24 14:25:36 +0100550 /* we want to debug INIT and we have no NVM - fake */
551 mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) +
552 sizeof(struct ieee80211_channel) +
553 sizeof(struct ieee80211_rate),
554 GFP_KERNEL);
555 if (!mvm->nvm_data)
556 return -ENOMEM;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100557 mvm->nvm_data->bands[0].channels = mvm->nvm_data->channels;
558 mvm->nvm_data->bands[0].n_channels = 1;
559 mvm->nvm_data->bands[0].n_bitrates = 1;
560 mvm->nvm_data->bands[0].bitrates =
561 (void *)mvm->nvm_data->channels + 1;
562 mvm->nvm_data->bands[0].bitrates->hw_value = 10;
563 }
564
565 return ret;
566}
567
Emmanuel Grumbach84bfffa2015-01-13 10:16:30 +0200568static int iwl_mvm_config_ltr(struct iwl_mvm *mvm)
569{
570 struct iwl_ltr_config_cmd cmd = {
571 .flags = cpu_to_le32(LTR_CFG_FLAG_FEATURE_ENABLE),
572 };
573
574 if (!mvm->trans->ltr_enabled)
575 return 0;
576
Emmanuel Grumbach84bfffa2015-01-13 10:16:30 +0200577 return iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0,
578 sizeof(cmd), &cmd);
579}
580
Luca Coelhoda2830a2016-05-30 13:00:44 +0300581#ifdef CONFIG_ACPI
Haim Dreyfussc386dac2016-12-28 15:58:22 +0200582#define ACPI_WRDS_METHOD "WRDS"
Luca Coelho69964902017-01-12 12:43:12 +0200583#define ACPI_EWRD_METHOD "EWRD"
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +0200584#define ACPI_WGDS_METHOD "WGDS"
Luca Coelho69964902017-01-12 12:43:12 +0200585#define ACPI_WIFI_DOMAIN (0x07)
Haim Dreyfussc386dac2016-12-28 15:58:22 +0200586#define ACPI_WRDS_WIFI_DATA_SIZE (IWL_MVM_SAR_TABLE_SIZE + 2)
Luca Coelho69964902017-01-12 12:43:12 +0200587#define ACPI_EWRD_WIFI_DATA_SIZE ((IWL_MVM_SAR_PROFILE_NUM - 1) * \
588 IWL_MVM_SAR_TABLE_SIZE + 3)
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +0200589#define ACPI_WGDS_WIFI_DATA_SIZE 18
590#define ACPI_WGDS_NUM_BANDS 2
591#define ACPI_WGDS_TABLE_SIZE 3
Haim Dreyfussc386dac2016-12-28 15:58:22 +0200592
593static int iwl_mvm_sar_set_profile(struct iwl_mvm *mvm,
594 union acpi_object *table,
595 struct iwl_mvm_sar_profile *profile,
596 bool enabled)
Luca Coelhoda2830a2016-05-30 13:00:44 +0300597{
Haim Dreyfussc386dac2016-12-28 15:58:22 +0200598 int i;
Luca Coelhoda2830a2016-05-30 13:00:44 +0300599
Haim Dreyfussc386dac2016-12-28 15:58:22 +0200600 profile->enabled = enabled;
Luca Coelhoda2830a2016-05-30 13:00:44 +0300601
Haim Dreyfussc386dac2016-12-28 15:58:22 +0200602 for (i = 0; i < IWL_MVM_SAR_TABLE_SIZE; i++) {
603 if ((table[i].type != ACPI_TYPE_INTEGER) ||
604 (table[i].integer.value > U8_MAX))
Luca Coelhoda2830a2016-05-30 13:00:44 +0300605 return -EINVAL;
606
Haim Dreyfussc386dac2016-12-28 15:58:22 +0200607 profile->table[i] = table[i].integer.value;
Luca Coelhoda2830a2016-05-30 13:00:44 +0300608 }
609
610 return 0;
611}
612
Haim Dreyfussc386dac2016-12-28 15:58:22 +0200613static union acpi_object *iwl_mvm_sar_find_wifi_pkg(struct iwl_mvm *mvm,
614 union acpi_object *data,
615 int data_size)
Luca Coelhoda2830a2016-05-30 13:00:44 +0300616{
Haim Dreyfussc386dac2016-12-28 15:58:22 +0200617 int i;
618 union acpi_object *wifi_pkg;
619
620 /*
621 * We need at least two packages, one for the revision and one
622 * for the data itself. Also check that the revision is valid
623 * (i.e. it is an integer set to 0).
624 */
625 if (data->type != ACPI_TYPE_PACKAGE ||
626 data->package.count < 2 ||
627 data->package.elements[0].type != ACPI_TYPE_INTEGER ||
628 data->package.elements[0].integer.value != 0) {
629 IWL_DEBUG_RADIO(mvm, "Unsupported packages structure\n");
630 return ERR_PTR(-EINVAL);
631 }
632
633 /* loop through all the packages to find the one for WiFi */
634 for (i = 1; i < data->package.count; i++) {
635 union acpi_object *domain;
636
637 wifi_pkg = &data->package.elements[i];
638
639 /* Skip anything that is not a package with the right
640 * amount of elements (i.e. domain_type,
641 * enabled/disabled plus the actual data size.
642 */
643 if (wifi_pkg->type != ACPI_TYPE_PACKAGE ||
644 wifi_pkg->package.count != data_size)
645 continue;
646
647 domain = &wifi_pkg->package.elements[0];
648 if (domain->type == ACPI_TYPE_INTEGER &&
Luca Coelho69964902017-01-12 12:43:12 +0200649 domain->integer.value == ACPI_WIFI_DOMAIN)
Haim Dreyfussc386dac2016-12-28 15:58:22 +0200650 break;
651
652 wifi_pkg = NULL;
653 }
654
655 if (!wifi_pkg)
656 return ERR_PTR(-ENOENT);
657
658 return wifi_pkg;
659}
660
661static int iwl_mvm_sar_get_wrds_table(struct iwl_mvm *mvm)
662{
663 union acpi_object *wifi_pkg, *table;
Luca Coelhoda2830a2016-05-30 13:00:44 +0300664 acpi_handle root_handle;
665 acpi_handle handle;
666 struct acpi_buffer wrds = {ACPI_ALLOCATE_BUFFER, NULL};
667 acpi_status status;
Haim Dreyfussc386dac2016-12-28 15:58:22 +0200668 bool enabled;
Luca Coelhoda2830a2016-05-30 13:00:44 +0300669 int ret;
670
671 root_handle = ACPI_HANDLE(mvm->dev);
672 if (!root_handle) {
673 IWL_DEBUG_RADIO(mvm,
674 "Could not retrieve root port ACPI handle\n");
675 return -ENOENT;
676 }
677
678 /* Get the method's handle */
679 status = acpi_get_handle(root_handle, (acpi_string)ACPI_WRDS_METHOD,
680 &handle);
681 if (ACPI_FAILURE(status)) {
682 IWL_DEBUG_RADIO(mvm, "WRDS method not found\n");
683 return -ENOENT;
684 }
685
686 /* Call WRDS with no arguments */
687 status = acpi_evaluate_object(handle, NULL, NULL, &wrds);
688 if (ACPI_FAILURE(status)) {
689 IWL_DEBUG_RADIO(mvm, "WRDS invocation failed (0x%x)\n", status);
690 return -ENOENT;
691 }
692
Haim Dreyfussc386dac2016-12-28 15:58:22 +0200693 wifi_pkg = iwl_mvm_sar_find_wifi_pkg(mvm, wrds.pointer,
694 ACPI_WRDS_WIFI_DATA_SIZE);
695 if (IS_ERR(wifi_pkg)) {
696 ret = PTR_ERR(wifi_pkg);
697 goto out_free;
698 }
Luca Coelhoda2830a2016-05-30 13:00:44 +0300699
Haim Dreyfussc386dac2016-12-28 15:58:22 +0200700 if (wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) {
701 ret = -EINVAL;
702 goto out_free;
703 }
704
705 enabled = !!(wifi_pkg->package.elements[1].integer.value);
706
707 /* position of the actual table */
708 table = &wifi_pkg->package.elements[2];
709
710 /* The profile from WRDS is officially profile 1, but goes
711 * into sar_profiles[0] (because we don't have a profile 0).
712 */
713 ret = iwl_mvm_sar_set_profile(mvm, table, &mvm->sar_profiles[0],
714 enabled);
715
716out_free:
717 kfree(wrds.pointer);
Luca Coelhoda2830a2016-05-30 13:00:44 +0300718 return ret;
719}
Luca Coelhoda2830a2016-05-30 13:00:44 +0300720
Luca Coelho69964902017-01-12 12:43:12 +0200721static int iwl_mvm_sar_get_ewrd_table(struct iwl_mvm *mvm)
722{
723 union acpi_object *wifi_pkg;
724 acpi_handle root_handle;
725 acpi_handle handle;
726 struct acpi_buffer ewrd = {ACPI_ALLOCATE_BUFFER, NULL};
727 acpi_status status;
728 bool enabled;
729 int i, n_profiles, ret;
730
731 root_handle = ACPI_HANDLE(mvm->dev);
732 if (!root_handle) {
733 IWL_DEBUG_RADIO(mvm,
734 "Could not retrieve root port ACPI handle\n");
735 return -ENOENT;
736 }
737
738 /* Get the method's handle */
739 status = acpi_get_handle(root_handle, (acpi_string)ACPI_EWRD_METHOD,
740 &handle);
741 if (ACPI_FAILURE(status)) {
742 IWL_DEBUG_RADIO(mvm, "EWRD method not found\n");
743 return -ENOENT;
744 }
745
746 /* Call EWRD with no arguments */
747 status = acpi_evaluate_object(handle, NULL, NULL, &ewrd);
748 if (ACPI_FAILURE(status)) {
749 IWL_DEBUG_RADIO(mvm, "EWRD invocation failed (0x%x)\n", status);
750 return -ENOENT;
751 }
752
753 wifi_pkg = iwl_mvm_sar_find_wifi_pkg(mvm, ewrd.pointer,
754 ACPI_EWRD_WIFI_DATA_SIZE);
755 if (IS_ERR(wifi_pkg)) {
756 ret = PTR_ERR(wifi_pkg);
757 goto out_free;
758 }
759
760 if ((wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) ||
761 (wifi_pkg->package.elements[2].type != ACPI_TYPE_INTEGER)) {
762 ret = -EINVAL;
763 goto out_free;
764 }
765
766 enabled = !!(wifi_pkg->package.elements[1].integer.value);
767 n_profiles = wifi_pkg->package.elements[2].integer.value;
768
Sharon Dvire2ef1472017-02-21 11:12:12 +0200769 /* in case of BIOS bug */
770 if (n_profiles <= 0) {
771 ret = -EINVAL;
772 goto out_free;
773 }
774
Luca Coelho69964902017-01-12 12:43:12 +0200775 for (i = 0; i < n_profiles; i++) {
776 /* the tables start at element 3 */
777 static int pos = 3;
778
779 /* The EWRD profiles officially go from 2 to 4, but we
780 * save them in sar_profiles[1-3] (because we don't
781 * have profile 0). So in the array we start from 1.
782 */
783 ret = iwl_mvm_sar_set_profile(mvm,
784 &wifi_pkg->package.elements[pos],
785 &mvm->sar_profiles[i + 1],
786 enabled);
787 if (ret < 0)
788 break;
789
790 /* go to the next table */
791 pos += IWL_MVM_SAR_TABLE_SIZE;
792 }
793
794out_free:
795 kfree(ewrd.pointer);
796 return ret;
797}
798
Haim Dreyfuss7fe90e02017-03-30 11:16:17 +0300799static int iwl_mvm_sar_get_wgds_table(struct iwl_mvm *mvm)
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +0200800{
801 union acpi_object *wifi_pkg;
802 acpi_handle root_handle;
803 acpi_handle handle;
804 struct acpi_buffer wgds = {ACPI_ALLOCATE_BUFFER, NULL};
805 acpi_status status;
Haim Dreyfuss7fe90e02017-03-30 11:16:17 +0300806 int i, j, ret;
807 int idx = 1;
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +0200808
809 root_handle = ACPI_HANDLE(mvm->dev);
810 if (!root_handle) {
811 IWL_DEBUG_RADIO(mvm,
812 "Could not retrieve root port ACPI handle\n");
813 return -ENOENT;
814 }
815
816 /* Get the method's handle */
817 status = acpi_get_handle(root_handle, (acpi_string)ACPI_WGDS_METHOD,
818 &handle);
819 if (ACPI_FAILURE(status)) {
820 IWL_DEBUG_RADIO(mvm, "WGDS method not found\n");
821 return -ENOENT;
822 }
823
824 /* Call WGDS with no arguments */
825 status = acpi_evaluate_object(handle, NULL, NULL, &wgds);
826 if (ACPI_FAILURE(status)) {
827 IWL_DEBUG_RADIO(mvm, "WGDS invocation failed (0x%x)\n", status);
828 return -ENOENT;
829 }
830
831 wifi_pkg = iwl_mvm_sar_find_wifi_pkg(mvm, wgds.pointer,
832 ACPI_WGDS_WIFI_DATA_SIZE);
833 if (IS_ERR(wifi_pkg)) {
834 ret = PTR_ERR(wifi_pkg);
835 goto out_free;
836 }
837
Haim Dreyfuss7fe90e02017-03-30 11:16:17 +0300838 for (i = 0; i < IWL_NUM_GEO_PROFILES; i++) {
839 for (j = 0; j < IWL_MVM_GEO_TABLE_SIZE; j++) {
840 union acpi_object *entry;
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +0200841
Haim Dreyfuss7fe90e02017-03-30 11:16:17 +0300842 entry = &wifi_pkg->package.elements[idx++];
843 if ((entry->type != ACPI_TYPE_INTEGER) ||
844 (entry->integer.value > U8_MAX))
845 return -EINVAL;
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +0200846
Haim Dreyfuss7fe90e02017-03-30 11:16:17 +0300847 mvm->geo_profiles[i].values[j] = entry->integer.value;
848 }
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +0200849 }
850 ret = 0;
851out_free:
852 kfree(wgds.pointer);
853 return ret;
854}
855
Luca Coelho42ce76d2017-01-11 23:36:30 +0200856int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b)
Luca Coelhoda2830a2016-05-30 13:00:44 +0300857{
Luca Coelhoda2830a2016-05-30 13:00:44 +0300858 struct iwl_dev_tx_power_cmd cmd = {
Luca Coelho4b87e5a2016-09-12 16:03:30 +0300859 .v3.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_CHAINS),
Luca Coelhoda2830a2016-05-30 13:00:44 +0300860 };
Luca Coelho42ce76d2017-01-11 23:36:30 +0200861 int i, j, idx;
862 int profs[IWL_NUM_CHAIN_LIMITS] = { prof_a, prof_b };
Luca Coelho55bfa4b2016-06-29 00:38:40 +0300863 int len = sizeof(cmd);
Luca Coelhoda2830a2016-05-30 13:00:44 +0300864
Luca Coelho42ce76d2017-01-11 23:36:30 +0200865 BUILD_BUG_ON(IWL_NUM_CHAIN_LIMITS < 2);
866 BUILD_BUG_ON(IWL_NUM_CHAIN_LIMITS * IWL_NUM_SUB_BANDS !=
867 IWL_MVM_SAR_TABLE_SIZE);
868
Luca Coelho55bfa4b2016-06-29 00:38:40 +0300869 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TX_POWER_ACK))
870 len = sizeof(cmd.v3);
871
Luca Coelho42ce76d2017-01-11 23:36:30 +0200872 for (i = 0; i < IWL_NUM_CHAIN_LIMITS; i++) {
873 struct iwl_mvm_sar_profile *prof;
874
875 /* don't allow SAR to be disabled (profile 0 means disable) */
876 if (profs[i] == 0)
877 return -EPERM;
878
879 /* we are off by one, so allow up to IWL_MVM_SAR_PROFILE_NUM */
880 if (profs[i] > IWL_MVM_SAR_PROFILE_NUM)
881 return -EINVAL;
882
883 /* profiles go from 1 to 4, so decrement to access the array */
884 prof = &mvm->sar_profiles[profs[i] - 1];
885
886 /* if the profile is disabled, do nothing */
887 if (!prof->enabled) {
888 IWL_DEBUG_RADIO(mvm, "SAR profile %d is disabled.\n",
889 profs[i]);
890 /* if one of the profiles is disabled, we fail all */
891 return -ENOENT;
892 }
893
894 IWL_DEBUG_RADIO(mvm, " Chain[%d]:\n", i);
895 for (j = 0; j < IWL_NUM_SUB_BANDS; j++) {
896 idx = (i * IWL_NUM_SUB_BANDS) + j;
897 cmd.v3.per_chain_restriction[i][j] =
898 cpu_to_le16(prof->table[idx]);
899 IWL_DEBUG_RADIO(mvm, " Band[%d] = %d * .125dBm\n",
900 j, prof->table[idx]);
901 }
902 }
903
904 IWL_DEBUG_RADIO(mvm, "Sending REDUCE_TX_POWER_CMD per chain\n");
905
906 return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd);
907}
908
Haim Dreyfuss7fe90e02017-03-30 11:16:17 +0300909int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm)
910{
911 struct iwl_geo_tx_power_profiles_resp *resp;
912 int ret;
913
914 struct iwl_geo_tx_power_profiles_cmd geo_cmd = {
915 .ops = cpu_to_le32(IWL_PER_CHAIN_OFFSET_GET_CURRENT_TABLE),
916 };
917 struct iwl_host_cmd cmd = {
918 .id = WIDE_ID(PHY_OPS_GROUP, GEO_TX_POWER_LIMIT),
919 .len = { sizeof(geo_cmd), },
920 .flags = CMD_WANT_SKB,
921 .data = { &geo_cmd },
922 };
923
924 ret = iwl_mvm_send_cmd(mvm, &cmd);
925 if (ret) {
926 IWL_ERR(mvm, "Failed to get geographic profile info %d\n", ret);
927 return ret;
928 }
929
930 resp = (void *)cmd.resp_pkt->data;
931 ret = le32_to_cpu(resp->profile_idx);
932 if (WARN_ON(ret > IWL_NUM_GEO_PROFILES)) {
933 ret = -EIO;
934 IWL_WARN(mvm, "Invalid geographic profile idx (%d)\n", ret);
935 }
936
937 iwl_free_resp(&cmd);
938 return ret;
939}
940
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +0200941static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm)
942{
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +0200943 struct iwl_geo_tx_power_profiles_cmd cmd = {
944 .ops = cpu_to_le32(IWL_PER_CHAIN_OFFSET_SET_TABLES),
945 };
Haim Dreyfuss7fe90e02017-03-30 11:16:17 +0300946 int ret, i, j;
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +0200947 u16 cmd_wide_id = WIDE_ID(PHY_OPS_GROUP, GEO_TX_POWER_LIMIT);
948
Haim Dreyfuss7fe90e02017-03-30 11:16:17 +0300949 ret = iwl_mvm_sar_get_wgds_table(mvm);
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +0200950 if (ret < 0) {
951 IWL_DEBUG_RADIO(mvm,
952 "Geo SAR BIOS table invalid or unavailable. (%d)\n",
953 ret);
954 /* we don't fail if the table is not available */
955 return 0;
956 }
957
958 IWL_DEBUG_RADIO(mvm, "Sending GEO_TX_POWER_LIMIT\n");
959
960 BUILD_BUG_ON(IWL_NUM_GEO_PROFILES * ACPI_WGDS_NUM_BANDS *
961 ACPI_WGDS_TABLE_SIZE != ACPI_WGDS_WIFI_DATA_SIZE);
962
963 for (i = 0; i < IWL_NUM_GEO_PROFILES; i++) {
964 struct iwl_per_chain_offset *chain =
965 (struct iwl_per_chain_offset *)&cmd.table[i];
966
967 for (j = 0; j < ACPI_WGDS_NUM_BANDS; j++) {
968 u8 *value;
969
Haim Dreyfuss7fe90e02017-03-30 11:16:17 +0300970 value = &mvm->geo_profiles[i].values[j *
971 IWL_GEO_PER_CHAIN_SIZE];
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +0200972 chain[j].max_tx_power = cpu_to_le16(value[0]);
973 chain[j].chain_a = value[1];
974 chain[j].chain_b = value[2];
975 IWL_DEBUG_RADIO(mvm,
976 "SAR geographic profile[%d] Band[%d]: chain A = %d chain B = %d max_tx_power = %d\n",
977 i, j, value[1], value[2], value[0]);
978 }
979 }
980 return iwl_mvm_send_cmd_pdu(mvm, cmd_wide_id, 0, sizeof(cmd), &cmd);
981}
982
Luca Coelho69964902017-01-12 12:43:12 +0200983#else /* CONFIG_ACPI */
984static int iwl_mvm_sar_get_wrds_table(struct iwl_mvm *mvm)
985{
986 return -ENOENT;
987}
988
989static int iwl_mvm_sar_get_ewrd_table(struct iwl_mvm *mvm)
990{
991 return -ENOENT;
992}
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +0200993
994static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm)
995{
996 return 0;
997}
Luca Coelho69964902017-01-12 12:43:12 +0200998#endif /* CONFIG_ACPI */
999
Luca Coelho42ce76d2017-01-11 23:36:30 +02001000static int iwl_mvm_sar_init(struct iwl_mvm *mvm)
1001{
1002 int ret;
1003
Haim Dreyfussc386dac2016-12-28 15:58:22 +02001004 ret = iwl_mvm_sar_get_wrds_table(mvm);
Luca Coelhoda2830a2016-05-30 13:00:44 +03001005 if (ret < 0) {
1006 IWL_DEBUG_RADIO(mvm,
Luca Coelho69964902017-01-12 12:43:12 +02001007 "WRDS SAR BIOS table invalid or unavailable. (%d)\n",
Luca Coelhoda2830a2016-05-30 13:00:44 +03001008 ret);
Luca Coelho69964902017-01-12 12:43:12 +02001009 /* if not available, don't fail and don't bother with EWRD */
Luca Coelhoda2830a2016-05-30 13:00:44 +03001010 return 0;
1011 }
1012
Luca Coelho69964902017-01-12 12:43:12 +02001013 ret = iwl_mvm_sar_get_ewrd_table(mvm);
1014 /* if EWRD is not available, we can still use WRDS, so don't fail */
1015 if (ret < 0)
1016 IWL_DEBUG_RADIO(mvm,
1017 "EWRD SAR BIOS table invalid or unavailable. (%d)\n",
1018 ret);
1019
Luca Coelho42ce76d2017-01-11 23:36:30 +02001020 /* choose profile 1 (WRDS) as default for both chains */
1021 ret = iwl_mvm_sar_select_profile(mvm, 1, 1);
1022
1023 /* if we don't have profile 0 from BIOS, just skip it */
1024 if (ret == -ENOENT)
Luca Coelhoda2830a2016-05-30 13:00:44 +03001025 return 0;
1026
Luca Coelhoda2830a2016-05-30 13:00:44 +03001027 return ret;
1028}
1029
Sara Sharon1f370652016-08-31 18:13:57 +03001030static int iwl_mvm_load_rt_fw(struct iwl_mvm *mvm)
1031{
1032 int ret;
1033
Johannes Berg7d6222e22017-06-08 09:18:22 +02001034 if (iwl_mvm_has_unified_ucode(mvm))
Sara Sharon1f370652016-08-31 18:13:57 +03001035 return iwl_run_unified_mvm_ucode(mvm, false);
1036
1037 ret = iwl_run_init_mvm_ucode(mvm, false);
1038
1039 if (iwlmvm_mod_params.init_dbg)
1040 return 0;
1041
1042 if (ret) {
1043 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret);
1044 /* this can't happen */
1045 if (WARN_ON(ret > 0))
1046 ret = -ERFKILL;
1047 return ret;
1048 }
1049
1050 /*
1051 * Stop and start the transport without entering low power
1052 * mode. This will save the state of other components on the
1053 * device that are triggered by the INIT firwmare (MFUART).
1054 */
1055 _iwl_trans_stop_device(mvm->trans, false);
1056 ret = _iwl_trans_start_hw(mvm->trans, false);
1057 if (ret)
1058 return ret;
1059
1060 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR);
1061 if (ret)
1062 return ret;
1063
Johannes Berg702e9752017-06-02 11:56:58 +02001064 return iwl_init_paging(&mvm->fwrt, mvm->fwrt.cur_fw_img);
Sara Sharon1f370652016-08-31 18:13:57 +03001065}
1066
Johannes Berg8ca151b2013-01-24 14:25:36 +01001067int iwl_mvm_up(struct iwl_mvm *mvm)
1068{
1069 int ret, i;
Ilan Peer53a9d612013-04-28 11:55:08 +03001070 struct ieee80211_channel *chan;
1071 struct cfg80211_chan_def chandef;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001072
1073 lockdep_assert_held(&mvm->mutex);
1074
1075 ret = iwl_trans_start_hw(mvm->trans);
1076 if (ret)
1077 return ret;
1078
Sara Sharon1f370652016-08-31 18:13:57 +03001079 ret = iwl_mvm_load_rt_fw(mvm);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001080 if (ret) {
1081 IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret);
1082 goto error;
1083 }
1084
Johannes Bergd0b813f2017-06-01 14:44:40 +02001085 iwl_get_shared_mem_conf(&mvm->fwrt);
Liad Kaufman04fd2c22014-12-15 17:54:16 +02001086
Lilach Edelstein1f3b0ff2013-10-06 13:03:32 +02001087 ret = iwl_mvm_sf_update(mvm, NULL, false);
1088 if (ret)
1089 IWL_ERR(mvm, "Failed to initialize Smart Fifo\n");
1090
Johannes Berg7174beb2017-06-01 16:03:19 +02001091 mvm->fwrt.dump.conf = FW_DBG_INVALID;
Emmanuel Grumbach945d4202015-02-15 17:16:16 +02001092 /* if we have a destination, assume EARLY START */
1093 if (mvm->fw->dbg_dest_tlv)
Johannes Berg7174beb2017-06-01 16:03:19 +02001094 mvm->fwrt.dump.conf = FW_DBG_START_FROM_ALIVE;
1095 iwl_fw_start_dbg_conf(&mvm->fwrt, FW_DBG_START_FROM_ALIVE);
Liad Kaufman6a951262014-11-17 11:36:21 +02001096
Moshe Harela0544272014-12-08 21:13:14 +02001097 ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm));
Johannes Berg8ca151b2013-01-24 14:25:36 +01001098 if (ret)
1099 goto error;
1100
Johannes Berg7d6222e22017-06-08 09:18:22 +02001101 if (!iwl_mvm_has_unified_ucode(mvm)) {
1102 /* Send phy db control command and then phy db calibration */
Sara Sharon1f370652016-08-31 18:13:57 +03001103 ret = iwl_send_phy_db_data(mvm->phy_db);
1104 if (ret)
1105 goto error;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001106
Sara Sharon1f370652016-08-31 18:13:57 +03001107 ret = iwl_send_phy_cfg_cmd(mvm);
1108 if (ret)
1109 goto error;
1110 }
Johannes Berg8ca151b2013-01-24 14:25:36 +01001111
Emmanuel Grumbachb3de3ef2017-05-29 14:01:06 +03001112 ret = iwl_mvm_send_bt_init_conf(mvm);
1113 if (ret)
1114 goto error;
1115
Sara Sharon43413a92015-12-31 11:49:18 +02001116 /* Init RSS configuration */
Sara Sharon09a2e252016-12-19 14:10:35 +02001117 /* TODO - remove a000 disablement when we have RXQ config API */
Johannes Bergc8c017a2017-06-08 09:42:28 +02001118 if (iwl_mvm_has_new_rx_api(mvm) &&
1119 mvm->trans->cfg->device_family != IWL_DEVICE_FAMILY_A000) {
Sara Sharon43413a92015-12-31 11:49:18 +02001120 ret = iwl_send_rss_cfg_cmd(mvm);
1121 if (ret) {
1122 IWL_ERR(mvm, "Failed to configure RSS queues: %d\n",
1123 ret);
1124 goto error;
1125 }
1126 }
1127
Johannes Berg8ca151b2013-01-24 14:25:36 +01001128 /* init the fw <-> mac80211 STA mapping */
Sara Sharon0ae98812017-01-04 14:53:58 +02001129 for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++)
Johannes Berg8ca151b2013-01-24 14:25:36 +01001130 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL);
1131
Sara Sharon0ae98812017-01-04 14:53:58 +02001132 mvm->tdls_cs.peer.sta_id = IWL_MVM_INVALID_STA;
Arik Nemtsov1d3c3f62014-10-23 18:03:10 +03001133
Johannes Bergb2b78752014-09-08 16:42:54 +02001134 /* reset quota debouncing buffer - 0xff will yield invalid data */
1135 memset(&mvm->last_quota_cmd, 0xff, sizeof(mvm->last_quota_cmd));
1136
Johannes Bergc8f54702017-06-19 23:50:31 +02001137 ret = iwl_mvm_send_dqa_cmd(mvm);
1138 if (ret)
1139 goto error;
Liad Kaufman97d5be72015-08-31 14:33:23 +03001140
Johannes Berg8ca151b2013-01-24 14:25:36 +01001141 /* Add auxiliary station for scanning */
1142 ret = iwl_mvm_add_aux_sta(mvm);
1143 if (ret)
1144 goto error;
1145
Ilan Peer53a9d612013-04-28 11:55:08 +03001146 /* Add all the PHY contexts */
Johannes Berg57fbcce2016-04-12 15:56:15 +02001147 chan = &mvm->hw->wiphy->bands[NL80211_BAND_2GHZ]->channels[0];
Ilan Peer53a9d612013-04-28 11:55:08 +03001148 cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT);
1149 for (i = 0; i < NUM_PHY_CTX; i++) {
1150 /*
1151 * The channel used here isn't relevant as it's
1152 * going to be overwritten in the other flows.
1153 * For now use the first channel we have.
1154 */
1155 ret = iwl_mvm_phy_ctxt_add(mvm, &mvm->phy_ctxts[i],
1156 &chandef, 1, 1);
1157 if (ret)
1158 goto error;
1159 }
Johannes Berg8ca151b2013-01-24 14:25:36 +01001160
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +02001161#ifdef CONFIG_THERMAL
1162 if (iwl_mvm_is_tt_in_fw(mvm)) {
1163 /* in order to give the responsibility of ct-kill and
1164 * TX backoff to FW we need to send empty temperature reporting
1165 * cmd during init time
1166 */
1167 iwl_mvm_send_temp_report_ths_cmd(mvm);
1168 } else {
1169 /* Initialize tx backoffs to the minimal possible */
1170 iwl_mvm_tt_tx_backoff(mvm, 0);
1171 }
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +02001172
1173 /* TODO: read the budget from BIOS / Platform NVM */
Luca Coelho75cfe332016-09-14 11:54:36 +03001174 if (iwl_mvm_is_ctdp_supported(mvm) && mvm->cooling_dev.cur_state > 0) {
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +02001175 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START,
1176 mvm->cooling_dev.cur_state);
Luca Coelho75cfe332016-09-14 11:54:36 +03001177 if (ret)
1178 goto error;
1179 }
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +02001180#else
Ido Yariv0c0e2c72014-01-16 21:12:02 -05001181 /* Initialize tx backoffs to the minimal possible */
1182 iwl_mvm_tt_tx_backoff(mvm, 0);
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +02001183#endif
Ido Yariv0c0e2c72014-01-16 21:12:02 -05001184
Emmanuel Grumbach84bfffa2015-01-13 10:16:30 +02001185 WARN_ON(iwl_mvm_config_ltr(mvm));
Emmanuel Grumbach9180ac52014-09-23 23:02:41 +03001186
Emmanuel Grumbachc1cb92f2014-01-28 10:17:18 +02001187 ret = iwl_mvm_power_update_device(mvm);
Alexander Bondar64b928c2013-09-03 14:18:03 +03001188 if (ret)
1189 goto error;
1190
Arik Nemtsov35af15d2015-03-04 15:08:00 +02001191 /*
1192 * RTNL is not taken during Ct-kill, but we don't need to scan/Tx
1193 * anyway, so don't init MCC.
1194 */
1195 if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) {
1196 ret = iwl_mvm_init_mcc(mvm);
1197 if (ret)
1198 goto error;
1199 }
Arik Nemtsov90d4f7d2014-03-04 19:58:46 +02001200
Johannes Berg859d9142015-06-01 17:11:11 +02001201 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) {
Emmanuel Grumbach4ca87a52016-01-03 22:23:40 +02001202 mvm->scan_type = IWL_SCAN_TYPE_NOT_SET;
David Spinadeld2496222014-05-20 12:46:37 +03001203 ret = iwl_mvm_config_scan(mvm);
1204 if (ret)
1205 goto error;
1206 }
1207
Eliad Peller7498cf42014-01-16 17:10:44 +02001208 /* allow FW/transport low power modes if not during restart */
1209 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1210 iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN);
1211
Luca Coelhoda2830a2016-05-30 13:00:44 +03001212 ret = iwl_mvm_sar_init(mvm);
1213 if (ret)
1214 goto error;
1215
Haim Dreyfussa6bff3c2017-01-19 12:00:46 +02001216 ret = iwl_mvm_sar_geo_init(mvm);
1217 if (ret)
1218 goto error;
1219
Ilan Peer53a9d612013-04-28 11:55:08 +03001220 IWL_DEBUG_INFO(mvm, "RT uCode started.\n");
Johannes Berg8ca151b2013-01-24 14:25:36 +01001221 return 0;
1222 error:
Liad Kaufmande8ba412017-03-16 13:00:59 +02001223 if (!iwlmvm_mod_params.init_dbg)
1224 iwl_mvm_stop_device(mvm);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001225 return ret;
1226}
1227
1228int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm)
1229{
1230 int ret, i;
1231
1232 lockdep_assert_held(&mvm->mutex);
1233
1234 ret = iwl_trans_start_hw(mvm->trans);
1235 if (ret)
1236 return ret;
1237
1238 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_WOWLAN);
1239 if (ret) {
1240 IWL_ERR(mvm, "Failed to start WoWLAN firmware: %d\n", ret);
1241 goto error;
1242 }
1243
Moshe Harela0544272014-12-08 21:13:14 +02001244 ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm));
Johannes Berg8ca151b2013-01-24 14:25:36 +01001245 if (ret)
1246 goto error;
1247
1248 /* Send phy db control command and then phy db calibration*/
1249 ret = iwl_send_phy_db_data(mvm->phy_db);
1250 if (ret)
1251 goto error;
1252
1253 ret = iwl_send_phy_cfg_cmd(mvm);
1254 if (ret)
1255 goto error;
1256
1257 /* init the fw <-> mac80211 STA mapping */
Sara Sharon0ae98812017-01-04 14:53:58 +02001258 for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++)
Johannes Berg8ca151b2013-01-24 14:25:36 +01001259 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL);
1260
1261 /* Add auxiliary station for scanning */
1262 ret = iwl_mvm_add_aux_sta(mvm);
1263 if (ret)
1264 goto error;
1265
1266 return 0;
1267 error:
Chaya Rachel Ivgifcb6b922016-02-22 10:21:41 +02001268 iwl_mvm_stop_device(mvm);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001269 return ret;
1270}
1271
Johannes Berg04168412015-06-23 21:22:09 +02001272void iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm,
1273 struct iwl_rx_cmd_buffer *rxb)
Johannes Berg8ca151b2013-01-24 14:25:36 +01001274{
1275 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1276 struct iwl_card_state_notif *card_state_notif = (void *)pkt->data;
1277 u32 flags = le32_to_cpu(card_state_notif->flags);
1278
1279 IWL_DEBUG_RF_KILL(mvm, "Card state received: HW:%s SW:%s CT:%s\n",
1280 (flags & HW_CARD_DISABLED) ? "Kill" : "On",
1281 (flags & SW_CARD_DISABLED) ? "Kill" : "On",
1282 (flags & CT_KILL_CARD_DISABLED) ?
1283 "Reached" : "Not reached");
Johannes Berg8ca151b2013-01-24 14:25:36 +01001284}
1285
Johannes Berg04168412015-06-23 21:22:09 +02001286void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm,
1287 struct iwl_rx_cmd_buffer *rxb)
Chaya Rachel Ivgy30269c12014-11-15 21:08:29 +02001288{
1289 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1290 struct iwl_mfuart_load_notif *mfuart_notif = (void *)pkt->data;
1291
Golan Ben-Ami0c8d0a42017-01-25 15:11:30 +02001292 IWL_DEBUG_INFO(mvm,
1293 "MFUART: installed ver: 0x%08x, external ver: 0x%08x, status: 0x%08x, duration: 0x%08x\n",
1294 le32_to_cpu(mfuart_notif->installed_ver),
1295 le32_to_cpu(mfuart_notif->external_ver),
1296 le32_to_cpu(mfuart_notif->status),
1297 le32_to_cpu(mfuart_notif->duration));
1298
Golan Ben-Ami19f63c52016-11-07 17:40:43 +02001299 if (iwl_rx_packet_payload_len(pkt) == sizeof(*mfuart_notif))
1300 IWL_DEBUG_INFO(mvm,
Golan Ben-Ami0c8d0a42017-01-25 15:11:30 +02001301 "MFUART: image size: 0x%08x\n",
Golan Ben-Ami19f63c52016-11-07 17:40:43 +02001302 le32_to_cpu(mfuart_notif->image_size));
Chaya Rachel Ivgy30269c12014-11-15 21:08:29 +02001303}