iwl-1000.c 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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-5000-hw.h"
  46. #include "iwl-agn-led.h"
  47. /* Highest firmware API version supported */
  48. #define IWL1000_UCODE_API_MAX 3
  49. /* Lowest firmware API version supported */
  50. #define IWL1000_UCODE_API_MIN 1
  51. #define IWL1000_FW_PRE "iwlwifi-1000-"
  52. #define _IWL1000_MODULE_FIRMWARE(api) IWL1000_FW_PRE #api ".ucode"
  53. #define IWL1000_MODULE_FIRMWARE(api) _IWL1000_MODULE_FIRMWARE(api)
  54. /*
  55. * For 1000, use advance thermal throttling critical temperature threshold,
  56. * but legacy thermal management implementation for now.
  57. * This is for the reason of 1000 uCode using advance thermal throttling API
  58. * but not implement ct_kill_exit based on ct_kill exit temperature
  59. * so the thermal throttling will still based on legacy thermal throttling
  60. * management.
  61. * The code here need to be modified once 1000 uCode has the advanced thermal
  62. * throttling algorithm in place
  63. */
  64. static void iwl1000_set_ct_threshold(struct iwl_priv *priv)
  65. {
  66. /* want Celsius */
  67. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
  68. priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  69. }
  70. /* NIC configuration for 1000 series */
  71. static void iwl1000_nic_config(struct iwl_priv *priv)
  72. {
  73. /* set CSR_HW_CONFIG_REG for uCode use */
  74. iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
  75. CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
  76. CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
  77. /* Setting digital SVR for 1000 card to 1.32V */
  78. /* locking is acquired in iwl_set_bits_mask_prph() function */
  79. iwl_set_bits_mask_prph(priv, APMG_DIGITAL_SVR_REG,
  80. APMG_SVR_DIGITAL_VOLTAGE_1_32,
  81. ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK);
  82. }
  83. static struct iwl_sensitivity_ranges iwl1000_sensitivity = {
  84. .min_nrg_cck = 95,
  85. .max_nrg_cck = 0, /* not used, set to 0 */
  86. .auto_corr_min_ofdm = 90,
  87. .auto_corr_min_ofdm_mrc = 170,
  88. .auto_corr_min_ofdm_x1 = 120,
  89. .auto_corr_min_ofdm_mrc_x1 = 240,
  90. .auto_corr_max_ofdm = 120,
  91. .auto_corr_max_ofdm_mrc = 210,
  92. .auto_corr_max_ofdm_x1 = 155,
  93. .auto_corr_max_ofdm_mrc_x1 = 290,
  94. .auto_corr_min_cck = 125,
  95. .auto_corr_max_cck = 200,
  96. .auto_corr_min_cck_mrc = 170,
  97. .auto_corr_max_cck_mrc = 400,
  98. .nrg_th_cck = 95,
  99. .nrg_th_ofdm = 95,
  100. .barker_corr_th_min = 190,
  101. .barker_corr_th_min_mrc = 390,
  102. .nrg_th_cca = 62,
  103. };
  104. static int iwl1000_hw_set_hw_params(struct iwl_priv *priv)
  105. {
  106. if (priv->cfg->mod_params->num_of_queues >= IWL_MIN_NUM_QUEUES &&
  107. priv->cfg->mod_params->num_of_queues <= IWL50_NUM_QUEUES)
  108. priv->cfg->num_of_queues =
  109. priv->cfg->mod_params->num_of_queues;
  110. priv->hw_params.max_txq_num = priv->cfg->num_of_queues;
  111. priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
  112. priv->hw_params.scd_bc_tbls_size =
  113. priv->cfg->num_of_queues *
  114. sizeof(struct iwl5000_scd_bc_tbl);
  115. priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
  116. priv->hw_params.max_stations = IWL5000_STATION_COUNT;
  117. priv->hw_params.bcast_sta_id = IWL5000_BROADCAST_ID;
  118. priv->hw_params.max_data_size = IWL50_RTC_DATA_SIZE;
  119. priv->hw_params.max_inst_size = IWL50_RTC_INST_SIZE;
  120. priv->hw_params.max_bsm_size = 0;
  121. priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
  122. BIT(IEEE80211_BAND_5GHZ);
  123. priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR;
  124. priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
  125. priv->hw_params.rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant);
  126. priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
  127. priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
  128. if (priv->cfg->ops->lib->temp_ops.set_ct_kill)
  129. priv->cfg->ops->lib->temp_ops.set_ct_kill(priv);
  130. /* Set initial sensitivity parameters */
  131. /* Set initial calibration set */
  132. priv->hw_params.sens = &iwl1000_sensitivity;
  133. priv->hw_params.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. return 0;
  140. }
  141. static struct iwl_lib_ops iwl1000_lib = {
  142. .set_hw_params = iwl1000_hw_set_hw_params,
  143. .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl,
  144. .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl,
  145. .txq_set_sched = iwl5000_txq_set_sched,
  146. .txq_agg_enable = iwl5000_txq_agg_enable,
  147. .txq_agg_disable = iwl5000_txq_agg_disable,
  148. .txq_attach_buf_to_tfd = iwl_hw_txq_attach_buf_to_tfd,
  149. .txq_free_tfd = iwl_hw_txq_free_tfd,
  150. .txq_init = iwl_hw_tx_queue_init,
  151. .rx_handler_setup = iwl5000_rx_handler_setup,
  152. .setup_deferred_work = iwl5000_setup_deferred_work,
  153. .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
  154. .load_ucode = iwlagn_load_ucode,
  155. .dump_nic_event_log = iwl_dump_nic_event_log,
  156. .dump_nic_error_log = iwl_dump_nic_error_log,
  157. .dump_csr = iwl_dump_csr,
  158. .dump_fh = iwl_dump_fh,
  159. .init_alive_start = iwl5000_init_alive_start,
  160. .alive_notify = iwl5000_alive_notify,
  161. .send_tx_power = iwl5000_send_tx_power,
  162. .update_chain_flags = iwl_update_chain_flags,
  163. .apm_ops = {
  164. .init = iwl_apm_init,
  165. .stop = iwl_apm_stop,
  166. .config = iwl1000_nic_config,
  167. .set_pwr_src = iwl_set_pwr_src,
  168. },
  169. .eeprom_ops = {
  170. .regulatory_bands = {
  171. EEPROM_5000_REG_BAND_1_CHANNELS,
  172. EEPROM_5000_REG_BAND_2_CHANNELS,
  173. EEPROM_5000_REG_BAND_3_CHANNELS,
  174. EEPROM_5000_REG_BAND_4_CHANNELS,
  175. EEPROM_5000_REG_BAND_5_CHANNELS,
  176. EEPROM_5000_REG_BAND_24_HT40_CHANNELS,
  177. EEPROM_5000_REG_BAND_52_HT40_CHANNELS
  178. },
  179. .verify_signature = iwlcore_eeprom_verify_signature,
  180. .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
  181. .release_semaphore = iwlcore_eeprom_release_semaphore,
  182. .calib_version = iwl5000_eeprom_calib_version,
  183. .query_addr = iwl5000_eeprom_query_addr,
  184. },
  185. .post_associate = iwl_post_associate,
  186. .isr = iwl_isr_ict,
  187. .config_ap = iwl_config_ap,
  188. .temp_ops = {
  189. .temperature = iwl5000_temperature,
  190. .set_ct_kill = iwl1000_set_ct_threshold,
  191. },
  192. .add_bcast_station = iwl_add_bcast_station,
  193. .recover_from_tx_stall = iwl_bg_monitor_recover,
  194. .check_plcp_health = iwl_good_plcp_health,
  195. .check_ack_health = iwl_good_ack_health,
  196. };
  197. static const struct iwl_ops iwl1000_ops = {
  198. .ucode = &iwlagn_ucode,
  199. .lib = &iwl1000_lib,
  200. .hcmd = &iwl5000_hcmd,
  201. .utils = &iwl5000_hcmd_utils,
  202. .led = &iwlagn_led_ops,
  203. };
  204. struct iwl_cfg iwl1000_bgn_cfg = {
  205. .name = "Intel(R) Centrino(R) Wireless-N 1000 BGN",
  206. .fw_name_pre = IWL1000_FW_PRE,
  207. .ucode_api_max = IWL1000_UCODE_API_MAX,
  208. .ucode_api_min = IWL1000_UCODE_API_MIN,
  209. .sku = IWL_SKU_G|IWL_SKU_N,
  210. .ops = &iwl1000_ops,
  211. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  212. .eeprom_ver = EEPROM_1000_EEPROM_VERSION,
  213. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  214. .num_of_queues = IWL50_NUM_QUEUES,
  215. .num_of_ampdu_queues = IWL50_NUM_AMPDU_QUEUES,
  216. .mod_params = &iwl50_mod_params,
  217. .valid_tx_ant = ANT_A,
  218. .valid_rx_ant = ANT_AB,
  219. .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
  220. .set_l0s = true,
  221. .use_bsm = false,
  222. .max_ll_items = OTP_MAX_LL_ITEMS_1000,
  223. .shadow_ram_support = false,
  224. .ht_greenfield_support = true,
  225. .led_compensation = 51,
  226. .use_rts_for_ht = true, /* use rts/cts protection */
  227. .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
  228. .support_ct_kill_exit = true,
  229. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
  230. .chain_noise_scale = 1000,
  231. .monitor_recover_period = IWL_MONITORING_PERIOD,
  232. };
  233. struct iwl_cfg iwl1000_bg_cfg = {
  234. .name = "Intel(R) Centrino(R) Wireless-N 1000 BG",
  235. .fw_name_pre = IWL1000_FW_PRE,
  236. .ucode_api_max = IWL1000_UCODE_API_MAX,
  237. .ucode_api_min = IWL1000_UCODE_API_MIN,
  238. .sku = IWL_SKU_G,
  239. .ops = &iwl1000_ops,
  240. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  241. .eeprom_ver = EEPROM_1000_EEPROM_VERSION,
  242. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  243. .num_of_queues = IWL50_NUM_QUEUES,
  244. .num_of_ampdu_queues = IWL50_NUM_AMPDU_QUEUES,
  245. .mod_params = &iwl50_mod_params,
  246. .valid_tx_ant = ANT_A,
  247. .valid_rx_ant = ANT_AB,
  248. .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
  249. .set_l0s = true,
  250. .use_bsm = false,
  251. .max_ll_items = OTP_MAX_LL_ITEMS_1000,
  252. .shadow_ram_support = false,
  253. .ht_greenfield_support = true,
  254. .led_compensation = 51,
  255. .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
  256. .support_ct_kill_exit = true,
  257. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
  258. .chain_noise_scale = 1000,
  259. .monitor_recover_period = IWL_MONITORING_PERIOD,
  260. };
  261. MODULE_FIRMWARE(IWL1000_MODULE_FIRMWARE(IWL1000_UCODE_API_MAX));