Lines Matching +full:memcpy +full:- +full:channels
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2012-2014, 2018-2019, 2021-2024 Intel Corporation
4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5 * Copyright (C) 2016-2017 Intel Deutschland GmbH
9 #include "iwl-trans.h"
10 #include "iwl-csr.h"
12 #include "iwl-nvm-utils.h"
13 #include "iwl-nvm-parse.h"
14 #include "iwl-prph.h"
60 nvm_resp = (void *)pkt->data; in iwl_nvm_write_chunk()
61 if (le16_to_cpu(nvm_resp->status) != READ_NVM_CHUNK_SUCCEED) { in iwl_nvm_write_chunk()
64 section, le16_to_cpu(nvm_resp->status)); in iwl_nvm_write_chunk()
65 ret = -EIO; in iwl_nvm_write_chunk()
100 nvm_resp = (void *)pkt->data; in iwl_nvm_read_chunk()
101 ret = le16_to_cpu(nvm_resp->status); in iwl_nvm_read_chunk()
102 bytes_read = le16_to_cpu(nvm_resp->length); in iwl_nvm_read_chunk()
103 offset_read = le16_to_cpu(nvm_resp->offset); in iwl_nvm_read_chunk()
104 resp_data = nvm_resp->data; in iwl_nvm_read_chunk()
116 IWL_DEBUG_EEPROM(mvm->trans->dev, in iwl_nvm_read_chunk()
121 IWL_DEBUG_EEPROM(mvm->trans->dev, in iwl_nvm_read_chunk()
123 ret, mvm->trans->name); in iwl_nvm_read_chunk()
124 ret = -ENODATA; in iwl_nvm_read_chunk()
132 ret = -EINVAL; in iwl_nvm_read_chunk()
137 memcpy(data + offset, resp_data, bytes_read); in iwl_nvm_read_chunk()
156 length - offset); in iwl_nvm_write_section()
194 mvm->trans->trans_cfg->base_params->eeprom_size) { in iwl_nvm_read_section()
196 return -ENOBUFS; in iwl_nvm_read_section()
201 IWL_DEBUG_EEPROM(mvm->trans->dev, in iwl_nvm_read_section()
209 iwl_nvm_fixups(mvm->trans->hw_id, section, data, offset); in iwl_nvm_read_section()
211 IWL_DEBUG_EEPROM(mvm->trans->dev, in iwl_nvm_read_section()
219 struct iwl_nvm_section *sections = mvm->nvm_sections; in iwl_parse_nvm_sections()
222 u8 tx_ant = mvm->fw->valid_tx_ant; in iwl_parse_nvm_sections()
223 u8 rx_ant = mvm->fw->valid_rx_ant; in iwl_parse_nvm_sections()
227 if (mvm->trans->cfg->nvm_type == IWL_NVM) { in iwl_parse_nvm_sections()
228 if (!mvm->nvm_sections[NVM_SECTION_TYPE_SW].data || in iwl_parse_nvm_sections()
229 !mvm->nvm_sections[mvm->cfg->nvm_hw_section_num].data) { in iwl_parse_nvm_sections()
234 if (mvm->trans->cfg->nvm_type == IWL_NVM_SDP) in iwl_parse_nvm_sections()
240 if (!mvm->nvm_sections[NVM_SECTION_TYPE_SW].data || in iwl_parse_nvm_sections()
241 !mvm->nvm_sections[regulatory_type].data) { in iwl_parse_nvm_sections()
247 if (!mvm->nvm_sections[mvm->cfg->nvm_hw_section_num].data && in iwl_parse_nvm_sections()
248 !mvm->nvm_sections[NVM_SECTION_TYPE_MAC_OVERRIDE].data) { in iwl_parse_nvm_sections()
255 if (mvm->trans->cfg->nvm_type == IWL_NVM_EXT && in iwl_parse_nvm_sections()
256 !mvm->nvm_sections[NVM_SECTION_TYPE_PHY_SKU].data) { in iwl_parse_nvm_sections()
263 hw = (const __be16 *)sections[mvm->cfg->nvm_hw_section_num].data; in iwl_parse_nvm_sections()
270 regulatory = mvm->trans->cfg->nvm_type == IWL_NVM_SDP ? in iwl_parse_nvm_sections()
274 if (mvm->set_tx_ant) in iwl_parse_nvm_sections()
275 tx_ant &= mvm->set_tx_ant; in iwl_parse_nvm_sections()
277 if (mvm->set_rx_ant) in iwl_parse_nvm_sections()
278 rx_ant &= mvm->set_rx_ant; in iwl_parse_nvm_sections()
280 return iwl_parse_nvm_data(mvm->trans, mvm->cfg, mvm->fw, hw, sw, calib, in iwl_parse_nvm_sections()
285 /* Loads the NVM data stored in mvm->nvm_sections into the NIC */
289 struct iwl_nvm_section *sections = mvm->nvm_sections; in iwl_mvm_load_nvm_to_nic()
291 IWL_DEBUG_EEPROM(mvm->trans->dev, "'Write to NVM\n"); in iwl_mvm_load_nvm_to_nic()
293 for (i = 0; i < ARRAY_SIZE(mvm->nvm_sections); i++) { in iwl_mvm_load_nvm_to_nic()
294 if (!mvm->nvm_sections[i].data || !mvm->nvm_sections[i].length) in iwl_mvm_load_nvm_to_nic()
311 const char *nvm_file_C = mvm->cfg->default_nvm_file_C_step; in iwl_nvm_init()
313 if (WARN_ON_ONCE(mvm->cfg->nvm_hw_section_num >= NVM_MAX_NUM_SECTIONS)) in iwl_nvm_init()
314 return -EINVAL; in iwl_nvm_init()
318 IWL_DEBUG_EEPROM(mvm->trans->dev, "Read from NVM\n"); in iwl_nvm_init()
320 nvm_buffer = kmalloc(mvm->trans->trans_cfg->base_params->eeprom_size, in iwl_nvm_init()
323 return -ENOMEM; in iwl_nvm_init()
328 if (ret == -ENODATA) { in iwl_nvm_init()
337 ret = -ENOMEM; in iwl_nvm_init()
341 iwl_nvm_fixups(mvm->trans->hw_id, section, temp, ret); in iwl_nvm_init()
343 mvm->nvm_sections[section].data = temp; in iwl_nvm_init()
344 mvm->nvm_sections[section].length = ret; in iwl_nvm_init()
349 mvm->nvm_sw_blob.data = temp; in iwl_nvm_init()
350 mvm->nvm_sw_blob.size = ret; in iwl_nvm_init()
353 mvm->nvm_calib_blob.data = temp; in iwl_nvm_init()
354 mvm->nvm_calib_blob.size = ret; in iwl_nvm_init()
357 mvm->nvm_prod_blob.data = temp; in iwl_nvm_init()
358 mvm->nvm_prod_blob.size = ret; in iwl_nvm_init()
361 mvm->nvm_phy_sku_blob.data = temp; in iwl_nvm_init()
362 mvm->nvm_phy_sku_blob.size = ret; in iwl_nvm_init()
366 mvm->nvm_reg_blob.data = temp; in iwl_nvm_init()
367 mvm->nvm_reg_blob.size = ret; in iwl_nvm_init()
370 if (section == mvm->cfg->nvm_hw_section_num) { in iwl_nvm_init()
371 mvm->nvm_hw_blob.data = temp; in iwl_nvm_init()
372 mvm->nvm_hw_blob.size = ret; in iwl_nvm_init()
382 /* Only if PNVM selected in the mod param - load external NVM */ in iwl_nvm_init()
383 if (mvm->nvm_file_name) { in iwl_nvm_init()
385 ret = iwl_read_external_nvm(mvm->trans, mvm->nvm_file_name, in iwl_nvm_init()
386 mvm->nvm_sections); in iwl_nvm_init()
388 mvm->nvm_file_name = nvm_file_C; in iwl_nvm_init()
390 if ((ret == -EFAULT || ret == -ENOENT) && in iwl_nvm_init()
391 mvm->nvm_file_name) { in iwl_nvm_init()
393 ret = iwl_read_external_nvm(mvm->trans, in iwl_nvm_init()
394 mvm->nvm_file_name, in iwl_nvm_init()
395 mvm->nvm_sections); in iwl_nvm_init()
405 mvm->nvm_data = iwl_parse_nvm_sections(mvm); in iwl_nvm_init()
406 if (!mvm->nvm_data) in iwl_nvm_init()
407 return -ENODATA; in iwl_nvm_init()
408 IWL_DEBUG_EEPROM(mvm->trans->dev, "nvm version = %x\n", in iwl_nvm_init()
409 mvm->nvm_data->nvm_version); in iwl_nvm_init()
436 return ERR_PTR(-EOPNOTSUPP); in iwl_mvm_update_mcc()
449 resp_ver = iwl_fw_lookup_notif_ver(mvm->fw, IWL_ALWAYS_LONG_GROUP, in iwl_mvm_update_mcc()
454 struct iwl_mcc_update_resp_v8 *mcc_resp_v8 = (void *)pkt->data; in iwl_mvm_update_mcc()
456 n_channels = __le32_to_cpu(mcc_resp_v8->n_channels); in iwl_mvm_update_mcc()
458 struct_size(mcc_resp_v8, channels, n_channels)) { in iwl_mvm_update_mcc()
459 resp_cp = ERR_PTR(-EINVAL); in iwl_mvm_update_mcc()
462 resp_len = struct_size(resp_cp, channels, n_channels); in iwl_mvm_update_mcc()
465 resp_cp = ERR_PTR(-ENOMEM); in iwl_mvm_update_mcc()
468 resp_cp->status = mcc_resp_v8->status; in iwl_mvm_update_mcc()
469 resp_cp->mcc = mcc_resp_v8->mcc; in iwl_mvm_update_mcc()
470 resp_cp->cap = mcc_resp_v8->cap; in iwl_mvm_update_mcc()
471 resp_cp->source_id = mcc_resp_v8->source_id; in iwl_mvm_update_mcc()
472 resp_cp->time = mcc_resp_v8->time; in iwl_mvm_update_mcc()
473 resp_cp->geo_info = mcc_resp_v8->geo_info; in iwl_mvm_update_mcc()
474 resp_cp->n_channels = mcc_resp_v8->n_channels; in iwl_mvm_update_mcc()
475 memcpy(resp_cp->channels, mcc_resp_v8->channels, in iwl_mvm_update_mcc()
477 } else if (fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_update_mcc()
479 struct iwl_mcc_update_resp_v4 *mcc_resp_v4 = (void *)pkt->data; in iwl_mvm_update_mcc()
481 n_channels = __le32_to_cpu(mcc_resp_v4->n_channels); in iwl_mvm_update_mcc()
483 struct_size(mcc_resp_v4, channels, n_channels)) { in iwl_mvm_update_mcc()
484 resp_cp = ERR_PTR(-EINVAL); in iwl_mvm_update_mcc()
487 resp_len = struct_size(resp_cp, channels, n_channels); in iwl_mvm_update_mcc()
490 resp_cp = ERR_PTR(-ENOMEM); in iwl_mvm_update_mcc()
494 resp_cp->status = mcc_resp_v4->status; in iwl_mvm_update_mcc()
495 resp_cp->mcc = mcc_resp_v4->mcc; in iwl_mvm_update_mcc()
496 resp_cp->cap = cpu_to_le32(le16_to_cpu(mcc_resp_v4->cap)); in iwl_mvm_update_mcc()
497 resp_cp->source_id = mcc_resp_v4->source_id; in iwl_mvm_update_mcc()
498 resp_cp->time = mcc_resp_v4->time; in iwl_mvm_update_mcc()
499 resp_cp->geo_info = mcc_resp_v4->geo_info; in iwl_mvm_update_mcc()
500 resp_cp->n_channels = mcc_resp_v4->n_channels; in iwl_mvm_update_mcc()
501 memcpy(resp_cp->channels, mcc_resp_v4->channels, in iwl_mvm_update_mcc()
504 struct iwl_mcc_update_resp_v3 *mcc_resp_v3 = (void *)pkt->data; in iwl_mvm_update_mcc()
506 n_channels = __le32_to_cpu(mcc_resp_v3->n_channels); in iwl_mvm_update_mcc()
508 struct_size(mcc_resp_v3, channels, n_channels)) { in iwl_mvm_update_mcc()
509 resp_cp = ERR_PTR(-EINVAL); in iwl_mvm_update_mcc()
512 resp_len = struct_size(resp_cp, channels, n_channels); in iwl_mvm_update_mcc()
515 resp_cp = ERR_PTR(-ENOMEM); in iwl_mvm_update_mcc()
519 resp_cp->status = mcc_resp_v3->status; in iwl_mvm_update_mcc()
520 resp_cp->mcc = mcc_resp_v3->mcc; in iwl_mvm_update_mcc()
521 resp_cp->cap = cpu_to_le32(mcc_resp_v3->cap); in iwl_mvm_update_mcc()
522 resp_cp->source_id = mcc_resp_v3->source_id; in iwl_mvm_update_mcc()
523 resp_cp->time = mcc_resp_v3->time; in iwl_mvm_update_mcc()
524 resp_cp->geo_info = mcc_resp_v3->geo_info; in iwl_mvm_update_mcc()
525 resp_cp->n_channels = mcc_resp_v3->n_channels; in iwl_mvm_update_mcc()
526 memcpy(resp_cp->channels, mcc_resp_v3->channels, in iwl_mvm_update_mcc()
530 status = le32_to_cpu(resp_cp->status); in iwl_mvm_update_mcc()
532 mcc = le16_to_cpu(resp_cp->mcc); in iwl_mvm_update_mcc()
534 /* W/A for a FW/NVM issue - returns 0x00 for the world domain */ in iwl_mvm_update_mcc()
536 mcc = 0x3030; /* "00" - world */ in iwl_mvm_update_mcc()
537 resp_cp->mcc = cpu_to_le16(mcc); in iwl_mvm_update_mcc()
557 if (mvm->cfg->nvm_type == IWL_NVM_EXT) { in iwl_mvm_init_mcc()
558 tlv_lar = fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_init_mcc()
560 nvm_lar = mvm->nvm_data->lar_enabled; in iwl_mvm_init_mcc()
576 if (retval != -ENOENT) in iwl_mvm_init_mcc()
585 mvm->lar_regdom_set = false; in iwl_mvm_init_mcc()
589 return -EIO; in iwl_mvm_init_mcc()
592 !iwl_bios_get_mcc(&mvm->fwrt, mcc)) { in iwl_mvm_init_mcc()
594 regd = iwl_mvm_get_regdomain(mvm->hw->wiphy, mcc, in iwl_mvm_init_mcc()
597 return -EIO; in iwl_mvm_init_mcc()
600 retval = regulatory_set_wiphy_regd_sync(mvm->hw->wiphy, regd); in iwl_mvm_init_mcc()
609 struct iwl_mcc_chub_notif *notif = (void *)pkt->data; in iwl_mvm_rx_chub_update_mcc()
616 lockdep_assert_held(&mvm->mutex); in iwl_mvm_rx_chub_update_mcc()
618 if (iwl_mvm_is_vif_assoc(mvm) && notif->source_id == MCC_SOURCE_WIFI) { in iwl_mvm_rx_chub_update_mcc()
626 mcc[0] = le16_to_cpu(notif->mcc) >> 8; in iwl_mvm_rx_chub_update_mcc()
627 mcc[1] = le16_to_cpu(notif->mcc) & 0xff; in iwl_mvm_rx_chub_update_mcc()
629 src = notif->source_id; in iwl_mvm_rx_chub_update_mcc()
634 regd = iwl_mvm_get_regdomain(mvm->hw->wiphy, mcc, src, &changed); in iwl_mvm_rx_chub_update_mcc()
652 regulatory_set_wiphy_regd(mvm->hw->wiphy, regd); in iwl_mvm_rx_chub_update_mcc()