aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2008-10-07 21:37:27 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-10-31 19:00:02 -0400
commitbe5d56ed885a2897ec813eab4a8055d495816e9a (patch)
tree26cada5850d10ec41b912f66f33130727e866a33
parent1397dcebd8f1d66528e8f86b0dfb603281558f79 (diff)
iwlwifi: make initial calibration set configurable
This patch adds ability to configure initial calibration set. Not all HW supported by iwlwifi use the same calibration set, XTAL is one example. Some clean ups are also included in this patch. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000-hw.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c44
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-calib.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h27
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h4
5 files changed, 49 insertions, 35 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000-hw.h b/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
index c479ee211c5c..66ed993a7298 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
@@ -132,6 +132,7 @@ struct iwl5000_shared {
132/* calibrations defined for 5000 */ 132/* calibrations defined for 5000 */
133/* defines the order in which results should be sent to the runtime uCode */ 133/* defines the order in which results should be sent to the runtime uCode */
134enum iwl5000_calib { 134enum iwl5000_calib {
135 IWL5000_CALIB_XTAL,
135 IWL5000_CALIB_LO, 136 IWL5000_CALIB_LO,
136 IWL5000_CALIB_TX_IQ, 137 IWL5000_CALIB_TX_IQ,
137 IWL5000_CALIB_TX_IQ_PERD, 138 IWL5000_CALIB_TX_IQ_PERD,
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 5155b8a760a7..c1300fb71615 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -429,20 +429,19 @@ static const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv,
429/* 429/*
430 * Calibration 430 * Calibration
431 */ 431 */
432static int iwl5000_send_Xtal_calib(struct iwl_priv *priv) 432static int iwl5000_set_Xtal_calib(struct iwl_priv *priv)
433{ 433{
434 u8 data[sizeof(struct iwl5000_calib_hdr) +
435 sizeof(struct iwl_cal_xtal_freq)];
436 struct iwl5000_calib_cmd *cmd = (struct iwl5000_calib_cmd *)data;
437 struct iwl_cal_xtal_freq *xtal = (struct iwl_cal_xtal_freq *)cmd->data;
434 u16 *xtal_calib = (u16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL); 438 u16 *xtal_calib = (u16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL);
435 439
436 struct iwl5000_calibration cal_cmd = { 440 cmd->hdr.op_code = IWL5000_PHY_CALIBRATE_CRYSTAL_FRQ_CMD;
437 .op_code = IWL5000_PHY_CALIBRATE_CRYSTAL_FRQ_CMD, 441 xtal->cap_pin1 = (u8)xtal_calib[0];
438 .data = { 442 xtal->cap_pin2 = (u8)xtal_calib[1];
439 (u8)xtal_calib[0], 443 return iwl_calib_set(&priv->calib_results[IWL5000_CALIB_XTAL],
440 (u8)xtal_calib[1], 444 data, sizeof(data));
441 }
442 };
443
444 return iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
445 sizeof(cal_cmd), &cal_cmd);
446} 445}
447 446
448static int iwl5000_send_calib_cfg(struct iwl_priv *priv) 447static int iwl5000_send_calib_cfg(struct iwl_priv *priv)
@@ -784,10 +783,8 @@ static int iwl5000_alive_notify(struct iwl_priv *priv)
784 783
785 iwl5000_send_wimax_coex(priv); 784 iwl5000_send_wimax_coex(priv);
786 785
787 iwl5000_send_Xtal_calib(priv); 786 iwl5000_set_Xtal_calib(priv);
788 787 iwl_send_calib_results(priv);
789 if (priv->ucode_type == UCODE_RT)
790 iwl_send_calib_results(priv);
791 788
792 return 0; 789 return 0;
793} 790}
@@ -844,6 +841,23 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
844 break; 841 break;
845 } 842 }
846 843
844 /* Set initial calibration set */
845 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
846 case CSR_HW_REV_TYPE_5100:
847 case CSR_HW_REV_TYPE_5300:
848 case CSR_HW_REV_TYPE_5350:
849 priv->hw_params.calib_init_cfg =
850 BIT(IWL5000_CALIB_XTAL) |
851 BIT(IWL5000_CALIB_LO) |
852 BIT(IWL5000_CALIB_TX_IQ) |
853 BIT(IWL5000_CALIB_TX_IQ_PERD);
854 break;
855 case CSR_HW_REV_TYPE_5150:
856 priv->hw_params.calib_init_cfg = 0;
857 break;
858 }
859
860
847 return 0; 861 return 0;
848} 862}
849 863
diff --git a/drivers/net/wireless/iwlwifi/iwl-calib.c b/drivers/net/wireless/iwlwifi/iwl-calib.c
index 72fbf47229db..25f4658f1a76 100644
--- a/drivers/net/wireless/iwlwifi/iwl-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-calib.c
@@ -70,7 +70,7 @@
70 * INIT calibrations framework 70 * INIT calibrations framework
71 *****************************************************************************/ 71 *****************************************************************************/
72 72
73 int iwl_send_calib_results(struct iwl_priv *priv) 73int iwl_send_calib_results(struct iwl_priv *priv)
74{ 74{
75 int ret = 0; 75 int ret = 0;
76 int i = 0; 76 int i = 0;
@@ -80,14 +80,16 @@
80 .meta.flags = CMD_SIZE_HUGE, 80 .meta.flags = CMD_SIZE_HUGE,
81 }; 81 };
82 82
83 for (i = 0; i < IWL_CALIB_MAX; i++) 83 for (i = 0; i < IWL_CALIB_MAX; i++) {
84 if (priv->calib_results[i].buf) { 84 if ((BIT(i) & priv->hw_params.calib_init_cfg) &&
85 priv->calib_results[i].buf) {
85 hcmd.len = priv->calib_results[i].buf_len; 86 hcmd.len = priv->calib_results[i].buf_len;
86 hcmd.data = priv->calib_results[i].buf; 87 hcmd.data = priv->calib_results[i].buf;
87 ret = iwl_send_cmd_sync(priv, &hcmd); 88 ret = iwl_send_cmd_sync(priv, &hcmd);
88 if (ret) 89 if (ret)
89 goto err; 90 goto err;
90 } 91 }
92 }
91 93
92 return 0; 94 return 0;
93err: 95err:
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index 8d04e966ad48..fc467c545ce8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -98,6 +98,11 @@ enum {
98 COEX_MEDIUM_NOTIFICATION = 0x5b, 98 COEX_MEDIUM_NOTIFICATION = 0x5b,
99 COEX_EVENT_CMD = 0x5c, 99 COEX_EVENT_CMD = 0x5c,
100 100
101 /* Calibration */
102 CALIBRATION_CFG_CMD = 0x65,
103 CALIBRATION_RES_NOTIFICATION = 0x66,
104 CALIBRATION_COMPLETE_NOTIFICATION = 0x67,
105
101 /* 802.11h related */ 106 /* 802.11h related */
102 RADAR_NOTIFICATION = 0x70, /* not used */ 107 RADAR_NOTIFICATION = 0x70, /* not used */
103 REPLY_QUIET_CMD = 0x71, /* not used */ 108 REPLY_QUIET_CMD = 0x71, /* not used */
@@ -2879,25 +2884,11 @@ enum {
2879 IWL5000_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD = 19, 2884 IWL5000_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD = 19,
2880}; 2885};
2881 2886
2882enum { 2887struct iwl_cal_xtal_freq {
2883 CALIBRATION_CFG_CMD = 0x65,
2884 CALIBRATION_RES_NOTIFICATION = 0x66,
2885 CALIBRATION_COMPLETE_NOTIFICATION = 0x67
2886};
2887
2888struct iwl_cal_crystal_freq_cmd {
2889 u8 cap_pin1; 2888 u8 cap_pin1;
2890 u8 cap_pin2; 2889 u8 cap_pin2;
2891} __attribute__ ((packed)); 2890} __attribute__ ((packed));
2892 2891
2893struct iwl5000_calibration {
2894 u8 op_code;
2895 u8 first_group;
2896 u8 num_groups;
2897 u8 all_data_valid;
2898 struct iwl_cal_crystal_freq_cmd data;
2899} __attribute__ ((packed));
2900
2901#define IWL_CALIB_INIT_CFG_ALL __constant_cpu_to_le32(0xffffffff) 2892#define IWL_CALIB_INIT_CFG_ALL __constant_cpu_to_le32(0xffffffff)
2902 2893
2903struct iwl_calib_cfg_elmnt_s { 2894struct iwl_calib_cfg_elmnt_s {
@@ -2927,6 +2918,11 @@ struct iwl5000_calib_hdr {
2927 u8 data_valid; 2918 u8 data_valid;
2928} __attribute__ ((packed)); 2919} __attribute__ ((packed));
2929 2920
2921struct iwl5000_calib_cmd {
2922 struct iwl5000_calib_hdr hdr;
2923 u8 data[0];
2924} __attribute__ ((packed));
2925
2930struct iwl5000_calibration_chain_noise_reset_cmd { 2926struct iwl5000_calibration_chain_noise_reset_cmd {
2931 u8 op_code; /* IWL5000_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */ 2927 u8 op_code; /* IWL5000_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
2932 u8 flags; /* not used */ 2928 u8 flags; /* not used */
@@ -3039,7 +3035,6 @@ struct iwl_rx_packet {
3039 struct iwl_notif_statistics stats; 3035 struct iwl_notif_statistics stats;
3040 struct iwl_compressed_ba_resp compressed_ba; 3036 struct iwl_compressed_ba_resp compressed_ba;
3041 struct iwl4965_missed_beacon_notif missed_beacon; 3037 struct iwl4965_missed_beacon_notif missed_beacon;
3042 struct iwl5000_calibration calib;
3043 __le32 status; 3038 __le32 status;
3044 u8 raw[0]; 3039 u8 raw[0];
3045 } u; 3040 } u;
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index c018121085e9..21258443141e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -527,6 +527,7 @@ struct iwl_sensitivity_ranges {
527 * @sw_crypto: 0 for hw, 1 for sw 527 * @sw_crypto: 0 for hw, 1 for sw
528 * @max_xxx_size: for ucode uses 528 * @max_xxx_size: for ucode uses
529 * @ct_kill_threshold: temperature threshold 529 * @ct_kill_threshold: temperature threshold
530 * @calib_init_cfg: setup initial claibrations for the hw
530 * @struct iwl_sensitivity_ranges: range of sensitivity values 531 * @struct iwl_sensitivity_ranges: range of sensitivity values
531 * @first_ampdu_q: first HW queue available for ampdu 532 * @first_ampdu_q: first HW queue available for ampdu
532 */ 533 */
@@ -548,6 +549,7 @@ struct iwl_hw_params {
548 u32 max_data_size; 549 u32 max_data_size;
549 u32 max_bsm_size; 550 u32 max_bsm_size;
550 u32 ct_kill_threshold; /* value in hw-dependent units */ 551 u32 ct_kill_threshold; /* value in hw-dependent units */
552 u32 calib_init_cfg;
551 const struct iwl_sensitivity_ranges *sens; 553 const struct iwl_sensitivity_ranges *sens;
552 u8 first_ampdu_q; 554 u8 first_ampdu_q;
553}; 555};
@@ -765,7 +767,7 @@ enum {
765 767
766 768
767#define IWL_MAX_NUM_QUEUES 20 /* FIXME: do dynamic allocation */ 769#define IWL_MAX_NUM_QUEUES 20 /* FIXME: do dynamic allocation */
768#define IWL_CALIB_MAX 3 770#define IWL_CALIB_MAX 4
769 771
770struct iwl_priv { 772struct iwl_priv {
771 773