devices.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2008 - 2013 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. /*
  27. * DVM device-specific data & functions
  28. */
  29. #include "iwl-io.h"
  30. #include "iwl-prph.h"
  31. #include "iwl-eeprom-parse.h"
  32. #include "agn.h"
  33. #include "dev.h"
  34. #include "commands.h"
  35. /*
  36. * 1000 series
  37. * ===========
  38. */
  39. /*
  40. * For 1000, use advance thermal throttling critical temperature threshold,
  41. * but legacy thermal management implementation for now.
  42. * This is for the reason of 1000 uCode using advance thermal throttling API
  43. * but not implement ct_kill_exit based on ct_kill exit temperature
  44. * so the thermal throttling will still based on legacy thermal throttling
  45. * management.
  46. * The code here need to be modified once 1000 uCode has the advanced thermal
  47. * throttling algorithm in place
  48. */
  49. static void iwl1000_set_ct_threshold(struct iwl_priv *priv)
  50. {
  51. /* want Celsius */
  52. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
  53. priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  54. }
  55. /* NIC configuration for 1000 series */
  56. static void iwl1000_nic_config(struct iwl_priv *priv)
  57. {
  58. /* Setting digital SVR for 1000 card to 1.32V */
  59. /* locking is acquired in iwl_set_bits_mask_prph() function */
  60. iwl_set_bits_mask_prph(priv->trans, APMG_DIGITAL_SVR_REG,
  61. APMG_SVR_DIGITAL_VOLTAGE_1_32,
  62. ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK);
  63. }
  64. /**
  65. * iwl_beacon_time_mask_low - mask of lower 32 bit of beacon time
  66. * @priv -- pointer to iwl_priv data structure
  67. * @tsf_bits -- number of bits need to shift for masking)
  68. */
  69. static inline u32 iwl_beacon_time_mask_low(struct iwl_priv *priv,
  70. u16 tsf_bits)
  71. {
  72. return (1 << tsf_bits) - 1;
  73. }
  74. /**
  75. * iwl_beacon_time_mask_high - mask of higher 32 bit of beacon time
  76. * @priv -- pointer to iwl_priv data structure
  77. * @tsf_bits -- number of bits need to shift for masking)
  78. */
  79. static inline u32 iwl_beacon_time_mask_high(struct iwl_priv *priv,
  80. u16 tsf_bits)
  81. {
  82. return ((1 << (32 - tsf_bits)) - 1) << tsf_bits;
  83. }
  84. /*
  85. * extended beacon time format
  86. * time in usec will be changed into a 32-bit value in extended:internal format
  87. * the extended part is the beacon counts
  88. * the internal part is the time in usec within one beacon interval
  89. */
  90. static u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec,
  91. u32 beacon_interval)
  92. {
  93. u32 quot;
  94. u32 rem;
  95. u32 interval = beacon_interval * TIME_UNIT;
  96. if (!interval || !usec)
  97. return 0;
  98. quot = (usec / interval) &
  99. (iwl_beacon_time_mask_high(priv, IWLAGN_EXT_BEACON_TIME_POS) >>
  100. IWLAGN_EXT_BEACON_TIME_POS);
  101. rem = (usec % interval) & iwl_beacon_time_mask_low(priv,
  102. IWLAGN_EXT_BEACON_TIME_POS);
  103. return (quot << IWLAGN_EXT_BEACON_TIME_POS) + rem;
  104. }
  105. /* base is usually what we get from ucode with each received frame,
  106. * the same as HW timer counter counting down
  107. */
  108. static __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
  109. u32 addon, u32 beacon_interval)
  110. {
  111. u32 base_low = base & iwl_beacon_time_mask_low(priv,
  112. IWLAGN_EXT_BEACON_TIME_POS);
  113. u32 addon_low = addon & iwl_beacon_time_mask_low(priv,
  114. IWLAGN_EXT_BEACON_TIME_POS);
  115. u32 interval = beacon_interval * TIME_UNIT;
  116. u32 res = (base & iwl_beacon_time_mask_high(priv,
  117. IWLAGN_EXT_BEACON_TIME_POS)) +
  118. (addon & iwl_beacon_time_mask_high(priv,
  119. IWLAGN_EXT_BEACON_TIME_POS));
  120. if (base_low > addon_low)
  121. res += base_low - addon_low;
  122. else if (base_low < addon_low) {
  123. res += interval + base_low - addon_low;
  124. res += (1 << IWLAGN_EXT_BEACON_TIME_POS);
  125. } else
  126. res += (1 << IWLAGN_EXT_BEACON_TIME_POS);
  127. return cpu_to_le32(res);
  128. }
  129. static const struct iwl_sensitivity_ranges iwl1000_sensitivity = {
  130. .min_nrg_cck = 95,
  131. .auto_corr_min_ofdm = 90,
  132. .auto_corr_min_ofdm_mrc = 170,
  133. .auto_corr_min_ofdm_x1 = 120,
  134. .auto_corr_min_ofdm_mrc_x1 = 240,
  135. .auto_corr_max_ofdm = 120,
  136. .auto_corr_max_ofdm_mrc = 210,
  137. .auto_corr_max_ofdm_x1 = 155,
  138. .auto_corr_max_ofdm_mrc_x1 = 290,
  139. .auto_corr_min_cck = 125,
  140. .auto_corr_max_cck = 200,
  141. .auto_corr_min_cck_mrc = 170,
  142. .auto_corr_max_cck_mrc = 400,
  143. .nrg_th_cck = 95,
  144. .nrg_th_ofdm = 95,
  145. .barker_corr_th_min = 190,
  146. .barker_corr_th_min_mrc = 390,
  147. .nrg_th_cca = 62,
  148. };
  149. static void iwl1000_hw_set_hw_params(struct iwl_priv *priv)
  150. {
  151. iwl1000_set_ct_threshold(priv);
  152. /* Set initial sensitivity parameters */
  153. priv->hw_params.sens = &iwl1000_sensitivity;
  154. }
  155. const struct iwl_dvm_cfg iwl_dvm_1000_cfg = {
  156. .set_hw_params = iwl1000_hw_set_hw_params,
  157. .nic_config = iwl1000_nic_config,
  158. .temperature = iwlagn_temperature,
  159. .support_ct_kill_exit = true,
  160. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
  161. .chain_noise_scale = 1000,
  162. };
  163. /*
  164. * 2000 series
  165. * ===========
  166. */
  167. static void iwl2000_set_ct_threshold(struct iwl_priv *priv)
  168. {
  169. /* want Celsius */
  170. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
  171. priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  172. }
  173. /* NIC configuration for 2000 series */
  174. static void iwl2000_nic_config(struct iwl_priv *priv)
  175. {
  176. iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
  177. CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
  178. }
  179. static const struct iwl_sensitivity_ranges iwl2000_sensitivity = {
  180. .min_nrg_cck = 97,
  181. .auto_corr_min_ofdm = 80,
  182. .auto_corr_min_ofdm_mrc = 128,
  183. .auto_corr_min_ofdm_x1 = 105,
  184. .auto_corr_min_ofdm_mrc_x1 = 192,
  185. .auto_corr_max_ofdm = 145,
  186. .auto_corr_max_ofdm_mrc = 232,
  187. .auto_corr_max_ofdm_x1 = 110,
  188. .auto_corr_max_ofdm_mrc_x1 = 232,
  189. .auto_corr_min_cck = 125,
  190. .auto_corr_max_cck = 175,
  191. .auto_corr_min_cck_mrc = 160,
  192. .auto_corr_max_cck_mrc = 310,
  193. .nrg_th_cck = 97,
  194. .nrg_th_ofdm = 100,
  195. .barker_corr_th_min = 190,
  196. .barker_corr_th_min_mrc = 390,
  197. .nrg_th_cca = 62,
  198. };
  199. static void iwl2000_hw_set_hw_params(struct iwl_priv *priv)
  200. {
  201. iwl2000_set_ct_threshold(priv);
  202. /* Set initial sensitivity parameters */
  203. priv->hw_params.sens = &iwl2000_sensitivity;
  204. }
  205. const struct iwl_dvm_cfg iwl_dvm_2000_cfg = {
  206. .set_hw_params = iwl2000_hw_set_hw_params,
  207. .nic_config = iwl2000_nic_config,
  208. .temperature = iwlagn_temperature,
  209. .adv_thermal_throttle = true,
  210. .support_ct_kill_exit = true,
  211. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  212. .chain_noise_scale = 1000,
  213. .hd_v2 = true,
  214. .need_temp_offset_calib = true,
  215. .temp_offset_v2 = true,
  216. };
  217. const struct iwl_dvm_cfg iwl_dvm_105_cfg = {
  218. .set_hw_params = iwl2000_hw_set_hw_params,
  219. .nic_config = iwl2000_nic_config,
  220. .temperature = iwlagn_temperature,
  221. .adv_thermal_throttle = true,
  222. .support_ct_kill_exit = true,
  223. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  224. .chain_noise_scale = 1000,
  225. .hd_v2 = true,
  226. .need_temp_offset_calib = true,
  227. .temp_offset_v2 = true,
  228. .adv_pm = true,
  229. };
  230. static const struct iwl_dvm_bt_params iwl2030_bt_params = {
  231. /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
  232. .advanced_bt_coexist = true,
  233. .agg_time_limit = BT_AGG_THRESHOLD_DEF,
  234. .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
  235. .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT32,
  236. .bt_sco_disable = true,
  237. .bt_session_2 = true,
  238. };
  239. const struct iwl_dvm_cfg iwl_dvm_2030_cfg = {
  240. .set_hw_params = iwl2000_hw_set_hw_params,
  241. .nic_config = iwl2000_nic_config,
  242. .temperature = iwlagn_temperature,
  243. .adv_thermal_throttle = true,
  244. .support_ct_kill_exit = true,
  245. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  246. .chain_noise_scale = 1000,
  247. .hd_v2 = true,
  248. .bt_params = &iwl2030_bt_params,
  249. .need_temp_offset_calib = true,
  250. .temp_offset_v2 = true,
  251. .adv_pm = true,
  252. };
  253. /*
  254. * 5000 series
  255. * ===========
  256. */
  257. /* NIC configuration for 5000 series */
  258. static const struct iwl_sensitivity_ranges iwl5000_sensitivity = {
  259. .min_nrg_cck = 100,
  260. .auto_corr_min_ofdm = 90,
  261. .auto_corr_min_ofdm_mrc = 170,
  262. .auto_corr_min_ofdm_x1 = 105,
  263. .auto_corr_min_ofdm_mrc_x1 = 220,
  264. .auto_corr_max_ofdm = 120,
  265. .auto_corr_max_ofdm_mrc = 210,
  266. .auto_corr_max_ofdm_x1 = 120,
  267. .auto_corr_max_ofdm_mrc_x1 = 240,
  268. .auto_corr_min_cck = 125,
  269. .auto_corr_max_cck = 200,
  270. .auto_corr_min_cck_mrc = 200,
  271. .auto_corr_max_cck_mrc = 400,
  272. .nrg_th_cck = 100,
  273. .nrg_th_ofdm = 100,
  274. .barker_corr_th_min = 190,
  275. .barker_corr_th_min_mrc = 390,
  276. .nrg_th_cca = 62,
  277. };
  278. static struct iwl_sensitivity_ranges iwl5150_sensitivity = {
  279. .min_nrg_cck = 95,
  280. .auto_corr_min_ofdm = 90,
  281. .auto_corr_min_ofdm_mrc = 170,
  282. .auto_corr_min_ofdm_x1 = 105,
  283. .auto_corr_min_ofdm_mrc_x1 = 220,
  284. .auto_corr_max_ofdm = 120,
  285. .auto_corr_max_ofdm_mrc = 210,
  286. /* max = min for performance bug in 5150 DSP */
  287. .auto_corr_max_ofdm_x1 = 105,
  288. .auto_corr_max_ofdm_mrc_x1 = 220,
  289. .auto_corr_min_cck = 125,
  290. .auto_corr_max_cck = 200,
  291. .auto_corr_min_cck_mrc = 170,
  292. .auto_corr_max_cck_mrc = 400,
  293. .nrg_th_cck = 95,
  294. .nrg_th_ofdm = 95,
  295. .barker_corr_th_min = 190,
  296. .barker_corr_th_min_mrc = 390,
  297. .nrg_th_cca = 62,
  298. };
  299. #define IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF (-5)
  300. static s32 iwl_temp_calib_to_offset(struct iwl_priv *priv)
  301. {
  302. u16 temperature, voltage;
  303. temperature = le16_to_cpu(priv->nvm_data->kelvin_temperature);
  304. voltage = le16_to_cpu(priv->nvm_data->kelvin_voltage);
  305. /* offset = temp - volt / coeff */
  306. return (s32)(temperature -
  307. voltage / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF);
  308. }
  309. static void iwl5150_set_ct_threshold(struct iwl_priv *priv)
  310. {
  311. const s32 volt2temp_coef = IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF;
  312. s32 threshold = (s32)CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY) -
  313. iwl_temp_calib_to_offset(priv);
  314. priv->hw_params.ct_kill_threshold = threshold * volt2temp_coef;
  315. }
  316. static void iwl5000_set_ct_threshold(struct iwl_priv *priv)
  317. {
  318. /* want Celsius */
  319. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
  320. }
  321. static void iwl5000_hw_set_hw_params(struct iwl_priv *priv)
  322. {
  323. iwl5000_set_ct_threshold(priv);
  324. /* Set initial sensitivity parameters */
  325. priv->hw_params.sens = &iwl5000_sensitivity;
  326. }
  327. static void iwl5150_hw_set_hw_params(struct iwl_priv *priv)
  328. {
  329. iwl5150_set_ct_threshold(priv);
  330. /* Set initial sensitivity parameters */
  331. priv->hw_params.sens = &iwl5150_sensitivity;
  332. }
  333. static void iwl5150_temperature(struct iwl_priv *priv)
  334. {
  335. u32 vt = 0;
  336. s32 offset = iwl_temp_calib_to_offset(priv);
  337. vt = le32_to_cpu(priv->statistics.common.temperature);
  338. vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset;
  339. /* now vt hold the temperature in Kelvin */
  340. priv->temperature = KELVIN_TO_CELSIUS(vt);
  341. iwl_tt_handler(priv);
  342. }
  343. static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
  344. struct ieee80211_channel_switch *ch_switch)
  345. {
  346. /*
  347. * MULTI-FIXME
  348. * See iwlagn_mac_channel_switch.
  349. */
  350. struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
  351. struct iwl5000_channel_switch_cmd cmd;
  352. u32 switch_time_in_usec, ucode_switch_time;
  353. u16 ch;
  354. u32 tsf_low;
  355. u8 switch_count;
  356. u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
  357. struct ieee80211_vif *vif = ctx->vif;
  358. struct iwl_host_cmd hcmd = {
  359. .id = REPLY_CHANNEL_SWITCH,
  360. .len = { sizeof(cmd), },
  361. .flags = CMD_SYNC,
  362. .data = { &cmd, },
  363. };
  364. cmd.band = priv->band == IEEE80211_BAND_2GHZ;
  365. ch = ch_switch->chandef.chan->hw_value;
  366. IWL_DEBUG_11H(priv, "channel switch from %d to %d\n",
  367. ctx->active.channel, ch);
  368. cmd.channel = cpu_to_le16(ch);
  369. cmd.rxon_flags = ctx->staging.flags;
  370. cmd.rxon_filter_flags = ctx->staging.filter_flags;
  371. switch_count = ch_switch->count;
  372. tsf_low = ch_switch->timestamp & 0x0ffffffff;
  373. /*
  374. * calculate the ucode channel switch time
  375. * adding TSF as one of the factor for when to switch
  376. */
  377. if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) {
  378. if (switch_count > ((priv->ucode_beacon_time - tsf_low) /
  379. beacon_interval)) {
  380. switch_count -= (priv->ucode_beacon_time -
  381. tsf_low) / beacon_interval;
  382. } else
  383. switch_count = 0;
  384. }
  385. if (switch_count <= 1)
  386. cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time);
  387. else {
  388. switch_time_in_usec =
  389. vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
  390. ucode_switch_time = iwl_usecs_to_beacons(priv,
  391. switch_time_in_usec,
  392. beacon_interval);
  393. cmd.switch_time = iwl_add_beacon_time(priv,
  394. priv->ucode_beacon_time,
  395. ucode_switch_time,
  396. beacon_interval);
  397. }
  398. IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
  399. cmd.switch_time);
  400. cmd.expect_beacon =
  401. ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
  402. return iwl_dvm_send_cmd(priv, &hcmd);
  403. }
  404. const struct iwl_dvm_cfg iwl_dvm_5000_cfg = {
  405. .set_hw_params = iwl5000_hw_set_hw_params,
  406. .set_channel_switch = iwl5000_hw_channel_switch,
  407. .temperature = iwlagn_temperature,
  408. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
  409. .chain_noise_scale = 1000,
  410. .no_idle_support = true,
  411. };
  412. const struct iwl_dvm_cfg iwl_dvm_5150_cfg = {
  413. .set_hw_params = iwl5150_hw_set_hw_params,
  414. .set_channel_switch = iwl5000_hw_channel_switch,
  415. .temperature = iwl5150_temperature,
  416. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
  417. .chain_noise_scale = 1000,
  418. .no_idle_support = true,
  419. .no_xtal_calib = true,
  420. };
  421. /*
  422. * 6000 series
  423. * ===========
  424. */
  425. static void iwl6000_set_ct_threshold(struct iwl_priv *priv)
  426. {
  427. /* want Celsius */
  428. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
  429. priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  430. }
  431. /* NIC configuration for 6000 series */
  432. static void iwl6000_nic_config(struct iwl_priv *priv)
  433. {
  434. switch (priv->cfg->device_family) {
  435. case IWL_DEVICE_FAMILY_6005:
  436. case IWL_DEVICE_FAMILY_6030:
  437. case IWL_DEVICE_FAMILY_6000:
  438. break;
  439. case IWL_DEVICE_FAMILY_6000i:
  440. /* 2x2 IPA phy type */
  441. iwl_write32(priv->trans, CSR_GP_DRIVER_REG,
  442. CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
  443. break;
  444. case IWL_DEVICE_FAMILY_6050:
  445. /* Indicate calibration version to uCode. */
  446. if (priv->nvm_data->calib_version >= 6)
  447. iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
  448. CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
  449. break;
  450. case IWL_DEVICE_FAMILY_6150:
  451. /* Indicate calibration version to uCode. */
  452. if (priv->nvm_data->calib_version >= 6)
  453. iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
  454. CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
  455. iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
  456. CSR_GP_DRIVER_REG_BIT_6050_1x2);
  457. break;
  458. default:
  459. WARN_ON(1);
  460. }
  461. }
  462. static const struct iwl_sensitivity_ranges iwl6000_sensitivity = {
  463. .min_nrg_cck = 110,
  464. .auto_corr_min_ofdm = 80,
  465. .auto_corr_min_ofdm_mrc = 128,
  466. .auto_corr_min_ofdm_x1 = 105,
  467. .auto_corr_min_ofdm_mrc_x1 = 192,
  468. .auto_corr_max_ofdm = 145,
  469. .auto_corr_max_ofdm_mrc = 232,
  470. .auto_corr_max_ofdm_x1 = 110,
  471. .auto_corr_max_ofdm_mrc_x1 = 232,
  472. .auto_corr_min_cck = 125,
  473. .auto_corr_max_cck = 175,
  474. .auto_corr_min_cck_mrc = 160,
  475. .auto_corr_max_cck_mrc = 310,
  476. .nrg_th_cck = 110,
  477. .nrg_th_ofdm = 110,
  478. .barker_corr_th_min = 190,
  479. .barker_corr_th_min_mrc = 336,
  480. .nrg_th_cca = 62,
  481. };
  482. static void iwl6000_hw_set_hw_params(struct iwl_priv *priv)
  483. {
  484. iwl6000_set_ct_threshold(priv);
  485. /* Set initial sensitivity parameters */
  486. priv->hw_params.sens = &iwl6000_sensitivity;
  487. }
  488. static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
  489. struct ieee80211_channel_switch *ch_switch)
  490. {
  491. /*
  492. * MULTI-FIXME
  493. * See iwlagn_mac_channel_switch.
  494. */
  495. struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
  496. struct iwl6000_channel_switch_cmd *cmd;
  497. u32 switch_time_in_usec, ucode_switch_time;
  498. u16 ch;
  499. u32 tsf_low;
  500. u8 switch_count;
  501. u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
  502. struct ieee80211_vif *vif = ctx->vif;
  503. struct iwl_host_cmd hcmd = {
  504. .id = REPLY_CHANNEL_SWITCH,
  505. .len = { sizeof(*cmd), },
  506. .flags = CMD_SYNC,
  507. .dataflags[0] = IWL_HCMD_DFL_NOCOPY,
  508. };
  509. int err;
  510. cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
  511. if (!cmd)
  512. return -ENOMEM;
  513. hcmd.data[0] = cmd;
  514. cmd->band = priv->band == IEEE80211_BAND_2GHZ;
  515. ch = ch_switch->chandef.chan->hw_value;
  516. IWL_DEBUG_11H(priv, "channel switch from %u to %u\n",
  517. ctx->active.channel, ch);
  518. cmd->channel = cpu_to_le16(ch);
  519. cmd->rxon_flags = ctx->staging.flags;
  520. cmd->rxon_filter_flags = ctx->staging.filter_flags;
  521. switch_count = ch_switch->count;
  522. tsf_low = ch_switch->timestamp & 0x0ffffffff;
  523. /*
  524. * calculate the ucode channel switch time
  525. * adding TSF as one of the factor for when to switch
  526. */
  527. if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) {
  528. if (switch_count > ((priv->ucode_beacon_time - tsf_low) /
  529. beacon_interval)) {
  530. switch_count -= (priv->ucode_beacon_time -
  531. tsf_low) / beacon_interval;
  532. } else
  533. switch_count = 0;
  534. }
  535. if (switch_count <= 1)
  536. cmd->switch_time = cpu_to_le32(priv->ucode_beacon_time);
  537. else {
  538. switch_time_in_usec =
  539. vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
  540. ucode_switch_time = iwl_usecs_to_beacons(priv,
  541. switch_time_in_usec,
  542. beacon_interval);
  543. cmd->switch_time = iwl_add_beacon_time(priv,
  544. priv->ucode_beacon_time,
  545. ucode_switch_time,
  546. beacon_interval);
  547. }
  548. IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
  549. cmd->switch_time);
  550. cmd->expect_beacon =
  551. ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
  552. err = iwl_dvm_send_cmd(priv, &hcmd);
  553. kfree(cmd);
  554. return err;
  555. }
  556. const struct iwl_dvm_cfg iwl_dvm_6000_cfg = {
  557. .set_hw_params = iwl6000_hw_set_hw_params,
  558. .set_channel_switch = iwl6000_hw_channel_switch,
  559. .nic_config = iwl6000_nic_config,
  560. .temperature = iwlagn_temperature,
  561. .adv_thermal_throttle = true,
  562. .support_ct_kill_exit = true,
  563. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  564. .chain_noise_scale = 1000,
  565. };
  566. const struct iwl_dvm_cfg iwl_dvm_6005_cfg = {
  567. .set_hw_params = iwl6000_hw_set_hw_params,
  568. .set_channel_switch = iwl6000_hw_channel_switch,
  569. .nic_config = iwl6000_nic_config,
  570. .temperature = iwlagn_temperature,
  571. .adv_thermal_throttle = true,
  572. .support_ct_kill_exit = true,
  573. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  574. .chain_noise_scale = 1000,
  575. .need_temp_offset_calib = true,
  576. };
  577. const struct iwl_dvm_cfg iwl_dvm_6050_cfg = {
  578. .set_hw_params = iwl6000_hw_set_hw_params,
  579. .set_channel_switch = iwl6000_hw_channel_switch,
  580. .nic_config = iwl6000_nic_config,
  581. .temperature = iwlagn_temperature,
  582. .adv_thermal_throttle = true,
  583. .support_ct_kill_exit = true,
  584. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  585. .chain_noise_scale = 1500,
  586. };
  587. static const struct iwl_dvm_bt_params iwl6000_bt_params = {
  588. /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
  589. .advanced_bt_coexist = true,
  590. .agg_time_limit = BT_AGG_THRESHOLD_DEF,
  591. .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
  592. .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
  593. .bt_sco_disable = true,
  594. };
  595. const struct iwl_dvm_cfg iwl_dvm_6030_cfg = {
  596. .set_hw_params = iwl6000_hw_set_hw_params,
  597. .set_channel_switch = iwl6000_hw_channel_switch,
  598. .nic_config = iwl6000_nic_config,
  599. .temperature = iwlagn_temperature,
  600. .adv_thermal_throttle = true,
  601. .support_ct_kill_exit = true,
  602. .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
  603. .chain_noise_scale = 1000,
  604. .bt_params = &iwl6000_bt_params,
  605. .need_temp_offset_calib = true,
  606. .adv_pm = true,
  607. };