Commit | Line | Data |
---|---|---|
8ca151b5 JB |
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 | * | |
51368bf7 | 8 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
8ca151b5 JB |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of version 2 of the GNU General Public License as | |
12 | * published by the Free Software Foundation. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, but | |
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, | |
22 | * USA | |
23 | * | |
24 | * The full GNU General Public License is included in this distribution | |
410dc5aa | 25 | * in the file called COPYING. |
8ca151b5 JB |
26 | * |
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 | * | |
51368bf7 | 33 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
8ca151b5 JB |
34 | * All rights reserved. |
35 | * | |
36 | * Redistribution and use in source and binary forms, with or without | |
37 | * modification, are permitted provided that the following conditions | |
38 | * are met: | |
39 | * | |
40 | * * Redistributions of source code must retain the above copyright | |
41 | * notice, this list of conditions and the following disclaimer. | |
42 | * * Redistributions in binary form must reproduce the above copyright | |
43 | * notice, this list of conditions and the following disclaimer in | |
44 | * the documentation and/or other materials provided with the | |
45 | * distribution. | |
46 | * * Neither the name Intel Corporation nor the names of its | |
47 | * contributors may be used to endorse or promote products derived | |
48 | * from this software without specific prior written permission. | |
49 | * | |
50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
51 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
52 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
53 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
54 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
55 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
56 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
57 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
58 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
59 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
61 | * | |
62 | *****************************************************************************/ | |
63 | #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 | ||
8ca151b5 JB |
81 | struct iwl_mvm_alive_data { |
82 | bool valid; | |
83 | u32 scd_base_addr; | |
84 | }; | |
85 | ||
86 | static inline const struct fw_img * | |
87 | iwl_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 | ||
95 | static 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 | ||
33223542 | 101 | IWL_DEBUG_FW(mvm, "select valid tx ant: %u\n", valid_tx_ant); |
8ca151b5 JB |
102 | return iwl_mvm_send_cmd_pdu(mvm, TX_ANT_CONFIGURATION_CMD, CMD_SYNC, |
103 | sizeof(tx_ant_cmd), &tx_ant_cmd); | |
104 | } | |
105 | ||
106 | static 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; | |
01a9ca51 EH |
113 | struct mvm_alive_resp_ver2 *palive2; |
114 | ||
115 | if (iwl_rx_packet_payload_len(pkt) == sizeof(*palive)) { | |
116 | palive = (void *)pkt->data; | |
117 | ||
118 | 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); | |
123 | ||
124 | 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 | ||
01a9ca51 EH |
133 | mvm->error_event_table = |
134 | le32_to_cpu(palive2->error_event_table_ptr); | |
135 | mvm->log_event_table = | |
136 | le32_to_cpu(palive2->log_event_table_ptr); | |
137 | alive_data->scd_base_addr = le32_to_cpu(palive2->scd_base_ptr); | |
138 | mvm->umac_error_event_table = | |
139 | le32_to_cpu(palive2->error_info_addr); | |
140 | ||
141 | alive_data->valid = le16_to_cpu(palive2->status) == | |
142 | IWL_ALIVE_STATUS_OK; | |
ffa70264 EG |
143 | if (mvm->umac_error_event_table) |
144 | mvm->support_umac_log = true; | |
145 | ||
01a9ca51 EH |
146 | IWL_DEBUG_FW(mvm, |
147 | "Alive VER2 ucode status 0x%04x revision 0x%01X 0x%01X flags 0x%01X\n", | |
148 | le16_to_cpu(palive2->status), palive2->ver_type, | |
149 | palive2->ver_subtype, palive2->flags); | |
150 | ||
151 | IWL_DEBUG_FW(mvm, | |
152 | "UMAC version: Major - 0x%x, Minor - 0x%x\n", | |
153 | palive2->umac_major, palive2->umac_minor); | |
154 | } | |
8ca151b5 JB |
155 | |
156 | return true; | |
157 | } | |
158 | ||
159 | static bool iwl_wait_phy_db_entry(struct iwl_notif_wait_data *notif_wait, | |
160 | struct iwl_rx_packet *pkt, void *data) | |
161 | { | |
162 | struct iwl_phy_db *phy_db = data; | |
163 | ||
164 | if (pkt->hdr.cmd != CALIB_RES_NOTIF_PHY_DB) { | |
165 | WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF); | |
166 | return true; | |
167 | } | |
168 | ||
169 | WARN_ON(iwl_phy_db_set_section(phy_db, pkt, GFP_ATOMIC)); | |
170 | ||
171 | return false; | |
172 | } | |
173 | ||
174 | static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm, | |
175 | enum iwl_ucode_type ucode_type) | |
176 | { | |
177 | struct iwl_notification_wait alive_wait; | |
178 | struct iwl_mvm_alive_data alive_data; | |
179 | const struct fw_img *fw; | |
180 | int ret, i; | |
181 | enum iwl_ucode_type old_type = mvm->cur_ucode; | |
182 | static const u8 alive_cmd[] = { MVM_ALIVE }; | |
183 | ||
8ca151b5 | 184 | fw = iwl_get_ucode_image(mvm, ucode_type); |
befe9b6f | 185 | if (WARN_ON(!fw)) |
8ca151b5 | 186 | return -EINVAL; |
befe9b6f JB |
187 | mvm->cur_ucode = ucode_type; |
188 | mvm->ucode_loaded = false; | |
8ca151b5 JB |
189 | |
190 | iwl_init_notification_wait(&mvm->notif_wait, &alive_wait, | |
191 | alive_cmd, ARRAY_SIZE(alive_cmd), | |
192 | iwl_alive_fn, &alive_data); | |
193 | ||
194 | ret = iwl_trans_start_fw(mvm->trans, fw, ucode_type == IWL_UCODE_INIT); | |
195 | if (ret) { | |
196 | mvm->cur_ucode = old_type; | |
197 | iwl_remove_notification(&mvm->notif_wait, &alive_wait); | |
198 | return ret; | |
199 | } | |
200 | ||
201 | /* | |
202 | * Some things may run in the background now, but we | |
203 | * just wait for the ALIVE notification here. | |
204 | */ | |
205 | ret = iwl_wait_notification(&mvm->notif_wait, &alive_wait, | |
206 | MVM_UCODE_ALIVE_TIMEOUT); | |
207 | if (ret) { | |
208 | mvm->cur_ucode = old_type; | |
209 | return ret; | |
210 | } | |
211 | ||
212 | if (!alive_data.valid) { | |
213 | IWL_ERR(mvm, "Loaded ucode is not valid!\n"); | |
214 | mvm->cur_ucode = old_type; | |
215 | return -EIO; | |
216 | } | |
217 | ||
218 | iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr); | |
219 | ||
220 | /* | |
221 | * Note: all the queues are enabled as part of the interface | |
222 | * initialization, but in firmware restart scenarios they | |
223 | * could be stopped, so wake them up. In firmware restart, | |
224 | * mac80211 will have the queues stopped as well until the | |
225 | * reconfiguration completes. During normal startup, they | |
226 | * will be empty. | |
227 | */ | |
228 | ||
229 | for (i = 0; i < IWL_MAX_HW_QUEUES; i++) { | |
19e737c9 | 230 | if (i < mvm->first_agg_queue && i != IWL_MVM_CMD_QUEUE) |
8ca151b5 JB |
231 | mvm->queue_to_mac80211[i] = i; |
232 | else | |
233 | mvm->queue_to_mac80211[i] = IWL_INVALID_MAC80211_QUEUE; | |
234 | atomic_set(&mvm->queue_stop_count[i], 0); | |
235 | } | |
236 | ||
237 | mvm->transport_queue_stop = 0; | |
238 | ||
239 | mvm->ucode_loaded = true; | |
240 | ||
241 | return 0; | |
242 | } | |
8ca151b5 JB |
243 | |
244 | static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm) | |
245 | { | |
246 | struct iwl_phy_cfg_cmd phy_cfg_cmd; | |
247 | enum iwl_ucode_type ucode_type = mvm->cur_ucode; | |
248 | ||
249 | /* Set parameters */ | |
6221d47c | 250 | phy_cfg_cmd.phy_cfg = cpu_to_le32(mvm->fw->phy_config); |
8ca151b5 JB |
251 | phy_cfg_cmd.calib_control.event_trigger = |
252 | mvm->fw->default_calib[ucode_type].event_trigger; | |
253 | phy_cfg_cmd.calib_control.flow_trigger = | |
254 | mvm->fw->default_calib[ucode_type].flow_trigger; | |
255 | ||
256 | IWL_DEBUG_INFO(mvm, "Sending Phy CFG command: 0x%x\n", | |
257 | phy_cfg_cmd.phy_cfg); | |
258 | ||
259 | return iwl_mvm_send_cmd_pdu(mvm, PHY_CONFIGURATION_CMD, CMD_SYNC, | |
260 | sizeof(phy_cfg_cmd), &phy_cfg_cmd); | |
261 | } | |
262 | ||
8ca151b5 JB |
263 | int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) |
264 | { | |
265 | struct iwl_notification_wait calib_wait; | |
266 | static const u8 init_complete[] = { | |
267 | INIT_COMPLETE_NOTIF, | |
268 | CALIB_RES_NOTIF_PHY_DB | |
269 | }; | |
270 | int ret; | |
271 | ||
272 | lockdep_assert_held(&mvm->mutex); | |
273 | ||
a4082843 | 274 | if (WARN_ON_ONCE(mvm->init_ucode_complete)) |
8ca151b5 JB |
275 | return 0; |
276 | ||
277 | iwl_init_notification_wait(&mvm->notif_wait, | |
278 | &calib_wait, | |
279 | init_complete, | |
280 | ARRAY_SIZE(init_complete), | |
281 | iwl_wait_phy_db_entry, | |
282 | mvm->phy_db); | |
283 | ||
284 | /* Will also start the device */ | |
285 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_INIT); | |
286 | if (ret) { | |
287 | IWL_ERR(mvm, "Failed to start INIT ucode: %d\n", ret); | |
288 | goto error; | |
289 | } | |
290 | ||
ae397472 | 291 | ret = iwl_send_bt_init_conf(mvm); |
931d4160 EG |
292 | if (ret) |
293 | goto error; | |
294 | ||
81a67e32 | 295 | /* Read the NVM only at driver load time, no need to do this twice */ |
8ca151b5 JB |
296 | if (read_nvm) { |
297 | /* Read nvm */ | |
298 | ret = iwl_nvm_init(mvm); | |
299 | if (ret) { | |
300 | IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); | |
301 | goto error; | |
302 | } | |
303 | } | |
304 | ||
81a67e32 EL |
305 | /* In case we read the NVM from external file, load it to the NIC */ |
306 | if (iwlwifi_mod_params.nvm_file) | |
307 | iwl_mvm_load_nvm_to_nic(mvm); | |
308 | ||
8ca151b5 JB |
309 | ret = iwl_nvm_check_version(mvm->nvm_data, mvm->trans); |
310 | WARN_ON(ret); | |
311 | ||
4f59334b EH |
312 | /* |
313 | * abort after reading the nvm in case RF Kill is on, we will complete | |
314 | * the init seq later when RF kill will switch to off | |
315 | */ | |
9ee718aa | 316 | if (iwl_mvm_is_radio_killed(mvm)) { |
4f59334b EH |
317 | IWL_DEBUG_RF_KILL(mvm, |
318 | "jump over all phy activities due to RF kill\n"); | |
319 | iwl_remove_notification(&mvm->notif_wait, &calib_wait); | |
a4082843 AN |
320 | ret = 1; |
321 | goto out; | |
4f59334b EH |
322 | } |
323 | ||
e07cbb53 | 324 | /* Send TX valid antennas before triggering calibrations */ |
4ed735e7 | 325 | ret = iwl_send_tx_ant_cfg(mvm, mvm->fw->valid_tx_ant); |
e07cbb53 DS |
326 | if (ret) |
327 | goto error; | |
328 | ||
8ca151b5 JB |
329 | /* |
330 | * Send phy configurations command to init uCode | |
331 | * to start the 16.0 uCode init image internal calibrations. | |
332 | */ | |
333 | ret = iwl_send_phy_cfg_cmd(mvm); | |
334 | if (ret) { | |
335 | IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n", | |
336 | ret); | |
337 | goto error; | |
338 | } | |
339 | ||
340 | /* | |
341 | * Some things may run in the background now, but we | |
342 | * just wait for the calibration complete notification. | |
343 | */ | |
344 | ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait, | |
345 | MVM_UCODE_CALIB_TIMEOUT); | |
346 | if (!ret) | |
ff116373 | 347 | mvm->init_ucode_complete = true; |
8ca151b5 JB |
348 | goto out; |
349 | ||
350 | error: | |
351 | iwl_remove_notification(&mvm->notif_wait, &calib_wait); | |
352 | out: | |
a4082843 | 353 | if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) { |
8ca151b5 JB |
354 | /* we want to debug INIT and we have no NVM - fake */ |
355 | mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) + | |
356 | sizeof(struct ieee80211_channel) + | |
357 | sizeof(struct ieee80211_rate), | |
358 | GFP_KERNEL); | |
359 | if (!mvm->nvm_data) | |
360 | return -ENOMEM; | |
8ca151b5 JB |
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 | ||
8ca151b5 JB |
372 | int iwl_mvm_up(struct iwl_mvm *mvm) |
373 | { | |
374 | int ret, i; | |
53a9d61e IP |
375 | struct ieee80211_channel *chan; |
376 | struct cfg80211_chan_def chandef; | |
8ca151b5 JB |
377 | |
378 | lockdep_assert_held(&mvm->mutex); | |
379 | ||
380 | ret = iwl_trans_start_hw(mvm->trans); | |
381 | if (ret) | |
382 | return ret; | |
383 | ||
ff116373 EL |
384 | /* |
385 | * If we haven't completed the run of the init ucode during | |
386 | * module loading, load init ucode now | |
387 | * (for example, if we were in RFKILL) | |
388 | */ | |
389 | if (!mvm->init_ucode_complete) { | |
8ca151b5 JB |
390 | ret = iwl_run_init_mvm_ucode(mvm, false); |
391 | if (ret && !iwlmvm_mod_params.init_dbg) { | |
392 | IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret); | |
4f59334b EH |
393 | /* this can't happen */ |
394 | if (WARN_ON(ret > 0)) | |
395 | ret = -ERFKILL; | |
8ca151b5 JB |
396 | goto error; |
397 | } | |
a4082843 AN |
398 | if (!iwlmvm_mod_params.init_dbg) { |
399 | /* | |
400 | * should stop and start HW since that INIT | |
401 | * image just loaded | |
402 | */ | |
403 | iwl_trans_stop_device(mvm->trans); | |
404 | ret = iwl_trans_start_hw(mvm->trans); | |
405 | if (ret) | |
406 | return ret; | |
407 | } | |
8ca151b5 JB |
408 | } |
409 | ||
410 | if (iwlmvm_mod_params.init_dbg) | |
411 | return 0; | |
412 | ||
413 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR); | |
414 | if (ret) { | |
415 | IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret); | |
416 | goto error; | |
417 | } | |
418 | ||
1f3b0ff8 LE |
419 | ret = iwl_mvm_sf_update(mvm, NULL, false); |
420 | if (ret) | |
421 | IWL_ERR(mvm, "Failed to initialize Smart Fifo\n"); | |
422 | ||
4ed735e7 | 423 | ret = iwl_send_tx_ant_cfg(mvm, mvm->fw->valid_tx_ant); |
8ca151b5 JB |
424 | if (ret) |
425 | goto error; | |
426 | ||
931d4160 EG |
427 | ret = iwl_send_bt_init_conf(mvm); |
428 | if (ret) | |
429 | goto error; | |
430 | ||
8ca151b5 JB |
431 | /* Send phy db control command and then phy db calibration*/ |
432 | ret = iwl_send_phy_db_data(mvm->phy_db); | |
433 | if (ret) | |
434 | goto error; | |
435 | ||
436 | ret = iwl_send_phy_cfg_cmd(mvm); | |
437 | if (ret) | |
438 | goto error; | |
439 | ||
440 | /* init the fw <-> mac80211 STA mapping */ | |
441 | for (i = 0; i < IWL_MVM_STATION_COUNT; i++) | |
442 | RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); | |
443 | ||
444 | /* Add auxiliary station for scanning */ | |
445 | ret = iwl_mvm_add_aux_sta(mvm); | |
446 | if (ret) | |
447 | goto error; | |
448 | ||
53a9d61e IP |
449 | /* Add all the PHY contexts */ |
450 | chan = &mvm->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->channels[0]; | |
451 | cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT); | |
452 | for (i = 0; i < NUM_PHY_CTX; i++) { | |
453 | /* | |
454 | * The channel used here isn't relevant as it's | |
455 | * going to be overwritten in the other flows. | |
456 | * For now use the first channel we have. | |
457 | */ | |
458 | ret = iwl_mvm_phy_ctxt_add(mvm, &mvm->phy_ctxts[i], | |
459 | &chandef, 1, 1); | |
460 | if (ret) | |
461 | goto error; | |
462 | } | |
8ca151b5 | 463 | |
0c0e2c71 IY |
464 | /* Initialize tx backoffs to the minimal possible */ |
465 | iwl_mvm_tt_tx_backoff(mvm, 0); | |
466 | ||
c1cb92fc | 467 | ret = iwl_mvm_power_update_device(mvm); |
64b928c4 AB |
468 | if (ret) |
469 | goto error; | |
470 | ||
7498cf4c EP |
471 | /* allow FW/transport low power modes if not during restart */ |
472 | if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) | |
473 | iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN); | |
474 | ||
53a9d61e | 475 | IWL_DEBUG_INFO(mvm, "RT uCode started.\n"); |
8ca151b5 JB |
476 | return 0; |
477 | error: | |
478 | iwl_trans_stop_device(mvm->trans); | |
479 | return ret; | |
480 | } | |
481 | ||
482 | int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm) | |
483 | { | |
484 | int ret, i; | |
485 | ||
486 | lockdep_assert_held(&mvm->mutex); | |
487 | ||
488 | ret = iwl_trans_start_hw(mvm->trans); | |
489 | if (ret) | |
490 | return ret; | |
491 | ||
492 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_WOWLAN); | |
493 | if (ret) { | |
494 | IWL_ERR(mvm, "Failed to start WoWLAN firmware: %d\n", ret); | |
495 | goto error; | |
496 | } | |
497 | ||
4ed735e7 | 498 | ret = iwl_send_tx_ant_cfg(mvm, mvm->fw->valid_tx_ant); |
8ca151b5 JB |
499 | if (ret) |
500 | goto error; | |
501 | ||
502 | /* Send phy db control command and then phy db calibration*/ | |
503 | ret = iwl_send_phy_db_data(mvm->phy_db); | |
504 | if (ret) | |
505 | goto error; | |
506 | ||
507 | ret = iwl_send_phy_cfg_cmd(mvm); | |
508 | if (ret) | |
509 | goto error; | |
510 | ||
511 | /* init the fw <-> mac80211 STA mapping */ | |
512 | for (i = 0; i < IWL_MVM_STATION_COUNT; i++) | |
513 | RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); | |
514 | ||
515 | /* Add auxiliary station for scanning */ | |
516 | ret = iwl_mvm_add_aux_sta(mvm); | |
517 | if (ret) | |
518 | goto error; | |
519 | ||
520 | return 0; | |
521 | error: | |
522 | iwl_trans_stop_device(mvm->trans); | |
523 | return ret; | |
524 | } | |
525 | ||
526 | int iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm, | |
527 | struct iwl_rx_cmd_buffer *rxb, | |
528 | struct iwl_device_cmd *cmd) | |
529 | { | |
530 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | |
531 | struct iwl_card_state_notif *card_state_notif = (void *)pkt->data; | |
532 | u32 flags = le32_to_cpu(card_state_notif->flags); | |
533 | ||
534 | IWL_DEBUG_RF_KILL(mvm, "Card state received: HW:%s SW:%s CT:%s\n", | |
535 | (flags & HW_CARD_DISABLED) ? "Kill" : "On", | |
536 | (flags & SW_CARD_DISABLED) ? "Kill" : "On", | |
537 | (flags & CT_KILL_CARD_DISABLED) ? | |
538 | "Reached" : "Not reached"); | |
539 | ||
8ca151b5 JB |
540 | return 0; |
541 | } | |
542 | ||
543 | int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb, | |
544 | struct iwl_device_cmd *cmd) | |
545 | { | |
546 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | |
547 | struct iwl_radio_version_notif *radio_version = (void *)pkt->data; | |
548 | ||
549 | /* TODO: what to do with that? */ | |
550 | IWL_DEBUG_INFO(mvm, | |
551 | "Radio version: flavor: 0x%08x, step 0x%08x, dash 0x%08x\n", | |
552 | le32_to_cpu(radio_version->radio_flavor), | |
553 | le32_to_cpu(radio_version->radio_step), | |
554 | le32_to_cpu(radio_version->radio_dash)); | |
555 | return 0; | |
556 | } |