162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2005-2015, 2018-2022 Intel Corporation 462306a36Sopenharmony_ci * Copyright (C) 2016-2017 Intel Deutschland GmbH 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#ifndef __iwl_nvm_parse_h__ 762306a36Sopenharmony_ci#define __iwl_nvm_parse_h__ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#include <net/cfg80211.h> 1062306a36Sopenharmony_ci#include "iwl-eeprom-parse.h" 1162306a36Sopenharmony_ci#include "mei/iwl-mei.h" 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci/** 1462306a36Sopenharmony_ci * enum iwl_nvm_sbands_flags - modification flags for the channel profiles 1562306a36Sopenharmony_ci * 1662306a36Sopenharmony_ci * @IWL_NVM_SBANDS_FLAGS_LAR: LAR is enabled 1762306a36Sopenharmony_ci * @IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ: disallow 40, 80 and 160MHz on 5GHz 1862306a36Sopenharmony_ci */ 1962306a36Sopenharmony_cienum iwl_nvm_sbands_flags { 2062306a36Sopenharmony_ci IWL_NVM_SBANDS_FLAGS_LAR = BIT(0), 2162306a36Sopenharmony_ci IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ = BIT(1), 2262306a36Sopenharmony_ci}; 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci/** 2562306a36Sopenharmony_ci * iwl_parse_nvm_data - parse NVM data and return values 2662306a36Sopenharmony_ci * 2762306a36Sopenharmony_ci * This function parses all NVM values we need and then 2862306a36Sopenharmony_ci * returns a (newly allocated) struct containing all the 2962306a36Sopenharmony_ci * relevant values for driver use. The struct must be freed 3062306a36Sopenharmony_ci * later with iwl_free_nvm_data(). 3162306a36Sopenharmony_ci */ 3262306a36Sopenharmony_cistruct iwl_nvm_data * 3362306a36Sopenharmony_ciiwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, 3462306a36Sopenharmony_ci const struct iwl_fw *fw, 3562306a36Sopenharmony_ci const __be16 *nvm_hw, const __le16 *nvm_sw, 3662306a36Sopenharmony_ci const __le16 *nvm_calib, const __le16 *regulatory, 3762306a36Sopenharmony_ci const __le16 *mac_override, const __le16 *phy_sku, 3862306a36Sopenharmony_ci u8 tx_chains, u8 rx_chains); 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci/** 4162306a36Sopenharmony_ci * iwl_parse_mcc_info - parse MCC (mobile country code) info coming from FW 4262306a36Sopenharmony_ci * 4362306a36Sopenharmony_ci * This function parses the regulatory channel data received as a 4462306a36Sopenharmony_ci * MCC_UPDATE_CMD command. It returns a newly allocation regulatory domain, 4562306a36Sopenharmony_ci * to be fed into the regulatory core. In case the geo_info is set handle 4662306a36Sopenharmony_ci * accordingly. An ERR_PTR is returned on error. 4762306a36Sopenharmony_ci * If not given to the regulatory core, the user is responsible for freeing 4862306a36Sopenharmony_ci * the regdomain returned here with kfree. 4962306a36Sopenharmony_ci */ 5062306a36Sopenharmony_cistruct ieee80211_regdomain * 5162306a36Sopenharmony_ciiwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, 5262306a36Sopenharmony_ci int num_of_ch, __le32 *channels, u16 fw_mcc, 5362306a36Sopenharmony_ci u16 geo_info, u32 cap, u8 resp_ver); 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci/** 5662306a36Sopenharmony_ci * struct iwl_nvm_section - describes an NVM section in memory. 5762306a36Sopenharmony_ci * 5862306a36Sopenharmony_ci * This struct holds an NVM section read from the NIC using NVM_ACCESS_CMD, 5962306a36Sopenharmony_ci * and saved for later use by the driver. Not all NVM sections are saved 6062306a36Sopenharmony_ci * this way, only the needed ones. 6162306a36Sopenharmony_ci */ 6262306a36Sopenharmony_cistruct iwl_nvm_section { 6362306a36Sopenharmony_ci u16 length; 6462306a36Sopenharmony_ci const u8 *data; 6562306a36Sopenharmony_ci}; 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci/** 6862306a36Sopenharmony_ci * iwl_read_external_nvm - Reads external NVM from a file into nvm_sections 6962306a36Sopenharmony_ci */ 7062306a36Sopenharmony_ciint iwl_read_external_nvm(struct iwl_trans *trans, 7162306a36Sopenharmony_ci const char *nvm_file_name, 7262306a36Sopenharmony_ci struct iwl_nvm_section *nvm_sections); 7362306a36Sopenharmony_civoid iwl_nvm_fixups(u32 hw_id, unsigned int section, u8 *data, 7462306a36Sopenharmony_ci unsigned int len); 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci/** 7762306a36Sopenharmony_ci * iwl_get_nvm - retrieve NVM data from firmware 7862306a36Sopenharmony_ci * 7962306a36Sopenharmony_ci * Allocates a new iwl_nvm_data structure, fills it with 8062306a36Sopenharmony_ci * NVM data, and returns it to caller. 8162306a36Sopenharmony_ci */ 8262306a36Sopenharmony_cistruct iwl_nvm_data *iwl_get_nvm(struct iwl_trans *trans, 8362306a36Sopenharmony_ci const struct iwl_fw *fw); 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci/** 8662306a36Sopenharmony_ci * iwl_parse_mei_nvm_data - parse the mei_nvm_data and get an iwl_nvm_data 8762306a36Sopenharmony_ci */ 8862306a36Sopenharmony_cistruct iwl_nvm_data * 8962306a36Sopenharmony_ciiwl_parse_mei_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, 9062306a36Sopenharmony_ci const struct iwl_mei_nvm *mei_nvm, 9162306a36Sopenharmony_ci const struct iwl_fw *fw); 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci#endif /* __iwl_nvm_parse_h__ */ 94