Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * This file is provided under a dual BSD/GPLv2 license. When using or |
| 4 | * redistributing this file, you may do so under either license. |
| 5 | * |
| 6 | * GPL LICENSE SUMMARY |
| 7 | * |
| 8 | * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved. |
| 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 |
Emmanuel Grumbach | 410dc5a | 2013-02-18 09:22:28 +0200 | [diff] [blame] | 25 | * in the file called COPYING. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 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 | * |
| 33 | * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved. |
| 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 | |
| 81 | /* Default calibration values for WkP - set to INIT image w/o running */ |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 82 | static const u8 wkp_calib_values_rx_iq_skew[] = { 0x00, 0x00, 0x01, 0x00 }; |
| 83 | static const u8 wkp_calib_values_tx_iq_skew[] = { 0x01, 0x00, 0x00, 0x00 }; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 84 | |
| 85 | struct iwl_calib_default_data { |
| 86 | u16 size; |
| 87 | void *data; |
| 88 | }; |
| 89 | |
| 90 | #define CALIB_SIZE_N_DATA(_buf) {.size = sizeof(_buf), .data = &_buf} |
| 91 | |
| 92 | static const struct iwl_calib_default_data wkp_calib_default_data[12] = { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 93 | [9] = CALIB_SIZE_N_DATA(wkp_calib_values_tx_iq_skew), |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 94 | [11] = CALIB_SIZE_N_DATA(wkp_calib_values_rx_iq_skew), |
| 95 | }; |
| 96 | |
| 97 | struct iwl_mvm_alive_data { |
| 98 | bool valid; |
| 99 | u32 scd_base_addr; |
| 100 | }; |
| 101 | |
| 102 | static inline const struct fw_img * |
| 103 | iwl_get_ucode_image(struct iwl_mvm *mvm, enum iwl_ucode_type ucode_type) |
| 104 | { |
| 105 | if (ucode_type >= IWL_UCODE_TYPE_MAX) |
| 106 | return NULL; |
| 107 | |
| 108 | return &mvm->fw->img[ucode_type]; |
| 109 | } |
| 110 | |
| 111 | static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant) |
| 112 | { |
| 113 | struct iwl_tx_ant_cfg_cmd tx_ant_cmd = { |
| 114 | .valid = cpu_to_le32(valid_tx_ant), |
| 115 | }; |
| 116 | |
| 117 | IWL_DEBUG_HC(mvm, "select valid tx ant: %u\n", valid_tx_ant); |
| 118 | return iwl_mvm_send_cmd_pdu(mvm, TX_ANT_CONFIGURATION_CMD, CMD_SYNC, |
| 119 | sizeof(tx_ant_cmd), &tx_ant_cmd); |
| 120 | } |
| 121 | |
| 122 | static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait, |
| 123 | struct iwl_rx_packet *pkt, void *data) |
| 124 | { |
| 125 | struct iwl_mvm *mvm = |
| 126 | container_of(notif_wait, struct iwl_mvm, notif_wait); |
| 127 | struct iwl_mvm_alive_data *alive_data = data; |
| 128 | struct mvm_alive_resp *palive; |
| 129 | |
| 130 | palive = (void *)pkt->data; |
| 131 | |
| 132 | mvm->error_event_table = le32_to_cpu(palive->error_event_table_ptr); |
| 133 | mvm->log_event_table = le32_to_cpu(palive->log_event_table_ptr); |
| 134 | alive_data->scd_base_addr = le32_to_cpu(palive->scd_base_ptr); |
| 135 | |
| 136 | alive_data->valid = le16_to_cpu(palive->status) == IWL_ALIVE_STATUS_OK; |
| 137 | IWL_DEBUG_FW(mvm, "Alive ucode status 0x%04x revision 0x%01X 0x%01X\n", |
| 138 | le16_to_cpu(palive->status), palive->ver_type, |
| 139 | palive->ver_subtype); |
| 140 | |
| 141 | return true; |
| 142 | } |
| 143 | |
| 144 | static bool iwl_wait_phy_db_entry(struct iwl_notif_wait_data *notif_wait, |
| 145 | struct iwl_rx_packet *pkt, void *data) |
| 146 | { |
| 147 | struct iwl_phy_db *phy_db = data; |
| 148 | |
| 149 | if (pkt->hdr.cmd != CALIB_RES_NOTIF_PHY_DB) { |
| 150 | WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF); |
| 151 | return true; |
| 152 | } |
| 153 | |
| 154 | WARN_ON(iwl_phy_db_set_section(phy_db, pkt, GFP_ATOMIC)); |
| 155 | |
| 156 | return false; |
| 157 | } |
| 158 | |
| 159 | static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm, |
| 160 | enum iwl_ucode_type ucode_type) |
| 161 | { |
| 162 | struct iwl_notification_wait alive_wait; |
| 163 | struct iwl_mvm_alive_data alive_data; |
| 164 | const struct fw_img *fw; |
| 165 | int ret, i; |
| 166 | enum iwl_ucode_type old_type = mvm->cur_ucode; |
| 167 | static const u8 alive_cmd[] = { MVM_ALIVE }; |
| 168 | |
| 169 | mvm->cur_ucode = ucode_type; |
| 170 | fw = iwl_get_ucode_image(mvm, ucode_type); |
| 171 | |
| 172 | mvm->ucode_loaded = false; |
| 173 | |
| 174 | if (!fw) |
| 175 | return -EINVAL; |
| 176 | |
| 177 | iwl_init_notification_wait(&mvm->notif_wait, &alive_wait, |
| 178 | alive_cmd, ARRAY_SIZE(alive_cmd), |
| 179 | iwl_alive_fn, &alive_data); |
| 180 | |
| 181 | ret = iwl_trans_start_fw(mvm->trans, fw, ucode_type == IWL_UCODE_INIT); |
| 182 | if (ret) { |
| 183 | mvm->cur_ucode = old_type; |
| 184 | iwl_remove_notification(&mvm->notif_wait, &alive_wait); |
| 185 | return ret; |
| 186 | } |
| 187 | |
| 188 | /* |
| 189 | * Some things may run in the background now, but we |
| 190 | * just wait for the ALIVE notification here. |
| 191 | */ |
| 192 | ret = iwl_wait_notification(&mvm->notif_wait, &alive_wait, |
| 193 | MVM_UCODE_ALIVE_TIMEOUT); |
| 194 | if (ret) { |
| 195 | mvm->cur_ucode = old_type; |
| 196 | return ret; |
| 197 | } |
| 198 | |
| 199 | if (!alive_data.valid) { |
| 200 | IWL_ERR(mvm, "Loaded ucode is not valid!\n"); |
| 201 | mvm->cur_ucode = old_type; |
| 202 | return -EIO; |
| 203 | } |
| 204 | |
| 205 | iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr); |
| 206 | |
| 207 | /* |
| 208 | * Note: all the queues are enabled as part of the interface |
| 209 | * initialization, but in firmware restart scenarios they |
| 210 | * could be stopped, so wake them up. In firmware restart, |
| 211 | * mac80211 will have the queues stopped as well until the |
| 212 | * reconfiguration completes. During normal startup, they |
| 213 | * will be empty. |
| 214 | */ |
| 215 | |
| 216 | for (i = 0; i < IWL_MAX_HW_QUEUES; i++) { |
| 217 | if (i < IWL_MVM_FIRST_AGG_QUEUE && i != IWL_MVM_CMD_QUEUE) |
| 218 | mvm->queue_to_mac80211[i] = i; |
| 219 | else |
| 220 | mvm->queue_to_mac80211[i] = IWL_INVALID_MAC80211_QUEUE; |
| 221 | atomic_set(&mvm->queue_stop_count[i], 0); |
| 222 | } |
| 223 | |
| 224 | mvm->transport_queue_stop = 0; |
| 225 | |
| 226 | mvm->ucode_loaded = true; |
| 227 | |
| 228 | return 0; |
| 229 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 230 | |
| 231 | static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm) |
| 232 | { |
| 233 | struct iwl_phy_cfg_cmd phy_cfg_cmd; |
| 234 | enum iwl_ucode_type ucode_type = mvm->cur_ucode; |
| 235 | |
| 236 | /* Set parameters */ |
Dor Shaish | 6221d47 | 2013-02-27 15:55:48 +0200 | [diff] [blame] | 237 | phy_cfg_cmd.phy_cfg = cpu_to_le32(mvm->fw->phy_config); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 238 | phy_cfg_cmd.calib_control.event_trigger = |
| 239 | mvm->fw->default_calib[ucode_type].event_trigger; |
| 240 | phy_cfg_cmd.calib_control.flow_trigger = |
| 241 | mvm->fw->default_calib[ucode_type].flow_trigger; |
| 242 | |
| 243 | IWL_DEBUG_INFO(mvm, "Sending Phy CFG command: 0x%x\n", |
| 244 | phy_cfg_cmd.phy_cfg); |
| 245 | |
| 246 | return iwl_mvm_send_cmd_pdu(mvm, PHY_CONFIGURATION_CMD, CMD_SYNC, |
| 247 | sizeof(phy_cfg_cmd), &phy_cfg_cmd); |
| 248 | } |
| 249 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 250 | static int iwl_set_default_calibrations(struct iwl_mvm *mvm) |
| 251 | { |
| 252 | u8 cmd_raw[16]; /* holds the variable size commands */ |
| 253 | struct iwl_set_calib_default_cmd *cmd = |
| 254 | (struct iwl_set_calib_default_cmd *)cmd_raw; |
| 255 | int ret, i; |
| 256 | |
| 257 | /* Setting default values for calibrations we don't run */ |
| 258 | for (i = 0; i < ARRAY_SIZE(wkp_calib_default_data); i++) { |
| 259 | u16 cmd_len; |
| 260 | |
| 261 | if (wkp_calib_default_data[i].size == 0) |
| 262 | continue; |
| 263 | |
| 264 | memset(cmd_raw, 0, sizeof(cmd_raw)); |
| 265 | cmd_len = wkp_calib_default_data[i].size + sizeof(cmd); |
| 266 | cmd->calib_index = cpu_to_le16(i); |
| 267 | cmd->length = cpu_to_le16(wkp_calib_default_data[i].size); |
| 268 | if (WARN_ONCE(cmd_len > sizeof(cmd_raw), |
| 269 | "Need to enlarge cmd_raw to %d\n", cmd_len)) |
| 270 | break; |
| 271 | memcpy(cmd->data, wkp_calib_default_data[i].data, |
| 272 | wkp_calib_default_data[i].size); |
| 273 | ret = iwl_mvm_send_cmd_pdu(mvm, SET_CALIB_DEFAULT_CMD, 0, |
| 274 | sizeof(*cmd) + |
| 275 | wkp_calib_default_data[i].size, |
| 276 | cmd); |
| 277 | if (ret) |
| 278 | return ret; |
| 279 | } |
| 280 | |
| 281 | return 0; |
| 282 | } |
| 283 | |
| 284 | int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) |
| 285 | { |
| 286 | struct iwl_notification_wait calib_wait; |
| 287 | static const u8 init_complete[] = { |
| 288 | INIT_COMPLETE_NOTIF, |
| 289 | CALIB_RES_NOTIF_PHY_DB |
| 290 | }; |
| 291 | int ret; |
| 292 | |
| 293 | lockdep_assert_held(&mvm->mutex); |
| 294 | |
| 295 | if (mvm->init_ucode_run) |
| 296 | return 0; |
| 297 | |
| 298 | iwl_init_notification_wait(&mvm->notif_wait, |
| 299 | &calib_wait, |
| 300 | init_complete, |
| 301 | ARRAY_SIZE(init_complete), |
| 302 | iwl_wait_phy_db_entry, |
| 303 | mvm->phy_db); |
| 304 | |
| 305 | /* Will also start the device */ |
| 306 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_INIT); |
| 307 | if (ret) { |
| 308 | IWL_ERR(mvm, "Failed to start INIT ucode: %d\n", ret); |
| 309 | goto error; |
| 310 | } |
| 311 | |
Emmanuel Grumbach | 931d416 | 2013-01-17 09:42:25 +0200 | [diff] [blame] | 312 | ret = iwl_send_bt_prio_tbl(mvm); |
| 313 | if (ret) |
| 314 | goto error; |
| 315 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 316 | if (read_nvm) { |
| 317 | /* Read nvm */ |
| 318 | ret = iwl_nvm_init(mvm); |
| 319 | if (ret) { |
| 320 | IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); |
| 321 | goto error; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | ret = iwl_nvm_check_version(mvm->nvm_data, mvm->trans); |
| 326 | WARN_ON(ret); |
| 327 | |
Dor Shaish | e07cbb5 | 2013-02-27 23:00:27 +0200 | [diff] [blame] | 328 | /* Send TX valid antennas before triggering calibrations */ |
| 329 | ret = iwl_send_tx_ant_cfg(mvm, mvm->nvm_data->valid_tx_ant); |
| 330 | if (ret) |
| 331 | goto error; |
| 332 | |
Emmanuel Grumbach | b9545b4 | 2013-03-06 11:34:44 +0200 | [diff] [blame] | 333 | /* need to set default values */ |
| 334 | ret = iwl_set_default_calibrations(mvm); |
| 335 | if (ret) |
| 336 | goto error; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 337 | |
| 338 | /* |
| 339 | * Send phy configurations command to init uCode |
| 340 | * to start the 16.0 uCode init image internal calibrations. |
| 341 | */ |
| 342 | ret = iwl_send_phy_cfg_cmd(mvm); |
| 343 | if (ret) { |
| 344 | IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n", |
| 345 | ret); |
| 346 | goto error; |
| 347 | } |
| 348 | |
| 349 | /* |
| 350 | * Some things may run in the background now, but we |
| 351 | * just wait for the calibration complete notification. |
| 352 | */ |
| 353 | ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait, |
| 354 | MVM_UCODE_CALIB_TIMEOUT); |
| 355 | if (!ret) |
| 356 | mvm->init_ucode_run = true; |
| 357 | goto out; |
| 358 | |
| 359 | error: |
| 360 | iwl_remove_notification(&mvm->notif_wait, &calib_wait); |
| 361 | out: |
| 362 | if (!iwlmvm_mod_params.init_dbg) { |
| 363 | iwl_trans_stop_device(mvm->trans); |
| 364 | } else if (!mvm->nvm_data) { |
| 365 | /* we want to debug INIT and we have no NVM - fake */ |
| 366 | mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) + |
| 367 | sizeof(struct ieee80211_channel) + |
| 368 | sizeof(struct ieee80211_rate), |
| 369 | GFP_KERNEL); |
| 370 | if (!mvm->nvm_data) |
| 371 | return -ENOMEM; |
| 372 | mvm->nvm_data->valid_rx_ant = 1; |
| 373 | mvm->nvm_data->valid_tx_ant = 1; |
| 374 | mvm->nvm_data->bands[0].channels = mvm->nvm_data->channels; |
| 375 | mvm->nvm_data->bands[0].n_channels = 1; |
| 376 | mvm->nvm_data->bands[0].n_bitrates = 1; |
| 377 | mvm->nvm_data->bands[0].bitrates = |
| 378 | (void *)mvm->nvm_data->channels + 1; |
| 379 | mvm->nvm_data->bands[0].bitrates->hw_value = 10; |
| 380 | } |
| 381 | |
| 382 | return ret; |
| 383 | } |
| 384 | |
| 385 | #define UCODE_CALIB_TIMEOUT (2*HZ) |
| 386 | |
| 387 | int iwl_mvm_up(struct iwl_mvm *mvm) |
| 388 | { |
| 389 | int ret, i; |
| 390 | |
| 391 | lockdep_assert_held(&mvm->mutex); |
| 392 | |
| 393 | ret = iwl_trans_start_hw(mvm->trans); |
| 394 | if (ret) |
| 395 | return ret; |
| 396 | |
| 397 | /* If we were in RFKILL during module loading, load init ucode now */ |
| 398 | if (!mvm->init_ucode_run) { |
| 399 | ret = iwl_run_init_mvm_ucode(mvm, false); |
| 400 | if (ret && !iwlmvm_mod_params.init_dbg) { |
| 401 | IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret); |
| 402 | goto error; |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | if (iwlmvm_mod_params.init_dbg) |
| 407 | return 0; |
| 408 | |
| 409 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR); |
| 410 | if (ret) { |
| 411 | IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret); |
| 412 | goto error; |
| 413 | } |
| 414 | |
| 415 | ret = iwl_send_tx_ant_cfg(mvm, mvm->nvm_data->valid_tx_ant); |
| 416 | if (ret) |
| 417 | goto error; |
| 418 | |
Emmanuel Grumbach | 931d416 | 2013-01-17 09:42:25 +0200 | [diff] [blame] | 419 | ret = iwl_send_bt_prio_tbl(mvm); |
| 420 | if (ret) |
| 421 | goto error; |
| 422 | |
| 423 | ret = iwl_send_bt_init_conf(mvm); |
| 424 | if (ret) |
| 425 | goto error; |
| 426 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 427 | /* Send phy db control command and then phy db calibration*/ |
| 428 | ret = iwl_send_phy_db_data(mvm->phy_db); |
| 429 | if (ret) |
| 430 | goto error; |
| 431 | |
| 432 | ret = iwl_send_phy_cfg_cmd(mvm); |
| 433 | if (ret) |
| 434 | goto error; |
| 435 | |
| 436 | /* init the fw <-> mac80211 STA mapping */ |
| 437 | for (i = 0; i < IWL_MVM_STATION_COUNT; i++) |
| 438 | RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); |
| 439 | |
| 440 | /* Add auxiliary station for scanning */ |
| 441 | ret = iwl_mvm_add_aux_sta(mvm); |
| 442 | if (ret) |
| 443 | goto error; |
| 444 | |
| 445 | IWL_DEBUG_INFO(mvm, "RT uCode started.\n"); |
| 446 | |
| 447 | return 0; |
| 448 | error: |
| 449 | iwl_trans_stop_device(mvm->trans); |
| 450 | return ret; |
| 451 | } |
| 452 | |
| 453 | int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm) |
| 454 | { |
| 455 | int ret, i; |
| 456 | |
| 457 | lockdep_assert_held(&mvm->mutex); |
| 458 | |
| 459 | ret = iwl_trans_start_hw(mvm->trans); |
| 460 | if (ret) |
| 461 | return ret; |
| 462 | |
| 463 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_WOWLAN); |
| 464 | if (ret) { |
| 465 | IWL_ERR(mvm, "Failed to start WoWLAN firmware: %d\n", ret); |
| 466 | goto error; |
| 467 | } |
| 468 | |
| 469 | ret = iwl_send_tx_ant_cfg(mvm, mvm->nvm_data->valid_tx_ant); |
| 470 | if (ret) |
| 471 | goto error; |
| 472 | |
| 473 | /* Send phy db control command and then phy db calibration*/ |
| 474 | ret = iwl_send_phy_db_data(mvm->phy_db); |
| 475 | if (ret) |
| 476 | goto error; |
| 477 | |
| 478 | ret = iwl_send_phy_cfg_cmd(mvm); |
| 479 | if (ret) |
| 480 | goto error; |
| 481 | |
| 482 | /* init the fw <-> mac80211 STA mapping */ |
| 483 | for (i = 0; i < IWL_MVM_STATION_COUNT; i++) |
| 484 | RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); |
| 485 | |
| 486 | /* Add auxiliary station for scanning */ |
| 487 | ret = iwl_mvm_add_aux_sta(mvm); |
| 488 | if (ret) |
| 489 | goto error; |
| 490 | |
| 491 | return 0; |
| 492 | error: |
| 493 | iwl_trans_stop_device(mvm->trans); |
| 494 | return ret; |
| 495 | } |
| 496 | |
| 497 | int iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm, |
| 498 | struct iwl_rx_cmd_buffer *rxb, |
| 499 | struct iwl_device_cmd *cmd) |
| 500 | { |
| 501 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 502 | struct iwl_card_state_notif *card_state_notif = (void *)pkt->data; |
| 503 | u32 flags = le32_to_cpu(card_state_notif->flags); |
| 504 | |
| 505 | IWL_DEBUG_RF_KILL(mvm, "Card state received: HW:%s SW:%s CT:%s\n", |
| 506 | (flags & HW_CARD_DISABLED) ? "Kill" : "On", |
| 507 | (flags & SW_CARD_DISABLED) ? "Kill" : "On", |
| 508 | (flags & CT_KILL_CARD_DISABLED) ? |
| 509 | "Reached" : "Not reached"); |
| 510 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 511 | return 0; |
| 512 | } |
| 513 | |
| 514 | int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb, |
| 515 | struct iwl_device_cmd *cmd) |
| 516 | { |
| 517 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 518 | struct iwl_radio_version_notif *radio_version = (void *)pkt->data; |
| 519 | |
| 520 | /* TODO: what to do with that? */ |
| 521 | IWL_DEBUG_INFO(mvm, |
| 522 | "Radio version: flavor: 0x%08x, step 0x%08x, dash 0x%08x\n", |
| 523 | le32_to_cpu(radio_version->radio_flavor), |
| 524 | le32_to_cpu(radio_version->radio_step), |
| 525 | le32_to_cpu(radio_version->radio_dash)); |
| 526 | return 0; |
| 527 | } |