iwl-1000.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2008 - 2010 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-led.h"
  47. #include "iwl-agn-debugfs.h"
  48. /* Highest firmware API version supported */
  49. #define IWL1000_UCODE_API_MAX 3
  50. /* Lowest firmware API version supported */
  51. #define IWL1000_UCODE_API_MIN 1
  52. #define IWL1000_FW_PRE "iwlwifi-1000-"
  53. #define _IWL1000_MODULE_FIRMWARE(api) IWL1000_FW_PRE #api ".ucode"
  54. #define IWL1000_MODULE_FIRMWARE(api) _IWL1000_MODULE_FIRMWARE(api)
  55. /*
  56. * For 1000, use advance thermal throttling critical temperature threshold,
  57. * but legacy thermal management implementation for now.
  58. * This is for the reason of 1000 uCode using advance thermal throttling API
  59. * but not implement ct_kill_exit based on ct_kill exit temperature
  60. * so the thermal throttling will still based on legacy thermal throttling
  61. * management.
  62. * The code here need to be modified once 1000 uCode has the advanced thermal
  63. * throttling algorithm in place
  64. */
  65. static void iwl1000_set_ct_threshold(struct iwl_priv *priv)
  66. {
  67. /* want Celsius */
  68. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
  69. priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  70. }
  71. /* NIC configuration for 1000 series */
  72. static void iwl1000_nic_config(struct iwl_priv *priv)
  73. {
  74. /* set CSR_HW_CONFIG_REG for uCode use */
  75. iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
  76. CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
  77. CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
  78. /* Setting digital SVR for 1000 card to 1.32V */
  79. /* locking is acquired in iwl_set_bits_mask_prph() function */
  80. iwl_set_bits_mask_prph(priv, APMG_DIGITAL_SVR_REG,
  81. APMG_SVR_DIGITAL_VOLTAGE_1_32,
  82. ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK);
  83. }
  84. static struct iwl_sensitivity_ranges iwl1000_sensitivity = {
  85. .min_nrg_cck = 95,
  86. .max_nrg_cck = 0, /* not used, set to 0 */
  87. .auto_corr_min_ofdm = 90,
  88. .auto_corr_min_ofdm_mrc = 170,
  89. .auto_corr_min_ofdm_x1 = 120,
  90. .auto_corr_min_ofdm_mrc_x1 = 240,
  91. .auto_corr_max_ofdm = 120,
  92. .auto_corr_max_ofdm_mrc = 210,
  93. .auto_corr_max_ofdm_x1 = 155,
  94. .auto_corr_max_ofdm_mrc_x1 = 290,
  95. .auto_corr_min_cck = 125,
  96. .auto_corr_max_cck = 200,
  97. .auto_corr_min_cck_mrc = 170,
  98. .auto_corr_max_cck_mrc = 400,
  99. .nrg_th_cck = 95,
  100. .nrg_th_ofdm = 95,
  101. .barker_corr_th_min = 190,
  102. .barker_corr_th_min_mrc = 390,
  103. .nrg_th_cca = 62,
  104. };
  105. static int iwl1000_hw_set_hw_params(struct iwl_priv *priv)
  106. {
  107. if (priv->cfg->mod_params->num_of_queues >= IWL_MIN_NUM_QUEUES &&
  108. priv->cfg->mod_params->num_of_queues <= IWLAGN_NUM_QUEUES)
  109. priv->cfg->num_of_queues =
  110. priv->cfg->mod_params->num_of_queues;
  111. priv->hw_params.max_txq_num = priv->cfg->num_of_queues;
  112. priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
  113. priv->hw_params.scd_bc_tbls_size =
  114. priv->cfg->num_of_queues *
  115. sizeof(struct iwlagn_scd_bc_tbl);
  116. priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
  117. priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
  118. priv->hw_params.bcast_sta_id = IWLAGN_BROADCAST_ID;
  119. priv->hw_params.max_data_size = IWLAGN_RTC_DATA_SIZE;
  120. priv->hw_params.max_inst_size = IWLAGN_RTC_INST_SIZE;
  121. priv->hw_params.max_bsm_size = 0;
  122. priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
  123. BIT(IEEE80211_BAND_5GHZ);
  124. priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR;
  125. priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
  126. priv->hw_params.rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant);
  127. priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
  128. priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
  129. if (priv->cfg->ops->lib->temp_ops.set_ct_kill)
  130. priv->cfg->ops->lib->temp_ops.set_ct_kill(priv);
  131. /* Set initial sensitivity parameters */
  132. /* Set initial calibration set */
  133. priv->hw_params.sens = &iwl1000_sensitivity;
  134. priv->hw_params.calib_init_cfg =
  135. BIT(IWL_CALIB_XTAL) |
  136. BIT(IWL_CALIB_LO) |
  137. BIT(IWL_CALIB_TX_IQ) |
  138. BIT(IWL_CALIB_TX_IQ_PERD) |
  139. BIT(IWL_CALIB_BASE_BAND);
  140. if (priv->cfg->need_dc_calib)
  141. priv->hw_params.calib_init_cfg |= BIT(IWL_CALIB_DC);
  142. priv->hw_params.beacon_time_tsf_bits = IWLAGN_EXT_BEACON_TIME_POS;
  143. return 0;
  144. }
  145. static struct iwl_lib_ops iwl1000_lib = {
  146. .set_hw_params = iwl1000_hw_set_hw_params,
  147. .txq_update_byte_cnt_tbl = iwlagn_txq_update_byte_cnt_tbl,
  148. .txq_inval_byte_cnt_tbl = iwlagn_txq_inval_byte_cnt_tbl,
  149. .txq_set_sched = iwlagn_txq_set_sched,
  150. .txq_agg_enable = iwlagn_txq_agg_enable,
  151. .txq_agg_disable = iwlagn_txq_agg_disable,
  152. .txq_attach_buf_to_tfd = iwl_hw_txq_attach_buf_to_tfd,
  153. .txq_free_tfd = iwl_hw_txq_free_tfd,
  154. .txq_init = iwl_hw_tx_queue_init,
  155. .rx_handler_setup = iwlagn_rx_handler_setup,
  156. .setup_deferred_work = iwlagn_setup_deferred_work,
  157. .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
  158. .load_ucode = iwlagn_load_ucode,
  159. .dump_nic_event_log = iwl_dump_nic_event_log,
  160. .dump_nic_error_log = iwl_dump_nic_error_log,
  161. .dump_csr = iwl_dump_csr,
  162. .dump_fh = iwl_dump_fh,
  163. .init_alive_start = iwlagn_init_alive_start,
  164. .alive_notify = iwlagn_alive_notify,
  165. .send_tx_power = iwlagn_send_tx_power,
  166. .update_chain_flags = iwl_update_chain_flags,
  167. .apm_ops = {
  168. .init = iwl_apm_init,
  169. .stop = iwl_apm_stop,
  170. .config = iwl1000_nic_config,
  171. .set_pwr_src = iwl_set_pwr_src,
  172. },
  173. .eeprom_ops = {
  174. .regulatory_bands = {
  175. EEPROM_REG_BAND_1_CHANNELS,
  176. EEPROM_REG_BAND_2_CHANNELS,
  177. EEPROM_REG_BAND_3_CHANNELS,
  178. EEPROM_REG_BAND_4_CHANNELS,
  179. EEPROM_REG_BAND_5_CHANNELS,
  180. EEPROM_REG_BAND_24_HT40_CHANNELS,
  181. EEPROM_REG_BAND_52_HT40_CHANNELS
  182. },
  183. .verify_signature = iwlcore_eeprom_verify_signature,
  184. .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
  185. .release_semaphore = iwlcore_eeprom_release_semaphore,
  186. .calib_version = iwlagn_eeprom_calib_version,
  187. .query_addr = iwlagn_eeprom_query_addr,
  188. },
  189. .post_associate = iwl_post_associate,
  190. .isr = iwl_isr_ict,
  191. .config_ap = iwl_config_ap,
  192. .temp_ops = {
  193. .temperature = iwlagn_temperature,
  194. .set_ct_kill = iwl1000_set_ct_threshold,
  195. },
  196. .manage_ibss_station = iwlagn_manage_ibss_station,
  197. .update_bcast_station = iwl_update_bcast_station,
  198. .debugfs_ops = {
  199. .rx_stats_read = iwl_ucode_rx_stats_read,
  200. .tx_stats_read = iwl_ucode_tx_stats_read,
  201. .general_stats_read = iwl_ucode_general_stats_read,
  202. },
  203. .recover_from_tx_stall = iwl_bg_monitor_recover,
  204. .check_plcp_health = iwl_good_plcp_health,
  205. .check_ack_health = iwl_good_ack_health,
  206. .txfifo_flush = iwlagn_txfifo_flush,
  207. .dev_txfifo_flush = iwlagn_dev_txfifo_flush,
  208. };
  209. static const struct iwl_ops iwl1000_ops = {
  210. .lib = &iwl1000_lib,
  211. .hcmd = &iwlagn_hcmd,
  212. .utils = &iwlagn_hcmd_utils,
  213. .led = &iwlagn_led_ops,
  214. };
  215. struct iwl_cfg iwl1000_bgn_cfg = {
  216. .name = "Intel(R) Centrino(R) Wireless-N 1000 BGN",
  217. .fw_name_pre = IWL1000_FW_PRE,
  218. .ucode_api_max = IWL1000_UCODE_API_MAX,
  219. .ucode_api_min = IWL1000_UCODE_API_MIN,
  220. .sku = IWL_SKU_G|IWL_SKU_N,
  221. .ops = &iwl1000_ops,
  222. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  223. .eeprom_ver = EEPROM_1000_EEPROM_VERSION,
  224. .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION,
  225. .num_of_queues = IWLAGN_NUM_QUEUES,
  226. .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
  227. .mod_params = &iwlagn_mod_params,
  228. .valid_tx_ant = ANT_A,
  229. .valid_rx_ant = ANT_AB,
  230. .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
  231. .set_l0s = true,
  232. .use_bsm = false,
  233. .max_ll_items = OTP_MAX_LL_ITEMS_1000,
  234. .shadow_ram_support = false,
  235. .ht_greenfield_support = true,
  236. .led_compensation = 51,
  237. .use_rts_for_ht = true, /* use rts/cts protection */
  238. .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
  239. .support_ct_kill_exit = true,
  240. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
  241. .chain_noise_scale = 1000,
  242. .monitor_recover_period = IWL_MONITORING_PERIOD,
  243. .max_event_log_size = 128,
  244. .ucode_tracing = true,
  245. .sensitivity_calib_by_driver = true,
  246. .chain_noise_calib_by_driver = true,
  247. };
  248. struct iwl_cfg iwl1000_bg_cfg = {
  249. .name = "Intel(R) Centrino(R) Wireless-N 1000 BG",
  250. .fw_name_pre = IWL1000_FW_PRE,
  251. .ucode_api_max = IWL1000_UCODE_API_MAX,
  252. .ucode_api_min = IWL1000_UCODE_API_MIN,
  253. .sku = IWL_SKU_G,
  254. .ops = &iwl1000_ops,
  255. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  256. .eeprom_ver = EEPROM_1000_EEPROM_VERSION,
  257. .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION,
  258. .num_of_queues = IWLAGN_NUM_QUEUES,
  259. .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
  260. .mod_params = &iwlagn_mod_params,
  261. .valid_tx_ant = ANT_A,
  262. .valid_rx_ant = ANT_AB,
  263. .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
  264. .set_l0s = true,
  265. .use_bsm = false,
  266. .max_ll_items = OTP_MAX_LL_ITEMS_1000,
  267. .shadow_ram_support = false,
  268. .led_compensation = 51,
  269. .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
  270. .support_ct_kill_exit = true,
  271. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
  272. .chain_noise_scale = 1000,
  273. .monitor_recover_period = IWL_MONITORING_PERIOD,
  274. .max_event_log_size = 128,
  275. .ucode_tracing = true,
  276. .sensitivity_calib_by_driver = true,
  277. .chain_noise_calib_by_driver = true,
  278. };
  279. MODULE_FIRMWARE(IWL1000_MODULE_FIRMWARE(IWL1000_UCODE_API_MAX));