iwl-1000.c 9.2 KB

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