Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * This file is provided under a dual BSD/GPLv2 license. When using or |
| 4 | * redistributing this file, you may do so under either license. |
| 5 | * |
| 6 | * GPL LICENSE SUMMARY |
| 7 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 8 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
Eran Harary | 8d193ca | 2015-04-27 10:29:31 +0300 | [diff] [blame] | 9 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH |
Golan Ben-Ami | bdccdb8 | 2016-11-15 14:45:29 +0200 | [diff] [blame] | 10 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH |
Shaul Triebitz | 9c4f7d5 | 2018-01-14 19:06:09 +0200 | [diff] [blame] | 11 | * Copyright(c) 2018 Intel Corporation |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of version 2 of the GNU General Public License as |
| 15 | * published by the Free Software Foundation. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, but |
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 20 | * General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, |
| 25 | * USA |
| 26 | * |
| 27 | * The full GNU General Public License is included in this distribution |
Emmanuel Grumbach | 410dc5a | 2013-02-18 09:22:28 +0200 | [diff] [blame] | 28 | * in the file called COPYING. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 29 | * |
| 30 | * Contact Information: |
Emmanuel Grumbach | cb2f827 | 2015-11-17 15:39:56 +0200 | [diff] [blame] | 31 | * Intel Linux Wireless <linuxwifi@intel.com> |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 32 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 33 | * |
| 34 | * BSD LICENSE |
| 35 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 36 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
Eran Harary | 8d193ca | 2015-04-27 10:29:31 +0300 | [diff] [blame] | 37 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH |
Golan Ben-Ami | bdccdb8 | 2016-11-15 14:45:29 +0200 | [diff] [blame] | 38 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH |
Shaul Triebitz | 9c4f7d5 | 2018-01-14 19:06:09 +0200 | [diff] [blame] | 39 | * Copyright(c) 2018 Intel Corporation |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 40 | * All rights reserved. |
| 41 | * |
| 42 | * Redistribution and use in source and binary forms, with or without |
| 43 | * modification, are permitted provided that the following conditions |
| 44 | * are met: |
| 45 | * |
| 46 | * * Redistributions of source code must retain the above copyright |
| 47 | * notice, this list of conditions and the following disclaimer. |
| 48 | * * Redistributions in binary form must reproduce the above copyright |
| 49 | * notice, this list of conditions and the following disclaimer in |
| 50 | * the documentation and/or other materials provided with the |
| 51 | * distribution. |
| 52 | * * Neither the name Intel Corporation nor the names of its |
| 53 | * contributors may be used to endorse or promote products derived |
| 54 | * from this software without specific prior written permission. |
| 55 | * |
| 56 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 57 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 58 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 59 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 60 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 61 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 62 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 63 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 64 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 65 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 66 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 67 | * |
| 68 | *****************************************************************************/ |
| 69 | #include <net/mac80211.h> |
Sara Sharon | 854d773 | 2016-03-22 15:55:58 +0200 | [diff] [blame] | 70 | #include <linux/netdevice.h> |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 71 | |
| 72 | #include "iwl-trans.h" |
| 73 | #include "iwl-op-mode.h" |
Johannes Berg | d962f9b | 2017-06-01 10:22:09 +0200 | [diff] [blame] | 74 | #include "fw/img.h" |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 75 | #include "iwl-debug.h" |
| 76 | #include "iwl-csr.h" /* for iwl_mvm_rx_card_state_notif */ |
| 77 | #include "iwl-io.h" /* for iwl_mvm_rx_card_state_notif */ |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 78 | #include "iwl-prph.h" |
Luca Coelho | 813df5c | 2017-09-19 12:35:18 +0300 | [diff] [blame] | 79 | #include "fw/acpi.h" |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 80 | |
| 81 | #include "mvm.h" |
Johannes Berg | 7174beb | 2017-06-01 16:03:19 +0200 | [diff] [blame] | 82 | #include "fw/dbg.h" |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 83 | #include "iwl-phy-db.h" |
Shaul Triebitz | 9c4f7d5 | 2018-01-14 19:06:09 +0200 | [diff] [blame] | 84 | #include "iwl-modparams.h" |
| 85 | #include "iwl-nvm-parse.h" |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 86 | |
| 87 | #define MVM_UCODE_ALIVE_TIMEOUT HZ |
| 88 | #define MVM_UCODE_CALIB_TIMEOUT (2*HZ) |
| 89 | |
| 90 | #define UCODE_VALID_OK cpu_to_le32(0x1) |
| 91 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 92 | struct iwl_mvm_alive_data { |
| 93 | bool valid; |
| 94 | u32 scd_base_addr; |
| 95 | }; |
| 96 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 97 | static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant) |
| 98 | { |
| 99 | struct iwl_tx_ant_cfg_cmd tx_ant_cmd = { |
| 100 | .valid = cpu_to_le32(valid_tx_ant), |
| 101 | }; |
| 102 | |
Emmanuel Grumbach | 3322354 | 2013-03-09 20:38:19 +0200 | [diff] [blame] | 103 | IWL_DEBUG_FW(mvm, "select valid tx ant: %u\n", valid_tx_ant); |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 104 | return iwl_mvm_send_cmd_pdu(mvm, TX_ANT_CONFIGURATION_CMD, 0, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 105 | sizeof(tx_ant_cmd), &tx_ant_cmd); |
| 106 | } |
| 107 | |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 108 | static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm) |
| 109 | { |
| 110 | int i; |
| 111 | struct iwl_rss_config_cmd cmd = { |
| 112 | .flags = cpu_to_le32(IWL_RSS_ENABLE), |
| 113 | .hash_mask = IWL_RSS_HASH_TYPE_IPV4_TCP | |
Sara Sharon | 854d773 | 2016-03-22 15:55:58 +0200 | [diff] [blame] | 114 | IWL_RSS_HASH_TYPE_IPV4_UDP | |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 115 | IWL_RSS_HASH_TYPE_IPV4_PAYLOAD | |
| 116 | IWL_RSS_HASH_TYPE_IPV6_TCP | |
Sara Sharon | 854d773 | 2016-03-22 15:55:58 +0200 | [diff] [blame] | 117 | IWL_RSS_HASH_TYPE_IPV6_UDP | |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 118 | IWL_RSS_HASH_TYPE_IPV6_PAYLOAD, |
| 119 | }; |
| 120 | |
Sara Sharon | f43495f | 2016-05-04 14:22:10 +0300 | [diff] [blame] | 121 | if (mvm->trans->num_rx_queues == 1) |
| 122 | return 0; |
| 123 | |
Sara Sharon | 854d773 | 2016-03-22 15:55:58 +0200 | [diff] [blame] | 124 | /* Do not direct RSS traffic to Q 0 which is our fallback queue */ |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 125 | for (i = 0; i < ARRAY_SIZE(cmd.indirection_table); i++) |
Sara Sharon | 854d773 | 2016-03-22 15:55:58 +0200 | [diff] [blame] | 126 | cmd.indirection_table[i] = |
| 127 | 1 + (i % (mvm->trans->num_rx_queues - 1)); |
| 128 | netdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key)); |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 129 | |
| 130 | return iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0, sizeof(cmd), &cmd); |
| 131 | } |
| 132 | |
Sara Sharon | 8edbfaa | 2018-02-05 12:42:44 +0200 | [diff] [blame^] | 133 | static int iwl_configure_rxq(struct iwl_mvm *mvm) |
| 134 | { |
| 135 | int i, num_queues, size; |
| 136 | struct iwl_rfh_queue_config *cmd; |
| 137 | |
| 138 | /* Do not configure default queue, it is configured via context info */ |
| 139 | num_queues = mvm->trans->num_rx_queues - 1; |
| 140 | |
| 141 | size = sizeof(*cmd) + num_queues * sizeof(struct iwl_rfh_queue_data); |
| 142 | |
| 143 | cmd = kzalloc(size, GFP_KERNEL); |
| 144 | if (!cmd) |
| 145 | return -ENOMEM; |
| 146 | |
| 147 | cmd->num_queues = num_queues; |
| 148 | |
| 149 | for (i = 0; i < num_queues; i++) { |
| 150 | struct iwl_trans_rxq_dma_data data; |
| 151 | |
| 152 | cmd->data[i].q_num = i + 1; |
| 153 | iwl_trans_get_rxq_dma_data(mvm->trans, i + 1, &data); |
| 154 | |
| 155 | cmd->data[i].fr_bd_cb = cpu_to_le64(data.fr_bd_cb); |
| 156 | cmd->data[i].urbd_stts_wrptr = |
| 157 | cpu_to_le64(data.urbd_stts_wrptr); |
| 158 | cmd->data[i].ur_bd_cb = cpu_to_le64(data.ur_bd_cb); |
| 159 | cmd->data[i].fr_bd_wid = cpu_to_le32(data.fr_bd_wid); |
| 160 | } |
| 161 | |
| 162 | return iwl_mvm_send_cmd_pdu(mvm, |
| 163 | WIDE_ID(DATA_PATH_GROUP, |
| 164 | RFH_QUEUE_CONFIG_CMD), |
| 165 | 0, size, cmd); |
| 166 | } |
| 167 | |
Liad Kaufman | 97d5be7 | 2015-08-31 14:33:23 +0300 | [diff] [blame] | 168 | static int iwl_mvm_send_dqa_cmd(struct iwl_mvm *mvm) |
| 169 | { |
| 170 | struct iwl_dqa_enable_cmd dqa_cmd = { |
| 171 | .cmd_queue = cpu_to_le32(IWL_MVM_DQA_CMD_QUEUE), |
| 172 | }; |
| 173 | u32 cmd_id = iwl_cmd_id(DQA_ENABLE_CMD, DATA_PATH_GROUP, 0); |
| 174 | int ret; |
| 175 | |
| 176 | ret = iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, sizeof(dqa_cmd), &dqa_cmd); |
| 177 | if (ret) |
| 178 | IWL_ERR(mvm, "Failed to send DQA enabling command: %d\n", ret); |
| 179 | else |
| 180 | IWL_DEBUG_FW(mvm, "Working in DQA mode\n"); |
| 181 | |
| 182 | return ret; |
| 183 | } |
| 184 | |
Golan Ben-Ami | bdccdb8 | 2016-11-15 14:45:29 +0200 | [diff] [blame] | 185 | void iwl_mvm_mfu_assert_dump_notif(struct iwl_mvm *mvm, |
| 186 | struct iwl_rx_cmd_buffer *rxb) |
| 187 | { |
| 188 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 189 | struct iwl_mfu_assert_dump_notif *mfu_dump_notif = (void *)pkt->data; |
| 190 | __le32 *dump_data = mfu_dump_notif->data; |
| 191 | int n_words = le32_to_cpu(mfu_dump_notif->data_size) / sizeof(__le32); |
| 192 | int i; |
| 193 | |
| 194 | if (mfu_dump_notif->index_num == 0) |
| 195 | IWL_INFO(mvm, "MFUART assert id 0x%x occurred\n", |
| 196 | le32_to_cpu(mfu_dump_notif->assert_id)); |
| 197 | |
| 198 | for (i = 0; i < n_words; i++) |
| 199 | IWL_DEBUG_INFO(mvm, |
| 200 | "MFUART assert dump, dword %u: 0x%08x\n", |
| 201 | le16_to_cpu(mfu_dump_notif->index_num) * |
| 202 | n_words + i, |
| 203 | le32_to_cpu(dump_data[i])); |
| 204 | } |
| 205 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 206 | static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait, |
| 207 | struct iwl_rx_packet *pkt, void *data) |
| 208 | { |
| 209 | struct iwl_mvm *mvm = |
| 210 | container_of(notif_wait, struct iwl_mvm, notif_wait); |
| 211 | struct iwl_mvm_alive_data *alive_data = data; |
Sara Sharon | 5c228d6 | 2016-11-24 13:48:27 +0200 | [diff] [blame] | 212 | struct mvm_alive_resp_v3 *palive3; |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 213 | struct mvm_alive_resp *palive; |
Sara Sharon | 5c228d6 | 2016-11-24 13:48:27 +0200 | [diff] [blame] | 214 | struct iwl_umac_alive *umac; |
| 215 | struct iwl_lmac_alive *lmac1; |
| 216 | struct iwl_lmac_alive *lmac2 = NULL; |
| 217 | u16 status; |
Luca Coelho | 3485e76 | 2017-10-02 16:12:23 +0300 | [diff] [blame] | 218 | u32 umac_error_event_table; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 219 | |
Sara Sharon | 5c228d6 | 2016-11-24 13:48:27 +0200 | [diff] [blame] | 220 | if (iwl_rx_packet_payload_len(pkt) == sizeof(*palive)) { |
Emmanuel Grumbach | 7e1223b | 2015-02-03 20:11:48 +0200 | [diff] [blame] | 221 | palive = (void *)pkt->data; |
Sara Sharon | 5c228d6 | 2016-11-24 13:48:27 +0200 | [diff] [blame] | 222 | umac = &palive->umac_data; |
| 223 | lmac1 = &palive->lmac_data[0]; |
| 224 | lmac2 = &palive->lmac_data[1]; |
| 225 | status = le16_to_cpu(palive->status); |
| 226 | } else { |
| 227 | palive3 = (void *)pkt->data; |
| 228 | umac = &palive3->umac_data; |
| 229 | lmac1 = &palive3->lmac_data; |
| 230 | status = le16_to_cpu(palive3->status); |
Eran Harary | 01a9ca5 | 2014-02-03 09:29:57 +0200 | [diff] [blame] | 231 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 232 | |
Sara Sharon | 5c228d6 | 2016-11-24 13:48:27 +0200 | [diff] [blame] | 233 | mvm->error_event_table[0] = le32_to_cpu(lmac1->error_event_table_ptr); |
| 234 | if (lmac2) |
| 235 | mvm->error_event_table[1] = |
| 236 | le32_to_cpu(lmac2->error_event_table_ptr); |
| 237 | mvm->log_event_table = le32_to_cpu(lmac1->log_event_table_ptr); |
Sara Sharon | 5c228d6 | 2016-11-24 13:48:27 +0200 | [diff] [blame] | 238 | |
Luca Coelho | 3485e76 | 2017-10-02 16:12:23 +0300 | [diff] [blame] | 239 | umac_error_event_table = le32_to_cpu(umac->error_info_addr); |
Sara Sharon | 5c228d6 | 2016-11-24 13:48:27 +0200 | [diff] [blame] | 240 | |
Luca Coelho | 3485e76 | 2017-10-02 16:12:23 +0300 | [diff] [blame] | 241 | if (!umac_error_event_table) { |
| 242 | mvm->support_umac_log = false; |
| 243 | } else if (umac_error_event_table >= |
| 244 | mvm->trans->cfg->min_umac_error_event_table) { |
| 245 | mvm->support_umac_log = true; |
| 246 | mvm->umac_error_event_table = umac_error_event_table; |
| 247 | } else { |
Luca Coelho | fb5b284 | 2017-10-02 15:44:20 +0300 | [diff] [blame] | 248 | IWL_ERR(mvm, |
| 249 | "Not valid error log pointer 0x%08X for %s uCode\n", |
| 250 | mvm->umac_error_event_table, |
| 251 | (mvm->fwrt.cur_fw_img == IWL_UCODE_INIT) ? |
| 252 | "Init" : "RT"); |
Luca Coelho | 3485e76 | 2017-10-02 16:12:23 +0300 | [diff] [blame] | 253 | mvm->support_umac_log = false; |
| 254 | } |
Luca Coelho | fb5b284 | 2017-10-02 15:44:20 +0300 | [diff] [blame] | 255 | |
Sara Sharon | 5c228d6 | 2016-11-24 13:48:27 +0200 | [diff] [blame] | 256 | alive_data->scd_base_addr = le32_to_cpu(lmac1->scd_base_ptr); |
| 257 | alive_data->valid = status == IWL_ALIVE_STATUS_OK; |
Sara Sharon | 5c228d6 | 2016-11-24 13:48:27 +0200 | [diff] [blame] | 258 | |
| 259 | IWL_DEBUG_FW(mvm, |
| 260 | "Alive ucode status 0x%04x revision 0x%01X 0x%01X\n", |
| 261 | status, lmac1->ver_type, lmac1->ver_subtype); |
| 262 | |
| 263 | if (lmac2) |
| 264 | IWL_DEBUG_FW(mvm, "Alive ucode CDB\n"); |
| 265 | |
| 266 | IWL_DEBUG_FW(mvm, |
| 267 | "UMAC version: Major - 0x%x, Minor - 0x%x\n", |
| 268 | le32_to_cpu(umac->umac_major), |
| 269 | le32_to_cpu(umac->umac_minor)); |
| 270 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 271 | return true; |
| 272 | } |
| 273 | |
Sara Sharon | 1f37065 | 2016-08-31 18:13:57 +0300 | [diff] [blame] | 274 | static bool iwl_wait_init_complete(struct iwl_notif_wait_data *notif_wait, |
| 275 | struct iwl_rx_packet *pkt, void *data) |
| 276 | { |
| 277 | WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF); |
| 278 | |
| 279 | return true; |
| 280 | } |
| 281 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 282 | static bool iwl_wait_phy_db_entry(struct iwl_notif_wait_data *notif_wait, |
| 283 | struct iwl_rx_packet *pkt, void *data) |
| 284 | { |
| 285 | struct iwl_phy_db *phy_db = data; |
| 286 | |
| 287 | if (pkt->hdr.cmd != CALIB_RES_NOTIF_PHY_DB) { |
| 288 | WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF); |
| 289 | return true; |
| 290 | } |
| 291 | |
Sara Sharon | ce1f277 | 2016-04-10 16:02:12 +0300 | [diff] [blame] | 292 | WARN_ON(iwl_phy_db_set_section(phy_db, pkt)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 293 | |
| 294 | return false; |
| 295 | } |
| 296 | |
| 297 | static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm, |
| 298 | enum iwl_ucode_type ucode_type) |
| 299 | { |
| 300 | struct iwl_notification_wait alive_wait; |
| 301 | struct iwl_mvm_alive_data alive_data; |
| 302 | const struct fw_img *fw; |
| 303 | int ret, i; |
Johannes Berg | 702e975 | 2017-06-02 11:56:58 +0200 | [diff] [blame] | 304 | enum iwl_ucode_type old_type = mvm->fwrt.cur_fw_img; |
Sara Sharon | 6eb031d | 2015-07-13 14:50:47 +0300 | [diff] [blame] | 305 | static const u16 alive_cmd[] = { MVM_ALIVE }; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 306 | |
Eran Harary | 61df750 | 2014-12-01 17:40:37 +0200 | [diff] [blame] | 307 | if (ucode_type == IWL_UCODE_REGULAR && |
Golan Ben-Ami | 3d2d442 | 2016-02-23 10:34:48 +0200 | [diff] [blame] | 308 | iwl_fw_dbg_conf_usniffer(mvm->fw, FW_DBG_START_FROM_ALIVE) && |
| 309 | !(fw_has_capa(&mvm->fw->ucode_capa, |
| 310 | IWL_UCODE_TLV_CAPA_USNIFFER_UNIFIED))) |
Sharon Dvir | 612da1e | 2016-08-03 10:55:45 +0300 | [diff] [blame] | 311 | fw = iwl_get_ucode_image(mvm->fw, IWL_UCODE_REGULAR_USNIFFER); |
Eran Harary | 61df750 | 2014-12-01 17:40:37 +0200 | [diff] [blame] | 312 | else |
Sharon Dvir | 612da1e | 2016-08-03 10:55:45 +0300 | [diff] [blame] | 313 | fw = iwl_get_ucode_image(mvm->fw, ucode_type); |
Johannes Berg | befe9b6 | 2013-10-25 12:32:51 +0200 | [diff] [blame] | 314 | if (WARN_ON(!fw)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 315 | return -EINVAL; |
Johannes Berg | 702e975 | 2017-06-02 11:56:58 +0200 | [diff] [blame] | 316 | iwl_fw_set_current_image(&mvm->fwrt, ucode_type); |
Johannes Berg | 65b280f | 2017-03-22 22:10:36 +0100 | [diff] [blame] | 317 | clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 318 | |
| 319 | iwl_init_notification_wait(&mvm->notif_wait, &alive_wait, |
| 320 | alive_cmd, ARRAY_SIZE(alive_cmd), |
| 321 | iwl_alive_fn, &alive_data); |
| 322 | |
| 323 | ret = iwl_trans_start_fw(mvm->trans, fw, ucode_type == IWL_UCODE_INIT); |
| 324 | if (ret) { |
Johannes Berg | 702e975 | 2017-06-02 11:56:58 +0200 | [diff] [blame] | 325 | iwl_fw_set_current_image(&mvm->fwrt, old_type); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 326 | iwl_remove_notification(&mvm->notif_wait, &alive_wait); |
| 327 | return ret; |
| 328 | } |
| 329 | |
| 330 | /* |
| 331 | * Some things may run in the background now, but we |
| 332 | * just wait for the ALIVE notification here. |
| 333 | */ |
| 334 | ret = iwl_wait_notification(&mvm->notif_wait, &alive_wait, |
| 335 | MVM_UCODE_ALIVE_TIMEOUT); |
| 336 | if (ret) { |
Sara Sharon | d6be9c1 | 2017-01-12 11:31:25 +0200 | [diff] [blame] | 337 | struct iwl_trans *trans = mvm->trans; |
| 338 | |
Golan Ben Ami | 5f01df3 | 2018-02-07 20:08:56 +0200 | [diff] [blame] | 339 | if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_22000) |
Dor Shaish | 192de2b | 2015-07-15 11:41:21 +0300 | [diff] [blame] | 340 | IWL_ERR(mvm, |
| 341 | "SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n", |
Sara Sharon | d6be9c1 | 2017-01-12 11:31:25 +0200 | [diff] [blame] | 342 | iwl_read_prph(trans, UMAG_SB_CPU_1_STATUS), |
| 343 | iwl_read_prph(trans, UMAG_SB_CPU_2_STATUS)); |
Sara Sharon | 6e58487 | 2017-03-22 14:07:50 +0200 | [diff] [blame] | 344 | else if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_8000) |
Sara Sharon | d6be9c1 | 2017-01-12 11:31:25 +0200 | [diff] [blame] | 345 | IWL_ERR(mvm, |
| 346 | "SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n", |
| 347 | iwl_read_prph(trans, SB_CPU_1_STATUS), |
| 348 | iwl_read_prph(trans, SB_CPU_2_STATUS)); |
Johannes Berg | 702e975 | 2017-06-02 11:56:58 +0200 | [diff] [blame] | 349 | iwl_fw_set_current_image(&mvm->fwrt, old_type); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 350 | return ret; |
| 351 | } |
| 352 | |
| 353 | if (!alive_data.valid) { |
| 354 | IWL_ERR(mvm, "Loaded ucode is not valid!\n"); |
Johannes Berg | 702e975 | 2017-06-02 11:56:58 +0200 | [diff] [blame] | 355 | iwl_fw_set_current_image(&mvm->fwrt, old_type); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 356 | return -EIO; |
| 357 | } |
| 358 | |
| 359 | iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr); |
| 360 | |
| 361 | /* |
| 362 | * Note: all the queues are enabled as part of the interface |
| 363 | * initialization, but in firmware restart scenarios they |
| 364 | * could be stopped, so wake them up. In firmware restart, |
| 365 | * mac80211 will have the queues stopped as well until the |
| 366 | * reconfiguration completes. During normal startup, they |
| 367 | * will be empty. |
| 368 | */ |
| 369 | |
Liad Kaufman | 4ecafae | 2015-07-14 13:36:18 +0300 | [diff] [blame] | 370 | memset(&mvm->queue_info, 0, sizeof(mvm->queue_info)); |
Johannes Berg | c8f5470 | 2017-06-19 23:50:31 +0200 | [diff] [blame] | 371 | mvm->queue_info[IWL_MVM_DQA_CMD_QUEUE].hw_queue_refcount = 1; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 372 | |
Johannes Berg | df197c0 | 2014-08-01 18:14:45 +0200 | [diff] [blame] | 373 | for (i = 0; i < IEEE80211_MAX_QUEUES; i++) |
| 374 | atomic_set(&mvm->mac80211_queue_stop_count[i], 0); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 375 | |
Johannes Berg | 65b280f | 2017-03-22 22:10:36 +0100 | [diff] [blame] | 376 | set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 377 | |
| 378 | return 0; |
| 379 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 380 | |
Johannes Berg | 8c5f47b | 2017-02-20 17:47:04 +0100 | [diff] [blame] | 381 | static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) |
| 382 | { |
| 383 | struct iwl_notification_wait init_wait; |
| 384 | struct iwl_nvm_access_complete_cmd nvm_complete = {}; |
| 385 | struct iwl_init_extended_cfg_cmd init_cfg = { |
| 386 | .init_flags = cpu_to_le32(BIT(IWL_INIT_NVM)), |
| 387 | }; |
| 388 | static const u16 init_complete[] = { |
| 389 | INIT_COMPLETE_NOTIF, |
| 390 | }; |
| 391 | int ret; |
| 392 | |
| 393 | lockdep_assert_held(&mvm->mutex); |
| 394 | |
| 395 | iwl_init_notification_wait(&mvm->notif_wait, |
| 396 | &init_wait, |
| 397 | init_complete, |
| 398 | ARRAY_SIZE(init_complete), |
| 399 | iwl_wait_init_complete, |
| 400 | NULL); |
| 401 | |
| 402 | /* Will also start the device */ |
| 403 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR); |
| 404 | if (ret) { |
| 405 | IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret); |
| 406 | goto error; |
| 407 | } |
| 408 | |
| 409 | /* Send init config command to mark that we are sending NVM access |
| 410 | * commands |
| 411 | */ |
| 412 | ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(SYSTEM_GROUP, |
| 413 | INIT_EXTENDED_CFG_CMD), 0, |
| 414 | sizeof(init_cfg), &init_cfg); |
| 415 | if (ret) { |
| 416 | IWL_ERR(mvm, "Failed to run init config command: %d\n", |
| 417 | ret); |
| 418 | goto error; |
| 419 | } |
| 420 | |
Sara Sharon | e9e1ba3 | 2017-01-08 16:46:14 +0200 | [diff] [blame] | 421 | /* Load NVM to NIC if needed */ |
| 422 | if (mvm->nvm_file_name) { |
Shaul Triebitz | 9c4f7d5 | 2018-01-14 19:06:09 +0200 | [diff] [blame] | 423 | iwl_read_external_nvm(mvm->trans, mvm->nvm_file_name, |
| 424 | mvm->nvm_sections); |
Johannes Berg | 8c5f47b | 2017-02-20 17:47:04 +0100 | [diff] [blame] | 425 | iwl_mvm_load_nvm_to_nic(mvm); |
Sara Sharon | e9e1ba3 | 2017-01-08 16:46:14 +0200 | [diff] [blame] | 426 | } |
Johannes Berg | 8c5f47b | 2017-02-20 17:47:04 +0100 | [diff] [blame] | 427 | |
Sara Sharon | d4f3695 | 2017-03-06 11:13:02 +0200 | [diff] [blame] | 428 | if (IWL_MVM_PARSE_NVM && read_nvm) { |
Luca Coelho | 5bd1d2c | 2017-08-15 18:46:44 +0300 | [diff] [blame] | 429 | ret = iwl_nvm_init(mvm); |
Sara Sharon | d4f3695 | 2017-03-06 11:13:02 +0200 | [diff] [blame] | 430 | if (ret) { |
| 431 | IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); |
| 432 | goto error; |
| 433 | } |
| 434 | } |
| 435 | |
Johannes Berg | 8c5f47b | 2017-02-20 17:47:04 +0100 | [diff] [blame] | 436 | ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(REGULATORY_AND_NVM_GROUP, |
| 437 | NVM_ACCESS_COMPLETE), 0, |
| 438 | sizeof(nvm_complete), &nvm_complete); |
| 439 | if (ret) { |
| 440 | IWL_ERR(mvm, "Failed to run complete NVM access: %d\n", |
| 441 | ret); |
| 442 | goto error; |
| 443 | } |
| 444 | |
| 445 | /* We wait for the INIT complete notification */ |
Sara Sharon | e9e1ba3 | 2017-01-08 16:46:14 +0200 | [diff] [blame] | 446 | ret = iwl_wait_notification(&mvm->notif_wait, &init_wait, |
| 447 | MVM_UCODE_ALIVE_TIMEOUT); |
| 448 | if (ret) |
| 449 | return ret; |
| 450 | |
| 451 | /* Read the NVM only at driver load time, no need to do this twice */ |
Sara Sharon | d4f3695 | 2017-03-06 11:13:02 +0200 | [diff] [blame] | 452 | if (!IWL_MVM_PARSE_NVM && read_nvm) { |
Shaul Triebitz | 4c625c5 | 2018-01-24 16:12:49 +0200 | [diff] [blame] | 453 | mvm->nvm_data = iwl_get_nvm(mvm->trans, mvm->fw); |
Shaul Triebitz | c135cb5 | 2017-06-22 17:09:08 +0300 | [diff] [blame] | 454 | if (IS_ERR(mvm->nvm_data)) { |
| 455 | ret = PTR_ERR(mvm->nvm_data); |
| 456 | mvm->nvm_data = NULL; |
Sara Sharon | e9e1ba3 | 2017-01-08 16:46:14 +0200 | [diff] [blame] | 457 | IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); |
| 458 | return ret; |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | return 0; |
Johannes Berg | 8c5f47b | 2017-02-20 17:47:04 +0100 | [diff] [blame] | 463 | |
| 464 | error: |
| 465 | iwl_remove_notification(&mvm->notif_wait, &init_wait); |
| 466 | return ret; |
| 467 | } |
| 468 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 469 | static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm) |
| 470 | { |
| 471 | struct iwl_phy_cfg_cmd phy_cfg_cmd; |
Johannes Berg | 702e975 | 2017-06-02 11:56:58 +0200 | [diff] [blame] | 472 | enum iwl_ucode_type ucode_type = mvm->fwrt.cur_fw_img; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 473 | |
| 474 | /* Set parameters */ |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 475 | phy_cfg_cmd.phy_cfg = cpu_to_le32(iwl_mvm_get_phy_config(mvm)); |
Luca Coelho | 86a2b20 | 2018-02-21 22:18:59 +0200 | [diff] [blame] | 476 | |
| 477 | /* set flags extra PHY configuration flags from the device's cfg */ |
| 478 | phy_cfg_cmd.phy_cfg |= cpu_to_le32(mvm->cfg->extra_phy_cfg_flags); |
| 479 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 480 | phy_cfg_cmd.calib_control.event_trigger = |
| 481 | mvm->fw->default_calib[ucode_type].event_trigger; |
| 482 | phy_cfg_cmd.calib_control.flow_trigger = |
| 483 | mvm->fw->default_calib[ucode_type].flow_trigger; |
| 484 | |
| 485 | IWL_DEBUG_INFO(mvm, "Sending Phy CFG command: 0x%x\n", |
| 486 | phy_cfg_cmd.phy_cfg); |
| 487 | |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 488 | return iwl_mvm_send_cmd_pdu(mvm, PHY_CONFIGURATION_CMD, 0, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 489 | sizeof(phy_cfg_cmd), &phy_cfg_cmd); |
| 490 | } |
| 491 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 492 | int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) |
| 493 | { |
| 494 | struct iwl_notification_wait calib_wait; |
Sara Sharon | 6eb031d | 2015-07-13 14:50:47 +0300 | [diff] [blame] | 495 | static const u16 init_complete[] = { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 496 | INIT_COMPLETE_NOTIF, |
| 497 | CALIB_RES_NOTIF_PHY_DB |
| 498 | }; |
| 499 | int ret; |
| 500 | |
Johannes Berg | 7d6222e2 | 2017-06-08 09:18:22 +0200 | [diff] [blame] | 501 | if (iwl_mvm_has_unified_ucode(mvm)) |
Johannes Berg | 8c5f47b | 2017-02-20 17:47:04 +0100 | [diff] [blame] | 502 | return iwl_run_unified_mvm_ucode(mvm, true); |
| 503 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 504 | lockdep_assert_held(&mvm->mutex); |
| 505 | |
Eran Harary | 8d193ca | 2015-04-27 10:29:31 +0300 | [diff] [blame] | 506 | if (WARN_ON_ONCE(mvm->calibrating)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 507 | return 0; |
| 508 | |
| 509 | iwl_init_notification_wait(&mvm->notif_wait, |
| 510 | &calib_wait, |
| 511 | init_complete, |
| 512 | ARRAY_SIZE(init_complete), |
| 513 | iwl_wait_phy_db_entry, |
| 514 | mvm->phy_db); |
| 515 | |
| 516 | /* Will also start the device */ |
| 517 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_INIT); |
| 518 | if (ret) { |
| 519 | IWL_ERR(mvm, "Failed to start INIT ucode: %d\n", ret); |
Luca Coelho | 00e0c6c | 2017-07-24 14:47:52 +0300 | [diff] [blame] | 520 | goto remove_notif; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 521 | } |
| 522 | |
Emmanuel Grumbach | b3de3ef | 2017-05-29 14:01:06 +0300 | [diff] [blame] | 523 | if (mvm->cfg->device_family < IWL_DEVICE_FAMILY_8000) { |
| 524 | ret = iwl_mvm_send_bt_init_conf(mvm); |
| 525 | if (ret) |
Luca Coelho | 00e0c6c | 2017-07-24 14:47:52 +0300 | [diff] [blame] | 526 | goto remove_notif; |
Emmanuel Grumbach | b3de3ef | 2017-05-29 14:01:06 +0300 | [diff] [blame] | 527 | } |
Emmanuel Grumbach | 931d416 | 2013-01-17 09:42:25 +0200 | [diff] [blame] | 528 | |
Eytan Lifshitz | 81a67e3 | 2013-09-11 12:39:18 +0200 | [diff] [blame] | 529 | /* Read the NVM only at driver load time, no need to do this twice */ |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 530 | if (read_nvm) { |
Luca Coelho | 5bd1d2c | 2017-08-15 18:46:44 +0300 | [diff] [blame] | 531 | ret = iwl_nvm_init(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 532 | if (ret) { |
| 533 | IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); |
Luca Coelho | 00e0c6c | 2017-07-24 14:47:52 +0300 | [diff] [blame] | 534 | goto remove_notif; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 535 | } |
| 536 | } |
| 537 | |
Eytan Lifshitz | 81a67e3 | 2013-09-11 12:39:18 +0200 | [diff] [blame] | 538 | /* In case we read the NVM from external file, load it to the NIC */ |
Eran Harary | e02a9d6 | 2014-05-07 12:27:10 +0300 | [diff] [blame] | 539 | if (mvm->nvm_file_name) |
Eytan Lifshitz | 81a67e3 | 2013-09-11 12:39:18 +0200 | [diff] [blame] | 540 | iwl_mvm_load_nvm_to_nic(mvm); |
| 541 | |
Luca Coelho | 00e0c6c | 2017-07-24 14:47:52 +0300 | [diff] [blame] | 542 | WARN_ON(iwl_nvm_check_version(mvm->nvm_data, mvm->trans)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 543 | |
Eran Harary | 4f59334 | 2013-05-13 07:53:26 +0300 | [diff] [blame] | 544 | /* |
| 545 | * abort after reading the nvm in case RF Kill is on, we will complete |
| 546 | * the init seq later when RF kill will switch to off |
| 547 | */ |
Arik Nemtsov | 1a3fe0b | 2015-09-30 11:19:55 +0300 | [diff] [blame] | 548 | if (iwl_mvm_is_radio_hw_killed(mvm)) { |
Eran Harary | 4f59334 | 2013-05-13 07:53:26 +0300 | [diff] [blame] | 549 | IWL_DEBUG_RF_KILL(mvm, |
| 550 | "jump over all phy activities due to RF kill\n"); |
Luca Coelho | 00e0c6c | 2017-07-24 14:47:52 +0300 | [diff] [blame] | 551 | goto remove_notif; |
Eran Harary | 4f59334 | 2013-05-13 07:53:26 +0300 | [diff] [blame] | 552 | } |
| 553 | |
Emmanuel Grumbach | 31b8b34 | 2014-11-02 15:48:09 +0200 | [diff] [blame] | 554 | mvm->calibrating = true; |
| 555 | |
Dor Shaish | e07cbb5 | 2013-02-27 23:00:27 +0200 | [diff] [blame] | 556 | /* Send TX valid antennas before triggering calibrations */ |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 557 | ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm)); |
Dor Shaish | e07cbb5 | 2013-02-27 23:00:27 +0200 | [diff] [blame] | 558 | if (ret) |
Luca Coelho | 00e0c6c | 2017-07-24 14:47:52 +0300 | [diff] [blame] | 559 | goto remove_notif; |
Dor Shaish | e07cbb5 | 2013-02-27 23:00:27 +0200 | [diff] [blame] | 560 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 561 | ret = iwl_send_phy_cfg_cmd(mvm); |
| 562 | if (ret) { |
| 563 | IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n", |
| 564 | ret); |
Luca Coelho | 00e0c6c | 2017-07-24 14:47:52 +0300 | [diff] [blame] | 565 | goto remove_notif; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | /* |
| 569 | * Some things may run in the background now, but we |
| 570 | * just wait for the calibration complete notification. |
| 571 | */ |
| 572 | ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait, |
Luca Coelho | 00e0c6c | 2017-07-24 14:47:52 +0300 | [diff] [blame] | 573 | MVM_UCODE_CALIB_TIMEOUT); |
| 574 | if (!ret) |
| 575 | goto out; |
Emmanuel Grumbach | 31b8b34 | 2014-11-02 15:48:09 +0200 | [diff] [blame] | 576 | |
Luca Coelho | 00e0c6c | 2017-07-24 14:47:52 +0300 | [diff] [blame] | 577 | if (iwl_mvm_is_radio_hw_killed(mvm)) { |
Emmanuel Grumbach | 31b8b34 | 2014-11-02 15:48:09 +0200 | [diff] [blame] | 578 | IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n"); |
Luca Coelho | 00e0c6c | 2017-07-24 14:47:52 +0300 | [diff] [blame] | 579 | ret = 0; |
| 580 | } else { |
| 581 | IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n", |
| 582 | ret); |
Emmanuel Grumbach | 31b8b34 | 2014-11-02 15:48:09 +0200 | [diff] [blame] | 583 | } |
Luca Coelho | 00e0c6c | 2017-07-24 14:47:52 +0300 | [diff] [blame] | 584 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 585 | goto out; |
| 586 | |
Luca Coelho | 00e0c6c | 2017-07-24 14:47:52 +0300 | [diff] [blame] | 587 | remove_notif: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 588 | iwl_remove_notification(&mvm->notif_wait, &calib_wait); |
| 589 | out: |
Emmanuel Grumbach | 31b8b34 | 2014-11-02 15:48:09 +0200 | [diff] [blame] | 590 | mvm->calibrating = false; |
Arik Nemtsov | a408284 | 2013-11-24 19:10:46 +0200 | [diff] [blame] | 591 | if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 592 | /* we want to debug INIT and we have no NVM - fake */ |
| 593 | mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) + |
| 594 | sizeof(struct ieee80211_channel) + |
| 595 | sizeof(struct ieee80211_rate), |
| 596 | GFP_KERNEL); |
| 597 | if (!mvm->nvm_data) |
| 598 | return -ENOMEM; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 599 | mvm->nvm_data->bands[0].channels = mvm->nvm_data->channels; |
| 600 | mvm->nvm_data->bands[0].n_channels = 1; |
| 601 | mvm->nvm_data->bands[0].n_bitrates = 1; |
| 602 | mvm->nvm_data->bands[0].bitrates = |
| 603 | (void *)mvm->nvm_data->channels + 1; |
| 604 | mvm->nvm_data->bands[0].bitrates->hw_value = 10; |
| 605 | } |
| 606 | |
| 607 | return ret; |
| 608 | } |
| 609 | |
Emmanuel Grumbach | 84bfffa | 2015-01-13 10:16:30 +0200 | [diff] [blame] | 610 | static int iwl_mvm_config_ltr(struct iwl_mvm *mvm) |
| 611 | { |
| 612 | struct iwl_ltr_config_cmd cmd = { |
| 613 | .flags = cpu_to_le32(LTR_CFG_FLAG_FEATURE_ENABLE), |
| 614 | }; |
| 615 | |
| 616 | if (!mvm->trans->ltr_enabled) |
| 617 | return 0; |
| 618 | |
Emmanuel Grumbach | 84bfffa | 2015-01-13 10:16:30 +0200 | [diff] [blame] | 619 | return iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0, |
| 620 | sizeof(cmd), &cmd); |
| 621 | } |
| 622 | |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 623 | #ifdef CONFIG_ACPI |
Haim Dreyfuss | c386dac | 2016-12-28 15:58:22 +0200 | [diff] [blame] | 624 | static int iwl_mvm_sar_set_profile(struct iwl_mvm *mvm, |
| 625 | union acpi_object *table, |
| 626 | struct iwl_mvm_sar_profile *profile, |
| 627 | bool enabled) |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 628 | { |
Haim Dreyfuss | c386dac | 2016-12-28 15:58:22 +0200 | [diff] [blame] | 629 | int i; |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 630 | |
Haim Dreyfuss | c386dac | 2016-12-28 15:58:22 +0200 | [diff] [blame] | 631 | profile->enabled = enabled; |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 632 | |
Luca Coelho | e7a3b8d | 2017-09-21 13:22:59 +0300 | [diff] [blame] | 633 | for (i = 0; i < ACPI_SAR_TABLE_SIZE; i++) { |
Haim Dreyfuss | c386dac | 2016-12-28 15:58:22 +0200 | [diff] [blame] | 634 | if ((table[i].type != ACPI_TYPE_INTEGER) || |
| 635 | (table[i].integer.value > U8_MAX)) |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 636 | return -EINVAL; |
| 637 | |
Haim Dreyfuss | c386dac | 2016-12-28 15:58:22 +0200 | [diff] [blame] | 638 | profile->table[i] = table[i].integer.value; |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | return 0; |
| 642 | } |
| 643 | |
Haim Dreyfuss | c386dac | 2016-12-28 15:58:22 +0200 | [diff] [blame] | 644 | static int iwl_mvm_sar_get_wrds_table(struct iwl_mvm *mvm) |
| 645 | { |
Luca Coelho | 813df5c | 2017-09-19 12:35:18 +0300 | [diff] [blame] | 646 | union acpi_object *wifi_pkg, *table, *data; |
Haim Dreyfuss | c386dac | 2016-12-28 15:58:22 +0200 | [diff] [blame] | 647 | bool enabled; |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 648 | int ret; |
| 649 | |
Luca Coelho | 813df5c | 2017-09-19 12:35:18 +0300 | [diff] [blame] | 650 | data = iwl_acpi_get_object(mvm->dev, ACPI_WRDS_METHOD); |
| 651 | if (IS_ERR(data)) |
| 652 | return PTR_ERR(data); |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 653 | |
Luca Coelho | 2fa388c | 2017-09-21 14:30:53 +0300 | [diff] [blame] | 654 | wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data, |
| 655 | ACPI_WRDS_WIFI_DATA_SIZE); |
Haim Dreyfuss | c386dac | 2016-12-28 15:58:22 +0200 | [diff] [blame] | 656 | if (IS_ERR(wifi_pkg)) { |
| 657 | ret = PTR_ERR(wifi_pkg); |
| 658 | goto out_free; |
| 659 | } |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 660 | |
Haim Dreyfuss | c386dac | 2016-12-28 15:58:22 +0200 | [diff] [blame] | 661 | if (wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) { |
| 662 | ret = -EINVAL; |
| 663 | goto out_free; |
| 664 | } |
| 665 | |
| 666 | enabled = !!(wifi_pkg->package.elements[1].integer.value); |
| 667 | |
| 668 | /* position of the actual table */ |
| 669 | table = &wifi_pkg->package.elements[2]; |
| 670 | |
| 671 | /* The profile from WRDS is officially profile 1, but goes |
| 672 | * into sar_profiles[0] (because we don't have a profile 0). |
| 673 | */ |
| 674 | ret = iwl_mvm_sar_set_profile(mvm, table, &mvm->sar_profiles[0], |
| 675 | enabled); |
Haim Dreyfuss | c386dac | 2016-12-28 15:58:22 +0200 | [diff] [blame] | 676 | out_free: |
Luca Coelho | 813df5c | 2017-09-19 12:35:18 +0300 | [diff] [blame] | 677 | kfree(data); |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 678 | return ret; |
| 679 | } |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 680 | |
Luca Coelho | 6996490 | 2017-01-12 12:43:12 +0200 | [diff] [blame] | 681 | static int iwl_mvm_sar_get_ewrd_table(struct iwl_mvm *mvm) |
| 682 | { |
Luca Coelho | 813df5c | 2017-09-19 12:35:18 +0300 | [diff] [blame] | 683 | union acpi_object *wifi_pkg, *data; |
Luca Coelho | 6996490 | 2017-01-12 12:43:12 +0200 | [diff] [blame] | 684 | bool enabled; |
| 685 | int i, n_profiles, ret; |
| 686 | |
Luca Coelho | 813df5c | 2017-09-19 12:35:18 +0300 | [diff] [blame] | 687 | data = iwl_acpi_get_object(mvm->dev, ACPI_EWRD_METHOD); |
| 688 | if (IS_ERR(data)) |
| 689 | return PTR_ERR(data); |
Luca Coelho | 6996490 | 2017-01-12 12:43:12 +0200 | [diff] [blame] | 690 | |
Luca Coelho | 2fa388c | 2017-09-21 14:30:53 +0300 | [diff] [blame] | 691 | wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data, |
| 692 | ACPI_EWRD_WIFI_DATA_SIZE); |
Luca Coelho | 6996490 | 2017-01-12 12:43:12 +0200 | [diff] [blame] | 693 | if (IS_ERR(wifi_pkg)) { |
| 694 | ret = PTR_ERR(wifi_pkg); |
| 695 | goto out_free; |
| 696 | } |
| 697 | |
| 698 | if ((wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) || |
| 699 | (wifi_pkg->package.elements[2].type != ACPI_TYPE_INTEGER)) { |
| 700 | ret = -EINVAL; |
| 701 | goto out_free; |
| 702 | } |
| 703 | |
| 704 | enabled = !!(wifi_pkg->package.elements[1].integer.value); |
| 705 | n_profiles = wifi_pkg->package.elements[2].integer.value; |
| 706 | |
Sharon Dvir | e2ef147 | 2017-02-21 11:12:12 +0200 | [diff] [blame] | 707 | /* in case of BIOS bug */ |
| 708 | if (n_profiles <= 0) { |
| 709 | ret = -EINVAL; |
| 710 | goto out_free; |
| 711 | } |
| 712 | |
Luca Coelho | 6996490 | 2017-01-12 12:43:12 +0200 | [diff] [blame] | 713 | for (i = 0; i < n_profiles; i++) { |
| 714 | /* the tables start at element 3 */ |
| 715 | static int pos = 3; |
| 716 | |
| 717 | /* The EWRD profiles officially go from 2 to 4, but we |
| 718 | * save them in sar_profiles[1-3] (because we don't |
| 719 | * have profile 0). So in the array we start from 1. |
| 720 | */ |
| 721 | ret = iwl_mvm_sar_set_profile(mvm, |
| 722 | &wifi_pkg->package.elements[pos], |
| 723 | &mvm->sar_profiles[i + 1], |
| 724 | enabled); |
| 725 | if (ret < 0) |
| 726 | break; |
| 727 | |
| 728 | /* go to the next table */ |
Luca Coelho | e7a3b8d | 2017-09-21 13:22:59 +0300 | [diff] [blame] | 729 | pos += ACPI_SAR_TABLE_SIZE; |
Luca Coelho | 6996490 | 2017-01-12 12:43:12 +0200 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | out_free: |
Luca Coelho | 813df5c | 2017-09-19 12:35:18 +0300 | [diff] [blame] | 733 | kfree(data); |
Luca Coelho | 6996490 | 2017-01-12 12:43:12 +0200 | [diff] [blame] | 734 | return ret; |
| 735 | } |
| 736 | |
Haim Dreyfuss | 7fe90e0 | 2017-03-30 11:16:17 +0300 | [diff] [blame] | 737 | static int iwl_mvm_sar_get_wgds_table(struct iwl_mvm *mvm) |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 738 | { |
Luca Coelho | 813df5c | 2017-09-19 12:35:18 +0300 | [diff] [blame] | 739 | union acpi_object *wifi_pkg, *data; |
Haim Dreyfuss | 7fe90e0 | 2017-03-30 11:16:17 +0300 | [diff] [blame] | 740 | int i, j, ret; |
| 741 | int idx = 1; |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 742 | |
Luca Coelho | 813df5c | 2017-09-19 12:35:18 +0300 | [diff] [blame] | 743 | data = iwl_acpi_get_object(mvm->dev, ACPI_WGDS_METHOD); |
| 744 | if (IS_ERR(data)) |
| 745 | return PTR_ERR(data); |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 746 | |
Luca Coelho | 2fa388c | 2017-09-21 14:30:53 +0300 | [diff] [blame] | 747 | wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data, |
| 748 | ACPI_WGDS_WIFI_DATA_SIZE); |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 749 | if (IS_ERR(wifi_pkg)) { |
| 750 | ret = PTR_ERR(wifi_pkg); |
| 751 | goto out_free; |
| 752 | } |
| 753 | |
Luca Coelho | e7a3b8d | 2017-09-21 13:22:59 +0300 | [diff] [blame] | 754 | for (i = 0; i < ACPI_NUM_GEO_PROFILES; i++) { |
| 755 | for (j = 0; j < ACPI_GEO_TABLE_SIZE; j++) { |
Haim Dreyfuss | 7fe90e0 | 2017-03-30 11:16:17 +0300 | [diff] [blame] | 756 | union acpi_object *entry; |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 757 | |
Haim Dreyfuss | 7fe90e0 | 2017-03-30 11:16:17 +0300 | [diff] [blame] | 758 | entry = &wifi_pkg->package.elements[idx++]; |
| 759 | if ((entry->type != ACPI_TYPE_INTEGER) || |
Christophe Jaillet | aae9d56 | 2017-07-14 12:06:59 +0200 | [diff] [blame] | 760 | (entry->integer.value > U8_MAX)) { |
| 761 | ret = -EINVAL; |
| 762 | goto out_free; |
| 763 | } |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 764 | |
Haim Dreyfuss | 7fe90e0 | 2017-03-30 11:16:17 +0300 | [diff] [blame] | 765 | mvm->geo_profiles[i].values[j] = entry->integer.value; |
| 766 | } |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 767 | } |
| 768 | ret = 0; |
| 769 | out_free: |
Luca Coelho | 813df5c | 2017-09-19 12:35:18 +0300 | [diff] [blame] | 770 | kfree(data); |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 771 | return ret; |
| 772 | } |
| 773 | |
Luca Coelho | 42ce76d | 2017-01-11 23:36:30 +0200 | [diff] [blame] | 774 | int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b) |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 775 | { |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 776 | struct iwl_dev_tx_power_cmd cmd = { |
Luca Coelho | 4b87e5a | 2016-09-12 16:03:30 +0300 | [diff] [blame] | 777 | .v3.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_CHAINS), |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 778 | }; |
Luca Coelho | 42ce76d | 2017-01-11 23:36:30 +0200 | [diff] [blame] | 779 | int i, j, idx; |
Luca Coelho | e7a3b8d | 2017-09-21 13:22:59 +0300 | [diff] [blame] | 780 | int profs[ACPI_SAR_NUM_CHAIN_LIMITS] = { prof_a, prof_b }; |
Luca Coelho | 55bfa4b | 2016-06-29 00:38:40 +0300 | [diff] [blame] | 781 | int len = sizeof(cmd); |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 782 | |
Luca Coelho | e7a3b8d | 2017-09-21 13:22:59 +0300 | [diff] [blame] | 783 | BUILD_BUG_ON(ACPI_SAR_NUM_CHAIN_LIMITS < 2); |
| 784 | BUILD_BUG_ON(ACPI_SAR_NUM_CHAIN_LIMITS * ACPI_SAR_NUM_SUB_BANDS != |
| 785 | ACPI_SAR_TABLE_SIZE); |
Luca Coelho | 42ce76d | 2017-01-11 23:36:30 +0200 | [diff] [blame] | 786 | |
Luca Coelho | 55bfa4b | 2016-06-29 00:38:40 +0300 | [diff] [blame] | 787 | if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TX_POWER_ACK)) |
| 788 | len = sizeof(cmd.v3); |
| 789 | |
Luca Coelho | e7a3b8d | 2017-09-21 13:22:59 +0300 | [diff] [blame] | 790 | for (i = 0; i < ACPI_SAR_NUM_CHAIN_LIMITS; i++) { |
Luca Coelho | 42ce76d | 2017-01-11 23:36:30 +0200 | [diff] [blame] | 791 | struct iwl_mvm_sar_profile *prof; |
| 792 | |
| 793 | /* don't allow SAR to be disabled (profile 0 means disable) */ |
| 794 | if (profs[i] == 0) |
| 795 | return -EPERM; |
| 796 | |
Luca Coelho | e7a3b8d | 2017-09-21 13:22:59 +0300 | [diff] [blame] | 797 | /* we are off by one, so allow up to ACPI_SAR_PROFILE_NUM */ |
| 798 | if (profs[i] > ACPI_SAR_PROFILE_NUM) |
Luca Coelho | 42ce76d | 2017-01-11 23:36:30 +0200 | [diff] [blame] | 799 | return -EINVAL; |
| 800 | |
| 801 | /* profiles go from 1 to 4, so decrement to access the array */ |
| 802 | prof = &mvm->sar_profiles[profs[i] - 1]; |
| 803 | |
| 804 | /* if the profile is disabled, do nothing */ |
| 805 | if (!prof->enabled) { |
| 806 | IWL_DEBUG_RADIO(mvm, "SAR profile %d is disabled.\n", |
| 807 | profs[i]); |
| 808 | /* if one of the profiles is disabled, we fail all */ |
| 809 | return -ENOENT; |
| 810 | } |
| 811 | |
| 812 | IWL_DEBUG_RADIO(mvm, " Chain[%d]:\n", i); |
Luca Coelho | e7a3b8d | 2017-09-21 13:22:59 +0300 | [diff] [blame] | 813 | for (j = 0; j < ACPI_SAR_NUM_SUB_BANDS; j++) { |
| 814 | idx = (i * ACPI_SAR_NUM_SUB_BANDS) + j; |
Luca Coelho | 42ce76d | 2017-01-11 23:36:30 +0200 | [diff] [blame] | 815 | cmd.v3.per_chain_restriction[i][j] = |
| 816 | cpu_to_le16(prof->table[idx]); |
| 817 | IWL_DEBUG_RADIO(mvm, " Band[%d] = %d * .125dBm\n", |
| 818 | j, prof->table[idx]); |
| 819 | } |
| 820 | } |
| 821 | |
| 822 | IWL_DEBUG_RADIO(mvm, "Sending REDUCE_TX_POWER_CMD per chain\n"); |
| 823 | |
| 824 | return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd); |
| 825 | } |
| 826 | |
Haim Dreyfuss | 7fe90e0 | 2017-03-30 11:16:17 +0300 | [diff] [blame] | 827 | int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm) |
| 828 | { |
| 829 | struct iwl_geo_tx_power_profiles_resp *resp; |
| 830 | int ret; |
| 831 | |
| 832 | struct iwl_geo_tx_power_profiles_cmd geo_cmd = { |
| 833 | .ops = cpu_to_le32(IWL_PER_CHAIN_OFFSET_GET_CURRENT_TABLE), |
| 834 | }; |
| 835 | struct iwl_host_cmd cmd = { |
| 836 | .id = WIDE_ID(PHY_OPS_GROUP, GEO_TX_POWER_LIMIT), |
| 837 | .len = { sizeof(geo_cmd), }, |
| 838 | .flags = CMD_WANT_SKB, |
| 839 | .data = { &geo_cmd }, |
| 840 | }; |
| 841 | |
| 842 | ret = iwl_mvm_send_cmd(mvm, &cmd); |
| 843 | if (ret) { |
| 844 | IWL_ERR(mvm, "Failed to get geographic profile info %d\n", ret); |
| 845 | return ret; |
| 846 | } |
| 847 | |
| 848 | resp = (void *)cmd.resp_pkt->data; |
| 849 | ret = le32_to_cpu(resp->profile_idx); |
Luca Coelho | e7a3b8d | 2017-09-21 13:22:59 +0300 | [diff] [blame] | 850 | if (WARN_ON(ret > ACPI_NUM_GEO_PROFILES)) { |
Haim Dreyfuss | 7fe90e0 | 2017-03-30 11:16:17 +0300 | [diff] [blame] | 851 | ret = -EIO; |
| 852 | IWL_WARN(mvm, "Invalid geographic profile idx (%d)\n", ret); |
| 853 | } |
| 854 | |
| 855 | iwl_free_resp(&cmd); |
| 856 | return ret; |
| 857 | } |
| 858 | |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 859 | static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm) |
| 860 | { |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 861 | struct iwl_geo_tx_power_profiles_cmd cmd = { |
| 862 | .ops = cpu_to_le32(IWL_PER_CHAIN_OFFSET_SET_TABLES), |
| 863 | }; |
Haim Dreyfuss | 7fe90e0 | 2017-03-30 11:16:17 +0300 | [diff] [blame] | 864 | int ret, i, j; |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 865 | u16 cmd_wide_id = WIDE_ID(PHY_OPS_GROUP, GEO_TX_POWER_LIMIT); |
| 866 | |
Haim Dreyfuss | 7fe90e0 | 2017-03-30 11:16:17 +0300 | [diff] [blame] | 867 | ret = iwl_mvm_sar_get_wgds_table(mvm); |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 868 | if (ret < 0) { |
| 869 | IWL_DEBUG_RADIO(mvm, |
| 870 | "Geo SAR BIOS table invalid or unavailable. (%d)\n", |
| 871 | ret); |
| 872 | /* we don't fail if the table is not available */ |
| 873 | return 0; |
| 874 | } |
| 875 | |
| 876 | IWL_DEBUG_RADIO(mvm, "Sending GEO_TX_POWER_LIMIT\n"); |
| 877 | |
Luca Coelho | e7a3b8d | 2017-09-21 13:22:59 +0300 | [diff] [blame] | 878 | BUILD_BUG_ON(ACPI_NUM_GEO_PROFILES * ACPI_WGDS_NUM_BANDS * |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 879 | ACPI_WGDS_TABLE_SIZE != ACPI_WGDS_WIFI_DATA_SIZE); |
| 880 | |
Luca Coelho | e7a3b8d | 2017-09-21 13:22:59 +0300 | [diff] [blame] | 881 | BUILD_BUG_ON(ACPI_NUM_GEO_PROFILES > IWL_NUM_GEO_PROFILES); |
| 882 | |
| 883 | for (i = 0; i < ACPI_NUM_GEO_PROFILES; i++) { |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 884 | struct iwl_per_chain_offset *chain = |
| 885 | (struct iwl_per_chain_offset *)&cmd.table[i]; |
| 886 | |
| 887 | for (j = 0; j < ACPI_WGDS_NUM_BANDS; j++) { |
| 888 | u8 *value; |
| 889 | |
Haim Dreyfuss | 7fe90e0 | 2017-03-30 11:16:17 +0300 | [diff] [blame] | 890 | value = &mvm->geo_profiles[i].values[j * |
Luca Coelho | e7a3b8d | 2017-09-21 13:22:59 +0300 | [diff] [blame] | 891 | ACPI_GEO_PER_CHAIN_SIZE]; |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 892 | chain[j].max_tx_power = cpu_to_le16(value[0]); |
| 893 | chain[j].chain_a = value[1]; |
| 894 | chain[j].chain_b = value[2]; |
| 895 | IWL_DEBUG_RADIO(mvm, |
| 896 | "SAR geographic profile[%d] Band[%d]: chain A = %d chain B = %d max_tx_power = %d\n", |
| 897 | i, j, value[1], value[2], value[0]); |
| 898 | } |
| 899 | } |
| 900 | return iwl_mvm_send_cmd_pdu(mvm, cmd_wide_id, 0, sizeof(cmd), &cmd); |
| 901 | } |
| 902 | |
Luca Coelho | 6996490 | 2017-01-12 12:43:12 +0200 | [diff] [blame] | 903 | #else /* CONFIG_ACPI */ |
| 904 | static int iwl_mvm_sar_get_wrds_table(struct iwl_mvm *mvm) |
| 905 | { |
| 906 | return -ENOENT; |
| 907 | } |
| 908 | |
| 909 | static int iwl_mvm_sar_get_ewrd_table(struct iwl_mvm *mvm) |
| 910 | { |
| 911 | return -ENOENT; |
| 912 | } |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 913 | |
| 914 | static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm) |
| 915 | { |
| 916 | return 0; |
| 917 | } |
Luca Coelho | 18f1755 | 2017-07-26 15:20:18 +0300 | [diff] [blame] | 918 | |
| 919 | int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, |
| 920 | int prof_b) |
| 921 | { |
| 922 | return -ENOENT; |
| 923 | } |
| 924 | |
| 925 | int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm) |
| 926 | { |
| 927 | return -ENOENT; |
| 928 | } |
Luca Coelho | 6996490 | 2017-01-12 12:43:12 +0200 | [diff] [blame] | 929 | #endif /* CONFIG_ACPI */ |
| 930 | |
Luca Coelho | 42ce76d | 2017-01-11 23:36:30 +0200 | [diff] [blame] | 931 | static int iwl_mvm_sar_init(struct iwl_mvm *mvm) |
| 932 | { |
| 933 | int ret; |
| 934 | |
Haim Dreyfuss | c386dac | 2016-12-28 15:58:22 +0200 | [diff] [blame] | 935 | ret = iwl_mvm_sar_get_wrds_table(mvm); |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 936 | if (ret < 0) { |
| 937 | IWL_DEBUG_RADIO(mvm, |
Luca Coelho | 6996490 | 2017-01-12 12:43:12 +0200 | [diff] [blame] | 938 | "WRDS SAR BIOS table invalid or unavailable. (%d)\n", |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 939 | ret); |
Luca Coelho | 6996490 | 2017-01-12 12:43:12 +0200 | [diff] [blame] | 940 | /* if not available, don't fail and don't bother with EWRD */ |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 941 | return 0; |
| 942 | } |
| 943 | |
Luca Coelho | 6996490 | 2017-01-12 12:43:12 +0200 | [diff] [blame] | 944 | ret = iwl_mvm_sar_get_ewrd_table(mvm); |
| 945 | /* if EWRD is not available, we can still use WRDS, so don't fail */ |
| 946 | if (ret < 0) |
| 947 | IWL_DEBUG_RADIO(mvm, |
| 948 | "EWRD SAR BIOS table invalid or unavailable. (%d)\n", |
| 949 | ret); |
| 950 | |
Luca Coelho | 42ce76d | 2017-01-11 23:36:30 +0200 | [diff] [blame] | 951 | /* choose profile 1 (WRDS) as default for both chains */ |
| 952 | ret = iwl_mvm_sar_select_profile(mvm, 1, 1); |
| 953 | |
| 954 | /* if we don't have profile 0 from BIOS, just skip it */ |
| 955 | if (ret == -ENOENT) |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 956 | return 0; |
| 957 | |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 958 | return ret; |
| 959 | } |
| 960 | |
Sara Sharon | 1f37065 | 2016-08-31 18:13:57 +0300 | [diff] [blame] | 961 | static int iwl_mvm_load_rt_fw(struct iwl_mvm *mvm) |
| 962 | { |
| 963 | int ret; |
| 964 | |
Johannes Berg | 7d6222e2 | 2017-06-08 09:18:22 +0200 | [diff] [blame] | 965 | if (iwl_mvm_has_unified_ucode(mvm)) |
Sara Sharon | 1f37065 | 2016-08-31 18:13:57 +0300 | [diff] [blame] | 966 | return iwl_run_unified_mvm_ucode(mvm, false); |
| 967 | |
| 968 | ret = iwl_run_init_mvm_ucode(mvm, false); |
| 969 | |
Sara Sharon | 1f37065 | 2016-08-31 18:13:57 +0300 | [diff] [blame] | 970 | if (ret) { |
| 971 | IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret); |
Liad Kaufman | f474425 | 2017-11-23 10:29:04 +0200 | [diff] [blame] | 972 | |
| 973 | if (iwlmvm_mod_params.init_dbg) |
| 974 | return 0; |
Sara Sharon | 1f37065 | 2016-08-31 18:13:57 +0300 | [diff] [blame] | 975 | return ret; |
| 976 | } |
| 977 | |
| 978 | /* |
| 979 | * Stop and start the transport without entering low power |
| 980 | * mode. This will save the state of other components on the |
| 981 | * device that are triggered by the INIT firwmare (MFUART). |
| 982 | */ |
| 983 | _iwl_trans_stop_device(mvm->trans, false); |
| 984 | ret = _iwl_trans_start_hw(mvm->trans, false); |
| 985 | if (ret) |
| 986 | return ret; |
| 987 | |
| 988 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR); |
| 989 | if (ret) |
| 990 | return ret; |
| 991 | |
Johannes Berg | 702e975 | 2017-06-02 11:56:58 +0200 | [diff] [blame] | 992 | return iwl_init_paging(&mvm->fwrt, mvm->fwrt.cur_fw_img); |
Sara Sharon | 1f37065 | 2016-08-31 18:13:57 +0300 | [diff] [blame] | 993 | } |
| 994 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 995 | int iwl_mvm_up(struct iwl_mvm *mvm) |
| 996 | { |
| 997 | int ret, i; |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 998 | struct ieee80211_channel *chan; |
| 999 | struct cfg80211_chan_def chandef; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1000 | |
| 1001 | lockdep_assert_held(&mvm->mutex); |
| 1002 | |
| 1003 | ret = iwl_trans_start_hw(mvm->trans); |
| 1004 | if (ret) |
| 1005 | return ret; |
| 1006 | |
Sara Sharon | 1f37065 | 2016-08-31 18:13:57 +0300 | [diff] [blame] | 1007 | ret = iwl_mvm_load_rt_fw(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1008 | if (ret) { |
| 1009 | IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret); |
| 1010 | goto error; |
| 1011 | } |
| 1012 | |
Johannes Berg | d0b813f | 2017-06-01 14:44:40 +0200 | [diff] [blame] | 1013 | iwl_get_shared_mem_conf(&mvm->fwrt); |
Liad Kaufman | 04fd2c2 | 2014-12-15 17:54:16 +0200 | [diff] [blame] | 1014 | |
Lilach Edelstein | 1f3b0ff | 2013-10-06 13:03:32 +0200 | [diff] [blame] | 1015 | ret = iwl_mvm_sf_update(mvm, NULL, false); |
| 1016 | if (ret) |
| 1017 | IWL_ERR(mvm, "Failed to initialize Smart Fifo\n"); |
| 1018 | |
Johannes Berg | 7174beb | 2017-06-01 16:03:19 +0200 | [diff] [blame] | 1019 | mvm->fwrt.dump.conf = FW_DBG_INVALID; |
Emmanuel Grumbach | 945d420 | 2015-02-15 17:16:16 +0200 | [diff] [blame] | 1020 | /* if we have a destination, assume EARLY START */ |
| 1021 | if (mvm->fw->dbg_dest_tlv) |
Johannes Berg | 7174beb | 2017-06-01 16:03:19 +0200 | [diff] [blame] | 1022 | mvm->fwrt.dump.conf = FW_DBG_START_FROM_ALIVE; |
| 1023 | iwl_fw_start_dbg_conf(&mvm->fwrt, FW_DBG_START_FROM_ALIVE); |
Liad Kaufman | 6a95126 | 2014-11-17 11:36:21 +0200 | [diff] [blame] | 1024 | |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 1025 | ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1026 | if (ret) |
| 1027 | goto error; |
| 1028 | |
Johannes Berg | 7d6222e2 | 2017-06-08 09:18:22 +0200 | [diff] [blame] | 1029 | if (!iwl_mvm_has_unified_ucode(mvm)) { |
| 1030 | /* Send phy db control command and then phy db calibration */ |
Sara Sharon | 1f37065 | 2016-08-31 18:13:57 +0300 | [diff] [blame] | 1031 | ret = iwl_send_phy_db_data(mvm->phy_db); |
| 1032 | if (ret) |
| 1033 | goto error; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1034 | |
Sara Sharon | 1f37065 | 2016-08-31 18:13:57 +0300 | [diff] [blame] | 1035 | ret = iwl_send_phy_cfg_cmd(mvm); |
| 1036 | if (ret) |
| 1037 | goto error; |
| 1038 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1039 | |
Emmanuel Grumbach | b3de3ef | 2017-05-29 14:01:06 +0300 | [diff] [blame] | 1040 | ret = iwl_mvm_send_bt_init_conf(mvm); |
| 1041 | if (ret) |
| 1042 | goto error; |
| 1043 | |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 1044 | /* Init RSS configuration */ |
Sara Sharon | 8edbfaa | 2018-02-05 12:42:44 +0200 | [diff] [blame^] | 1045 | if (mvm->trans->cfg->device_family >= IWL_DEVICE_FAMILY_22000) { |
| 1046 | ret = iwl_configure_rxq(mvm); |
| 1047 | if (ret) { |
| 1048 | IWL_ERR(mvm, "Failed to configure RX queues: %d\n", |
| 1049 | ret); |
| 1050 | goto error; |
| 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | if (iwl_mvm_has_new_rx_api(mvm)) { |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 1055 | ret = iwl_send_rss_cfg_cmd(mvm); |
| 1056 | if (ret) { |
| 1057 | IWL_ERR(mvm, "Failed to configure RSS queues: %d\n", |
| 1058 | ret); |
| 1059 | goto error; |
| 1060 | } |
| 1061 | } |
| 1062 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1063 | /* init the fw <-> mac80211 STA mapping */ |
Sara Sharon | 0ae9881 | 2017-01-04 14:53:58 +0200 | [diff] [blame] | 1064 | for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1065 | RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); |
| 1066 | |
Sara Sharon | 0ae9881 | 2017-01-04 14:53:58 +0200 | [diff] [blame] | 1067 | mvm->tdls_cs.peer.sta_id = IWL_MVM_INVALID_STA; |
Arik Nemtsov | 1d3c3f6 | 2014-10-23 18:03:10 +0300 | [diff] [blame] | 1068 | |
Johannes Berg | b2b7875 | 2014-09-08 16:42:54 +0200 | [diff] [blame] | 1069 | /* reset quota debouncing buffer - 0xff will yield invalid data */ |
| 1070 | memset(&mvm->last_quota_cmd, 0xff, sizeof(mvm->last_quota_cmd)); |
| 1071 | |
Johannes Berg | c8f5470 | 2017-06-19 23:50:31 +0200 | [diff] [blame] | 1072 | ret = iwl_mvm_send_dqa_cmd(mvm); |
| 1073 | if (ret) |
| 1074 | goto error; |
Liad Kaufman | 97d5be7 | 2015-08-31 14:33:23 +0300 | [diff] [blame] | 1075 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1076 | /* Add auxiliary station for scanning */ |
| 1077 | ret = iwl_mvm_add_aux_sta(mvm); |
| 1078 | if (ret) |
| 1079 | goto error; |
| 1080 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1081 | /* Add all the PHY contexts */ |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 1082 | chan = &mvm->hw->wiphy->bands[NL80211_BAND_2GHZ]->channels[0]; |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1083 | cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT); |
| 1084 | for (i = 0; i < NUM_PHY_CTX; i++) { |
| 1085 | /* |
| 1086 | * The channel used here isn't relevant as it's |
| 1087 | * going to be overwritten in the other flows. |
| 1088 | * For now use the first channel we have. |
| 1089 | */ |
| 1090 | ret = iwl_mvm_phy_ctxt_add(mvm, &mvm->phy_ctxts[i], |
| 1091 | &chandef, 1, 1); |
| 1092 | if (ret) |
| 1093 | goto error; |
| 1094 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1095 | |
Chaya Rachel Ivgi | c221daf | 2015-12-29 09:54:49 +0200 | [diff] [blame] | 1096 | #ifdef CONFIG_THERMAL |
| 1097 | if (iwl_mvm_is_tt_in_fw(mvm)) { |
| 1098 | /* in order to give the responsibility of ct-kill and |
| 1099 | * TX backoff to FW we need to send empty temperature reporting |
| 1100 | * cmd during init time |
| 1101 | */ |
| 1102 | iwl_mvm_send_temp_report_ths_cmd(mvm); |
| 1103 | } else { |
| 1104 | /* Initialize tx backoffs to the minimal possible */ |
| 1105 | iwl_mvm_tt_tx_backoff(mvm, 0); |
| 1106 | } |
Chaya Rachel Ivgi | 5c89e7b | 2016-01-05 10:34:47 +0200 | [diff] [blame] | 1107 | |
| 1108 | /* TODO: read the budget from BIOS / Platform NVM */ |
Chaya Rachel Ivgi | 944eafc | 2017-07-09 16:35:14 +0300 | [diff] [blame] | 1109 | |
| 1110 | /* |
| 1111 | * In case there is no budget from BIOS / Platform NVM the default |
| 1112 | * budget should be 2000mW (cooling state 0). |
| 1113 | */ |
| 1114 | if (iwl_mvm_is_ctdp_supported(mvm)) { |
Chaya Rachel Ivgi | 5c89e7b | 2016-01-05 10:34:47 +0200 | [diff] [blame] | 1115 | ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START, |
| 1116 | mvm->cooling_dev.cur_state); |
Luca Coelho | 75cfe33 | 2016-09-14 11:54:36 +0300 | [diff] [blame] | 1117 | if (ret) |
| 1118 | goto error; |
| 1119 | } |
Chaya Rachel Ivgi | c221daf | 2015-12-29 09:54:49 +0200 | [diff] [blame] | 1120 | #else |
Ido Yariv | 0c0e2c7 | 2014-01-16 21:12:02 -0500 | [diff] [blame] | 1121 | /* Initialize tx backoffs to the minimal possible */ |
| 1122 | iwl_mvm_tt_tx_backoff(mvm, 0); |
Chaya Rachel Ivgi | c221daf | 2015-12-29 09:54:49 +0200 | [diff] [blame] | 1123 | #endif |
Ido Yariv | 0c0e2c7 | 2014-01-16 21:12:02 -0500 | [diff] [blame] | 1124 | |
Emmanuel Grumbach | 84bfffa | 2015-01-13 10:16:30 +0200 | [diff] [blame] | 1125 | WARN_ON(iwl_mvm_config_ltr(mvm)); |
Emmanuel Grumbach | 9180ac5 | 2014-09-23 23:02:41 +0300 | [diff] [blame] | 1126 | |
Emmanuel Grumbach | c1cb92f | 2014-01-28 10:17:18 +0200 | [diff] [blame] | 1127 | ret = iwl_mvm_power_update_device(mvm); |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 1128 | if (ret) |
| 1129 | goto error; |
| 1130 | |
Arik Nemtsov | 35af15d | 2015-03-04 15:08:00 +0200 | [diff] [blame] | 1131 | /* |
| 1132 | * RTNL is not taken during Ct-kill, but we don't need to scan/Tx |
| 1133 | * anyway, so don't init MCC. |
| 1134 | */ |
| 1135 | if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) { |
| 1136 | ret = iwl_mvm_init_mcc(mvm); |
| 1137 | if (ret) |
| 1138 | goto error; |
| 1139 | } |
Arik Nemtsov | 90d4f7d | 2014-03-04 19:58:46 +0200 | [diff] [blame] | 1140 | |
Johannes Berg | 859d914 | 2015-06-01 17:11:11 +0200 | [diff] [blame] | 1141 | if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { |
Emmanuel Grumbach | 4ca87a5 | 2016-01-03 22:23:40 +0200 | [diff] [blame] | 1142 | mvm->scan_type = IWL_SCAN_TYPE_NOT_SET; |
Sara Sharon | b66b581 | 2017-01-31 10:39:44 +0200 | [diff] [blame] | 1143 | mvm->hb_scan_type = IWL_SCAN_TYPE_NOT_SET; |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1144 | ret = iwl_mvm_config_scan(mvm); |
| 1145 | if (ret) |
| 1146 | goto error; |
| 1147 | } |
| 1148 | |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 1149 | /* allow FW/transport low power modes if not during restart */ |
| 1150 | if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
| 1151 | iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN); |
| 1152 | |
Luca Coelho | da2830a | 2016-05-30 13:00:44 +0300 | [diff] [blame] | 1153 | ret = iwl_mvm_sar_init(mvm); |
| 1154 | if (ret) |
| 1155 | goto error; |
| 1156 | |
Haim Dreyfuss | a6bff3c | 2017-01-19 12:00:46 +0200 | [diff] [blame] | 1157 | ret = iwl_mvm_sar_geo_init(mvm); |
| 1158 | if (ret) |
| 1159 | goto error; |
| 1160 | |
Johannes Berg | 7089ae6 | 2017-06-28 16:19:49 +0200 | [diff] [blame] | 1161 | iwl_mvm_leds_sync(mvm); |
| 1162 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1163 | IWL_DEBUG_INFO(mvm, "RT uCode started.\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1164 | return 0; |
| 1165 | error: |
Liad Kaufman | f474425 | 2017-11-23 10:29:04 +0200 | [diff] [blame] | 1166 | if (!iwlmvm_mod_params.init_dbg || !ret) |
Liad Kaufman | de8ba41 | 2017-03-16 13:00:59 +0200 | [diff] [blame] | 1167 | iwl_mvm_stop_device(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1168 | return ret; |
| 1169 | } |
| 1170 | |
| 1171 | int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm) |
| 1172 | { |
| 1173 | int ret, i; |
| 1174 | |
| 1175 | lockdep_assert_held(&mvm->mutex); |
| 1176 | |
| 1177 | ret = iwl_trans_start_hw(mvm->trans); |
| 1178 | if (ret) |
| 1179 | return ret; |
| 1180 | |
| 1181 | ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_WOWLAN); |
| 1182 | if (ret) { |
| 1183 | IWL_ERR(mvm, "Failed to start WoWLAN firmware: %d\n", ret); |
| 1184 | goto error; |
| 1185 | } |
| 1186 | |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 1187 | ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1188 | if (ret) |
| 1189 | goto error; |
| 1190 | |
| 1191 | /* Send phy db control command and then phy db calibration*/ |
| 1192 | ret = iwl_send_phy_db_data(mvm->phy_db); |
| 1193 | if (ret) |
| 1194 | goto error; |
| 1195 | |
| 1196 | ret = iwl_send_phy_cfg_cmd(mvm); |
| 1197 | if (ret) |
| 1198 | goto error; |
| 1199 | |
| 1200 | /* init the fw <-> mac80211 STA mapping */ |
Sara Sharon | 0ae9881 | 2017-01-04 14:53:58 +0200 | [diff] [blame] | 1201 | for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1202 | RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); |
| 1203 | |
| 1204 | /* Add auxiliary station for scanning */ |
| 1205 | ret = iwl_mvm_add_aux_sta(mvm); |
| 1206 | if (ret) |
| 1207 | goto error; |
| 1208 | |
| 1209 | return 0; |
| 1210 | error: |
Chaya Rachel Ivgi | fcb6b92 | 2016-02-22 10:21:41 +0200 | [diff] [blame] | 1211 | iwl_mvm_stop_device(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1212 | return ret; |
| 1213 | } |
| 1214 | |
Johannes Berg | 0416841 | 2015-06-23 21:22:09 +0200 | [diff] [blame] | 1215 | void iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm, |
| 1216 | struct iwl_rx_cmd_buffer *rxb) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1217 | { |
| 1218 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 1219 | struct iwl_card_state_notif *card_state_notif = (void *)pkt->data; |
| 1220 | u32 flags = le32_to_cpu(card_state_notif->flags); |
| 1221 | |
| 1222 | IWL_DEBUG_RF_KILL(mvm, "Card state received: HW:%s SW:%s CT:%s\n", |
| 1223 | (flags & HW_CARD_DISABLED) ? "Kill" : "On", |
| 1224 | (flags & SW_CARD_DISABLED) ? "Kill" : "On", |
| 1225 | (flags & CT_KILL_CARD_DISABLED) ? |
| 1226 | "Reached" : "Not reached"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1227 | } |
| 1228 | |
Johannes Berg | 0416841 | 2015-06-23 21:22:09 +0200 | [diff] [blame] | 1229 | void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm, |
| 1230 | struct iwl_rx_cmd_buffer *rxb) |
Chaya Rachel Ivgy | 30269c1 | 2014-11-15 21:08:29 +0200 | [diff] [blame] | 1231 | { |
| 1232 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 1233 | struct iwl_mfuart_load_notif *mfuart_notif = (void *)pkt->data; |
| 1234 | |
Golan Ben-Ami | 0c8d0a4 | 2017-01-25 15:11:30 +0200 | [diff] [blame] | 1235 | IWL_DEBUG_INFO(mvm, |
| 1236 | "MFUART: installed ver: 0x%08x, external ver: 0x%08x, status: 0x%08x, duration: 0x%08x\n", |
| 1237 | le32_to_cpu(mfuart_notif->installed_ver), |
| 1238 | le32_to_cpu(mfuart_notif->external_ver), |
| 1239 | le32_to_cpu(mfuart_notif->status), |
| 1240 | le32_to_cpu(mfuart_notif->duration)); |
| 1241 | |
Golan Ben-Ami | 19f63c5 | 2016-11-07 17:40:43 +0200 | [diff] [blame] | 1242 | if (iwl_rx_packet_payload_len(pkt) == sizeof(*mfuart_notif)) |
| 1243 | IWL_DEBUG_INFO(mvm, |
Golan Ben-Ami | 0c8d0a4 | 2017-01-25 15:11:30 +0200 | [diff] [blame] | 1244 | "MFUART: image size: 0x%08x\n", |
Golan Ben-Ami | 19f63c5 | 2016-11-07 17:40:43 +0200 | [diff] [blame] | 1245 | le32_to_cpu(mfuart_notif->image_size)); |
Chaya Rachel Ivgy | 30269c1 | 2014-11-15 21:08:29 +0200 | [diff] [blame] | 1246 | } |