Lines Matching +full:in +full:- +full:band

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2005-2014, 2018-2020 Intel Corporation
9 #include "iwl-drv.h"
10 #include "iwl-modparams.h"
11 #include "iwl-eeprom-parse.h"
29 /* corresponding link offsets in EEPROM */
75 #define EEPROM_RF_CFG_TYPE_MSK(x) (x & 0x3) /* bits 0-1 */
76 #define EEPROM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */
77 #define EEPROM_RF_CFG_DASH_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */
78 #define EEPROM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */
79 #define EEPROM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */
80 #define EEPROM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */
85 * These are the channel numbers from each band in the order
86 * that they are stored in the EEPROM band information. Note
88 * there are even special "ht40 bands" in the EEPROM.
94 static const u8 iwl_eeprom_band_2[] = { /* 4915-5080MHz */
98 static const u8 iwl_eeprom_band_3[] = { /* 5170-5320MHz */
102 static const u8 iwl_eeprom_band_4[] = { /* 5500-5700MHz */
106 static const u8 iwl_eeprom_band_5[] = { /* 5725-5825MHz */
145 #define N_RATES_52 (N_RATES_24 - RATES_52_OFFS)
225 return -ENODATA; in iwl_eeprom_read_calib()
226 data->calib_version = hdr->version; in iwl_eeprom_read_calib()
227 data->calib_voltage = hdr->voltage; in iwl_eeprom_read_calib()
233 * enum iwl_eeprom_channel_flags - channel flags in EEPROM
251 * struct iwl_eeprom_channel - EEPROM channel data
253 * @max_power_avg: max power (in dBm) on this channel, at most 31 dBm
276 * @chain_a_max: chain a max power in 1/2 dBm
277 * @chain_b_max: chain b max power in 1/2 dBm
278 * @chain_c_max: chain c max power in 1/2 dBm
279 * @delta_20_in_40: 20-in-40 deltas (hi/lo)
280 * @mimo2_max: mimo2 max power in 1/2 dBm
281 * @mimo3_max: mimo3 max power in 1/2 dBm
284 * in an EEPROM image.
303 if (data->valid_tx_ant & ANT_A && txp->chain_a_max > result) in iwl_get_max_txpwr_half_dbm()
304 result = txp->chain_a_max; in iwl_get_max_txpwr_half_dbm()
306 if (data->valid_tx_ant & ANT_B && txp->chain_b_max > result) in iwl_get_max_txpwr_half_dbm()
307 result = txp->chain_b_max; in iwl_get_max_txpwr_half_dbm()
309 if (data->valid_tx_ant & ANT_C && txp->chain_c_max > result) in iwl_get_max_txpwr_half_dbm()
310 result = txp->chain_c_max; in iwl_get_max_txpwr_half_dbm()
312 if ((data->valid_tx_ant == ANT_AB || in iwl_get_max_txpwr_half_dbm()
313 data->valid_tx_ant == ANT_BC || in iwl_get_max_txpwr_half_dbm()
314 data->valid_tx_ant == ANT_AC) && txp->mimo2_max > result) in iwl_get_max_txpwr_half_dbm()
315 result = txp->mimo2_max; in iwl_get_max_txpwr_half_dbm()
317 if (data->valid_tx_ant == ANT_ABC && txp->mimo3_max > result) in iwl_get_max_txpwr_half_dbm()
318 result = txp->mimo3_max; in iwl_get_max_txpwr_half_dbm()
328 ((txp->flags & IWL_EEPROM_ENH_TXP_FL_##x) ? # x " " : "")
336 enum nl80211_band band; in iwl_eeprom_enh_txp_read_element() local
338 band = txp->flags & IWL_EEPROM_ENH_TXP_FL_BAND_52G ? in iwl_eeprom_enh_txp_read_element()
342 struct ieee80211_channel *chan = &data->channels[ch_idx]; in iwl_eeprom_enh_txp_read_element()
345 if (txp->channel != 0 && chan->hw_value != txp->channel) in iwl_eeprom_enh_txp_read_element()
348 /* update matching band only */ in iwl_eeprom_enh_txp_read_element()
349 if (band != chan->band) in iwl_eeprom_enh_txp_read_element()
352 if (chan->max_power < max_txpower_avg && in iwl_eeprom_enh_txp_read_element()
353 !(txp->flags & IWL_EEPROM_ENH_TXP_FL_40MHZ)) in iwl_eeprom_enh_txp_read_element()
354 chan->max_power = max_txpower_avg; in iwl_eeprom_enh_txp_read_element()
370 /* the length is in 16-bit words, but we want entries */ in iwl_eeprom_enhanced_txpower()
381 if (!(txp->flags & IWL_EEPROM_ENH_TXP_FL_VALID)) in iwl_eeprom_enhanced_txpower()
385 (txp->channel && (txp->flags & in iwl_eeprom_enhanced_txpower()
387 "Common " : (txp->channel) ? in iwl_eeprom_enhanced_txpower()
389 (txp->channel), in iwl_eeprom_enhanced_txpower()
398 txp->flags); in iwl_eeprom_enhanced_txpower()
401 txp->chain_a_max, txp->chain_b_max, in iwl_eeprom_enhanced_txpower()
402 txp->chain_c_max); in iwl_eeprom_enhanced_txpower()
405 txp->mimo2_max, txp->mimo3_max, in iwl_eeprom_enhanced_txpower()
406 ((txp->delta_20_in_40 & 0xf0) >> 4), in iwl_eeprom_enhanced_txpower()
407 (txp->delta_20_in_40 & 0x0f)); in iwl_eeprom_enhanced_txpower()
414 if (max_txp_avg_halfdbm > data->max_tx_pwr_half_dbm) in iwl_eeprom_enhanced_txpower()
415 data->max_tx_pwr_half_dbm = max_txp_avg_halfdbm; in iwl_eeprom_enhanced_txpower()
425 u32 offset = cfg->eeprom_params->regulatory_bands[eeprom_band - 1]; in iwl_init_band_reference()
432 case 1: /* 2.4GHz band */ in iwl_init_band_reference()
436 case 2: /* 4.9GHz band */ in iwl_init_band_reference()
440 case 3: /* 5.2GHz band */ in iwl_init_band_reference()
444 case 4: /* 5.5GHz band */ in iwl_init_band_reference()
448 case 5: /* 5.7GHz band */ in iwl_init_band_reference()
468 ((eeprom_ch->flags & EEPROM_CHANNEL_##x) ? # x " " : "")
472 enum nl80211_band band, u16 channel, in iwl_mod_ht40_chan_info() argument
480 if (data->channels[i].band != band) in iwl_mod_ht40_chan_info()
482 if (data->channels[i].hw_value != channel) in iwl_mod_ht40_chan_info()
484 chan = &data->channels[i]; in iwl_mod_ht40_chan_info()
492 "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm): Ad-Hoc %ssupported\n", in iwl_mod_ht40_chan_info()
494 band == NL80211_BAND_5GHZ ? "5.2" : "2.4", in iwl_mod_ht40_chan_info()
500 eeprom_ch->flags, in iwl_mod_ht40_chan_info()
501 eeprom_ch->max_power_avg, in iwl_mod_ht40_chan_info()
502 ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS) && in iwl_mod_ht40_chan_info()
503 !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ? "" in iwl_mod_ht40_chan_info()
506 if (eeprom_ch->flags & EEPROM_CHANNEL_VALID) in iwl_mod_ht40_chan_info()
507 chan->flags &= ~clear_ht40_extension_channel; in iwl_mod_ht40_chan_info()
517 int band, ch_idx; in iwl_init_channel_map() local
526 for (band = 1; band <= 5; band++) { in iwl_init_channel_map()
529 iwl_init_band_reference(cfg, eeprom, eeprom_size, band, in iwl_init_channel_map()
533 /* Loop through each band adding each of the channels */ in iwl_init_channel_map()
539 if (!(eeprom_ch->flags & EEPROM_CHANNEL_VALID)) { in iwl_init_channel_map()
541 "Ch. %d Flags %x [%sGHz] - No traffic\n", in iwl_init_channel_map()
544 (band != 1) ? "5.2" : "2.4"); in iwl_init_channel_map()
548 channel = &data->channels[n_channels]; in iwl_init_channel_map()
551 channel->hw_value = eeprom_ch_array[ch_idx]; in iwl_init_channel_map()
552 channel->band = (band == 1) ? NL80211_BAND_2GHZ in iwl_init_channel_map()
554 channel->center_freq = in iwl_init_channel_map()
556 channel->hw_value, channel->band); in iwl_init_channel_map()
558 /* set no-HT40, will enable as appropriate later */ in iwl_init_channel_map()
559 channel->flags = IEEE80211_CHAN_NO_HT40; in iwl_init_channel_map()
561 if (!(eeprom_ch->flags & EEPROM_CHANNEL_IBSS)) in iwl_init_channel_map()
562 channel->flags |= IEEE80211_CHAN_NO_IR; in iwl_init_channel_map()
564 if (!(eeprom_ch->flags & EEPROM_CHANNEL_ACTIVE)) in iwl_init_channel_map()
565 channel->flags |= IEEE80211_CHAN_NO_IR; in iwl_init_channel_map()
567 if (eeprom_ch->flags & EEPROM_CHANNEL_RADAR) in iwl_init_channel_map()
568 channel->flags |= IEEE80211_CHAN_RADAR; in iwl_init_channel_map()
570 /* Initialize regulatory-based run-time data */ in iwl_init_channel_map()
571 channel->max_power = in iwl_init_channel_map()
574 "Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x %ddBm): Ad-Hoc %ssupported\n", in iwl_init_channel_map()
575 channel->hw_value, in iwl_init_channel_map()
576 (band != 1) ? "5.2" : "2.4", in iwl_init_channel_map()
593 if (cfg->eeprom_params->enhanced_txpower) { in iwl_init_channel_map()
606 data->max_tx_pwr_half_dbm = -128; in iwl_init_channel_map()
609 data->max_tx_pwr_half_dbm = in iwl_init_channel_map()
610 max_t(s8, data->max_tx_pwr_half_dbm, in iwl_init_channel_map()
611 data->channels[i].max_power * 2); in iwl_init_channel_map()
615 if (cfg->eeprom_params->regulatory_bands[5] == in iwl_init_channel_map()
617 cfg->eeprom_params->regulatory_bands[6] == in iwl_init_channel_map()
622 for (band = 6; band <= 7; band++) { in iwl_init_channel_map()
625 iwl_init_band_reference(cfg, eeprom, eeprom_size, band, in iwl_init_channel_map()
629 /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ in iwl_init_channel_map()
630 ieeeband = (band == 6) ? NL80211_BAND_2GHZ in iwl_init_channel_map()
633 /* Loop through each band adding each of the channels */ in iwl_init_channel_map()
655 int n_channels, enum nl80211_band band) in iwl_init_sband_channels() argument
657 struct ieee80211_channel *chan = &data->channels[0]; in iwl_init_sband_channels()
660 while (idx < n_channels && chan->band != band) in iwl_init_sband_channels()
661 chan = &data->channels[++idx]; in iwl_init_sband_channels()
663 sband->channels = &data->channels[idx]; in iwl_init_sband_channels()
665 while (idx < n_channels && chan->band == band) { in iwl_init_sband_channels()
666 chan = &data->channels[++idx]; in iwl_init_sband_channels()
670 sband->n_channels = n; in iwl_init_sband_channels()
681 enum nl80211_band band, in iwl_init_ht_hw_capab() argument
684 const struct iwl_cfg *cfg = trans->cfg; in iwl_init_ht_hw_capab()
688 if (cfg->rx_with_siso_diversity) in iwl_init_ht_hw_capab()
693 if (!(data->sku_cap_11n_enable) || in iwl_init_ht_hw_capab()
695 !cfg->ht_params) { in iwl_init_ht_hw_capab()
696 ht_info->ht_supported = false; in iwl_init_ht_hw_capab()
700 if (data->sku_cap_mimo_disabled) in iwl_init_ht_hw_capab()
703 ht_info->ht_supported = true; in iwl_init_ht_hw_capab()
704 ht_info->cap = IEEE80211_HT_CAP_DSSSCCK40; in iwl_init_ht_hw_capab()
706 if (cfg->ht_params->stbc) { in iwl_init_ht_hw_capab()
707 ht_info->cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); in iwl_init_ht_hw_capab()
710 ht_info->cap |= IEEE80211_HT_CAP_TX_STBC; in iwl_init_ht_hw_capab()
713 if (cfg->ht_params->ldpc) in iwl_init_ht_hw_capab()
714 ht_info->cap |= IEEE80211_HT_CAP_LDPC_CODING; in iwl_init_ht_hw_capab()
716 if (trans->trans_cfg->mq_rx_supported || in iwl_init_ht_hw_capab()
718 ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU; in iwl_init_ht_hw_capab()
720 ht_info->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; in iwl_init_ht_hw_capab()
721 ht_info->ampdu_density = IEEE80211_HT_MPDU_DENSITY_4; in iwl_init_ht_hw_capab()
723 ht_info->mcs.rx_mask[0] = 0xFF; in iwl_init_ht_hw_capab()
725 ht_info->mcs.rx_mask[1] = 0xFF; in iwl_init_ht_hw_capab()
727 ht_info->mcs.rx_mask[2] = 0xFF; in iwl_init_ht_hw_capab()
729 if (cfg->ht_params->ht_greenfield_support) in iwl_init_ht_hw_capab()
730 ht_info->cap |= IEEE80211_HT_CAP_GRN_FLD; in iwl_init_ht_hw_capab()
731 ht_info->cap |= IEEE80211_HT_CAP_SGI_20; in iwl_init_ht_hw_capab()
735 if (cfg->ht_params->ht40_bands & BIT(band)) { in iwl_init_ht_hw_capab()
736 ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; in iwl_init_ht_hw_capab()
737 ht_info->cap |= IEEE80211_HT_CAP_SGI_40; in iwl_init_ht_hw_capab()
744 ht_info->mcs.rx_highest = cpu_to_le16(max_bit_rate); in iwl_init_ht_hw_capab()
747 ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; in iwl_init_ht_hw_capab()
749 ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; in iwl_init_ht_hw_capab()
750 ht_info->mcs.tx_params |= ((tx_chains - 1) << in iwl_init_ht_hw_capab()
760 struct device *dev = trans->dev; in iwl_init_sbands()
766 sband = &data->bands[NL80211_BAND_2GHZ]; in iwl_init_sbands()
767 sband->band = NL80211_BAND_2GHZ; in iwl_init_sbands()
768 sband->bitrates = &iwl_cfg80211_rates[RATES_24_OFFS]; in iwl_init_sbands()
769 sband->n_bitrates = N_RATES_24; in iwl_init_sbands()
772 iwl_init_ht_hw_capab(trans, data, &sband->ht_cap, NL80211_BAND_2GHZ, in iwl_init_sbands()
773 data->valid_tx_ant, data->valid_rx_ant); in iwl_init_sbands()
775 sband = &data->bands[NL80211_BAND_5GHZ]; in iwl_init_sbands()
776 sband->band = NL80211_BAND_5GHZ; in iwl_init_sbands()
777 sband->bitrates = &iwl_cfg80211_rates[RATES_52_OFFS]; in iwl_init_sbands()
778 sband->n_bitrates = N_RATES_52; in iwl_init_sbands()
781 iwl_init_ht_hw_capab(trans, data, &sband->ht_cap, NL80211_BAND_5GHZ, in iwl_init_sbands()
782 data->valid_tx_ant, data->valid_rx_ant); in iwl_init_sbands()
796 struct device *dev = trans->dev; in iwl_parse_eeprom_data()
800 if (WARN_ON(!cfg || !cfg->eeprom_params)) in iwl_parse_eeprom_data()
812 memcpy(data->hw_addr, tmp, ETH_ALEN); in iwl_parse_eeprom_data()
813 data->n_hw_addrs = iwl_eeprom_query16(eeprom, eeprom_size, in iwl_parse_eeprom_data()
822 memcpy(data->xtal_calib, tmp, sizeof(data->xtal_calib)); in iwl_parse_eeprom_data()
828 data->raw_temperature = *(__le16 *)tmp; in iwl_parse_eeprom_data()
834 data->kelvin_temperature = *(__le16 *)tmp; in iwl_parse_eeprom_data()
835 data->kelvin_voltage = *((__le16 *)tmp + 1); in iwl_parse_eeprom_data()
839 data->radio_cfg_dash = EEPROM_RF_CFG_DASH_MSK(radio_cfg); in iwl_parse_eeprom_data()
840 data->radio_cfg_pnum = EEPROM_RF_CFG_PNUM_MSK(radio_cfg); in iwl_parse_eeprom_data()
841 data->radio_cfg_step = EEPROM_RF_CFG_STEP_MSK(radio_cfg); in iwl_parse_eeprom_data()
842 data->radio_cfg_type = EEPROM_RF_CFG_TYPE_MSK(radio_cfg); in iwl_parse_eeprom_data()
843 data->valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg); in iwl_parse_eeprom_data()
844 data->valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg); in iwl_parse_eeprom_data()
848 data->sku_cap_11n_enable = sku & EEPROM_SKU_CAP_11N_ENABLE; in iwl_parse_eeprom_data()
849 data->sku_cap_amt_enable = sku & EEPROM_SKU_CAP_AMT_ENABLE; in iwl_parse_eeprom_data()
850 data->sku_cap_band_24ghz_enable = sku & EEPROM_SKU_CAP_BAND_24GHZ; in iwl_parse_eeprom_data()
851 data->sku_cap_band_52ghz_enable = sku & EEPROM_SKU_CAP_BAND_52GHZ; in iwl_parse_eeprom_data()
852 data->sku_cap_ipan_enable = sku & EEPROM_SKU_CAP_IPAN_ENABLE; in iwl_parse_eeprom_data()
854 data->sku_cap_11n_enable = false; in iwl_parse_eeprom_data()
856 data->nvm_version = iwl_eeprom_query16(eeprom, eeprom_size, in iwl_parse_eeprom_data()
860 if (cfg->valid_tx_ant) in iwl_parse_eeprom_data()
861 data->valid_tx_ant = cfg->valid_tx_ant; in iwl_parse_eeprom_data()
862 if (cfg->valid_rx_ant) in iwl_parse_eeprom_data()
863 data->valid_rx_ant = cfg->valid_rx_ant; in iwl_parse_eeprom_data()
865 if (!data->valid_tx_ant || !data->valid_rx_ant) { in iwl_parse_eeprom_data()
867 data->valid_tx_ant, data->valid_rx_ant); in iwl_parse_eeprom_data()