iwl-2000.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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 6
  51. #define IWL2000_UCODE_API_OK 6
  52. #define IWL105_UCODE_API_OK 6
  53. #define IWL135_UCODE_API_OK 6
  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).ht40_channel = BIT(IEEE80211_BAND_2GHZ);
  104. hw_params(priv).tx_chains_num =
  105. num_of_ant(hw_params(priv).valid_tx_ant);
  106. if (cfg(priv)->rx_with_siso_diversity)
  107. hw_params(priv).rx_chains_num = 1;
  108. else
  109. hw_params(priv).rx_chains_num =
  110. num_of_ant(hw_params(priv).valid_rx_ant);
  111. iwl2000_set_ct_threshold(priv);
  112. /* Set initial sensitivity parameters */
  113. hw_params(priv).sens = &iwl2000_sensitivity;
  114. }
  115. static struct iwl_lib_ops iwl2000_lib = {
  116. .set_hw_params = iwl2000_hw_set_hw_params,
  117. .nic_config = iwl2000_nic_config,
  118. .eeprom_ops = {
  119. .regulatory_bands = {
  120. EEPROM_REG_BAND_1_CHANNELS,
  121. EEPROM_REG_BAND_2_CHANNELS,
  122. EEPROM_REG_BAND_3_CHANNELS,
  123. EEPROM_REG_BAND_4_CHANNELS,
  124. EEPROM_REG_BAND_5_CHANNELS,
  125. EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
  126. EEPROM_REGULATORY_BAND_NO_HT40,
  127. },
  128. .enhanced_txpower = true,
  129. },
  130. .temperature = iwlagn_temperature,
  131. };
  132. static struct iwl_lib_ops iwl2030_lib = {
  133. .set_hw_params = iwl2000_hw_set_hw_params,
  134. .nic_config = iwl2000_nic_config,
  135. .eeprom_ops = {
  136. .regulatory_bands = {
  137. EEPROM_REG_BAND_1_CHANNELS,
  138. EEPROM_REG_BAND_2_CHANNELS,
  139. EEPROM_REG_BAND_3_CHANNELS,
  140. EEPROM_REG_BAND_4_CHANNELS,
  141. EEPROM_REG_BAND_5_CHANNELS,
  142. EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
  143. EEPROM_REGULATORY_BAND_NO_HT40,
  144. },
  145. .enhanced_txpower = true,
  146. },
  147. .temperature = iwlagn_temperature,
  148. };
  149. static const struct iwl_base_params iwl2000_base_params = {
  150. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  151. .num_of_queues = IWLAGN_NUM_QUEUES,
  152. .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
  153. .pll_cfg_val = 0,
  154. .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
  155. .shadow_ram_support = true,
  156. .led_compensation = 51,
  157. .adv_thermal_throttle = true,
  158. .support_ct_kill_exit = true,
  159. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  160. .chain_noise_scale = 1000,
  161. .wd_timeout = IWL_DEF_WD_TIMEOUT,
  162. .max_event_log_size = 512,
  163. .shadow_reg_enable = false, /* TODO: fix bugs using this feature */
  164. .hd_v2 = true,
  165. };
  166. static const struct iwl_base_params iwl2030_base_params = {
  167. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  168. .num_of_queues = IWLAGN_NUM_QUEUES,
  169. .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
  170. .pll_cfg_val = 0,
  171. .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
  172. .shadow_ram_support = true,
  173. .led_compensation = 57,
  174. .adv_thermal_throttle = true,
  175. .support_ct_kill_exit = true,
  176. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  177. .chain_noise_scale = 1000,
  178. .wd_timeout = IWL_LONG_WD_TIMEOUT,
  179. .max_event_log_size = 512,
  180. .shadow_reg_enable = false, /* TODO: fix bugs using this feature */
  181. .hd_v2 = true,
  182. };
  183. static const struct iwl_ht_params iwl2000_ht_params = {
  184. .ht_greenfield_support = true,
  185. .use_rts_for_aggregation = true, /* use rts/cts protection */
  186. };
  187. static const struct iwl_bt_params iwl2030_bt_params = {
  188. /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
  189. .advanced_bt_coexist = true,
  190. .agg_time_limit = BT_AGG_THRESHOLD_DEF,
  191. .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
  192. .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
  193. .bt_sco_disable = true,
  194. .bt_session_2 = true,
  195. };
  196. #define IWL_DEVICE_2000 \
  197. .fw_name_pre = IWL2000_FW_PRE, \
  198. .ucode_api_max = IWL2000_UCODE_API_MAX, \
  199. .ucode_api_ok = IWL2000_UCODE_API_OK, \
  200. .ucode_api_min = IWL2000_UCODE_API_MIN, \
  201. .max_inst_size = IWL60_RTC_INST_SIZE, \
  202. .max_data_size = IWL60_RTC_DATA_SIZE, \
  203. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  204. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  205. .lib = &iwl2000_lib, \
  206. .base_params = &iwl2000_base_params, \
  207. .need_temp_offset_calib = true, \
  208. .temp_offset_v2 = true, \
  209. .led_mode = IWL_LED_RF_STATE, \
  210. .iq_invert = true \
  211. const struct iwl_cfg iwl2000_2bgn_cfg = {
  212. .name = "Intel(R) Centrino(R) Wireless-N 2200 BGN",
  213. IWL_DEVICE_2000,
  214. .ht_params = &iwl2000_ht_params,
  215. };
  216. const struct iwl_cfg iwl2000_2bgn_d_cfg = {
  217. .name = "Intel(R) Centrino(R) Wireless-N 2200D BGN",
  218. IWL_DEVICE_2000,
  219. .ht_params = &iwl2000_ht_params,
  220. };
  221. #define IWL_DEVICE_2030 \
  222. .fw_name_pre = IWL2030_FW_PRE, \
  223. .ucode_api_max = IWL2030_UCODE_API_MAX, \
  224. .ucode_api_ok = IWL2030_UCODE_API_OK, \
  225. .ucode_api_min = IWL2030_UCODE_API_MIN, \
  226. .max_inst_size = IWL60_RTC_INST_SIZE, \
  227. .max_data_size = IWL60_RTC_DATA_SIZE, \
  228. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  229. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  230. .lib = &iwl2030_lib, \
  231. .base_params = &iwl2030_base_params, \
  232. .bt_params = &iwl2030_bt_params, \
  233. .need_temp_offset_calib = true, \
  234. .temp_offset_v2 = true, \
  235. .led_mode = IWL_LED_RF_STATE, \
  236. .adv_pm = true, \
  237. .iq_invert = true \
  238. const struct iwl_cfg iwl2030_2bgn_cfg = {
  239. .name = "Intel(R) Centrino(R) Wireless-N 2230 BGN",
  240. IWL_DEVICE_2030,
  241. .ht_params = &iwl2000_ht_params,
  242. };
  243. #define IWL_DEVICE_105 \
  244. .fw_name_pre = IWL105_FW_PRE, \
  245. .ucode_api_max = IWL105_UCODE_API_MAX, \
  246. .ucode_api_ok = IWL105_UCODE_API_OK, \
  247. .ucode_api_min = IWL105_UCODE_API_MIN, \
  248. .max_inst_size = IWL60_RTC_INST_SIZE, \
  249. .max_data_size = IWL60_RTC_DATA_SIZE, \
  250. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  251. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  252. .lib = &iwl2000_lib, \
  253. .base_params = &iwl2000_base_params, \
  254. .need_temp_offset_calib = true, \
  255. .temp_offset_v2 = true, \
  256. .led_mode = IWL_LED_RF_STATE, \
  257. .adv_pm = true, \
  258. .rx_with_siso_diversity = true, \
  259. .iq_invert = true \
  260. const struct iwl_cfg iwl105_bgn_cfg = {
  261. .name = "Intel(R) Centrino(R) Wireless-N 105 BGN",
  262. IWL_DEVICE_105,
  263. .ht_params = &iwl2000_ht_params,
  264. };
  265. const struct iwl_cfg iwl105_bgn_d_cfg = {
  266. .name = "Intel(R) Centrino(R) Wireless-N 105D BGN",
  267. IWL_DEVICE_105,
  268. .ht_params = &iwl2000_ht_params,
  269. };
  270. #define IWL_DEVICE_135 \
  271. .fw_name_pre = IWL135_FW_PRE, \
  272. .ucode_api_max = IWL135_UCODE_API_MAX, \
  273. .ucode_api_ok = IWL135_UCODE_API_OK, \
  274. .ucode_api_min = IWL135_UCODE_API_MIN, \
  275. .max_inst_size = IWL60_RTC_INST_SIZE, \
  276. .max_data_size = IWL60_RTC_DATA_SIZE, \
  277. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  278. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  279. .lib = &iwl2030_lib, \
  280. .base_params = &iwl2030_base_params, \
  281. .bt_params = &iwl2030_bt_params, \
  282. .need_temp_offset_calib = true, \
  283. .temp_offset_v2 = true, \
  284. .led_mode = IWL_LED_RF_STATE, \
  285. .adv_pm = true, \
  286. .rx_with_siso_diversity = true, \
  287. .iq_invert = true \
  288. const struct iwl_cfg iwl135_bgn_cfg = {
  289. .name = "Intel(R) Centrino(R) Wireless-N 135 BGN",
  290. IWL_DEVICE_135,
  291. .ht_params = &iwl2000_ht_params,
  292. };
  293. MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_OK));
  294. MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_OK));
  295. MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_OK));
  296. MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_OK));