iwl-2000.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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 #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. hw_params(priv).beacon_time_tsf_bits = IWLAGN_EXT_BEACON_TIME_POS;
  139. return 0;
  140. }
  141. static struct iwl_lib_ops iwl2000_lib = {
  142. .set_hw_params = iwl2000_hw_set_hw_params,
  143. .nic_config = iwl2000_nic_config,
  144. .eeprom_ops = {
  145. .regulatory_bands = {
  146. EEPROM_REG_BAND_1_CHANNELS,
  147. EEPROM_REG_BAND_2_CHANNELS,
  148. EEPROM_REG_BAND_3_CHANNELS,
  149. EEPROM_REG_BAND_4_CHANNELS,
  150. EEPROM_REG_BAND_5_CHANNELS,
  151. EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
  152. EEPROM_REGULATORY_BAND_NO_HT40,
  153. },
  154. .update_enhanced_txpower = iwl_eeprom_enhanced_txpower,
  155. },
  156. .temperature = iwlagn_temperature,
  157. };
  158. static struct iwl_lib_ops iwl2030_lib = {
  159. .set_hw_params = iwl2000_hw_set_hw_params,
  160. .bt_rx_handler_setup = iwlagn_bt_rx_handler_setup,
  161. .bt_setup_deferred_work = iwlagn_bt_setup_deferred_work,
  162. .cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
  163. .nic_config = iwl2000_nic_config,
  164. .eeprom_ops = {
  165. .regulatory_bands = {
  166. EEPROM_REG_BAND_1_CHANNELS,
  167. EEPROM_REG_BAND_2_CHANNELS,
  168. EEPROM_REG_BAND_3_CHANNELS,
  169. EEPROM_REG_BAND_4_CHANNELS,
  170. EEPROM_REG_BAND_5_CHANNELS,
  171. EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
  172. EEPROM_REGULATORY_BAND_NO_HT40,
  173. },
  174. .update_enhanced_txpower = iwl_eeprom_enhanced_txpower,
  175. },
  176. .temperature = iwlagn_temperature,
  177. };
  178. static struct iwl_base_params iwl2000_base_params = {
  179. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  180. .num_of_queues = IWLAGN_NUM_QUEUES,
  181. .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
  182. .pll_cfg_val = 0,
  183. .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
  184. .shadow_ram_support = true,
  185. .led_compensation = 51,
  186. .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
  187. .adv_thermal_throttle = true,
  188. .support_ct_kill_exit = true,
  189. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  190. .chain_noise_scale = 1000,
  191. .wd_timeout = IWL_DEF_WD_TIMEOUT,
  192. .max_event_log_size = 512,
  193. .shadow_reg_enable = true,
  194. .hd_v2 = true,
  195. };
  196. static struct iwl_base_params iwl2030_base_params = {
  197. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  198. .num_of_queues = IWLAGN_NUM_QUEUES,
  199. .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
  200. .pll_cfg_val = 0,
  201. .max_ll_items = OTP_MAX_LL_ITEMS_2x00,
  202. .shadow_ram_support = true,
  203. .led_compensation = 57,
  204. .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
  205. .adv_thermal_throttle = true,
  206. .support_ct_kill_exit = true,
  207. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  208. .chain_noise_scale = 1000,
  209. .wd_timeout = IWL_LONG_WD_TIMEOUT,
  210. .max_event_log_size = 512,
  211. .shadow_reg_enable = true,
  212. .hd_v2 = true,
  213. };
  214. static struct iwl_ht_params iwl2000_ht_params = {
  215. .ht_greenfield_support = true,
  216. .use_rts_for_aggregation = true, /* use rts/cts protection */
  217. };
  218. static struct iwl_bt_params iwl2030_bt_params = {
  219. /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
  220. .advanced_bt_coexist = true,
  221. .agg_time_limit = BT_AGG_THRESHOLD_DEF,
  222. .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
  223. .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
  224. .bt_sco_disable = true,
  225. .bt_session_2 = true,
  226. };
  227. #define IWL_DEVICE_2000 \
  228. .fw_name_pre = IWL2000_FW_PRE, \
  229. .ucode_api_max = IWL2000_UCODE_API_MAX, \
  230. .ucode_api_ok = IWL2000_UCODE_API_OK, \
  231. .ucode_api_min = IWL2000_UCODE_API_MIN, \
  232. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  233. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  234. .lib = &iwl2000_lib, \
  235. .base_params = &iwl2000_base_params, \
  236. .need_dc_calib = true, \
  237. .need_temp_offset_calib = true, \
  238. .led_mode = IWL_LED_RF_STATE, \
  239. .iq_invert = true \
  240. struct iwl_cfg iwl2000_2bgn_cfg = {
  241. .name = "2000 Series 2x2 BGN",
  242. IWL_DEVICE_2000,
  243. .ht_params = &iwl2000_ht_params,
  244. };
  245. struct iwl_cfg iwl2000_2bg_cfg = {
  246. .name = "2000 Series 2x2 BG",
  247. IWL_DEVICE_2000,
  248. };
  249. struct iwl_cfg iwl2000_2bgn_d_cfg = {
  250. .name = "2000D Series 2x2 BGN",
  251. IWL_DEVICE_2000,
  252. .ht_params = &iwl2000_ht_params,
  253. };
  254. #define IWL_DEVICE_2030 \
  255. .fw_name_pre = IWL2030_FW_PRE, \
  256. .ucode_api_max = IWL2030_UCODE_API_MAX, \
  257. .ucode_api_ok = IWL2030_UCODE_API_OK, \
  258. .ucode_api_min = IWL2030_UCODE_API_MIN, \
  259. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  260. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  261. .lib = &iwl2030_lib, \
  262. .base_params = &iwl2030_base_params, \
  263. .bt_params = &iwl2030_bt_params, \
  264. .need_dc_calib = true, \
  265. .need_temp_offset_calib = true, \
  266. .led_mode = IWL_LED_RF_STATE, \
  267. .adv_pm = true, \
  268. .iq_invert = true \
  269. struct iwl_cfg iwl2030_2bgn_cfg = {
  270. .name = "2000 Series 2x2 BGN/BT",
  271. IWL_DEVICE_2030,
  272. .ht_params = &iwl2000_ht_params,
  273. };
  274. struct iwl_cfg iwl2030_2bg_cfg = {
  275. .name = "2000 Series 2x2 BG/BT",
  276. IWL_DEVICE_2030,
  277. };
  278. #define IWL_DEVICE_105 \
  279. .fw_name_pre = IWL105_FW_PRE, \
  280. .ucode_api_max = IWL105_UCODE_API_MAX, \
  281. .ucode_api_ok = IWL105_UCODE_API_OK, \
  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. .lib = &iwl2000_lib, \
  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. .iq_invert = true \
  293. struct iwl_cfg iwl105_bg_cfg = {
  294. .name = "105 Series 1x1 BG",
  295. IWL_DEVICE_105,
  296. };
  297. struct iwl_cfg iwl105_bgn_cfg = {
  298. .name = "105 Series 1x1 BGN",
  299. IWL_DEVICE_105,
  300. .ht_params = &iwl2000_ht_params,
  301. };
  302. #define IWL_DEVICE_135 \
  303. .fw_name_pre = IWL135_FW_PRE, \
  304. .ucode_api_max = IWL135_UCODE_API_MAX, \
  305. .ucode_api_ok = IWL135_UCODE_API_OK, \
  306. .ucode_api_min = IWL135_UCODE_API_MIN, \
  307. .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
  308. .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
  309. .lib = &iwl2030_lib, \
  310. .base_params = &iwl2030_base_params, \
  311. .bt_params = &iwl2030_bt_params, \
  312. .need_dc_calib = true, \
  313. .need_temp_offset_calib = true, \
  314. .led_mode = IWL_LED_RF_STATE, \
  315. .adv_pm = true, \
  316. .rx_with_siso_diversity = true, \
  317. .iq_invert = true \
  318. struct iwl_cfg iwl135_bg_cfg = {
  319. .name = "135 Series 1x1 BG/BT",
  320. IWL_DEVICE_135,
  321. };
  322. struct iwl_cfg iwl135_bgn_cfg = {
  323. .name = "135 Series 1x1 BGN/BT",
  324. IWL_DEVICE_135,
  325. .ht_params = &iwl2000_ht_params,
  326. };
  327. MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_MAX));
  328. MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_MAX));
  329. MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_MAX));
  330. MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_MAX));