1*8e99ea8dSJohannes Berg /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2*8e99ea8dSJohannes Berg /* 3*8e99ea8dSJohannes Berg * Copyright (C) 2005-2015, 2018-2020 Intel Corporation 4*8e99ea8dSJohannes Berg * Copyright (C) 2016-2017 Intel Deutschland GmbH 5*8e99ea8dSJohannes Berg */ 6e705c121SKalle Valo #ifndef __iwl_nvm_parse_h__ 7e705c121SKalle Valo #define __iwl_nvm_parse_h__ 8e705c121SKalle Valo 9e705c121SKalle Valo #include <net/cfg80211.h> 10e705c121SKalle Valo #include "iwl-eeprom-parse.h" 11e705c121SKalle Valo 12e705c121SKalle Valo /** 134b82455cSLuca Coelho * enum iwl_nvm_sbands_flags - modification flags for the channel profiles 144b82455cSLuca Coelho * 154b82455cSLuca Coelho * @IWL_NVM_SBANDS_FLAGS_LAR: LAR is enabled 164b82455cSLuca Coelho * @IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ: disallow 40, 80 and 160MHz on 5GHz 174b82455cSLuca Coelho */ 184b82455cSLuca Coelho enum iwl_nvm_sbands_flags { 194b82455cSLuca Coelho IWL_NVM_SBANDS_FLAGS_LAR = BIT(0), 204b82455cSLuca Coelho IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ = BIT(1), 214b82455cSLuca Coelho }; 224b82455cSLuca Coelho 234b82455cSLuca Coelho /** 24e705c121SKalle Valo * iwl_parse_nvm_data - parse NVM data and return values 25e705c121SKalle Valo * 26e705c121SKalle Valo * This function parses all NVM values we need and then 27e705c121SKalle Valo * returns a (newly allocated) struct containing all the 28e705c121SKalle Valo * relevant values for driver use. The struct must be freed 29e705c121SKalle Valo * later with iwl_free_nvm_data(). 30e705c121SKalle Valo */ 31e705c121SKalle Valo struct iwl_nvm_data * 32afd5b170SSara Sharon iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, 33f06021a1SLuca Coelho const struct iwl_fw *fw, 348fe34b06SLuca Coelho const __be16 *nvm_hw, const __le16 *nvm_sw, 35e705c121SKalle Valo const __le16 *nvm_calib, const __le16 *regulatory, 36e705c121SKalle Valo const __le16 *mac_override, const __le16 *phy_sku, 37f06021a1SLuca Coelho u8 tx_chains, u8 rx_chains); 38e705c121SKalle Valo 39e705c121SKalle Valo /** 40e705c121SKalle Valo * iwl_parse_mcc_info - parse MCC (mobile country code) info coming from FW 41e705c121SKalle Valo * 42e705c121SKalle Valo * This function parses the regulatory channel data received as a 43e705c121SKalle Valo * MCC_UPDATE_CMD command. It returns a newly allocation regulatory domain, 4477e30e10SHaim Dreyfuss * to be fed into the regulatory core. In case the geo_info is set handle 4577e30e10SHaim Dreyfuss * accordingly. An ERR_PTR is returned on error. 46e705c121SKalle Valo * If not given to the regulatory core, the user is responsible for freeing 47e705c121SKalle Valo * the regdomain returned here with kfree. 48e705c121SKalle Valo */ 49e705c121SKalle Valo struct ieee80211_regdomain * 50e705c121SKalle Valo iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, 5177e30e10SHaim Dreyfuss int num_of_ch, __le32 *channels, u16 fw_mcc, 52e27c506aSGil Adam u16 geo_info, u16 cap, u8 resp_ver); 53e705c121SKalle Valo 549c4f7d51SShaul Triebitz /** 559c4f7d51SShaul Triebitz * struct iwl_nvm_section - describes an NVM section in memory. 569c4f7d51SShaul Triebitz * 579c4f7d51SShaul Triebitz * This struct holds an NVM section read from the NIC using NVM_ACCESS_CMD, 589c4f7d51SShaul Triebitz * and saved for later use by the driver. Not all NVM sections are saved 599c4f7d51SShaul Triebitz * this way, only the needed ones. 609c4f7d51SShaul Triebitz */ 619c4f7d51SShaul Triebitz struct iwl_nvm_section { 629c4f7d51SShaul Triebitz u16 length; 639c4f7d51SShaul Triebitz const u8 *data; 649c4f7d51SShaul Triebitz }; 659c4f7d51SShaul Triebitz 669c4f7d51SShaul Triebitz /** 679c4f7d51SShaul Triebitz * iwl_read_external_nvm - Reads external NVM from a file into nvm_sections 689c4f7d51SShaul Triebitz */ 699c4f7d51SShaul Triebitz int iwl_read_external_nvm(struct iwl_trans *trans, 709c4f7d51SShaul Triebitz const char *nvm_file_name, 719c4f7d51SShaul Triebitz struct iwl_nvm_section *nvm_sections); 729c4f7d51SShaul Triebitz void iwl_nvm_fixups(u32 hw_id, unsigned int section, u8 *data, 739c4f7d51SShaul Triebitz unsigned int len); 749c4f7d51SShaul Triebitz 754c625c56SShaul Triebitz /** 764c625c56SShaul Triebitz * iwl_get_nvm - retrieve NVM data from firmware 774c625c56SShaul Triebitz * 784c625c56SShaul Triebitz * Allocates a new iwl_nvm_data structure, fills it with 794c625c56SShaul Triebitz * NVM data, and returns it to caller. 804c625c56SShaul Triebitz */ 814c625c56SShaul Triebitz struct iwl_nvm_data *iwl_get_nvm(struct iwl_trans *trans, 824c625c56SShaul Triebitz const struct iwl_fw *fw); 83e705c121SKalle Valo #endif /* __iwl_nvm_parse_h__ */ 84