iwlwifi: mvm: support NVM file with header
Handle NVM file header. When NVM header detected, skip the header and reading only the sections data. Signed-off-by: Idan Kahlon <idanx.kahlon@intel.com> Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
This commit is contained in:
parent
8ed4e659f3
commit
a4e5df283c
@ -339,11 +339,15 @@ static int iwl_mvm_read_external_nvm(struct iwl_mvm *mvm)
|
||||
} *file_sec;
|
||||
const u8 *eof, *temp;
|
||||
int max_section_size;
|
||||
const __le32 *dword_buff;
|
||||
|
||||
#define NVM_WORD1_LEN(x) (8 * (x & 0x03FF))
|
||||
#define NVM_WORD2_ID(x) (x >> 12)
|
||||
#define NVM_WORD2_LEN_FAMILY_8000(x) (2 * ((x & 0xFF) << 8 | x >> 8))
|
||||
#define NVM_WORD1_ID_FAMILY_8000(x) (x >> 4)
|
||||
#define NVM_HEADER_0 (0x2A504C54)
|
||||
#define NVM_HEADER_1 (0x4E564D2A)
|
||||
#define NVM_HEADER_SIZE (4 * sizeof(u32))
|
||||
|
||||
IWL_DEBUG_EEPROM(mvm->trans->dev, "Read from external NVM\n");
|
||||
|
||||
@ -372,12 +376,6 @@ static int iwl_mvm_read_external_nvm(struct iwl_mvm *mvm)
|
||||
IWL_INFO(mvm, "Loaded NVM file %s (%zu bytes)\n",
|
||||
mvm->nvm_file_name, fw_entry->size);
|
||||
|
||||
if (fw_entry->size < sizeof(*file_sec)) {
|
||||
IWL_ERR(mvm, "NVM file too small\n");
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (fw_entry->size > MAX_NVM_FILE_LEN) {
|
||||
IWL_ERR(mvm, "NVM file too large\n");
|
||||
ret = -EINVAL;
|
||||
@ -385,8 +383,25 @@ static int iwl_mvm_read_external_nvm(struct iwl_mvm *mvm)
|
||||
}
|
||||
|
||||
eof = fw_entry->data + fw_entry->size;
|
||||
dword_buff = (__le32 *)fw_entry->data;
|
||||
|
||||
file_sec = (void *)fw_entry->data;
|
||||
/* some NVM file will contain a header.
|
||||
* The header is identified by 2 dwords header as follow:
|
||||
* dword[0] = 0x2A504C54
|
||||
* dword[1] = 0x4E564D2A
|
||||
*
|
||||
* This header must be skipped when providing the NVM data to the FW.
|
||||
*/
|
||||
if (fw_entry->size > NVM_HEADER_SIZE &&
|
||||
dword_buff[0] == cpu_to_le32(NVM_HEADER_0) &&
|
||||
dword_buff[1] == cpu_to_le32(NVM_HEADER_1)) {
|
||||
file_sec = (void *)(fw_entry->data + NVM_HEADER_SIZE);
|
||||
IWL_INFO(mvm, "NVM Version %08X\n", le32_to_cpu(dword_buff[2]));
|
||||
IWL_INFO(mvm, "NVM Manufacturing date %08X\n",
|
||||
le32_to_cpu(dword_buff[3]));
|
||||
} else {
|
||||
file_sec = (void *)fw_entry->data;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (file_sec->data > eof) {
|
||||
|
Loading…
Reference in New Issue
Block a user