devices.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2008 - 2012 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. struct iwl_lib_ops iwl1000_lib = {
  156. .set_hw_params = iwl1000_hw_set_hw_params,
  157. .nic_config = iwl1000_nic_config,
  158. .temperature = iwlagn_temperature,
  159. };
  160. /*
  161. * 2000 series
  162. * ===========
  163. */
  164. static void iwl2000_set_ct_threshold(struct iwl_priv *priv)
  165. {
  166. /* want Celsius */
  167. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
  168. priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  169. }
  170. /* NIC configuration for 2000 series */
  171. static void iwl2000_nic_config(struct iwl_priv *priv)
  172. {
  173. iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
  174. CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
  175. }
  176. static const struct iwl_sensitivity_ranges iwl2000_sensitivity = {
  177. .min_nrg_cck = 97,
  178. .auto_corr_min_ofdm = 80,
  179. .auto_corr_min_ofdm_mrc = 128,
  180. .auto_corr_min_ofdm_x1 = 105,
  181. .auto_corr_min_ofdm_mrc_x1 = 192,
  182. .auto_corr_max_ofdm = 145,
  183. .auto_corr_max_ofdm_mrc = 232,
  184. .auto_corr_max_ofdm_x1 = 110,
  185. .auto_corr_max_ofdm_mrc_x1 = 232,
  186. .auto_corr_min_cck = 125,
  187. .auto_corr_max_cck = 175,
  188. .auto_corr_min_cck_mrc = 160,
  189. .auto_corr_max_cck_mrc = 310,
  190. .nrg_th_cck = 97,
  191. .nrg_th_ofdm = 100,
  192. .barker_corr_th_min = 190,
  193. .barker_corr_th_min_mrc = 390,
  194. .nrg_th_cca = 62,
  195. };
  196. static void iwl2000_hw_set_hw_params(struct iwl_priv *priv)
  197. {
  198. iwl2000_set_ct_threshold(priv);
  199. /* Set initial sensitivity parameters */
  200. priv->hw_params.sens = &iwl2000_sensitivity;
  201. }
  202. struct iwl_lib_ops iwl2000_lib = {
  203. .set_hw_params = iwl2000_hw_set_hw_params,
  204. .nic_config = iwl2000_nic_config,
  205. .temperature = iwlagn_temperature,
  206. };
  207. struct iwl_lib_ops iwl2030_lib = {
  208. .set_hw_params = iwl2000_hw_set_hw_params,
  209. .nic_config = iwl2000_nic_config,
  210. .temperature = iwlagn_temperature,
  211. };
  212. /*
  213. * 5000 series
  214. * ===========
  215. */
  216. /* NIC configuration for 5000 series */
  217. static void iwl5000_nic_config(struct iwl_priv *priv)
  218. {
  219. /* W/A : NIC is stuck in a reset state after Early PCIe power off
  220. * (PCIe power is lost before PERST# is asserted),
  221. * causing ME FW to lose ownership and not being able to obtain it back.
  222. */
  223. iwl_set_bits_mask_prph(priv->trans, APMG_PS_CTRL_REG,
  224. APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS,
  225. ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS);
  226. }
  227. static const struct iwl_sensitivity_ranges iwl5000_sensitivity = {
  228. .min_nrg_cck = 100,
  229. .auto_corr_min_ofdm = 90,
  230. .auto_corr_min_ofdm_mrc = 170,
  231. .auto_corr_min_ofdm_x1 = 105,
  232. .auto_corr_min_ofdm_mrc_x1 = 220,
  233. .auto_corr_max_ofdm = 120,
  234. .auto_corr_max_ofdm_mrc = 210,
  235. .auto_corr_max_ofdm_x1 = 120,
  236. .auto_corr_max_ofdm_mrc_x1 = 240,
  237. .auto_corr_min_cck = 125,
  238. .auto_corr_max_cck = 200,
  239. .auto_corr_min_cck_mrc = 200,
  240. .auto_corr_max_cck_mrc = 400,
  241. .nrg_th_cck = 100,
  242. .nrg_th_ofdm = 100,
  243. .barker_corr_th_min = 190,
  244. .barker_corr_th_min_mrc = 390,
  245. .nrg_th_cca = 62,
  246. };
  247. static struct iwl_sensitivity_ranges iwl5150_sensitivity = {
  248. .min_nrg_cck = 95,
  249. .auto_corr_min_ofdm = 90,
  250. .auto_corr_min_ofdm_mrc = 170,
  251. .auto_corr_min_ofdm_x1 = 105,
  252. .auto_corr_min_ofdm_mrc_x1 = 220,
  253. .auto_corr_max_ofdm = 120,
  254. .auto_corr_max_ofdm_mrc = 210,
  255. /* max = min for performance bug in 5150 DSP */
  256. .auto_corr_max_ofdm_x1 = 105,
  257. .auto_corr_max_ofdm_mrc_x1 = 220,
  258. .auto_corr_min_cck = 125,
  259. .auto_corr_max_cck = 200,
  260. .auto_corr_min_cck_mrc = 170,
  261. .auto_corr_max_cck_mrc = 400,
  262. .nrg_th_cck = 95,
  263. .nrg_th_ofdm = 95,
  264. .barker_corr_th_min = 190,
  265. .barker_corr_th_min_mrc = 390,
  266. .nrg_th_cca = 62,
  267. };
  268. #define IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF (-5)
  269. static s32 iwl_temp_calib_to_offset(struct iwl_priv *priv)
  270. {
  271. u16 temperature, voltage;
  272. temperature = le16_to_cpu(priv->eeprom_data->kelvin_temperature);
  273. voltage = le16_to_cpu(priv->eeprom_data->kelvin_voltage);
  274. /* offset = temp - volt / coeff */
  275. return (s32)(temperature -
  276. voltage / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF);
  277. }
  278. static void iwl5150_set_ct_threshold(struct iwl_priv *priv)
  279. {
  280. const s32 volt2temp_coef = IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF;
  281. s32 threshold = (s32)CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY) -
  282. iwl_temp_calib_to_offset(priv);
  283. priv->hw_params.ct_kill_threshold = threshold * volt2temp_coef;
  284. }
  285. static void iwl5000_set_ct_threshold(struct iwl_priv *priv)
  286. {
  287. /* want Celsius */
  288. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
  289. }
  290. static void iwl5000_hw_set_hw_params(struct iwl_priv *priv)
  291. {
  292. iwl5000_set_ct_threshold(priv);
  293. /* Set initial sensitivity parameters */
  294. priv->hw_params.sens = &iwl5000_sensitivity;
  295. }
  296. static void iwl5150_hw_set_hw_params(struct iwl_priv *priv)
  297. {
  298. iwl5150_set_ct_threshold(priv);
  299. /* Set initial sensitivity parameters */
  300. priv->hw_params.sens = &iwl5150_sensitivity;
  301. }
  302. static void iwl5150_temperature(struct iwl_priv *priv)
  303. {
  304. u32 vt = 0;
  305. s32 offset = iwl_temp_calib_to_offset(priv);
  306. vt = le32_to_cpu(priv->statistics.common.temperature);
  307. vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset;
  308. /* now vt hold the temperature in Kelvin */
  309. priv->temperature = KELVIN_TO_CELSIUS(vt);
  310. iwl_tt_handler(priv);
  311. }
  312. static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
  313. struct ieee80211_channel_switch *ch_switch)
  314. {
  315. /*
  316. * MULTI-FIXME
  317. * See iwlagn_mac_channel_switch.
  318. */
  319. struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
  320. struct iwl5000_channel_switch_cmd cmd;
  321. u32 switch_time_in_usec, ucode_switch_time;
  322. u16 ch;
  323. u32 tsf_low;
  324. u8 switch_count;
  325. u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
  326. struct ieee80211_vif *vif = ctx->vif;
  327. struct iwl_host_cmd hcmd = {
  328. .id = REPLY_CHANNEL_SWITCH,
  329. .len = { sizeof(cmd), },
  330. .flags = CMD_SYNC,
  331. .data = { &cmd, },
  332. };
  333. cmd.band = priv->band == IEEE80211_BAND_2GHZ;
  334. ch = ch_switch->channel->hw_value;
  335. IWL_DEBUG_11H(priv, "channel switch from %d to %d\n",
  336. ctx->active.channel, ch);
  337. cmd.channel = cpu_to_le16(ch);
  338. cmd.rxon_flags = ctx->staging.flags;
  339. cmd.rxon_filter_flags = ctx->staging.filter_flags;
  340. switch_count = ch_switch->count;
  341. tsf_low = ch_switch->timestamp & 0x0ffffffff;
  342. /*
  343. * calculate the ucode channel switch time
  344. * adding TSF as one of the factor for when to switch
  345. */
  346. if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) {
  347. if (switch_count > ((priv->ucode_beacon_time - tsf_low) /
  348. beacon_interval)) {
  349. switch_count -= (priv->ucode_beacon_time -
  350. tsf_low) / beacon_interval;
  351. } else
  352. switch_count = 0;
  353. }
  354. if (switch_count <= 1)
  355. cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time);
  356. else {
  357. switch_time_in_usec =
  358. vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
  359. ucode_switch_time = iwl_usecs_to_beacons(priv,
  360. switch_time_in_usec,
  361. beacon_interval);
  362. cmd.switch_time = iwl_add_beacon_time(priv,
  363. priv->ucode_beacon_time,
  364. ucode_switch_time,
  365. beacon_interval);
  366. }
  367. IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
  368. cmd.switch_time);
  369. cmd.expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR;
  370. return iwl_dvm_send_cmd(priv, &hcmd);
  371. }
  372. struct iwl_lib_ops iwl5000_lib = {
  373. .set_hw_params = iwl5000_hw_set_hw_params,
  374. .set_channel_switch = iwl5000_hw_channel_switch,
  375. .nic_config = iwl5000_nic_config,
  376. .temperature = iwlagn_temperature,
  377. };
  378. struct iwl_lib_ops iwl5150_lib = {
  379. .set_hw_params = iwl5150_hw_set_hw_params,
  380. .set_channel_switch = iwl5000_hw_channel_switch,
  381. .nic_config = iwl5000_nic_config,
  382. .temperature = iwl5150_temperature,
  383. };
  384. /*
  385. * 6000 series
  386. * ===========
  387. */
  388. static void iwl6000_set_ct_threshold(struct iwl_priv *priv)
  389. {
  390. /* want Celsius */
  391. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
  392. priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  393. }
  394. /* NIC configuration for 6000 series */
  395. static void iwl6000_nic_config(struct iwl_priv *priv)
  396. {
  397. switch (priv->cfg->device_family) {
  398. case IWL_DEVICE_FAMILY_6005:
  399. case IWL_DEVICE_FAMILY_6030:
  400. case IWL_DEVICE_FAMILY_6000:
  401. break;
  402. case IWL_DEVICE_FAMILY_6000i:
  403. /* 2x2 IPA phy type */
  404. iwl_write32(priv->trans, CSR_GP_DRIVER_REG,
  405. CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
  406. break;
  407. case IWL_DEVICE_FAMILY_6050:
  408. /* Indicate calibration version to uCode. */
  409. if (priv->eeprom_data->calib_version >= 6)
  410. iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
  411. CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
  412. break;
  413. case IWL_DEVICE_FAMILY_6150:
  414. /* Indicate calibration version to uCode. */
  415. if (priv->eeprom_data->calib_version >= 6)
  416. iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
  417. CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
  418. iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
  419. CSR_GP_DRIVER_REG_BIT_6050_1x2);
  420. break;
  421. default:
  422. WARN_ON(1);
  423. }
  424. }
  425. static const struct iwl_sensitivity_ranges iwl6000_sensitivity = {
  426. .min_nrg_cck = 110,
  427. .auto_corr_min_ofdm = 80,
  428. .auto_corr_min_ofdm_mrc = 128,
  429. .auto_corr_min_ofdm_x1 = 105,
  430. .auto_corr_min_ofdm_mrc_x1 = 192,
  431. .auto_corr_max_ofdm = 145,
  432. .auto_corr_max_ofdm_mrc = 232,
  433. .auto_corr_max_ofdm_x1 = 110,
  434. .auto_corr_max_ofdm_mrc_x1 = 232,
  435. .auto_corr_min_cck = 125,
  436. .auto_corr_max_cck = 175,
  437. .auto_corr_min_cck_mrc = 160,
  438. .auto_corr_max_cck_mrc = 310,
  439. .nrg_th_cck = 110,
  440. .nrg_th_ofdm = 110,
  441. .barker_corr_th_min = 190,
  442. .barker_corr_th_min_mrc = 336,
  443. .nrg_th_cca = 62,
  444. };
  445. static void iwl6000_hw_set_hw_params(struct iwl_priv *priv)
  446. {
  447. iwl6000_set_ct_threshold(priv);
  448. /* Set initial sensitivity parameters */
  449. priv->hw_params.sens = &iwl6000_sensitivity;
  450. }
  451. static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
  452. struct ieee80211_channel_switch *ch_switch)
  453. {
  454. /*
  455. * MULTI-FIXME
  456. * See iwlagn_mac_channel_switch.
  457. */
  458. struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
  459. struct iwl6000_channel_switch_cmd cmd;
  460. u32 switch_time_in_usec, ucode_switch_time;
  461. u16 ch;
  462. u32 tsf_low;
  463. u8 switch_count;
  464. u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
  465. struct ieee80211_vif *vif = ctx->vif;
  466. struct iwl_host_cmd hcmd = {
  467. .id = REPLY_CHANNEL_SWITCH,
  468. .len = { sizeof(cmd), },
  469. .flags = CMD_SYNC,
  470. .data = { &cmd, },
  471. };
  472. cmd.band = priv->band == IEEE80211_BAND_2GHZ;
  473. ch = ch_switch->channel->hw_value;
  474. IWL_DEBUG_11H(priv, "channel switch from %u to %u\n",
  475. ctx->active.channel, ch);
  476. cmd.channel = cpu_to_le16(ch);
  477. cmd.rxon_flags = ctx->staging.flags;
  478. cmd.rxon_filter_flags = ctx->staging.filter_flags;
  479. switch_count = ch_switch->count;
  480. tsf_low = ch_switch->timestamp & 0x0ffffffff;
  481. /*
  482. * calculate the ucode channel switch time
  483. * adding TSF as one of the factor for when to switch
  484. */
  485. if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) {
  486. if (switch_count > ((priv->ucode_beacon_time - tsf_low) /
  487. beacon_interval)) {
  488. switch_count -= (priv->ucode_beacon_time -
  489. tsf_low) / beacon_interval;
  490. } else
  491. switch_count = 0;
  492. }
  493. if (switch_count <= 1)
  494. cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time);
  495. else {
  496. switch_time_in_usec =
  497. vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
  498. ucode_switch_time = iwl_usecs_to_beacons(priv,
  499. switch_time_in_usec,
  500. beacon_interval);
  501. cmd.switch_time = iwl_add_beacon_time(priv,
  502. priv->ucode_beacon_time,
  503. ucode_switch_time,
  504. beacon_interval);
  505. }
  506. IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
  507. cmd.switch_time);
  508. cmd.expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR;
  509. return iwl_dvm_send_cmd(priv, &hcmd);
  510. }
  511. struct iwl_lib_ops iwl6000_lib = {
  512. .set_hw_params = iwl6000_hw_set_hw_params,
  513. .set_channel_switch = iwl6000_hw_channel_switch,
  514. .nic_config = iwl6000_nic_config,
  515. .temperature = iwlagn_temperature,
  516. };
  517. struct iwl_lib_ops iwl6030_lib = {
  518. .set_hw_params = iwl6000_hw_set_hw_params,
  519. .set_channel_switch = iwl6000_hw_channel_switch,
  520. .nic_config = iwl6000_nic_config,
  521. .temperature = iwlagn_temperature,
  522. };