diff options
author | Sara Sharon <sara.sharon@intel.com> | 2017-03-22 06:20:40 -0400 |
---|---|---|
committer | Luca Coelho <luciano.coelho@intel.com> | 2017-06-05 16:25:21 -0400 |
commit | 7042678dffa3707dea3feb34f09241d54e40648c (patch) | |
tree | 7e6bca9bdb8d431a03c190719ba2727b58c883a2 /drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | |
parent | 6ffe5de35b05907faf4edb66cfd8ddf3c47e099f (diff) |
iwlwifi: cleanup references to 8000 family in NVM code
NVM code is tightly coupled with 8000 family, while
it really refers to extended NVM format introduced
back then. Separate it to a configuration dependent
boolean, and rename defines accordingly.
Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Diffstat (limited to 'drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c')
-rw-r--r-- | drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 95 |
1 files changed, 43 insertions, 52 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c index 721ae6bef5da..070f3dfb94ce 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | |||
@@ -94,30 +94,21 @@ enum wkp_nvm_offsets { | |||
94 | XTAL_CALIB = 0x316 - NVM_CALIB_SECTION | 94 | XTAL_CALIB = 0x316 - NVM_CALIB_SECTION |
95 | }; | 95 | }; |
96 | 96 | ||
97 | enum family_8000_nvm_offsets { | 97 | enum ext_nvm_offsets { |
98 | /* NVM HW-Section offset (in words) definitions */ | 98 | /* NVM HW-Section offset (in words) definitions */ |
99 | HW_ADDR0_WFPM_FAMILY_8000 = 0x12, | 99 | MAC_ADDRESS_OVERRIDE_EXT_NVM = 1, |
100 | HW_ADDR1_WFPM_FAMILY_8000 = 0x16, | ||
101 | HW_ADDR0_PCIE_FAMILY_8000 = 0x8A, | ||
102 | HW_ADDR1_PCIE_FAMILY_8000 = 0x8E, | ||
103 | MAC_ADDRESS_OVERRIDE_FAMILY_8000 = 1, | ||
104 | 100 | ||
105 | /* NVM SW-Section offset (in words) definitions */ | 101 | /* NVM SW-Section offset (in words) definitions */ |
106 | NVM_SW_SECTION_FAMILY_8000 = 0x1C0, | 102 | NVM_VERSION_EXT_NVM = 0, |
107 | NVM_VERSION_FAMILY_8000 = 0, | 103 | RADIO_CFG_FAMILY_EXT_NVM = 0, |
108 | RADIO_CFG_FAMILY_8000 = 0, | ||
109 | SKU_FAMILY_8000 = 2, | 104 | SKU_FAMILY_8000 = 2, |
110 | N_HW_ADDRS_FAMILY_8000 = 3, | 105 | N_HW_ADDRS_FAMILY_8000 = 3, |
111 | 106 | ||
112 | /* NVM REGULATORY -Section offset (in words) definitions */ | 107 | /* NVM REGULATORY -Section offset (in words) definitions */ |
113 | NVM_CHANNELS_FAMILY_8000 = 0, | 108 | NVM_CHANNELS_EXTENDED = 0, |
114 | NVM_LAR_OFFSET_FAMILY_8000_OLD = 0x4C7, | 109 | NVM_LAR_OFFSET_OLD = 0x4C7, |
115 | NVM_LAR_OFFSET_FAMILY_8000 = 0x507, | 110 | NVM_LAR_OFFSET = 0x507, |
116 | NVM_LAR_ENABLED_FAMILY_8000 = 0x7, | 111 | NVM_LAR_ENABLED = 0x7, |
117 | |||
118 | /* NVM calibration section offset (in words) definitions */ | ||
119 | NVM_CALIB_SECTION_FAMILY_8000 = 0x2B8, | ||
120 | XTAL_CALIB_FAMILY_8000 = 0x316 - NVM_CALIB_SECTION_FAMILY_8000 | ||
121 | }; | 112 | }; |
122 | 113 | ||
123 | /* SKU Capabilities (actual values from NVM definition) */ | 114 | /* SKU Capabilities (actual values from NVM definition) */ |
@@ -141,7 +132,7 @@ static const u8 iwl_nvm_channels[] = { | |||
141 | 149, 153, 157, 161, 165 | 132 | 149, 153, 157, 161, 165 |
142 | }; | 133 | }; |
143 | 134 | ||
144 | static const u8 iwl_nvm_channels_family_8000[] = { | 135 | static const u8 iwl_ext_nvm_channels[] = { |
145 | /* 2.4 GHz */ | 136 | /* 2.4 GHz */ |
146 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, | 137 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
147 | /* 5 GHz */ | 138 | /* 5 GHz */ |
@@ -151,9 +142,9 @@ static const u8 iwl_nvm_channels_family_8000[] = { | |||
151 | }; | 142 | }; |
152 | 143 | ||
153 | #define IWL_NUM_CHANNELS ARRAY_SIZE(iwl_nvm_channels) | 144 | #define IWL_NUM_CHANNELS ARRAY_SIZE(iwl_nvm_channels) |
154 | #define IWL_NUM_CHANNELS_FAMILY_8000 ARRAY_SIZE(iwl_nvm_channels_family_8000) | 145 | #define IWL_NUM_CHANNELS_EXT ARRAY_SIZE(iwl_ext_nvm_channels) |
155 | #define NUM_2GHZ_CHANNELS 14 | 146 | #define NUM_2GHZ_CHANNELS 14 |
156 | #define NUM_2GHZ_CHANNELS_FAMILY_8000 14 | 147 | #define NUM_2GHZ_CHANNELS_EXT 14 |
157 | #define FIRST_2GHZ_HT_MINUS 5 | 148 | #define FIRST_2GHZ_HT_MINUS 5 |
158 | #define LAST_2GHZ_HT_PLUS 9 | 149 | #define LAST_2GHZ_HT_PLUS 9 |
159 | #define LAST_5GHZ_HT 165 | 150 | #define LAST_5GHZ_HT 165 |
@@ -219,7 +210,7 @@ static u32 iwl_get_channel_flags(u8 ch_num, int ch_idx, bool is_5ghz, | |||
219 | u32 flags = IEEE80211_CHAN_NO_HT40; | 210 | u32 flags = IEEE80211_CHAN_NO_HT40; |
220 | u32 last_5ghz_ht = LAST_5GHZ_HT; | 211 | u32 last_5ghz_ht = LAST_5GHZ_HT; |
221 | 212 | ||
222 | if (cfg->device_family == IWL_DEVICE_FAMILY_8000) | 213 | if (cfg->ext_nvm) |
223 | last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000; | 214 | last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000; |
224 | 215 | ||
225 | if (!is_5ghz && (nvm_flags & NVM_CHANNEL_40MHZ)) { | 216 | if (!is_5ghz && (nvm_flags & NVM_CHANNEL_40MHZ)) { |
@@ -273,14 +264,14 @@ static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg, | |||
273 | int num_of_ch, num_2ghz_channels; | 264 | int num_of_ch, num_2ghz_channels; |
274 | const u8 *nvm_chan; | 265 | const u8 *nvm_chan; |
275 | 266 | ||
276 | if (cfg->device_family != IWL_DEVICE_FAMILY_8000) { | 267 | if (!cfg->ext_nvm) { |
277 | num_of_ch = IWL_NUM_CHANNELS; | 268 | num_of_ch = IWL_NUM_CHANNELS; |
278 | nvm_chan = &iwl_nvm_channels[0]; | 269 | nvm_chan = &iwl_nvm_channels[0]; |
279 | num_2ghz_channels = NUM_2GHZ_CHANNELS; | 270 | num_2ghz_channels = NUM_2GHZ_CHANNELS; |
280 | } else { | 271 | } else { |
281 | num_of_ch = IWL_NUM_CHANNELS_FAMILY_8000; | 272 | num_of_ch = IWL_NUM_CHANNELS_EXT; |
282 | nvm_chan = &iwl_nvm_channels_family_8000[0]; | 273 | nvm_chan = &iwl_ext_nvm_channels[0]; |
283 | num_2ghz_channels = NUM_2GHZ_CHANNELS_FAMILY_8000; | 274 | num_2ghz_channels = NUM_2GHZ_CHANNELS_EXT; |
284 | } | 275 | } |
285 | 276 | ||
286 | for (ch_idx = 0; ch_idx < num_of_ch; ch_idx++) { | 277 | for (ch_idx = 0; ch_idx < num_of_ch; ch_idx++) { |
@@ -479,7 +470,7 @@ IWL_EXPORT_SYMBOL(iwl_init_sbands); | |||
479 | static int iwl_get_sku(const struct iwl_cfg *cfg, const __le16 *nvm_sw, | 470 | static int iwl_get_sku(const struct iwl_cfg *cfg, const __le16 *nvm_sw, |
480 | const __le16 *phy_sku) | 471 | const __le16 *phy_sku) |
481 | { | 472 | { |
482 | if (cfg->device_family != IWL_DEVICE_FAMILY_8000) | 473 | if (!cfg->ext_nvm) |
483 | return le16_to_cpup(nvm_sw + SKU); | 474 | return le16_to_cpup(nvm_sw + SKU); |
484 | 475 | ||
485 | return le32_to_cpup((__le32 *)(phy_sku + SKU_FAMILY_8000)); | 476 | return le32_to_cpup((__le32 *)(phy_sku + SKU_FAMILY_8000)); |
@@ -487,20 +478,20 @@ static int iwl_get_sku(const struct iwl_cfg *cfg, const __le16 *nvm_sw, | |||
487 | 478 | ||
488 | static int iwl_get_nvm_version(const struct iwl_cfg *cfg, const __le16 *nvm_sw) | 479 | static int iwl_get_nvm_version(const struct iwl_cfg *cfg, const __le16 *nvm_sw) |
489 | { | 480 | { |
490 | if (cfg->device_family != IWL_DEVICE_FAMILY_8000) | 481 | if (!cfg->ext_nvm) |
491 | return le16_to_cpup(nvm_sw + NVM_VERSION); | 482 | return le16_to_cpup(nvm_sw + NVM_VERSION); |
492 | else | 483 | else |
493 | return le32_to_cpup((__le32 *)(nvm_sw + | 484 | return le32_to_cpup((__le32 *)(nvm_sw + |
494 | NVM_VERSION_FAMILY_8000)); | 485 | NVM_VERSION_EXT_NVM)); |
495 | } | 486 | } |
496 | 487 | ||
497 | static int iwl_get_radio_cfg(const struct iwl_cfg *cfg, const __le16 *nvm_sw, | 488 | static int iwl_get_radio_cfg(const struct iwl_cfg *cfg, const __le16 *nvm_sw, |
498 | const __le16 *phy_sku) | 489 | const __le16 *phy_sku) |
499 | { | 490 | { |
500 | if (cfg->device_family != IWL_DEVICE_FAMILY_8000) | 491 | if (!cfg->ext_nvm) |
501 | return le16_to_cpup(nvm_sw + RADIO_CFG); | 492 | return le16_to_cpup(nvm_sw + RADIO_CFG); |
502 | 493 | ||
503 | return le32_to_cpup((__le32 *)(phy_sku + RADIO_CFG_FAMILY_8000)); | 494 | return le32_to_cpup((__le32 *)(phy_sku + RADIO_CFG_FAMILY_EXT_NVM)); |
504 | 495 | ||
505 | } | 496 | } |
506 | 497 | ||
@@ -508,7 +499,7 @@ static int iwl_get_n_hw_addrs(const struct iwl_cfg *cfg, const __le16 *nvm_sw) | |||
508 | { | 499 | { |
509 | int n_hw_addr; | 500 | int n_hw_addr; |
510 | 501 | ||
511 | if (cfg->device_family != IWL_DEVICE_FAMILY_8000) | 502 | if (!cfg->ext_nvm) |
512 | return le16_to_cpup(nvm_sw + N_HW_ADDRS); | 503 | return le16_to_cpup(nvm_sw + N_HW_ADDRS); |
513 | 504 | ||
514 | n_hw_addr = le32_to_cpup((__le32 *)(nvm_sw + N_HW_ADDRS_FAMILY_8000)); | 505 | n_hw_addr = le32_to_cpup((__le32 *)(nvm_sw + N_HW_ADDRS_FAMILY_8000)); |
@@ -520,7 +511,7 @@ static void iwl_set_radio_cfg(const struct iwl_cfg *cfg, | |||
520 | struct iwl_nvm_data *data, | 511 | struct iwl_nvm_data *data, |
521 | u32 radio_cfg) | 512 | u32 radio_cfg) |
522 | { | 513 | { |
523 | if (cfg->device_family != IWL_DEVICE_FAMILY_8000) { | 514 | if (!cfg->ext_nvm) { |
524 | data->radio_cfg_type = NVM_RF_CFG_TYPE_MSK(radio_cfg); | 515 | data->radio_cfg_type = NVM_RF_CFG_TYPE_MSK(radio_cfg); |
525 | data->radio_cfg_step = NVM_RF_CFG_STEP_MSK(radio_cfg); | 516 | data->radio_cfg_step = NVM_RF_CFG_STEP_MSK(radio_cfg); |
526 | data->radio_cfg_dash = NVM_RF_CFG_DASH_MSK(radio_cfg); | 517 | data->radio_cfg_dash = NVM_RF_CFG_DASH_MSK(radio_cfg); |
@@ -529,12 +520,12 @@ static void iwl_set_radio_cfg(const struct iwl_cfg *cfg, | |||
529 | } | 520 | } |
530 | 521 | ||
531 | /* set the radio configuration for family 8000 */ | 522 | /* set the radio configuration for family 8000 */ |
532 | data->radio_cfg_type = NVM_RF_CFG_TYPE_MSK_FAMILY_8000(radio_cfg); | 523 | data->radio_cfg_type = EXT_NVM_RF_CFG_TYPE_MSK(radio_cfg); |
533 | data->radio_cfg_step = NVM_RF_CFG_STEP_MSK_FAMILY_8000(radio_cfg); | 524 | data->radio_cfg_step = EXT_NVM_RF_CFG_STEP_MSK(radio_cfg); |
534 | data->radio_cfg_dash = NVM_RF_CFG_DASH_MSK_FAMILY_8000(radio_cfg); | 525 | data->radio_cfg_dash = EXT_NVM_RF_CFG_DASH_MSK(radio_cfg); |
535 | data->radio_cfg_pnum = NVM_RF_CFG_FLAVOR_MSK_FAMILY_8000(radio_cfg); | 526 | data->radio_cfg_pnum = EXT_NVM_RF_CFG_FLAVOR_MSK(radio_cfg); |
536 | data->valid_tx_ant = NVM_RF_CFG_TX_ANT_MSK_FAMILY_8000(radio_cfg); | 527 | data->valid_tx_ant = EXT_NVM_RF_CFG_TX_ANT_MSK(radio_cfg); |
537 | data->valid_rx_ant = NVM_RF_CFG_RX_ANT_MSK_FAMILY_8000(radio_cfg); | 528 | data->valid_rx_ant = EXT_NVM_RF_CFG_RX_ANT_MSK(radio_cfg); |
538 | } | 529 | } |
539 | 530 | ||
540 | static void iwl_flip_hw_address(__le32 mac_addr0, __le32 mac_addr1, u8 *dest) | 531 | static void iwl_flip_hw_address(__le32 mac_addr0, __le32 mac_addr1, u8 *dest) |
@@ -587,7 +578,7 @@ static void iwl_set_hw_address_family_8000(struct iwl_trans *trans, | |||
587 | }; | 578 | }; |
588 | 579 | ||
589 | hw_addr = (const u8 *)(mac_override + | 580 | hw_addr = (const u8 *)(mac_override + |
590 | MAC_ADDRESS_OVERRIDE_FAMILY_8000); | 581 | MAC_ADDRESS_OVERRIDE_EXT_NVM); |
591 | 582 | ||
592 | /* | 583 | /* |
593 | * Store the MAC address from MAO section. | 584 | * Store the MAC address from MAO section. |
@@ -629,7 +620,7 @@ static int iwl_set_hw_address(struct iwl_trans *trans, | |||
629 | { | 620 | { |
630 | if (cfg->mac_addr_from_csr) { | 621 | if (cfg->mac_addr_from_csr) { |
631 | iwl_set_hw_address_from_csr(trans, data); | 622 | iwl_set_hw_address_from_csr(trans, data); |
632 | } else if (cfg->device_family != IWL_DEVICE_FAMILY_8000) { | 623 | } else if (!cfg->ext_nvm) { |
633 | const u8 *hw_addr = (const u8 *)(nvm_hw + HW_ADDR); | 624 | const u8 *hw_addr = (const u8 *)(nvm_hw + HW_ADDR); |
634 | 625 | ||
635 | /* The byte order is little endian 16 bit, meaning 214365 */ | 626 | /* The byte order is little endian 16 bit, meaning 214365 */ |
@@ -666,7 +657,7 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, | |||
666 | u16 lar_config; | 657 | u16 lar_config; |
667 | const __le16 *ch_section; | 658 | const __le16 *ch_section; |
668 | 659 | ||
669 | if (cfg->device_family != IWL_DEVICE_FAMILY_8000) | 660 | if (!cfg->ext_nvm) |
670 | data = kzalloc(sizeof(*data) + | 661 | data = kzalloc(sizeof(*data) + |
671 | sizeof(struct ieee80211_channel) * | 662 | sizeof(struct ieee80211_channel) * |
672 | IWL_NUM_CHANNELS, | 663 | IWL_NUM_CHANNELS, |
@@ -674,7 +665,7 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, | |||
674 | else | 665 | else |
675 | data = kzalloc(sizeof(*data) + | 666 | data = kzalloc(sizeof(*data) + |
676 | sizeof(struct ieee80211_channel) * | 667 | sizeof(struct ieee80211_channel) * |
677 | IWL_NUM_CHANNELS_FAMILY_8000, | 668 | IWL_NUM_CHANNELS_EXT, |
678 | GFP_KERNEL); | 669 | GFP_KERNEL); |
679 | if (!data) | 670 | if (!data) |
680 | return NULL; | 671 | return NULL; |
@@ -700,7 +691,7 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, | |||
700 | 691 | ||
701 | data->n_hw_addrs = iwl_get_n_hw_addrs(cfg, nvm_sw); | 692 | data->n_hw_addrs = iwl_get_n_hw_addrs(cfg, nvm_sw); |
702 | 693 | ||
703 | if (cfg->device_family != IWL_DEVICE_FAMILY_8000) { | 694 | if (!cfg->ext_nvm) { |
704 | /* Checking for required sections */ | 695 | /* Checking for required sections */ |
705 | if (!nvm_calib) { | 696 | if (!nvm_calib) { |
706 | IWL_ERR(trans, | 697 | IWL_ERR(trans, |
@@ -715,14 +706,14 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, | |||
715 | ch_section = &nvm_sw[NVM_CHANNELS]; | 706 | ch_section = &nvm_sw[NVM_CHANNELS]; |
716 | } else { | 707 | } else { |
717 | u16 lar_offset = data->nvm_version < 0xE39 ? | 708 | u16 lar_offset = data->nvm_version < 0xE39 ? |
718 | NVM_LAR_OFFSET_FAMILY_8000_OLD : | 709 | NVM_LAR_OFFSET_OLD : |
719 | NVM_LAR_OFFSET_FAMILY_8000; | 710 | NVM_LAR_OFFSET; |
720 | 711 | ||
721 | lar_config = le16_to_cpup(regulatory + lar_offset); | 712 | lar_config = le16_to_cpup(regulatory + lar_offset); |
722 | data->lar_enabled = !!(lar_config & | 713 | data->lar_enabled = !!(lar_config & |
723 | NVM_LAR_ENABLED_FAMILY_8000); | 714 | NVM_LAR_ENABLED); |
724 | lar_enabled = data->lar_enabled; | 715 | lar_enabled = data->lar_enabled; |
725 | ch_section = ®ulatory[NVM_CHANNELS_FAMILY_8000]; | 716 | ch_section = ®ulatory[NVM_CHANNELS_EXTENDED]; |
726 | } | 717 | } |
727 | 718 | ||
728 | /* If no valid mac address was found - bail out */ | 719 | /* If no valid mac address was found - bail out */ |
@@ -746,7 +737,7 @@ static u32 iwl_nvm_get_regdom_bw_flags(const u8 *nvm_chan, | |||
746 | u32 flags = NL80211_RRF_NO_HT40; | 737 | u32 flags = NL80211_RRF_NO_HT40; |
747 | u32 last_5ghz_ht = LAST_5GHZ_HT; | 738 | u32 last_5ghz_ht = LAST_5GHZ_HT; |
748 | 739 | ||
749 | if (cfg->device_family == IWL_DEVICE_FAMILY_8000) | 740 | if (cfg->ext_nvm) |
750 | last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000; | 741 | last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000; |
751 | 742 | ||
752 | if (ch_idx < NUM_2GHZ_CHANNELS && | 743 | if (ch_idx < NUM_2GHZ_CHANNELS && |
@@ -793,8 +784,8 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, | |||
793 | { | 784 | { |
794 | int ch_idx; | 785 | int ch_idx; |
795 | u16 ch_flags, prev_ch_flags = 0; | 786 | u16 ch_flags, prev_ch_flags = 0; |
796 | const u8 *nvm_chan = cfg->device_family == IWL_DEVICE_FAMILY_8000 ? | 787 | const u8 *nvm_chan = cfg->ext_nvm ? |
797 | iwl_nvm_channels_family_8000 : iwl_nvm_channels; | 788 | iwl_ext_nvm_channels : iwl_nvm_channels; |
798 | struct ieee80211_regdomain *regd; | 789 | struct ieee80211_regdomain *regd; |
799 | int size_of_regd; | 790 | int size_of_regd; |
800 | struct ieee80211_reg_rule *rule; | 791 | struct ieee80211_reg_rule *rule; |
@@ -802,8 +793,8 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, | |||
802 | int center_freq, prev_center_freq = 0; | 793 | int center_freq, prev_center_freq = 0; |
803 | int valid_rules = 0; | 794 | int valid_rules = 0; |
804 | bool new_rule; | 795 | bool new_rule; |
805 | int max_num_ch = cfg->device_family == IWL_DEVICE_FAMILY_8000 ? | 796 | int max_num_ch = cfg->ext_nvm ? |
806 | IWL_NUM_CHANNELS_FAMILY_8000 : IWL_NUM_CHANNELS; | 797 | IWL_NUM_CHANNELS_EXT : IWL_NUM_CHANNELS; |
807 | 798 | ||
808 | if (WARN_ON_ONCE(num_of_ch > NL80211_MAX_SUPP_REG_RULES)) | 799 | if (WARN_ON_ONCE(num_of_ch > NL80211_MAX_SUPP_REG_RULES)) |
809 | return ERR_PTR(-EINVAL); | 800 | return ERR_PTR(-EINVAL); |