aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c88
1 files changed, 86 insertions, 2 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c
index dbada761624d..cf9194baadac 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c
@@ -433,7 +433,7 @@ static s8 iwl_update_channel_txpower(struct iwl_priv *priv,
433/** 433/**
434 * iwlcore_eeprom_enhanced_txpower: process enhanced tx power info 434 * iwlcore_eeprom_enhanced_txpower: process enhanced tx power info
435 */ 435 */
436void iwlcore_eeprom_enhanced_txpower(struct iwl_priv *priv) 436static void iwlcore_eeprom_enhanced_txpower_old(struct iwl_priv *priv)
437{ 437{
438 int eeprom_section_count = 0; 438 int eeprom_section_count = 0;
439 int section, element; 439 int section, element;
@@ -460,7 +460,8 @@ void iwlcore_eeprom_enhanced_txpower(struct iwl_priv *priv)
460 * always check for valid entry before process 460 * always check for valid entry before process
461 * the information 461 * the information
462 */ 462 */
463 if (!enhanced_txpower->common || enhanced_txpower->reserved) 463 if (!(enhanced_txpower->flags || enhanced_txpower->channel) ||
464 enhanced_txpower->delta_20_in_40)
464 continue; 465 continue;
465 466
466 for (element = 0; element < eeprom_section_count; element++) { 467 for (element = 0; element < eeprom_section_count; element++) {
@@ -493,3 +494,86 @@ void iwlcore_eeprom_enhanced_txpower(struct iwl_priv *priv)
493 } 494 }
494 } 495 }
495} 496}
497
498static void
499iwlcore_eeprom_enh_txp_read_element(struct iwl_priv *priv,
500 struct iwl_eeprom_enhanced_txpwr *txp,
501 s8 max_txpower_avg)
502{
503 int ch_idx;
504 bool is_ht40 = txp->flags & IWL_EEPROM_ENH_TXP_FL_40MHZ;
505 enum ieee80211_band band;
506
507 band = txp->flags & IWL_EEPROM_ENH_TXP_FL_BAND_52G ?
508 IEEE80211_BAND_5GHZ : IEEE80211_BAND_2GHZ;
509
510 for (ch_idx = 0; ch_idx < priv->channel_count; ch_idx++) {
511 struct iwl_channel_info *ch_info = &priv->channel_info[ch_idx];
512
513 /* update matching channel or from common data only */
514 if (txp->channel != 0 && ch_info->channel != txp->channel)
515 continue;
516
517 /* update matching band only */
518 if (band != ch_info->band)
519 continue;
520
521 if (ch_info->max_power_avg < max_txpower_avg && !is_ht40) {
522 ch_info->max_power_avg = max_txpower_avg;
523 ch_info->curr_txpow = max_txpower_avg;
524 ch_info->scan_power = max_txpower_avg;
525 }
526
527 if (is_ht40 && ch_info->ht40_max_power_avg < max_txpower_avg)
528 ch_info->ht40_max_power_avg = max_txpower_avg;
529 }
530}
531
532#define EEPROM_TXP_OFFS (0x00 | INDIRECT_ADDRESS | INDIRECT_TXP_LIMIT)
533#define EEPROM_TXP_ENTRY_LEN sizeof(struct iwl_eeprom_enhanced_txpwr)
534#define EEPROM_TXP_SZ_OFFS (0x00 | INDIRECT_ADDRESS | INDIRECT_TXP_LIMIT_SIZE)
535
536static void iwlcore_eeprom_enhanced_txpower_new(struct iwl_priv *priv)
537{
538 struct iwl_eeprom_enhanced_txpwr *txp_array, *txp;
539 int idx, entries;
540 __le16 *txp_len;
541 s8 max_txp_avg, max_txp_avg_halfdbm;
542
543 BUILD_BUG_ON(sizeof(struct iwl_eeprom_enhanced_txpwr) != 8);
544
545 /* the length is in 16-bit words, but we want entries */
546 txp_len = (__le16 *) iwlagn_eeprom_query_addr(priv, EEPROM_TXP_SZ_OFFS);
547 entries = le16_to_cpup(txp_len) * 2 / EEPROM_TXP_ENTRY_LEN;
548
549 txp_array = (void *) iwlagn_eeprom_query_addr(priv, EEPROM_TXP_OFFS);
550 for (idx = 0; idx < entries; idx++) {
551 txp = &txp_array[idx];
552
553 /* skip invalid entries */
554 if (!(txp->flags & IWL_EEPROM_ENH_TXP_FL_VALID))
555 continue;
556
557 max_txp_avg = iwl_get_max_txpower_avg(priv, txp_array, idx,
558 &max_txp_avg_halfdbm);
559
560 /*
561 * Update the user limit values values to the highest
562 * power supported by any channel
563 */
564 if (max_txp_avg > priv->tx_power_user_lmt)
565 priv->tx_power_user_lmt = max_txp_avg;
566 if (max_txp_avg_halfdbm > priv->tx_power_lmt_in_half_dbm)
567 priv->tx_power_lmt_in_half_dbm = max_txp_avg_halfdbm;
568
569 iwlcore_eeprom_enh_txp_read_element(priv, txp, max_txp_avg);
570 }
571}
572
573void iwlcore_eeprom_enhanced_txpower(struct iwl_priv *priv)
574{
575 if (priv->cfg->use_new_eeprom_reading)
576 iwlcore_eeprom_enhanced_txpower_new(priv);
577 else
578 iwlcore_eeprom_enhanced_txpower_old(priv);
579}