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