iwl-agn-devices.c 21 KB

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