iwl-2000.c 11 KB

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