blob: 4f398e63f44a31c3e8bdb24fe251c5dea8c99ae1 [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.
Johannes Berg8ca151b2013-01-24 14:25:36 +01009 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
Emmanuel Grumbach410dc5a2013-02-18 09:22:28 +020025 * in the file called COPYING.
Johannes Berg8ca151b2013-01-24 14:25:36 +010026 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +020033 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Johannes Berg8ca151b2013-01-24 14:25:36 +010034 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *
62 *****************************************************************************/
63#include <net/mac80211.h>
64
65#include "iwl-trans.h"
66#include "iwl-op-mode.h"
67#include "iwl-fw.h"
68#include "iwl-debug.h"
69#include "iwl-csr.h" /* for iwl_mvm_rx_card_state_notif */
70#include "iwl-io.h" /* for iwl_mvm_rx_card_state_notif */
71#include "iwl-eeprom-parse.h"
72
73#include "mvm.h"
74#include "iwl-phy-db.h"
75
76#define MVM_UCODE_ALIVE_TIMEOUT HZ
77#define MVM_UCODE_CALIB_TIMEOUT (2*HZ)
78
79#define UCODE_VALID_OK cpu_to_le32(0x1)
80
Johannes Berg8ca151b2013-01-24 14:25:36 +010081struct iwl_mvm_alive_data {
82 bool valid;
83 u32 scd_base_addr;
84};
85
86static inline const struct fw_img *
87iwl_get_ucode_image(struct iwl_mvm *mvm, enum iwl_ucode_type ucode_type)
88{
89 if (ucode_type >= IWL_UCODE_TYPE_MAX)
90 return NULL;
91
92 return &mvm->fw->img[ucode_type];
93}
94
95static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant)
96{
97 struct iwl_tx_ant_cfg_cmd tx_ant_cmd = {
98 .valid = cpu_to_le32(valid_tx_ant),
99 };
100
Emmanuel Grumbach33223542013-03-09 20:38:19 +0200101 IWL_DEBUG_FW(mvm, "select valid tx ant: %u\n", valid_tx_ant);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100102 return iwl_mvm_send_cmd_pdu(mvm, TX_ANT_CONFIGURATION_CMD, CMD_SYNC,
103 sizeof(tx_ant_cmd), &tx_ant_cmd);
104}
105
106static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait,
107 struct iwl_rx_packet *pkt, void *data)
108{
109 struct iwl_mvm *mvm =
110 container_of(notif_wait, struct iwl_mvm, notif_wait);
111 struct iwl_mvm_alive_data *alive_data = data;
112 struct mvm_alive_resp *palive;
Eran Harary01a9ca52014-02-03 09:29:57 +0200113 struct mvm_alive_resp_ver2 *palive2;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100114
Eran Harary01a9ca52014-02-03 09:29:57 +0200115 if (iwl_rx_packet_payload_len(pkt) == sizeof(*palive)) {
116 palive = (void *)pkt->data;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100117
Eran Harary01a9ca52014-02-03 09:29:57 +0200118 mvm->support_umac_log = false;
119 mvm->error_event_table =
120 le32_to_cpu(palive->error_event_table_ptr);
121 mvm->log_event_table = le32_to_cpu(palive->log_event_table_ptr);
122 alive_data->scd_base_addr = le32_to_cpu(palive->scd_base_ptr);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100123
Eran Harary01a9ca52014-02-03 09:29:57 +0200124 alive_data->valid = le16_to_cpu(palive->status) ==
125 IWL_ALIVE_STATUS_OK;
126 IWL_DEBUG_FW(mvm,
127 "Alive VER1 ucode status 0x%04x revision 0x%01X 0x%01X flags 0x%01X\n",
128 le16_to_cpu(palive->status), palive->ver_type,
129 palive->ver_subtype, palive->flags);
130 } else {
131 palive2 = (void *)pkt->data;
132
133 mvm->support_umac_log = true;
134 mvm->error_event_table =
135 le32_to_cpu(palive2->error_event_table_ptr);
136 mvm->log_event_table =
137 le32_to_cpu(palive2->log_event_table_ptr);
138 alive_data->scd_base_addr = le32_to_cpu(palive2->scd_base_ptr);
139 mvm->umac_error_event_table =
140 le32_to_cpu(palive2->error_info_addr);
141
142 alive_data->valid = le16_to_cpu(palive2->status) ==
143 IWL_ALIVE_STATUS_OK;
144 IWL_DEBUG_FW(mvm,
145 "Alive VER2 ucode status 0x%04x revision 0x%01X 0x%01X flags 0x%01X\n",
146 le16_to_cpu(palive2->status), palive2->ver_type,
147 palive2->ver_subtype, palive2->flags);
148
149 IWL_DEBUG_FW(mvm,
150 "UMAC version: Major - 0x%x, Minor - 0x%x\n",
151 palive2->umac_major, palive2->umac_minor);
152 }
Johannes Berg8ca151b2013-01-24 14:25:36 +0100153
154 return true;
155}
156
157static bool iwl_wait_phy_db_entry(struct iwl_notif_wait_data *notif_wait,
158 struct iwl_rx_packet *pkt, void *data)
159{
160 struct iwl_phy_db *phy_db = data;
161
162 if (pkt->hdr.cmd != CALIB_RES_NOTIF_PHY_DB) {
163 WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF);
164 return true;
165 }
166
167 WARN_ON(iwl_phy_db_set_section(phy_db, pkt, GFP_ATOMIC));
168
169 return false;
170}
171
172static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
173 enum iwl_ucode_type ucode_type)
174{
175 struct iwl_notification_wait alive_wait;
176 struct iwl_mvm_alive_data alive_data;
177 const struct fw_img *fw;
178 int ret, i;
179 enum iwl_ucode_type old_type = mvm->cur_ucode;
180 static const u8 alive_cmd[] = { MVM_ALIVE };
181
Johannes Berg8ca151b2013-01-24 14:25:36 +0100182 fw = iwl_get_ucode_image(mvm, ucode_type);
Johannes Bergbefe9b62013-10-25 12:32:51 +0200183 if (WARN_ON(!fw))
Johannes Berg8ca151b2013-01-24 14:25:36 +0100184 return -EINVAL;
Johannes Bergbefe9b62013-10-25 12:32:51 +0200185 mvm->cur_ucode = ucode_type;
186 mvm->ucode_loaded = false;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100187
188 iwl_init_notification_wait(&mvm->notif_wait, &alive_wait,
189 alive_cmd, ARRAY_SIZE(alive_cmd),
190 iwl_alive_fn, &alive_data);
191
192 ret = iwl_trans_start_fw(mvm->trans, fw, ucode_type == IWL_UCODE_INIT);
193 if (ret) {
194 mvm->cur_ucode = old_type;
195 iwl_remove_notification(&mvm->notif_wait, &alive_wait);
196 return ret;
197 }
198
199 /*
200 * Some things may run in the background now, but we
201 * just wait for the ALIVE notification here.
202 */
203 ret = iwl_wait_notification(&mvm->notif_wait, &alive_wait,
204 MVM_UCODE_ALIVE_TIMEOUT);
205 if (ret) {
206 mvm->cur_ucode = old_type;
207 return ret;
208 }
209
210 if (!alive_data.valid) {
211 IWL_ERR(mvm, "Loaded ucode is not valid!\n");
212 mvm->cur_ucode = old_type;
213 return -EIO;
214 }
215
216 iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr);
217
218 /*
219 * Note: all the queues are enabled as part of the interface
220 * initialization, but in firmware restart scenarios they
221 * could be stopped, so wake them up. In firmware restart,
222 * mac80211 will have the queues stopped as well until the
223 * reconfiguration completes. During normal startup, they
224 * will be empty.
225 */
226
227 for (i = 0; i < IWL_MAX_HW_QUEUES; i++) {
Eytan Lifshitz19e737c2013-09-09 13:30:15 +0200228 if (i < mvm->first_agg_queue && i != IWL_MVM_CMD_QUEUE)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100229 mvm->queue_to_mac80211[i] = i;
230 else
231 mvm->queue_to_mac80211[i] = IWL_INVALID_MAC80211_QUEUE;
232 atomic_set(&mvm->queue_stop_count[i], 0);
233 }
234
235 mvm->transport_queue_stop = 0;
236
237 mvm->ucode_loaded = true;
238
239 return 0;
240}
Johannes Berg8ca151b2013-01-24 14:25:36 +0100241
242static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm)
243{
244 struct iwl_phy_cfg_cmd phy_cfg_cmd;
245 enum iwl_ucode_type ucode_type = mvm->cur_ucode;
246
247 /* Set parameters */
Dor Shaish6221d472013-02-27 15:55:48 +0200248 phy_cfg_cmd.phy_cfg = cpu_to_le32(mvm->fw->phy_config);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100249 phy_cfg_cmd.calib_control.event_trigger =
250 mvm->fw->default_calib[ucode_type].event_trigger;
251 phy_cfg_cmd.calib_control.flow_trigger =
252 mvm->fw->default_calib[ucode_type].flow_trigger;
253
254 IWL_DEBUG_INFO(mvm, "Sending Phy CFG command: 0x%x\n",
255 phy_cfg_cmd.phy_cfg);
256
257 return iwl_mvm_send_cmd_pdu(mvm, PHY_CONFIGURATION_CMD, CMD_SYNC,
258 sizeof(phy_cfg_cmd), &phy_cfg_cmd);
259}
260
Johannes Berg8ca151b2013-01-24 14:25:36 +0100261int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
262{
263 struct iwl_notification_wait calib_wait;
264 static const u8 init_complete[] = {
265 INIT_COMPLETE_NOTIF,
266 CALIB_RES_NOTIF_PHY_DB
267 };
268 int ret;
269
270 lockdep_assert_held(&mvm->mutex);
271
Arik Nemtsova4082842013-11-24 19:10:46 +0200272 if (WARN_ON_ONCE(mvm->init_ucode_complete))
Johannes Berg8ca151b2013-01-24 14:25:36 +0100273 return 0;
274
275 iwl_init_notification_wait(&mvm->notif_wait,
276 &calib_wait,
277 init_complete,
278 ARRAY_SIZE(init_complete),
279 iwl_wait_phy_db_entry,
280 mvm->phy_db);
281
282 /* Will also start the device */
283 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_INIT);
284 if (ret) {
285 IWL_ERR(mvm, "Failed to start INIT ucode: %d\n", ret);
286 goto error;
287 }
288
Emmanuel Grumbach931d4162013-01-17 09:42:25 +0200289 ret = iwl_send_bt_prio_tbl(mvm);
290 if (ret)
291 goto error;
292
Eytan Lifshitz81a67e32013-09-11 12:39:18 +0200293 /* Read the NVM only at driver load time, no need to do this twice */
Johannes Berg8ca151b2013-01-24 14:25:36 +0100294 if (read_nvm) {
295 /* Read nvm */
296 ret = iwl_nvm_init(mvm);
297 if (ret) {
298 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
299 goto error;
300 }
301 }
302
Eytan Lifshitz81a67e32013-09-11 12:39:18 +0200303 /* In case we read the NVM from external file, load it to the NIC */
304 if (iwlwifi_mod_params.nvm_file)
305 iwl_mvm_load_nvm_to_nic(mvm);
306
Johannes Berg8ca151b2013-01-24 14:25:36 +0100307 ret = iwl_nvm_check_version(mvm->nvm_data, mvm->trans);
308 WARN_ON(ret);
309
Eran Harary4f593342013-05-13 07:53:26 +0300310 /*
311 * abort after reading the nvm in case RF Kill is on, we will complete
312 * the init seq later when RF kill will switch to off
313 */
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300314 if (iwl_mvm_is_radio_killed(mvm)) {
Eran Harary4f593342013-05-13 07:53:26 +0300315 IWL_DEBUG_RF_KILL(mvm,
316 "jump over all phy activities due to RF kill\n");
317 iwl_remove_notification(&mvm->notif_wait, &calib_wait);
Arik Nemtsova4082842013-11-24 19:10:46 +0200318 ret = 1;
319 goto out;
Eran Harary4f593342013-05-13 07:53:26 +0300320 }
321
Dor Shaishe07cbb52013-02-27 23:00:27 +0200322 /* Send TX valid antennas before triggering calibrations */
Johannes Berg4ed735e2014-02-12 21:47:44 +0100323 ret = iwl_send_tx_ant_cfg(mvm, mvm->fw->valid_tx_ant);
Dor Shaishe07cbb52013-02-27 23:00:27 +0200324 if (ret)
325 goto error;
326
Johannes Berg8ca151b2013-01-24 14:25:36 +0100327 /*
328 * Send phy configurations command to init uCode
329 * to start the 16.0 uCode init image internal calibrations.
330 */
331 ret = iwl_send_phy_cfg_cmd(mvm);
332 if (ret) {
333 IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n",
334 ret);
335 goto error;
336 }
337
338 /*
339 * Some things may run in the background now, but we
340 * just wait for the calibration complete notification.
341 */
342 ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait,
343 MVM_UCODE_CALIB_TIMEOUT);
344 if (!ret)
Eytan Lifshitzff116372013-09-03 12:06:11 +0300345 mvm->init_ucode_complete = true;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100346 goto out;
347
348error:
349 iwl_remove_notification(&mvm->notif_wait, &calib_wait);
350out:
Arik Nemtsova4082842013-11-24 19:10:46 +0200351 if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) {
Johannes Berg8ca151b2013-01-24 14:25:36 +0100352 /* we want to debug INIT and we have no NVM - fake */
353 mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) +
354 sizeof(struct ieee80211_channel) +
355 sizeof(struct ieee80211_rate),
356 GFP_KERNEL);
357 if (!mvm->nvm_data)
358 return -ENOMEM;
359 mvm->nvm_data->valid_rx_ant = 1;
360 mvm->nvm_data->valid_tx_ant = 1;
361 mvm->nvm_data->bands[0].channels = mvm->nvm_data->channels;
362 mvm->nvm_data->bands[0].n_channels = 1;
363 mvm->nvm_data->bands[0].n_bitrates = 1;
364 mvm->nvm_data->bands[0].bitrates =
365 (void *)mvm->nvm_data->channels + 1;
366 mvm->nvm_data->bands[0].bitrates->hw_value = 10;
367 }
368
369 return ret;
370}
371
372#define UCODE_CALIB_TIMEOUT (2*HZ)
373
374int iwl_mvm_up(struct iwl_mvm *mvm)
375{
376 int ret, i;
Ilan Peer53a9d612013-04-28 11:55:08 +0300377 struct ieee80211_channel *chan;
378 struct cfg80211_chan_def chandef;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100379
380 lockdep_assert_held(&mvm->mutex);
381
382 ret = iwl_trans_start_hw(mvm->trans);
383 if (ret)
384 return ret;
385
Eytan Lifshitzff116372013-09-03 12:06:11 +0300386 /*
387 * If we haven't completed the run of the init ucode during
388 * module loading, load init ucode now
389 * (for example, if we were in RFKILL)
390 */
391 if (!mvm->init_ucode_complete) {
Johannes Berg8ca151b2013-01-24 14:25:36 +0100392 ret = iwl_run_init_mvm_ucode(mvm, false);
393 if (ret && !iwlmvm_mod_params.init_dbg) {
394 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret);
Eran Harary4f593342013-05-13 07:53:26 +0300395 /* this can't happen */
396 if (WARN_ON(ret > 0))
397 ret = -ERFKILL;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100398 goto error;
399 }
Arik Nemtsova4082842013-11-24 19:10:46 +0200400 if (!iwlmvm_mod_params.init_dbg) {
401 /*
402 * should stop and start HW since that INIT
403 * image just loaded
404 */
405 iwl_trans_stop_device(mvm->trans);
406 ret = iwl_trans_start_hw(mvm->trans);
407 if (ret)
408 return ret;
409 }
Johannes Berg8ca151b2013-01-24 14:25:36 +0100410 }
411
412 if (iwlmvm_mod_params.init_dbg)
413 return 0;
414
415 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR);
416 if (ret) {
417 IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret);
418 goto error;
419 }
420
Lilach Edelstein1f3b0ff2013-10-06 13:03:32 +0200421 ret = iwl_mvm_sf_update(mvm, NULL, false);
422 if (ret)
423 IWL_ERR(mvm, "Failed to initialize Smart Fifo\n");
424
Johannes Berg4ed735e2014-02-12 21:47:44 +0100425 ret = iwl_send_tx_ant_cfg(mvm, mvm->fw->valid_tx_ant);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100426 if (ret)
427 goto error;
428
Emmanuel Grumbach931d4162013-01-17 09:42:25 +0200429 ret = iwl_send_bt_prio_tbl(mvm);
430 if (ret)
431 goto error;
432
433 ret = iwl_send_bt_init_conf(mvm);
434 if (ret)
435 goto error;
436
Johannes Berg8ca151b2013-01-24 14:25:36 +0100437 /* Send phy db control command and then phy db calibration*/
438 ret = iwl_send_phy_db_data(mvm->phy_db);
439 if (ret)
440 goto error;
441
442 ret = iwl_send_phy_cfg_cmd(mvm);
443 if (ret)
444 goto error;
445
446 /* init the fw <-> mac80211 STA mapping */
447 for (i = 0; i < IWL_MVM_STATION_COUNT; i++)
448 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL);
449
450 /* Add auxiliary station for scanning */
451 ret = iwl_mvm_add_aux_sta(mvm);
452 if (ret)
453 goto error;
454
Ilan Peer53a9d612013-04-28 11:55:08 +0300455 /* Add all the PHY contexts */
456 chan = &mvm->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->channels[0];
457 cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT);
458 for (i = 0; i < NUM_PHY_CTX; i++) {
459 /*
460 * The channel used here isn't relevant as it's
461 * going to be overwritten in the other flows.
462 * For now use the first channel we have.
463 */
464 ret = iwl_mvm_phy_ctxt_add(mvm, &mvm->phy_ctxts[i],
465 &chandef, 1, 1);
466 if (ret)
467 goto error;
468 }
Johannes Berg8ca151b2013-01-24 14:25:36 +0100469
Ido Yariv0c0e2c72014-01-16 21:12:02 -0500470 /* Initialize tx backoffs to the minimal possible */
471 iwl_mvm_tt_tx_backoff(mvm, 0);
472
Emmanuel Grumbachc1cb92f2014-01-28 10:17:18 +0200473 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PM_CMD_SUPPORT)) {
474 ret = iwl_power_legacy_set_cam_mode(mvm);
475 if (ret)
476 goto error;
477 }
478
479 ret = iwl_mvm_power_update_device(mvm);
Alexander Bondar64b928c2013-09-03 14:18:03 +0300480 if (ret)
481 goto error;
482
Eliad Peller7498cf42014-01-16 17:10:44 +0200483 /* allow FW/transport low power modes if not during restart */
484 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
485 iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN);
486
Ilan Peer53a9d612013-04-28 11:55:08 +0300487 IWL_DEBUG_INFO(mvm, "RT uCode started.\n");
Johannes Berg8ca151b2013-01-24 14:25:36 +0100488 return 0;
489 error:
490 iwl_trans_stop_device(mvm->trans);
491 return ret;
492}
493
494int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm)
495{
496 int ret, i;
497
498 lockdep_assert_held(&mvm->mutex);
499
500 ret = iwl_trans_start_hw(mvm->trans);
501 if (ret)
502 return ret;
503
504 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_WOWLAN);
505 if (ret) {
506 IWL_ERR(mvm, "Failed to start WoWLAN firmware: %d\n", ret);
507 goto error;
508 }
509
Johannes Berg4ed735e2014-02-12 21:47:44 +0100510 ret = iwl_send_tx_ant_cfg(mvm, mvm->fw->valid_tx_ant);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100511 if (ret)
512 goto error;
513
514 /* Send phy db control command and then phy db calibration*/
515 ret = iwl_send_phy_db_data(mvm->phy_db);
516 if (ret)
517 goto error;
518
519 ret = iwl_send_phy_cfg_cmd(mvm);
520 if (ret)
521 goto error;
522
523 /* init the fw <-> mac80211 STA mapping */
524 for (i = 0; i < IWL_MVM_STATION_COUNT; i++)
525 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL);
526
527 /* Add auxiliary station for scanning */
528 ret = iwl_mvm_add_aux_sta(mvm);
529 if (ret)
530 goto error;
531
532 return 0;
533 error:
534 iwl_trans_stop_device(mvm->trans);
535 return ret;
536}
537
538int iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm,
539 struct iwl_rx_cmd_buffer *rxb,
540 struct iwl_device_cmd *cmd)
541{
542 struct iwl_rx_packet *pkt = rxb_addr(rxb);
543 struct iwl_card_state_notif *card_state_notif = (void *)pkt->data;
544 u32 flags = le32_to_cpu(card_state_notif->flags);
545
546 IWL_DEBUG_RF_KILL(mvm, "Card state received: HW:%s SW:%s CT:%s\n",
547 (flags & HW_CARD_DISABLED) ? "Kill" : "On",
548 (flags & SW_CARD_DISABLED) ? "Kill" : "On",
549 (flags & CT_KILL_CARD_DISABLED) ?
550 "Reached" : "Not reached");
551
Johannes Berg8ca151b2013-01-24 14:25:36 +0100552 return 0;
553}
554
555int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
556 struct iwl_device_cmd *cmd)
557{
558 struct iwl_rx_packet *pkt = rxb_addr(rxb);
559 struct iwl_radio_version_notif *radio_version = (void *)pkt->data;
560
561 /* TODO: what to do with that? */
562 IWL_DEBUG_INFO(mvm,
563 "Radio version: flavor: 0x%08x, step 0x%08x, dash 0x%08x\n",
564 le32_to_cpu(radio_version->radio_flavor),
565 le32_to_cpu(radio_version->radio_step),
566 le32_to_cpu(radio_version->radio_dash));
567 return 0;
568}