devices.c 16 KB

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