iwl-2000.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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 <linux/wireless.h>
  33. #include <net/mac80211.h>
  34. #include <linux/etherdevice.h>
  35. #include <asm/unaligned.h>
  36. #include <linux/stringify.h>
  37. #include "iwl-eeprom.h"
  38. #include "iwl-dev.h"
  39. #include "iwl-core.h"
  40. #include "iwl-io.h"
  41. #include "iwl-sta.h"
  42. #include "iwl-agn.h"
  43. #include "iwl-helpers.h"
  44. #include "iwl-agn-hw.h"
  45. #include "iwl-6000-hw.h"
  46. /* Highest firmware API version supported */
  47. #define IWL2030_UCODE_API_MAX 5
  48. #define IWL2000_UCODE_API_MAX 5
  49. #define IWL105_UCODE_API_MAX 5
  50. #define IWL135_UCODE_API_MAX 5
  51. /* Lowest firmware API version supported */
  52. #define IWL2030_UCODE_API_MIN 5
  53. #define IWL2000_UCODE_API_MIN 5
  54. #define IWL105_UCODE_API_MIN 5
  55. #define IWL135_UCODE_API_MIN 5
  56. #define IWL2030_FW_PRE "iwlwifi-2030-"
  57. #define IWL2030_MODULE_FIRMWARE(api) IWL2030_FW_PRE __stringify(api) ".ucode"
  58. #define IWL2000_FW_PRE "iwlwifi-2000-"
  59. #define IWL2000_MODULE_FIRMWARE(api) IWL2000_FW_PRE __stringify(api) ".ucode"
  60. #define IWL105_FW_PRE "iwlwifi-105-"
  61. #define IWL105_MODULE_FIRMWARE(api) IWL105_FW_PRE __stringify(api) ".ucode"
  62. #define IWL135_FW_PRE "iwlwifi-135-"
  63. #define IWL135_MODULE_FIRMWARE(api) IWL135_FW_PRE #api ".ucode"
  64. static void iwl2000_set_ct_threshold(struct iwl_priv *priv)
  65. {
  66. /* want Celsius */
  67. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
  68. priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  69. }
  70. /* NIC configuration for 2000 series */
  71. static void iwl2000_nic_config(struct iwl_priv *priv)
  72. {
  73. iwl_rf_config(priv);
  74. if (priv->cfg->iq_invert)
  75. iwl_set_bit(priv, CSR_GP_DRIVER_REG,
  76. CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
  77. }
  78. static struct iwl_sensitivity_ranges iwl2000_sensitivity = {
  79. .min_nrg_cck = 97,
  80. .max_nrg_cck = 0, /* not used, set to 0 */
  81. .auto_corr_min_ofdm = 80,
  82. .auto_corr_min_ofdm_mrc = 128,
  83. .auto_corr_min_ofdm_x1 = 105,
  84. .auto_corr_min_ofdm_mrc_x1 = 192,
  85. .auto_corr_max_ofdm = 145,
  86. .auto_corr_max_ofdm_mrc = 232,
  87. .auto_corr_max_ofdm_x1 = 110,
  88. .auto_corr_max_ofdm_mrc_x1 = 232,
  89. .auto_corr_min_cck = 125,
  90. .auto_corr_max_cck = 175,
  91. .auto_corr_min_cck_mrc = 160,
  92. .auto_corr_max_cck_mrc = 310,
  93. .nrg_th_cck = 97,
  94. .nrg_th_ofdm = 100,
  95. .barker_corr_th_min = 190,
  96. .barker_corr_th_min_mrc = 390,
  97. .nrg_th_cca = 62,
  98. };
  99. static int iwl2000_hw_set_hw_params(struct iwl_priv *priv)
  100. {
  101. if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
  102. iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
  103. priv->cfg->base_params->num_of_queues =
  104. iwlagn_mod_params.num_of_queues;
  105. priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
  106. priv->hw_params.scd_bc_tbls_size =
  107. priv->cfg->base_params->num_of_queues *
  108. sizeof(struct iwlagn_scd_bc_tbl);
  109. priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
  110. priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
  111. priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
  112. priv->hw_params.max_data_size = IWL60_RTC_DATA_SIZE;
  113. priv->hw_params.max_inst_size = IWL60_RTC_INST_SIZE;
  114. priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
  115. BIT(IEEE80211_BAND_5GHZ);
  116. priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
  117. if (priv->cfg->rx_with_siso_diversity)
  118. priv->hw_params.rx_chains_num = 1;
  119. else
  120. priv->hw_params.rx_chains_num =
  121. num_of_ant(priv->cfg->valid_rx_ant);
  122. priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
  123. priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
  124. iwl2000_set_ct_threshold(priv);
  125. /* Set initial sensitivity parameters */
  126. /* Set initial calibration set */
  127. priv->hw_params.sens = &iwl2000_sensitivity;
  128. priv->hw_params.calib_init_cfg =
  129. BIT(IWL_CALIB_XTAL) |
  130. BIT(IWL_CALIB_LO) |
  131. BIT(IWL_CALIB_TX_IQ) |
  132. BIT(IWL_CALIB_BASE_BAND);
  133. if (priv->cfg->need_dc_calib)
  134. priv->hw_params.calib_rt_cfg |= IWL_CALIB_CFG_DC_IDX;
  135. if (priv->cfg->need_temp_offset_calib)
  136. priv->hw_params.calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET);
  137. priv->hw_params.beacon_time_tsf_bits = IWLAGN_EXT_BEACON_TIME_POS;
  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 = iwlcore_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 = iwlcore_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. .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
  186. .adv_thermal_throttle = true,
  187. .support_ct_kill_exit = true,
  188. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  189. .chain_noise_scale = 1000,
  190. .wd_timeout = IWL_DEF_WD_TIMEOUT,
  191. .max_event_log_size = 512,
  192. .shadow_reg_enable = 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. .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
  203. .adv_thermal_throttle = true,
  204. .support_ct_kill_exit = true,
  205. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  206. .chain_noise_scale = 1000,
  207. .wd_timeout = IWL_LONG_WD_TIMEOUT,
  208. .max_event_log_size = 512,
  209. .shadow_reg_enable = 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_min = IWL2000_UCODE_API_MIN, \
  228. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  229. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  230. .lib = &iwl2000_lib, \
  231. .base_params = &iwl2000_base_params, \
  232. .need_dc_calib = true, \
  233. .need_temp_offset_calib = true, \
  234. .led_mode = IWL_LED_RF_STATE, \
  235. .iq_invert = true \
  236. struct iwl_cfg iwl2000_2bgn_cfg = {
  237. .name = "2000 Series 2x2 BGN",
  238. IWL_DEVICE_2000,
  239. .ht_params = &iwl2000_ht_params,
  240. };
  241. struct iwl_cfg iwl2000_2bg_cfg = {
  242. .name = "2000 Series 2x2 BG",
  243. IWL_DEVICE_2000,
  244. };
  245. #define IWL_DEVICE_2030 \
  246. .fw_name_pre = IWL2030_FW_PRE, \
  247. .ucode_api_max = IWL2030_UCODE_API_MAX, \
  248. .ucode_api_min = IWL2030_UCODE_API_MIN, \
  249. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  250. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  251. .lib = &iwl2030_lib, \
  252. .base_params = &iwl2030_base_params, \
  253. .bt_params = &iwl2030_bt_params, \
  254. .need_dc_calib = true, \
  255. .need_temp_offset_calib = true, \
  256. .led_mode = IWL_LED_RF_STATE, \
  257. .adv_pm = true, \
  258. .iq_invert = true \
  259. struct iwl_cfg iwl2030_2bgn_cfg = {
  260. .name = "2000 Series 2x2 BGN/BT",
  261. IWL_DEVICE_2030,
  262. .ht_params = &iwl2000_ht_params,
  263. };
  264. struct iwl_cfg iwl2030_2bg_cfg = {
  265. .name = "2000 Series 2x2 BG/BT",
  266. IWL_DEVICE_2030,
  267. };
  268. #define IWL_DEVICE_105 \
  269. .fw_name_pre = IWL105_FW_PRE, \
  270. .ucode_api_max = IWL105_UCODE_API_MAX, \
  271. .ucode_api_min = IWL105_UCODE_API_MIN, \
  272. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  273. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  274. .lib = &iwl2000_lib, \
  275. .base_params = &iwl2000_base_params, \
  276. .need_dc_calib = true, \
  277. .need_temp_offset_calib = true, \
  278. .led_mode = IWL_LED_RF_STATE, \
  279. .adv_pm = true, \
  280. .rx_with_siso_diversity = true, \
  281. .iq_invert = true \
  282. struct iwl_cfg iwl105_bg_cfg = {
  283. .name = "105 Series 1x1 BG",
  284. IWL_DEVICE_105,
  285. };
  286. struct iwl_cfg iwl105_bgn_cfg = {
  287. .name = "105 Series 1x1 BGN",
  288. IWL_DEVICE_105,
  289. .ht_params = &iwl2000_ht_params,
  290. };
  291. #define IWL_DEVICE_135 \
  292. .fw_name_pre = IWL135_FW_PRE, \
  293. .ucode_api_max = IWL135_UCODE_API_MAX, \
  294. .ucode_api_min = IWL135_UCODE_API_MIN, \
  295. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  296. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  297. .lib = &iwl2030_lib, \
  298. .base_params = &iwl2030_base_params, \
  299. .bt_params = &iwl2030_bt_params, \
  300. .need_dc_calib = true, \
  301. .need_temp_offset_calib = true, \
  302. .led_mode = IWL_LED_RF_STATE, \
  303. .adv_pm = true, \
  304. .rx_with_siso_diversity = true, \
  305. .iq_invert = true \
  306. struct iwl_cfg iwl135_bg_cfg = {
  307. .name = "135 Series 1x1 BG/BT",
  308. IWL_DEVICE_135,
  309. };
  310. struct iwl_cfg iwl135_bgn_cfg = {
  311. .name = "135 Series 1x1 BGN/BT",
  312. IWL_DEVICE_135,
  313. .ht_params = &iwl2000_ht_params,
  314. };
  315. MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_MAX));
  316. MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_MAX));
  317. MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_MAX));
  318. MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_MAX));