iwl-2000.c 11 KB

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