iwl-1000.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2008 - 2011 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-sta.h"
  41. #include "iwl-agn.h"
  42. #include "iwl-helpers.h"
  43. #include "iwl-agn-hw.h"
  44. #include "iwl-shared.h"
  45. #include "iwl-cfg.h"
  46. /* Highest firmware API version supported */
  47. #define IWL1000_UCODE_API_MAX 6
  48. #define IWL100_UCODE_API_MAX 6
  49. /* Oldest version we won't warn about */
  50. #define IWL1000_UCODE_API_OK 5
  51. #define IWL100_UCODE_API_OK 5
  52. /* Lowest firmware API version supported */
  53. #define IWL1000_UCODE_API_MIN 1
  54. #define IWL100_UCODE_API_MIN 5
  55. #define IWL1000_FW_PRE "iwlwifi-1000-"
  56. #define IWL1000_MODULE_FIRMWARE(api) IWL1000_FW_PRE __stringify(api) ".ucode"
  57. #define IWL100_FW_PRE "iwlwifi-100-"
  58. #define IWL100_MODULE_FIRMWARE(api) IWL100_FW_PRE __stringify(api) ".ucode"
  59. /*
  60. * For 1000, use advance thermal throttling critical temperature threshold,
  61. * but legacy thermal management implementation for now.
  62. * This is for the reason of 1000 uCode using advance thermal throttling API
  63. * but not implement ct_kill_exit based on ct_kill exit temperature
  64. * so the thermal throttling will still based on legacy thermal throttling
  65. * management.
  66. * The code here need to be modified once 1000 uCode has the advanced thermal
  67. * throttling algorithm in place
  68. */
  69. static void iwl1000_set_ct_threshold(struct iwl_priv *priv)
  70. {
  71. /* want Celsius */
  72. hw_params(priv).ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
  73. hw_params(priv).ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  74. }
  75. /* NIC configuration for 1000 series */
  76. static void iwl1000_nic_config(struct iwl_priv *priv)
  77. {
  78. /* set CSR_HW_CONFIG_REG for uCode use */
  79. iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG,
  80. CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
  81. CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
  82. /* Setting digital SVR for 1000 card to 1.32V */
  83. /* locking is acquired in iwl_set_bits_mask_prph() function */
  84. iwl_set_bits_mask_prph(bus(priv), APMG_DIGITAL_SVR_REG,
  85. APMG_SVR_DIGITAL_VOLTAGE_1_32,
  86. ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK);
  87. }
  88. static struct iwl_sensitivity_ranges iwl1000_sensitivity = {
  89. .min_nrg_cck = 95,
  90. .max_nrg_cck = 0, /* not used, set to 0 */
  91. .auto_corr_min_ofdm = 90,
  92. .auto_corr_min_ofdm_mrc = 170,
  93. .auto_corr_min_ofdm_x1 = 120,
  94. .auto_corr_min_ofdm_mrc_x1 = 240,
  95. .auto_corr_max_ofdm = 120,
  96. .auto_corr_max_ofdm_mrc = 210,
  97. .auto_corr_max_ofdm_x1 = 155,
  98. .auto_corr_max_ofdm_mrc_x1 = 290,
  99. .auto_corr_min_cck = 125,
  100. .auto_corr_max_cck = 200,
  101. .auto_corr_min_cck_mrc = 170,
  102. .auto_corr_max_cck_mrc = 400,
  103. .nrg_th_cck = 95,
  104. .nrg_th_ofdm = 95,
  105. .barker_corr_th_min = 190,
  106. .barker_corr_th_min_mrc = 390,
  107. .nrg_th_cca = 62,
  108. };
  109. static int iwl1000_hw_set_hw_params(struct iwl_priv *priv)
  110. {
  111. if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
  112. iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
  113. priv->cfg->base_params->num_of_queues =
  114. iwlagn_mod_params.num_of_queues;
  115. hw_params(priv).max_txq_num = priv->cfg->base_params->num_of_queues;
  116. hw_params(priv).max_stations = IWLAGN_STATION_COUNT;
  117. priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
  118. hw_params(priv).max_data_size = IWLAGN_RTC_DATA_SIZE;
  119. hw_params(priv).max_inst_size = IWLAGN_RTC_INST_SIZE;
  120. hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ);
  121. hw_params(priv).tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
  122. if (priv->cfg->rx_with_siso_diversity)
  123. hw_params(priv).rx_chains_num = 1;
  124. else
  125. hw_params(priv).rx_chains_num =
  126. num_of_ant(priv->cfg->valid_rx_ant);
  127. hw_params(priv).valid_tx_ant = priv->cfg->valid_tx_ant;
  128. hw_params(priv).valid_rx_ant = priv->cfg->valid_rx_ant;
  129. iwl1000_set_ct_threshold(priv);
  130. /* Set initial sensitivity parameters */
  131. /* Set initial calibration set */
  132. hw_params(priv).sens = &iwl1000_sensitivity;
  133. hw_params(priv).calib_init_cfg =
  134. BIT(IWL_CALIB_XTAL) |
  135. BIT(IWL_CALIB_LO) |
  136. BIT(IWL_CALIB_TX_IQ) |
  137. BIT(IWL_CALIB_TX_IQ_PERD) |
  138. BIT(IWL_CALIB_BASE_BAND);
  139. if (priv->cfg->need_dc_calib)
  140. hw_params(priv).calib_init_cfg |= BIT(IWL_CALIB_DC);
  141. return 0;
  142. }
  143. static struct iwl_lib_ops iwl1000_lib = {
  144. .set_hw_params = iwl1000_hw_set_hw_params,
  145. .nic_config = iwl1000_nic_config,
  146. .eeprom_ops = {
  147. .regulatory_bands = {
  148. EEPROM_REG_BAND_1_CHANNELS,
  149. EEPROM_REG_BAND_2_CHANNELS,
  150. EEPROM_REG_BAND_3_CHANNELS,
  151. EEPROM_REG_BAND_4_CHANNELS,
  152. EEPROM_REG_BAND_5_CHANNELS,
  153. EEPROM_REG_BAND_24_HT40_CHANNELS,
  154. EEPROM_REGULATORY_BAND_NO_HT40,
  155. },
  156. },
  157. .temperature = iwlagn_temperature,
  158. };
  159. static struct iwl_base_params iwl1000_base_params = {
  160. .num_of_queues = IWLAGN_NUM_QUEUES,
  161. .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
  162. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  163. .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
  164. .max_ll_items = OTP_MAX_LL_ITEMS_1000,
  165. .shadow_ram_support = false,
  166. .led_compensation = 51,
  167. .support_ct_kill_exit = true,
  168. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
  169. .chain_noise_scale = 1000,
  170. .wd_timeout = IWL_DEF_WD_TIMEOUT,
  171. .max_event_log_size = 128,
  172. };
  173. static struct iwl_ht_params iwl1000_ht_params = {
  174. .ht_greenfield_support = true,
  175. .use_rts_for_aggregation = true, /* use rts/cts protection */
  176. .smps_mode = IEEE80211_SMPS_DYNAMIC,
  177. };
  178. #define IWL_DEVICE_1000 \
  179. .fw_name_pre = IWL1000_FW_PRE, \
  180. .ucode_api_max = IWL1000_UCODE_API_MAX, \
  181. .ucode_api_ok = IWL1000_UCODE_API_OK, \
  182. .ucode_api_min = IWL1000_UCODE_API_MIN, \
  183. .eeprom_ver = EEPROM_1000_EEPROM_VERSION, \
  184. .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION, \
  185. .lib = &iwl1000_lib, \
  186. .base_params = &iwl1000_base_params, \
  187. .led_mode = IWL_LED_BLINK
  188. struct iwl_cfg iwl1000_bgn_cfg = {
  189. .name = "Intel(R) Centrino(R) Wireless-N 1000 BGN",
  190. IWL_DEVICE_1000,
  191. .ht_params = &iwl1000_ht_params,
  192. };
  193. struct iwl_cfg iwl1000_bg_cfg = {
  194. .name = "Intel(R) Centrino(R) Wireless-N 1000 BG",
  195. IWL_DEVICE_1000,
  196. };
  197. #define IWL_DEVICE_100 \
  198. .fw_name_pre = IWL100_FW_PRE, \
  199. .ucode_api_max = IWL100_UCODE_API_MAX, \
  200. .ucode_api_ok = IWL100_UCODE_API_OK, \
  201. .ucode_api_min = IWL100_UCODE_API_MIN, \
  202. .eeprom_ver = EEPROM_1000_EEPROM_VERSION, \
  203. .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION, \
  204. .lib = &iwl1000_lib, \
  205. .base_params = &iwl1000_base_params, \
  206. .led_mode = IWL_LED_RF_STATE, \
  207. .rx_with_siso_diversity = true
  208. struct iwl_cfg iwl100_bgn_cfg = {
  209. .name = "Intel(R) Centrino(R) Wireless-N 100 BGN",
  210. IWL_DEVICE_100,
  211. .ht_params = &iwl1000_ht_params,
  212. };
  213. struct iwl_cfg iwl100_bg_cfg = {
  214. .name = "Intel(R) Centrino(R) Wireless-N 100 BG",
  215. IWL_DEVICE_100,
  216. };
  217. MODULE_FIRMWARE(IWL1000_MODULE_FIRMWARE(IWL1000_UCODE_API_MAX));
  218. MODULE_FIRMWARE(IWL100_MODULE_FIRMWARE(IWL100_UCODE_API_MAX));