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