devices.c 19 KB

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