iwl-1000.c 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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/pci.h>
  30. #include <linux/dma-mapping.h>
  31. #include <linux/delay.h>
  32. #include <linux/skbuff.h>
  33. #include <linux/netdevice.h>
  34. #include <linux/wireless.h>
  35. #include <net/mac80211.h>
  36. #include <linux/etherdevice.h>
  37. #include <asm/unaligned.h>
  38. #include "iwl-eeprom.h"
  39. #include "iwl-dev.h"
  40. #include "iwl-core.h"
  41. #include "iwl-io.h"
  42. #include "iwl-sta.h"
  43. #include "iwl-agn.h"
  44. #include "iwl-helpers.h"
  45. #include "iwl-agn-hw.h"
  46. #include "iwl-agn-debugfs.h"
  47. /* Highest firmware API version supported */
  48. #define IWL1000_UCODE_API_MAX 5
  49. #define IWL100_UCODE_API_MAX 5
  50. /* Lowest firmware API version supported */
  51. #define IWL1000_UCODE_API_MIN 1
  52. #define IWL100_UCODE_API_MIN 5
  53. #define IWL1000_FW_PRE "iwlwifi-1000-"
  54. #define IWL1000_MODULE_FIRMWARE(api) IWL1000_FW_PRE #api ".ucode"
  55. #define IWL100_FW_PRE "iwlwifi-100-"
  56. #define IWL100_MODULE_FIRMWARE(api) IWL100_FW_PRE #api ".ucode"
  57. /*
  58. * For 1000, use advance thermal throttling critical temperature threshold,
  59. * but legacy thermal management implementation for now.
  60. * This is for the reason of 1000 uCode using advance thermal throttling API
  61. * but not implement ct_kill_exit based on ct_kill exit temperature
  62. * so the thermal throttling will still based on legacy thermal throttling
  63. * management.
  64. * The code here need to be modified once 1000 uCode has the advanced thermal
  65. * throttling algorithm in place
  66. */
  67. static void iwl1000_set_ct_threshold(struct iwl_priv *priv)
  68. {
  69. /* want Celsius */
  70. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
  71. priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  72. }
  73. /* NIC configuration for 1000 series */
  74. static void iwl1000_nic_config(struct iwl_priv *priv)
  75. {
  76. /* set CSR_HW_CONFIG_REG for uCode use */
  77. iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
  78. CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
  79. CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
  80. /* Setting digital SVR for 1000 card to 1.32V */
  81. /* locking is acquired in iwl_set_bits_mask_prph() function */
  82. iwl_set_bits_mask_prph(priv, APMG_DIGITAL_SVR_REG,
  83. APMG_SVR_DIGITAL_VOLTAGE_1_32,
  84. ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK);
  85. }
  86. static struct iwl_sensitivity_ranges iwl1000_sensitivity = {
  87. .min_nrg_cck = 95,
  88. .max_nrg_cck = 0, /* not used, set to 0 */
  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 int iwl1000_hw_set_hw_params(struct iwl_priv *priv)
  108. {
  109. if (priv->cfg->mod_params->num_of_queues >= IWL_MIN_NUM_QUEUES &&
  110. priv->cfg->mod_params->num_of_queues <= IWLAGN_NUM_QUEUES)
  111. priv->cfg->base_params->num_of_queues =
  112. priv->cfg->mod_params->num_of_queues;
  113. priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
  114. priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
  115. priv->hw_params.scd_bc_tbls_size =
  116. priv->cfg->base_params->num_of_queues *
  117. sizeof(struct iwlagn_scd_bc_tbl);
  118. priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
  119. priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
  120. priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
  121. priv->hw_params.max_data_size = IWLAGN_RTC_DATA_SIZE;
  122. priv->hw_params.max_inst_size = IWLAGN_RTC_INST_SIZE;
  123. priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
  124. BIT(IEEE80211_BAND_5GHZ);
  125. priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR;
  126. priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
  127. if (priv->cfg->rx_with_siso_diversity)
  128. priv->hw_params.rx_chains_num = 1;
  129. else
  130. priv->hw_params.rx_chains_num =
  131. num_of_ant(priv->cfg->valid_rx_ant);
  132. priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
  133. priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
  134. iwl1000_set_ct_threshold(priv);
  135. /* Set initial sensitivity parameters */
  136. /* Set initial calibration set */
  137. priv->hw_params.sens = &iwl1000_sensitivity;
  138. priv->hw_params.calib_init_cfg =
  139. BIT(IWL_CALIB_XTAL) |
  140. BIT(IWL_CALIB_LO) |
  141. BIT(IWL_CALIB_TX_IQ) |
  142. BIT(IWL_CALIB_TX_IQ_PERD) |
  143. BIT(IWL_CALIB_BASE_BAND);
  144. if (priv->cfg->need_dc_calib)
  145. priv->hw_params.calib_init_cfg |= BIT(IWL_CALIB_DC);
  146. priv->hw_params.beacon_time_tsf_bits = IWLAGN_EXT_BEACON_TIME_POS;
  147. return 0;
  148. }
  149. static struct iwl_lib_ops iwl1000_lib = {
  150. .set_hw_params = iwl1000_hw_set_hw_params,
  151. .txq_update_byte_cnt_tbl = iwlagn_txq_update_byte_cnt_tbl,
  152. .txq_inval_byte_cnt_tbl = iwlagn_txq_inval_byte_cnt_tbl,
  153. .txq_set_sched = iwlagn_txq_set_sched,
  154. .txq_attach_buf_to_tfd = iwl_hw_txq_attach_buf_to_tfd,
  155. .txq_free_tfd = iwl_hw_txq_free_tfd,
  156. .txq_init = iwl_hw_tx_queue_init,
  157. .rx_handler_setup = iwlagn_rx_handler_setup,
  158. .setup_deferred_work = iwlagn_setup_deferred_work,
  159. .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
  160. .send_tx_power = iwlagn_send_tx_power,
  161. .update_chain_flags = iwl_update_chain_flags,
  162. .apm_ops = {
  163. .init = iwl_apm_init,
  164. .config = iwl1000_nic_config,
  165. },
  166. .eeprom_ops = {
  167. .regulatory_bands = {
  168. EEPROM_REG_BAND_1_CHANNELS,
  169. EEPROM_REG_BAND_2_CHANNELS,
  170. EEPROM_REG_BAND_3_CHANNELS,
  171. EEPROM_REG_BAND_4_CHANNELS,
  172. EEPROM_REG_BAND_5_CHANNELS,
  173. EEPROM_REG_BAND_24_HT40_CHANNELS,
  174. EEPROM_REGULATORY_BAND_NO_HT40,
  175. },
  176. .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
  177. .release_semaphore = iwlcore_eeprom_release_semaphore,
  178. .calib_version = iwlagn_eeprom_calib_version,
  179. .query_addr = iwlagn_eeprom_query_addr,
  180. },
  181. .temp_ops = {
  182. .temperature = iwlagn_temperature,
  183. },
  184. .debugfs_ops = {
  185. .rx_stats_read = iwl_ucode_rx_stats_read,
  186. .tx_stats_read = iwl_ucode_tx_stats_read,
  187. .general_stats_read = iwl_ucode_general_stats_read,
  188. .bt_stats_read = iwl_ucode_bt_stats_read,
  189. .reply_tx_error = iwl_reply_tx_error_read,
  190. },
  191. .txfifo_flush = iwlagn_txfifo_flush,
  192. .dev_txfifo_flush = iwlagn_dev_txfifo_flush,
  193. };
  194. static const struct iwl_ops iwl1000_ops = {
  195. .lib = &iwl1000_lib,
  196. .hcmd = &iwlagn_hcmd,
  197. .utils = &iwlagn_hcmd_utils,
  198. };
  199. static struct iwl_base_params iwl1000_base_params = {
  200. .num_of_queues = IWLAGN_NUM_QUEUES,
  201. .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
  202. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  203. .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
  204. .max_ll_items = OTP_MAX_LL_ITEMS_1000,
  205. .shadow_ram_support = false,
  206. .led_compensation = 51,
  207. .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
  208. .support_ct_kill_exit = true,
  209. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
  210. .chain_noise_scale = 1000,
  211. .wd_timeout = IWL_DEF_WD_TIMEOUT,
  212. .max_event_log_size = 128,
  213. };
  214. static struct iwl_ht_params iwl1000_ht_params = {
  215. .ht_greenfield_support = true,
  216. .use_rts_for_aggregation = true, /* use rts/cts protection */
  217. };
  218. #define IWL_DEVICE_1000 \
  219. .fw_name_pre = IWL1000_FW_PRE, \
  220. .ucode_api_max = IWL1000_UCODE_API_MAX, \
  221. .ucode_api_min = IWL1000_UCODE_API_MIN, \
  222. .eeprom_ver = EEPROM_1000_EEPROM_VERSION, \
  223. .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION, \
  224. .ops = &iwl1000_ops, \
  225. .mod_params = &iwlagn_mod_params, \
  226. .base_params = &iwl1000_base_params, \
  227. .led_mode = IWL_LED_BLINK
  228. struct iwl_cfg iwl1000_bgn_cfg = {
  229. .name = "Intel(R) Centrino(R) Wireless-N 1000 BGN",
  230. IWL_DEVICE_1000,
  231. .ht_params = &iwl1000_ht_params,
  232. };
  233. struct iwl_cfg iwl1000_bg_cfg = {
  234. .name = "Intel(R) Centrino(R) Wireless-N 1000 BG",
  235. IWL_DEVICE_1000,
  236. };
  237. #define IWL_DEVICE_100 \
  238. .fw_name_pre = IWL100_FW_PRE, \
  239. .ucode_api_max = IWL100_UCODE_API_MAX, \
  240. .ucode_api_min = IWL100_UCODE_API_MIN, \
  241. .eeprom_ver = EEPROM_1000_EEPROM_VERSION, \
  242. .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION, \
  243. .ops = &iwl1000_ops, \
  244. .mod_params = &iwlagn_mod_params, \
  245. .base_params = &iwl1000_base_params, \
  246. .led_mode = IWL_LED_RF_STATE, \
  247. .rx_with_siso_diversity = true
  248. struct iwl_cfg iwl100_bgn_cfg = {
  249. .name = "Intel(R) Centrino(R) Wireless-N 100 BGN",
  250. IWL_DEVICE_100,
  251. .ht_params = &iwl1000_ht_params,
  252. };
  253. struct iwl_cfg iwl100_bg_cfg = {
  254. .name = "Intel(R) Centrino(R) Wireless-N 100 BG",
  255. IWL_DEVICE_100,
  256. };
  257. MODULE_FIRMWARE(IWL1000_MODULE_FIRMWARE(IWL1000_UCODE_API_MAX));
  258. MODULE_FIRMWARE(IWL100_MODULE_FIRMWARE(IWL100_UCODE_API_MAX));