iwl-agn-devices.c 21 KB

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