iwl-1000.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * Intel Linux Wireless <ilw@linux.intel.com>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. *****************************************************************************/
  26. #include <linux/kernel.h>
  27. #include <linux/module.h>
  28. #include <linux/init.h>
  29. #include <linux/delay.h>
  30. #include <linux/skbuff.h>
  31. #include <linux/netdevice.h>
  32. #include <net/mac80211.h>
  33. #include <linux/etherdevice.h>
  34. #include <asm/unaligned.h>
  35. #include <linux/stringify.h>
  36. #include "iwl-eeprom.h"
  37. #include "iwl-dev.h"
  38. #include "iwl-core.h"
  39. #include "iwl-io.h"
  40. #include "iwl-agn.h"
  41. #include "iwl-agn-hw.h"
  42. #include "iwl-shared.h"
  43. #include "iwl-cfg.h"
  44. #include "iwl-prph.h"
  45. /* Highest firmware API version supported */
  46. #define IWL1000_UCODE_API_MAX 5
  47. #define IWL100_UCODE_API_MAX 5
  48. /* Oldest version we won't warn about */
  49. #define IWL1000_UCODE_API_OK 5
  50. #define IWL100_UCODE_API_OK 5
  51. /* Lowest firmware API version supported */
  52. #define IWL1000_UCODE_API_MIN 1
  53. #define IWL100_UCODE_API_MIN 5
  54. #define IWL1000_FW_PRE "iwlwifi-1000-"
  55. #define IWL1000_MODULE_FIRMWARE(api) IWL1000_FW_PRE __stringify(api) ".ucode"
  56. #define IWL100_FW_PRE "iwlwifi-100-"
  57. #define IWL100_MODULE_FIRMWARE(api) IWL100_FW_PRE __stringify(api) ".ucode"
  58. /*
  59. * For 1000, use advance thermal throttling critical temperature threshold,
  60. * but legacy thermal management implementation for now.
  61. * This is for the reason of 1000 uCode using advance thermal throttling API
  62. * but not implement ct_kill_exit based on ct_kill exit temperature
  63. * so the thermal throttling will still based on legacy thermal throttling
  64. * management.
  65. * The code here need to be modified once 1000 uCode has the advanced thermal
  66. * throttling algorithm in place
  67. */
  68. static void iwl1000_set_ct_threshold(struct iwl_priv *priv)
  69. {
  70. /* want Celsius */
  71. hw_params(priv).ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
  72. hw_params(priv).ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  73. }
  74. /* NIC configuration for 1000 series */
  75. static void iwl1000_nic_config(struct iwl_priv *priv)
  76. {
  77. /* set CSR_HW_CONFIG_REG for uCode use */
  78. iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG,
  79. CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
  80. CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
  81. /* Setting digital SVR for 1000 card to 1.32V */
  82. /* locking is acquired in iwl_set_bits_mask_prph() function */
  83. iwl_set_bits_mask_prph(trans(priv), APMG_DIGITAL_SVR_REG,
  84. APMG_SVR_DIGITAL_VOLTAGE_1_32,
  85. ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK);
  86. }
  87. static const struct iwl_sensitivity_ranges iwl1000_sensitivity = {
  88. .min_nrg_cck = 95,
  89. .auto_corr_min_ofdm = 90,
  90. .auto_corr_min_ofdm_mrc = 170,
  91. .auto_corr_min_ofdm_x1 = 120,
  92. .auto_corr_min_ofdm_mrc_x1 = 240,
  93. .auto_corr_max_ofdm = 120,
  94. .auto_corr_max_ofdm_mrc = 210,
  95. .auto_corr_max_ofdm_x1 = 155,
  96. .auto_corr_max_ofdm_mrc_x1 = 290,
  97. .auto_corr_min_cck = 125,
  98. .auto_corr_max_cck = 200,
  99. .auto_corr_min_cck_mrc = 170,
  100. .auto_corr_max_cck_mrc = 400,
  101. .nrg_th_cck = 95,
  102. .nrg_th_ofdm = 95,
  103. .barker_corr_th_min = 190,
  104. .barker_corr_th_min_mrc = 390,
  105. .nrg_th_cca = 62,
  106. };
  107. static void iwl1000_hw_set_hw_params(struct iwl_priv *priv)
  108. {
  109. hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ);
  110. hw_params(priv).tx_chains_num =
  111. num_of_ant(hw_params(priv).valid_tx_ant);
  112. if (cfg(priv)->rx_with_siso_diversity)
  113. hw_params(priv).rx_chains_num = 1;
  114. else
  115. hw_params(priv).rx_chains_num =
  116. num_of_ant(hw_params(priv).valid_rx_ant);
  117. iwl1000_set_ct_threshold(priv);
  118. /* Set initial sensitivity parameters */
  119. hw_params(priv).sens = &iwl1000_sensitivity;
  120. }
  121. static struct iwl_lib_ops iwl1000_lib = {
  122. .set_hw_params = iwl1000_hw_set_hw_params,
  123. .nic_config = iwl1000_nic_config,
  124. .eeprom_ops = {
  125. .regulatory_bands = {
  126. EEPROM_REG_BAND_1_CHANNELS,
  127. EEPROM_REG_BAND_2_CHANNELS,
  128. EEPROM_REG_BAND_3_CHANNELS,
  129. EEPROM_REG_BAND_4_CHANNELS,
  130. EEPROM_REG_BAND_5_CHANNELS,
  131. EEPROM_REG_BAND_24_HT40_CHANNELS,
  132. EEPROM_REGULATORY_BAND_NO_HT40,
  133. },
  134. },
  135. .temperature = iwlagn_temperature,
  136. };
  137. static const struct iwl_base_params iwl1000_base_params = {
  138. .num_of_queues = IWLAGN_NUM_QUEUES,
  139. .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
  140. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  141. .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
  142. .max_ll_items = OTP_MAX_LL_ITEMS_1000,
  143. .shadow_ram_support = false,
  144. .led_compensation = 51,
  145. .support_ct_kill_exit = true,
  146. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
  147. .chain_noise_scale = 1000,
  148. .wd_timeout = IWL_DEF_WD_TIMEOUT,
  149. .max_event_log_size = 128,
  150. .wd_disable = true,
  151. };
  152. static const struct iwl_ht_params iwl1000_ht_params = {
  153. .ht_greenfield_support = true,
  154. .use_rts_for_aggregation = true, /* use rts/cts protection */
  155. .smps_mode = IEEE80211_SMPS_DYNAMIC,
  156. };
  157. #define IWL_DEVICE_1000 \
  158. .fw_name_pre = IWL1000_FW_PRE, \
  159. .ucode_api_max = IWL1000_UCODE_API_MAX, \
  160. .ucode_api_ok = IWL1000_UCODE_API_OK, \
  161. .ucode_api_min = IWL1000_UCODE_API_MIN, \
  162. .max_inst_size = IWLAGN_RTC_INST_SIZE, \
  163. .max_data_size = IWLAGN_RTC_DATA_SIZE, \
  164. .eeprom_ver = EEPROM_1000_EEPROM_VERSION, \
  165. .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION, \
  166. .lib = &iwl1000_lib, \
  167. .base_params = &iwl1000_base_params, \
  168. .led_mode = IWL_LED_BLINK
  169. const struct iwl_cfg iwl1000_bgn_cfg = {
  170. .name = "Intel(R) Centrino(R) Wireless-N 1000 BGN",
  171. IWL_DEVICE_1000,
  172. .ht_params = &iwl1000_ht_params,
  173. };
  174. const struct iwl_cfg iwl1000_bg_cfg = {
  175. .name = "Intel(R) Centrino(R) Wireless-N 1000 BG",
  176. IWL_DEVICE_1000,
  177. };
  178. #define IWL_DEVICE_100 \
  179. .fw_name_pre = IWL100_FW_PRE, \
  180. .ucode_api_max = IWL100_UCODE_API_MAX, \
  181. .ucode_api_ok = IWL100_UCODE_API_OK, \
  182. .ucode_api_min = IWL100_UCODE_API_MIN, \
  183. .max_inst_size = IWLAGN_RTC_INST_SIZE, \
  184. .max_data_size = IWLAGN_RTC_DATA_SIZE, \
  185. .eeprom_ver = EEPROM_1000_EEPROM_VERSION, \
  186. .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION, \
  187. .lib = &iwl1000_lib, \
  188. .base_params = &iwl1000_base_params, \
  189. .led_mode = IWL_LED_RF_STATE, \
  190. .rx_with_siso_diversity = true
  191. const struct iwl_cfg iwl100_bgn_cfg = {
  192. .name = "Intel(R) Centrino(R) Wireless-N 100 BGN",
  193. IWL_DEVICE_100,
  194. .ht_params = &iwl1000_ht_params,
  195. };
  196. const struct iwl_cfg iwl100_bg_cfg = {
  197. .name = "Intel(R) Centrino(R) Wireless-N 100 BG",
  198. IWL_DEVICE_100,
  199. };
  200. MODULE_FIRMWARE(IWL1000_MODULE_FIRMWARE(IWL1000_UCODE_API_OK));
  201. MODULE_FIRMWARE(IWL100_MODULE_FIRMWARE(IWL100_UCODE_API_OK));