Commit 3a27a1a1 authored by Mukesh Sisodiya's avatar Mukesh Sisodiya Committed by Gregory Greenman

wifi: iwlwifi: pcie: Add reading and storing of crf and cdb id.

Read and store crf and cdb id details to make it
available during driver's lifetime
Signed-off-by: default avatarMukesh Sisodiya <mukesh.sisodiya@intel.com>
Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20221205102808.888b30780128.Ic8c4c088a75a0d7092d6301ef3760a118a06d819@changeid
parent 6d7cb4a6
...@@ -976,6 +976,8 @@ struct iwl_trans_txqs { ...@@ -976,6 +976,8 @@ struct iwl_trans_txqs {
* @max_skb_frags: maximum number of fragments an SKB can have when transmitted. * @max_skb_frags: maximum number of fragments an SKB can have when transmitted.
* 0 indicates that frag SKBs (NETIF_F_SG) aren't supported. * 0 indicates that frag SKBs (NETIF_F_SG) aren't supported.
* @hw_rf_id a u32 with the device RF ID * @hw_rf_id a u32 with the device RF ID
* @hw_crf_id a u32 with the device CRF ID
* @hw_cdb_id a u32 with the device CDB ID
* @hw_id: a u32 with the ID of the device / sub-device. * @hw_id: a u32 with the ID of the device / sub-device.
* Set during transport allocation. * Set during transport allocation.
* @hw_id_str: a string with info about HW ID. Set during transport allocation. * @hw_id_str: a string with info about HW ID. Set during transport allocation.
...@@ -1015,6 +1017,8 @@ struct iwl_trans { ...@@ -1015,6 +1017,8 @@ struct iwl_trans {
u32 hw_rev; u32 hw_rev;
u32 hw_rev_step; u32 hw_rev_step;
u32 hw_rf_id; u32 hw_rf_id;
u32 hw_crf_id;
u32 hw_cdb_id;
u32 hw_id; u32 hw_id;
char hw_id_str[52]; char hw_id_str[52];
u32 sku_id[3]; u32 sku_id[3];
......
...@@ -1350,15 +1350,13 @@ static const struct iwl_dev_info iwl_dev_info_table[] = { ...@@ -1350,15 +1350,13 @@ static const struct iwl_dev_info iwl_dev_info_table[] = {
}; };
/* /*
* In case that there is no OTP on the NIC, get the rf id and cdb info * Read rf id and cdb info from prph register and store it
* from the prph registers.
*/ */
static int get_crf_id(struct iwl_trans *iwl_trans) static int get_crf_id(struct iwl_trans *iwl_trans)
{ {
int ret = 0; int ret = 0;
u32 sd_reg_ver_addr; u32 sd_reg_ver_addr;
u32 cdb = 0; u32 val = 0;
u32 val;
if (iwl_trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) if (iwl_trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210)
sd_reg_ver_addr = SD_REG_VER_GEN2; sd_reg_ver_addr = SD_REG_VER_GEN2;
...@@ -1377,10 +1375,26 @@ static int get_crf_id(struct iwl_trans *iwl_trans) ...@@ -1377,10 +1375,26 @@ static int get_crf_id(struct iwl_trans *iwl_trans)
iwl_write_umac_prph_no_grab(iwl_trans, WFPM_CTRL_REG, val); iwl_write_umac_prph_no_grab(iwl_trans, WFPM_CTRL_REG, val);
/* Read crf info */ /* Read crf info */
val = iwl_read_prph_no_grab(iwl_trans, sd_reg_ver_addr); iwl_trans->hw_crf_id = iwl_read_prph_no_grab(iwl_trans, sd_reg_ver_addr);
/* Read cdb info (also contains the jacket info if needed in the future */ /* Read cdb info (also contains the jacket info if needed in the future */
cdb = iwl_read_umac_prph_no_grab(iwl_trans, WFPM_OTP_CFG1_ADDR); iwl_trans->hw_cdb_id = iwl_read_umac_prph_no_grab(iwl_trans, WFPM_OTP_CFG1_ADDR);
iwl_trans_release_nic_access(iwl_trans);
out:
return ret;
}
/*
* In case that there is no OTP on the NIC, map the rf id and cdb info
* from the prph registers.
*/
static int map_crf_id(struct iwl_trans *iwl_trans)
{
int ret = 0;
u32 val = iwl_trans->hw_crf_id;
u32 cdb = iwl_trans->hw_cdb_id;
/* Map between crf id to rf id */ /* Map between crf id to rf id */
switch (REG_CRF_ID_TYPE(val)) { switch (REG_CRF_ID_TYPE(val)) {
...@@ -1410,7 +1424,7 @@ static int get_crf_id(struct iwl_trans *iwl_trans) ...@@ -1410,7 +1424,7 @@ static int get_crf_id(struct iwl_trans *iwl_trans)
IWL_ERR(iwl_trans, IWL_ERR(iwl_trans,
"Can find a correct rfid for crf id 0x%x\n", "Can find a correct rfid for crf id 0x%x\n",
REG_CRF_ID_TYPE(val)); REG_CRF_ID_TYPE(val));
goto out_release; goto out;
} }
...@@ -1423,8 +1437,6 @@ static int get_crf_id(struct iwl_trans *iwl_trans) ...@@ -1423,8 +1437,6 @@ static int get_crf_id(struct iwl_trans *iwl_trans)
IWL_INFO(iwl_trans, "Detected RF 0x%x from crf id 0x%x\n", IWL_INFO(iwl_trans, "Detected RF 0x%x from crf id 0x%x\n",
iwl_trans->hw_rf_id, REG_CRF_ID_TYPE(val)); iwl_trans->hw_rf_id, REG_CRF_ID_TYPE(val));
out_release:
iwl_trans_release_nic_access(iwl_trans);
out: out:
return ret; return ret;
...@@ -1544,6 +1556,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1544,6 +1556,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
iwl_trans->hw_rf_id = iwl_read32(iwl_trans, CSR_HW_RF_ID); iwl_trans->hw_rf_id = iwl_read32(iwl_trans, CSR_HW_RF_ID);
get_crf_id(iwl_trans);
/* /*
* The RF_ID is set to zero in blank OTP so read version to * The RF_ID is set to zero in blank OTP so read version to
...@@ -1552,7 +1565,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1552,7 +1565,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
*/ */
if (iwl_trans->trans_cfg->rf_id && if (iwl_trans->trans_cfg->rf_id &&
iwl_trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_9000 && iwl_trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_9000 &&
!CSR_HW_RFID_TYPE(iwl_trans->hw_rf_id) && get_crf_id(iwl_trans)) { !CSR_HW_RFID_TYPE(iwl_trans->hw_rf_id) && map_crf_id(iwl_trans)) {
ret = -EINVAL; ret = -EINVAL;
goto out_free_trans; goto out_free_trans;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment