iwl-2000.c 11 KB

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