aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-agn-calib.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
index 988ee454a944..84cbe7bb504c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
@@ -68,13 +68,19 @@
68#include "iwl-agn-calib.h" 68#include "iwl-agn-calib.h"
69#include "iwl-trans.h" 69#include "iwl-trans.h"
70#include "iwl-agn.h" 70#include "iwl-agn.h"
71#include "iwl-wifi.h"
72#include "iwl-ucode.h"
73 71
74/***************************************************************************** 72/*****************************************************************************
75 * INIT calibrations framework 73 * INIT calibrations framework
76 *****************************************************************************/ 74 *****************************************************************************/
77 75
76/* Opaque calibration results */
77struct iwl_calib_result {
78 struct list_head list;
79 size_t cmd_len;
80 struct iwl_calib_hdr hdr;
81 /* data follows */
82};
83
78struct statistics_general_data { 84struct statistics_general_data {
79 u32 beacon_silence_rssi_a; 85 u32 beacon_silence_rssi_a;
80 u32 beacon_silence_rssi_b; 86 u32 beacon_silence_rssi_b;
@@ -84,7 +90,7 @@ struct statistics_general_data {
84 u32 beacon_energy_c; 90 u32 beacon_energy_c;
85}; 91};
86 92
87int iwl_send_calib_results(struct iwl_trans *trans) 93int iwl_send_calib_results(struct iwl_priv *priv)
88{ 94{
89 struct iwl_host_cmd hcmd = { 95 struct iwl_host_cmd hcmd = {
90 .id = REPLY_PHY_CALIBRATION_CMD, 96 .id = REPLY_PHY_CALIBRATION_CMD,
@@ -92,15 +98,15 @@ int iwl_send_calib_results(struct iwl_trans *trans)
92 }; 98 };
93 struct iwl_calib_result *res; 99 struct iwl_calib_result *res;
94 100
95 list_for_each_entry(res, &trans->calib_results, list) { 101 list_for_each_entry(res, &priv->calib_results, list) {
96 int ret; 102 int ret;
97 103
98 hcmd.len[0] = res->cmd_len; 104 hcmd.len[0] = res->cmd_len;
99 hcmd.data[0] = &res->hdr; 105 hcmd.data[0] = &res->hdr;
100 hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; 106 hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY;
101 ret = iwl_trans_send_cmd(trans, &hcmd); 107 ret = iwl_dvm_send_cmd(priv, &hcmd);
102 if (ret) { 108 if (ret) {
103 IWL_ERR(trans, "Error %d on calib cmd %d\n", 109 IWL_ERR(priv, "Error %d on calib cmd %d\n",
104 ret, res->hdr.op_code); 110 ret, res->hdr.op_code);
105 return ret; 111 return ret;
106 } 112 }
@@ -109,7 +115,7 @@ int iwl_send_calib_results(struct iwl_trans *trans)
109 return 0; 115 return 0;
110} 116}
111 117
112int iwl_calib_set(struct iwl_trans *trans, 118int iwl_calib_set(struct iwl_priv *priv,
113 const struct iwl_calib_hdr *cmd, int len) 119 const struct iwl_calib_hdr *cmd, int len)
114{ 120{
115 struct iwl_calib_result *res, *tmp; 121 struct iwl_calib_result *res, *tmp;
@@ -121,7 +127,7 @@ int iwl_calib_set(struct iwl_trans *trans,
121 memcpy(&res->hdr, cmd, len); 127 memcpy(&res->hdr, cmd, len);
122 res->cmd_len = len; 128 res->cmd_len = len;
123 129
124 list_for_each_entry(tmp, &trans->calib_results, list) { 130 list_for_each_entry(tmp, &priv->calib_results, list) {
125 if (tmp->hdr.op_code == res->hdr.op_code) { 131 if (tmp->hdr.op_code == res->hdr.op_code) {
126 list_replace(&tmp->list, &res->list); 132 list_replace(&tmp->list, &res->list);
127 kfree(tmp); 133 kfree(tmp);
@@ -130,16 +136,16 @@ int iwl_calib_set(struct iwl_trans *trans,
130 } 136 }
131 137
132 /* wasn't in list already */ 138 /* wasn't in list already */
133 list_add_tail(&res->list, &trans->calib_results); 139 list_add_tail(&res->list, &priv->calib_results);
134 140
135 return 0; 141 return 0;
136} 142}
137 143
138void iwl_calib_free_results(struct iwl_trans *trans) 144void iwl_calib_free_results(struct iwl_priv *priv)
139{ 145{
140 struct iwl_calib_result *res, *tmp; 146 struct iwl_calib_result *res, *tmp;
141 147
142 list_for_each_entry_safe(res, tmp, &trans->calib_results, list) { 148 list_for_each_entry_safe(res, tmp, &priv->calib_results, list) {
143 list_del(&res->list); 149 list_del(&res->list);
144 kfree(res); 150 kfree(res);
145 } 151 }
@@ -494,7 +500,7 @@ static int iwl_sensitivity_write(struct iwl_priv *priv)
494 memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), 500 memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]),
495 sizeof(u16)*HD_TABLE_SIZE); 501 sizeof(u16)*HD_TABLE_SIZE);
496 502
497 return iwl_trans_send_cmd(trans(priv), &cmd_out); 503 return iwl_dvm_send_cmd(priv, &cmd_out);
498} 504}
499 505
500/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ 506/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */
@@ -583,7 +589,7 @@ static int iwl_enhance_sensitivity_write(struct iwl_priv *priv)
583 &(cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX]), 589 &(cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX]),
584 sizeof(u16)*ENHANCE_HD_TABLE_ENTRIES); 590 sizeof(u16)*ENHANCE_HD_TABLE_ENTRIES);
585 591
586 return iwl_trans_send_cmd(trans(priv), &cmd_out); 592 return iwl_dvm_send_cmd(priv, &cmd_out);
587} 593}
588 594
589void iwl_init_sensitivity(struct iwl_priv *priv) 595void iwl_init_sensitivity(struct iwl_priv *priv)
@@ -636,7 +642,7 @@ void iwl_init_sensitivity(struct iwl_priv *priv)
636 data->last_bad_plcp_cnt_cck = 0; 642 data->last_bad_plcp_cnt_cck = 0;
637 data->last_fa_cnt_cck = 0; 643 data->last_fa_cnt_cck = 0;
638 644
639 if (nic(priv)->fw.enhance_sensitivity_table) 645 if (priv->fw->enhance_sensitivity_table)
640 ret |= iwl_enhance_sensitivity_write(priv); 646 ret |= iwl_enhance_sensitivity_write(priv);
641 else 647 else
642 ret |= iwl_sensitivity_write(priv); 648 ret |= iwl_sensitivity_write(priv);
@@ -655,7 +661,6 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv)
655 struct iwl_sensitivity_data *data = NULL; 661 struct iwl_sensitivity_data *data = NULL;
656 struct statistics_rx_non_phy *rx_info; 662 struct statistics_rx_non_phy *rx_info;
657 struct statistics_rx_phy *ofdm, *cck; 663 struct statistics_rx_phy *ofdm, *cck;
658 unsigned long flags;
659 struct statistics_general_data statis; 664 struct statistics_general_data statis;
660 665
661 if (priv->disable_sens_cal) 666 if (priv->disable_sens_cal)
@@ -668,13 +673,13 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv)
668 return; 673 return;
669 } 674 }
670 675
671 spin_lock_irqsave(&priv->shrd->lock, flags); 676 spin_lock_bh(&priv->statistics.lock);
672 rx_info = &priv->statistics.rx_non_phy; 677 rx_info = &priv->statistics.rx_non_phy;
673 ofdm = &priv->statistics.rx_ofdm; 678 ofdm = &priv->statistics.rx_ofdm;
674 cck = &priv->statistics.rx_cck; 679 cck = &priv->statistics.rx_cck;
675 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { 680 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) {
676 IWL_DEBUG_CALIB(priv, "<< invalid data.\n"); 681 IWL_DEBUG_CALIB(priv, "<< invalid data.\n");
677 spin_unlock_irqrestore(&priv->shrd->lock, flags); 682 spin_unlock_bh(&priv->statistics.lock);
678 return; 683 return;
679 } 684 }
680 685
@@ -698,7 +703,7 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv)
698 statis.beacon_energy_c = 703 statis.beacon_energy_c =
699 le32_to_cpu(rx_info->beacon_energy_c); 704 le32_to_cpu(rx_info->beacon_energy_c);
700 705
701 spin_unlock_irqrestore(&priv->shrd->lock, flags); 706 spin_unlock_bh(&priv->statistics.lock);
702 707
703 IWL_DEBUG_CALIB(priv, "rx_enable_time = %u usecs\n", rx_enable_time); 708 IWL_DEBUG_CALIB(priv, "rx_enable_time = %u usecs\n", rx_enable_time);
704 709
@@ -747,7 +752,7 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv)
747 752
748 iwl_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time); 753 iwl_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time);
749 iwl_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis); 754 iwl_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis);
750 if (nic(priv)->fw.enhance_sensitivity_table) 755 if (priv->fw->enhance_sensitivity_table)
751 iwl_enhance_sensitivity_write(priv); 756 iwl_enhance_sensitivity_write(priv);
752 else 757 else
753 iwl_sensitivity_write(priv); 758 iwl_sensitivity_write(priv);
@@ -849,7 +854,7 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig,
849 * connect the first valid tx chain 854 * connect the first valid tx chain
850 */ 855 */
851 first_chain = 856 first_chain =
852 find_first_chain(cfg(priv)->valid_tx_ant); 857 find_first_chain(hw_params(priv).valid_tx_ant);
853 data->disconn_array[first_chain] = 0; 858 data->disconn_array[first_chain] = 0;
854 active_chains |= BIT(first_chain); 859 active_chains |= BIT(first_chain);
855 IWL_DEBUG_CALIB(priv, 860 IWL_DEBUG_CALIB(priv,
@@ -874,10 +879,8 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig,
874} 879}
875 880
876static void iwlagn_gain_computation(struct iwl_priv *priv, 881static void iwlagn_gain_computation(struct iwl_priv *priv,
877 u32 average_noise[NUM_RX_CHAINS], 882 u32 average_noise[NUM_RX_CHAINS],
878 u16 min_average_noise_antenna_i, 883 u8 default_chain)
879 u32 min_average_noise,
880 u8 default_chain)
881{ 884{
882 int i; 885 int i;
883 s32 delta_g; 886 s32 delta_g;
@@ -925,7 +928,7 @@ static void iwlagn_gain_computation(struct iwl_priv *priv,
925 priv->phy_calib_chain_noise_gain_cmd); 928 priv->phy_calib_chain_noise_gain_cmd);
926 cmd.delta_gain_1 = data->delta_gain_code[1]; 929 cmd.delta_gain_1 = data->delta_gain_code[1];
927 cmd.delta_gain_2 = data->delta_gain_code[2]; 930 cmd.delta_gain_2 = data->delta_gain_code[2];
928 iwl_trans_send_cmd_pdu(trans(priv), REPLY_PHY_CALIBRATION_CMD, 931 iwl_dvm_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
929 CMD_ASYNC, sizeof(cmd), &cmd); 932 CMD_ASYNC, sizeof(cmd), &cmd);
930 933
931 data->radio_write = 1; 934 data->radio_write = 1;
@@ -958,7 +961,6 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
958 u16 stat_chnum = INITIALIZATION_VALUE; 961 u16 stat_chnum = INITIALIZATION_VALUE;
959 u8 rxon_band24; 962 u8 rxon_band24;
960 u8 stat_band24; 963 u8 stat_band24;
961 unsigned long flags;
962 struct statistics_rx_non_phy *rx_info; 964 struct statistics_rx_non_phy *rx_info;
963 965
964 /* 966 /*
@@ -983,13 +985,13 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
983 return; 985 return;
984 } 986 }
985 987
986 spin_lock_irqsave(&priv->shrd->lock, flags); 988 spin_lock_bh(&priv->statistics.lock);
987 989
988 rx_info = &priv->statistics.rx_non_phy; 990 rx_info = &priv->statistics.rx_non_phy;
989 991
990 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { 992 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) {
991 IWL_DEBUG_CALIB(priv, " << Interference data unavailable\n"); 993 IWL_DEBUG_CALIB(priv, " << Interference data unavailable\n");
992 spin_unlock_irqrestore(&priv->shrd->lock, flags); 994 spin_unlock_bh(&priv->statistics.lock);
993 return; 995 return;
994 } 996 }
995 997
@@ -1004,7 +1006,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
1004 if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) { 1006 if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) {
1005 IWL_DEBUG_CALIB(priv, "Stats not from chan=%d, band24=%d\n", 1007 IWL_DEBUG_CALIB(priv, "Stats not from chan=%d, band24=%d\n",
1006 rxon_chnum, rxon_band24); 1008 rxon_chnum, rxon_band24);
1007 spin_unlock_irqrestore(&priv->shrd->lock, flags); 1009 spin_unlock_bh(&priv->statistics.lock);
1008 return; 1010 return;
1009 } 1011 }
1010 1012
@@ -1023,7 +1025,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
1023 chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER; 1025 chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER;
1024 chain_sig_c = le32_to_cpu(rx_info->beacon_rssi_c) & IN_BAND_FILTER; 1026 chain_sig_c = le32_to_cpu(rx_info->beacon_rssi_c) & IN_BAND_FILTER;
1025 1027
1026 spin_unlock_irqrestore(&priv->shrd->lock, flags); 1028 spin_unlock_bh(&priv->statistics.lock);
1027 1029
1028 data->beacon_count++; 1030 data->beacon_count++;
1029 1031
@@ -1083,8 +1085,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
1083 min_average_noise, min_average_noise_antenna_i); 1085 min_average_noise, min_average_noise_antenna_i);
1084 1086
1085 iwlagn_gain_computation(priv, average_noise, 1087 iwlagn_gain_computation(priv, average_noise,
1086 min_average_noise_antenna_i, min_average_noise, 1088 find_first_chain(hw_params(priv).valid_rx_ant));
1087 find_first_chain(cfg(priv)->valid_rx_ant));
1088 1089
1089 /* Some power changes may have been made during the calibration. 1090 /* Some power changes may have been made during the calibration.
1090 * Update and commit the RXON 1091 * Update and commit the RXON