iwl-2000.c 10 KB

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