iwl-2000.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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-6000-hw.h"
  45. /* Highest firmware API version supported */
  46. #define IWL2030_UCODE_API_MAX 5
  47. #define IWL2000_UCODE_API_MAX 5
  48. #define IWL105_UCODE_API_MAX 5
  49. #define IWL135_UCODE_API_MAX 5
  50. /* Lowest firmware API version supported */
  51. #define IWL2030_UCODE_API_MIN 5
  52. #define IWL2000_UCODE_API_MIN 5
  53. #define IWL105_UCODE_API_MIN 5
  54. #define IWL135_UCODE_API_MIN 5
  55. #define IWL2030_FW_PRE "iwlwifi-2030-"
  56. #define IWL2030_MODULE_FIRMWARE(api) IWL2030_FW_PRE __stringify(api) ".ucode"
  57. #define IWL2000_FW_PRE "iwlwifi-2000-"
  58. #define IWL2000_MODULE_FIRMWARE(api) IWL2000_FW_PRE __stringify(api) ".ucode"
  59. #define IWL105_FW_PRE "iwlwifi-105-"
  60. #define IWL105_MODULE_FIRMWARE(api) IWL105_FW_PRE __stringify(api) ".ucode"
  61. #define IWL135_FW_PRE "iwlwifi-135-"
  62. #define IWL135_MODULE_FIRMWARE(api) IWL135_FW_PRE #api ".ucode"
  63. static void iwl2000_set_ct_threshold(struct iwl_priv *priv)
  64. {
  65. /* want Celsius */
  66. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
  67. priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  68. }
  69. /* NIC configuration for 2000 series */
  70. static void iwl2000_nic_config(struct iwl_priv *priv)
  71. {
  72. iwl_rf_config(priv);
  73. if (priv->cfg->iq_invert)
  74. iwl_set_bit(priv, CSR_GP_DRIVER_REG,
  75. CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
  76. }
  77. static struct iwl_sensitivity_ranges iwl2000_sensitivity = {
  78. .min_nrg_cck = 97,
  79. .max_nrg_cck = 0, /* not used, set to 0 */
  80. .auto_corr_min_ofdm = 80,
  81. .auto_corr_min_ofdm_mrc = 128,
  82. .auto_corr_min_ofdm_x1 = 105,
  83. .auto_corr_min_ofdm_mrc_x1 = 192,
  84. .auto_corr_max_ofdm = 145,
  85. .auto_corr_max_ofdm_mrc = 232,
  86. .auto_corr_max_ofdm_x1 = 110,
  87. .auto_corr_max_ofdm_mrc_x1 = 232,
  88. .auto_corr_min_cck = 125,
  89. .auto_corr_max_cck = 175,
  90. .auto_corr_min_cck_mrc = 160,
  91. .auto_corr_max_cck_mrc = 310,
  92. .nrg_th_cck = 97,
  93. .nrg_th_ofdm = 100,
  94. .barker_corr_th_min = 190,
  95. .barker_corr_th_min_mrc = 390,
  96. .nrg_th_cca = 62,
  97. };
  98. static int iwl2000_hw_set_hw_params(struct iwl_priv *priv)
  99. {
  100. if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
  101. iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
  102. priv->cfg->base_params->num_of_queues =
  103. iwlagn_mod_params.num_of_queues;
  104. priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
  105. priv->hw_params.scd_bc_tbls_size =
  106. priv->cfg->base_params->num_of_queues *
  107. sizeof(struct iwlagn_scd_bc_tbl);
  108. priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
  109. priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
  110. priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
  111. priv->hw_params.max_data_size = IWL60_RTC_DATA_SIZE;
  112. priv->hw_params.max_inst_size = IWL60_RTC_INST_SIZE;
  113. priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ);
  114. priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
  115. if (priv->cfg->rx_with_siso_diversity)
  116. priv->hw_params.rx_chains_num = 1;
  117. else
  118. priv->hw_params.rx_chains_num =
  119. num_of_ant(priv->cfg->valid_rx_ant);
  120. priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
  121. priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
  122. iwl2000_set_ct_threshold(priv);
  123. /* Set initial sensitivity parameters */
  124. /* Set initial calibration set */
  125. priv->hw_params.sens = &iwl2000_sensitivity;
  126. priv->hw_params.calib_init_cfg =
  127. BIT(IWL_CALIB_XTAL) |
  128. BIT(IWL_CALIB_LO) |
  129. BIT(IWL_CALIB_TX_IQ) |
  130. BIT(IWL_CALIB_BASE_BAND);
  131. if (priv->cfg->need_dc_calib)
  132. priv->hw_params.calib_rt_cfg |= IWL_CALIB_CFG_DC_IDX;
  133. if (priv->cfg->need_temp_offset_calib)
  134. priv->hw_params.calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET);
  135. priv->hw_params.beacon_time_tsf_bits = IWLAGN_EXT_BEACON_TIME_POS;
  136. return 0;
  137. }
  138. static struct iwl_lib_ops iwl2000_lib = {
  139. .set_hw_params = iwl2000_hw_set_hw_params,
  140. .nic_config = iwl2000_nic_config,
  141. .eeprom_ops = {
  142. .regulatory_bands = {
  143. EEPROM_REG_BAND_1_CHANNELS,
  144. EEPROM_REG_BAND_2_CHANNELS,
  145. EEPROM_REG_BAND_3_CHANNELS,
  146. EEPROM_REG_BAND_4_CHANNELS,
  147. EEPROM_REG_BAND_5_CHANNELS,
  148. EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
  149. EEPROM_REGULATORY_BAND_NO_HT40,
  150. },
  151. .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
  152. },
  153. .temperature = iwlagn_temperature,
  154. };
  155. static struct iwl_lib_ops iwl2030_lib = {
  156. .set_hw_params = iwl2000_hw_set_hw_params,
  157. .bt_rx_handler_setup = iwlagn_bt_rx_handler_setup,
  158. .bt_setup_deferred_work = iwlagn_bt_setup_deferred_work,
  159. .cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
  160. .nic_config = iwl2000_nic_config,
  161. .eeprom_ops = {
  162. .regulatory_bands = {
  163. EEPROM_REG_BAND_1_CHANNELS,
  164. EEPROM_REG_BAND_2_CHANNELS,
  165. EEPROM_REG_BAND_3_CHANNELS,
  166. EEPROM_REG_BAND_4_CHANNELS,
  167. EEPROM_REG_BAND_5_CHANNELS,
  168. EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
  169. EEPROM_REGULATORY_BAND_NO_HT40,
  170. },
  171. .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
  172. },
  173. .temperature = iwlagn_temperature,
  174. };
  175. static struct iwl_base_params iwl2000_base_params = {
  176. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  177. .num_of_queues = IWLAGN_NUM_QUEUES,
  178. .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
  179. .pll_cfg_val = 0,
  180. .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
  181. .shadow_ram_support = true,
  182. .led_compensation = 51,
  183. .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
  184. .adv_thermal_throttle = true,
  185. .support_ct_kill_exit = true,
  186. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  187. .chain_noise_scale = 1000,
  188. .wd_timeout = IWL_DEF_WD_TIMEOUT,
  189. .max_event_log_size = 512,
  190. .shadow_reg_enable = true,
  191. };
  192. static struct iwl_base_params iwl2030_base_params = {
  193. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  194. .num_of_queues = IWLAGN_NUM_QUEUES,
  195. .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
  196. .pll_cfg_val = 0,
  197. .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
  198. .shadow_ram_support = true,
  199. .led_compensation = 57,
  200. .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
  201. .adv_thermal_throttle = true,
  202. .support_ct_kill_exit = true,
  203. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  204. .chain_noise_scale = 1000,
  205. .wd_timeout = IWL_LONG_WD_TIMEOUT,
  206. .max_event_log_size = 512,
  207. .shadow_reg_enable = true,
  208. };
  209. static struct iwl_ht_params iwl2000_ht_params = {
  210. .ht_greenfield_support = true,
  211. .use_rts_for_aggregation = true, /* use rts/cts protection */
  212. };
  213. static struct iwl_bt_params iwl2030_bt_params = {
  214. /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
  215. .advanced_bt_coexist = true,
  216. .agg_time_limit = BT_AGG_THRESHOLD_DEF,
  217. .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
  218. .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
  219. .bt_sco_disable = true,
  220. .bt_session_2 = true,
  221. };
  222. #define IWL_DEVICE_2000 \
  223. .fw_name_pre = IWL2000_FW_PRE, \
  224. .ucode_api_max = IWL2000_UCODE_API_MAX, \
  225. .ucode_api_min = IWL2000_UCODE_API_MIN, \
  226. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  227. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  228. .lib = &iwl2000_lib, \
  229. .base_params = &iwl2000_base_params, \
  230. .need_dc_calib = true, \
  231. .need_temp_offset_calib = true, \
  232. .led_mode = IWL_LED_RF_STATE, \
  233. .iq_invert = true \
  234. struct iwl_cfg iwl2000_2bgn_cfg = {
  235. .name = "2000 Series 2x2 BGN",
  236. IWL_DEVICE_2000,
  237. .ht_params = &iwl2000_ht_params,
  238. };
  239. struct iwl_cfg iwl2000_2bg_cfg = {
  240. .name = "2000 Series 2x2 BG",
  241. IWL_DEVICE_2000,
  242. };
  243. #define IWL_DEVICE_2030 \
  244. .fw_name_pre = IWL2030_FW_PRE, \
  245. .ucode_api_max = IWL2030_UCODE_API_MAX, \
  246. .ucode_api_min = IWL2030_UCODE_API_MIN, \
  247. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  248. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  249. .lib = &iwl2030_lib, \
  250. .base_params = &iwl2030_base_params, \
  251. .bt_params = &iwl2030_bt_params, \
  252. .need_dc_calib = true, \
  253. .need_temp_offset_calib = true, \
  254. .led_mode = IWL_LED_RF_STATE, \
  255. .adv_pm = true, \
  256. .iq_invert = true \
  257. struct iwl_cfg iwl2030_2bgn_cfg = {
  258. .name = "2000 Series 2x2 BGN/BT",
  259. IWL_DEVICE_2030,
  260. .ht_params = &iwl2000_ht_params,
  261. };
  262. struct iwl_cfg iwl2030_2bg_cfg = {
  263. .name = "2000 Series 2x2 BG/BT",
  264. IWL_DEVICE_2030,
  265. };
  266. #define IWL_DEVICE_105 \
  267. .fw_name_pre = IWL105_FW_PRE, \
  268. .ucode_api_max = IWL105_UCODE_API_MAX, \
  269. .ucode_api_min = IWL105_UCODE_API_MIN, \
  270. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  271. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  272. .lib = &iwl2000_lib, \
  273. .base_params = &iwl2000_base_params, \
  274. .need_dc_calib = true, \
  275. .need_temp_offset_calib = true, \
  276. .led_mode = IWL_LED_RF_STATE, \
  277. .adv_pm = true, \
  278. .rx_with_siso_diversity = true, \
  279. .iq_invert = true \
  280. struct iwl_cfg iwl105_bg_cfg = {
  281. .name = "105 Series 1x1 BG",
  282. IWL_DEVICE_105,
  283. };
  284. struct iwl_cfg iwl105_bgn_cfg = {
  285. .name = "105 Series 1x1 BGN",
  286. IWL_DEVICE_105,
  287. .ht_params = &iwl2000_ht_params,
  288. };
  289. #define IWL_DEVICE_135 \
  290. .fw_name_pre = IWL135_FW_PRE, \
  291. .ucode_api_max = IWL135_UCODE_API_MAX, \
  292. .ucode_api_min = IWL135_UCODE_API_MIN, \
  293. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  294. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  295. .lib = &iwl2030_lib, \
  296. .base_params = &iwl2030_base_params, \
  297. .bt_params = &iwl2030_bt_params, \
  298. .need_dc_calib = true, \
  299. .need_temp_offset_calib = true, \
  300. .led_mode = IWL_LED_RF_STATE, \
  301. .adv_pm = true, \
  302. .rx_with_siso_diversity = true, \
  303. .iq_invert = true \
  304. struct iwl_cfg iwl135_bg_cfg = {
  305. .name = "135 Series 1x1 BG/BT",
  306. IWL_DEVICE_135,
  307. };
  308. struct iwl_cfg iwl135_bgn_cfg = {
  309. .name = "135 Series 1x1 BGN/BT",
  310. IWL_DEVICE_135,
  311. .ht_params = &iwl2000_ht_params,
  312. };
  313. MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_MAX));
  314. MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_MAX));
  315. MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_MAX));
  316. MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_MAX));