iwl-5000.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007-2008 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 Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  23. *
  24. *****************************************************************************/
  25. #include <linux/kernel.h>
  26. #include <linux/module.h>
  27. #include <linux/init.h>
  28. #include <linux/pci.h>
  29. #include <linux/dma-mapping.h>
  30. #include <linux/delay.h>
  31. #include <linux/skbuff.h>
  32. #include <linux/netdevice.h>
  33. #include <linux/wireless.h>
  34. #include <net/mac80211.h>
  35. #include <linux/etherdevice.h>
  36. #include <asm/unaligned.h>
  37. #include "iwl-eeprom.h"
  38. #include "iwl-dev.h"
  39. #include "iwl-core.h"
  40. #include "iwl-io.h"
  41. #include "iwl-sta.h"
  42. #include "iwl-helpers.h"
  43. #include "iwl-5000-hw.h"
  44. #define IWL5000_UCODE_API "-1"
  45. #define IWL5000_MODULE_FIRMWARE "iwlwifi-5000" IWL5000_UCODE_API ".ucode"
  46. static const u16 iwl5000_default_queue_to_tx_fifo[] = {
  47. IWL_TX_FIFO_AC3,
  48. IWL_TX_FIFO_AC2,
  49. IWL_TX_FIFO_AC1,
  50. IWL_TX_FIFO_AC0,
  51. IWL50_CMD_FIFO_NUM,
  52. IWL_TX_FIFO_HCCA_1,
  53. IWL_TX_FIFO_HCCA_2
  54. };
  55. /* FIXME: same implementation as 4965 */
  56. static int iwl5000_apm_stop_master(struct iwl_priv *priv)
  57. {
  58. int ret = 0;
  59. unsigned long flags;
  60. spin_lock_irqsave(&priv->lock, flags);
  61. /* set stop master bit */
  62. iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
  63. ret = iwl_poll_bit(priv, CSR_RESET,
  64. CSR_RESET_REG_FLAG_MASTER_DISABLED,
  65. CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
  66. if (ret < 0)
  67. goto out;
  68. out:
  69. spin_unlock_irqrestore(&priv->lock, flags);
  70. IWL_DEBUG_INFO("stop master\n");
  71. return ret;
  72. }
  73. static int iwl5000_apm_init(struct iwl_priv *priv)
  74. {
  75. int ret = 0;
  76. iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS,
  77. CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
  78. /* disable L0s without affecting L1 :don't wait for ICH L0s bug W/A) */
  79. iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS,
  80. CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX);
  81. /* Set FH wait threshold to maximum (HW error during stress W/A) */
  82. iwl_set_bit(priv, CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL);
  83. /* enable HAP INTA to move device L1a -> L0s */
  84. iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
  85. CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A);
  86. iwl_set_bit(priv, CSR_ANA_PLL_CFG, CSR50_ANA_PLL_CFG_VAL);
  87. /* set "initialization complete" bit to move adapter
  88. * D0U* --> D0A* state */
  89. iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
  90. /* wait for clock stabilization */
  91. ret = iwl_poll_bit(priv, CSR_GP_CNTRL,
  92. CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
  93. CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
  94. if (ret < 0) {
  95. IWL_DEBUG_INFO("Failed to init the card\n");
  96. return ret;
  97. }
  98. ret = iwl_grab_nic_access(priv);
  99. if (ret)
  100. return ret;
  101. /* enable DMA */
  102. iwl_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT);
  103. udelay(20);
  104. /* disable L1-Active */
  105. iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG,
  106. APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
  107. iwl_release_nic_access(priv);
  108. return ret;
  109. }
  110. /* FIXME: this is identical to 4965 */
  111. static void iwl5000_apm_stop(struct iwl_priv *priv)
  112. {
  113. unsigned long flags;
  114. iwl5000_apm_stop_master(priv);
  115. spin_lock_irqsave(&priv->lock, flags);
  116. iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
  117. udelay(10);
  118. /* clear "init complete" move adapter D0A* --> D0U state */
  119. iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
  120. spin_unlock_irqrestore(&priv->lock, flags);
  121. }
  122. static int iwl5000_apm_reset(struct iwl_priv *priv)
  123. {
  124. int ret = 0;
  125. unsigned long flags;
  126. iwl5000_apm_stop_master(priv);
  127. spin_lock_irqsave(&priv->lock, flags);
  128. iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
  129. udelay(10);
  130. /* FIXME: put here L1A -L0S w/a */
  131. iwl_set_bit(priv, CSR_ANA_PLL_CFG, CSR50_ANA_PLL_CFG_VAL);
  132. /* set "initialization complete" bit to move adapter
  133. * D0U* --> D0A* state */
  134. iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
  135. /* wait for clock stabilization */
  136. ret = iwl_poll_bit(priv, CSR_GP_CNTRL,
  137. CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
  138. CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
  139. if (ret < 0) {
  140. IWL_DEBUG_INFO("Failed to init the card\n");
  141. goto out;
  142. }
  143. ret = iwl_grab_nic_access(priv);
  144. if (ret)
  145. goto out;
  146. /* enable DMA */
  147. iwl_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT);
  148. udelay(20);
  149. /* disable L1-Active */
  150. iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG,
  151. APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
  152. iwl_release_nic_access(priv);
  153. out:
  154. spin_unlock_irqrestore(&priv->lock, flags);
  155. return ret;
  156. }
  157. static void iwl5000_nic_config(struct iwl_priv *priv)
  158. {
  159. unsigned long flags;
  160. u16 radio_cfg;
  161. u16 link;
  162. spin_lock_irqsave(&priv->lock, flags);
  163. pci_read_config_word(priv->pci_dev, PCI_CFG_LINK_CTRL, &link);
  164. /* L1 is enabled by BIOS */
  165. if ((link & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN)
  166. /* disable L0S disabled L1A enabled */
  167. iwl_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
  168. else
  169. /* L0S enabled L1A disabled */
  170. iwl_clear_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
  171. radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG);
  172. /* write radio config values to register */
  173. if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) < EEPROM_5000_RF_CFG_TYPE_MAX)
  174. iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
  175. EEPROM_RF_CFG_TYPE_MSK(radio_cfg) |
  176. EEPROM_RF_CFG_STEP_MSK(radio_cfg) |
  177. EEPROM_RF_CFG_DASH_MSK(radio_cfg));
  178. /* set CSR_HW_CONFIG_REG for uCode use */
  179. iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
  180. CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
  181. CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
  182. /* W/A : NIC is stuck in a reset state after Early PCIe power off
  183. * (PCIe power is lost before PERST# is asserted),
  184. * causing ME FW to lose ownership and not being able to obtain it back.
  185. */
  186. iwl_grab_nic_access(priv);
  187. iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG,
  188. APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS,
  189. ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS);
  190. iwl_release_nic_access(priv);
  191. spin_unlock_irqrestore(&priv->lock, flags);
  192. }
  193. /*
  194. * EEPROM
  195. */
  196. static u32 eeprom_indirect_address(const struct iwl_priv *priv, u32 address)
  197. {
  198. u16 offset = 0;
  199. if ((address & INDIRECT_ADDRESS) == 0)
  200. return address;
  201. switch (address & INDIRECT_TYPE_MSK) {
  202. case INDIRECT_HOST:
  203. offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_HOST);
  204. break;
  205. case INDIRECT_GENERAL:
  206. offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_GENERAL);
  207. break;
  208. case INDIRECT_REGULATORY:
  209. offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_REGULATORY);
  210. break;
  211. case INDIRECT_CALIBRATION:
  212. offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_CALIBRATION);
  213. break;
  214. case INDIRECT_PROCESS_ADJST:
  215. offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_PROCESS_ADJST);
  216. break;
  217. case INDIRECT_OTHERS:
  218. offset = iwl_eeprom_query16(priv, EEPROM_5000_LINK_OTHERS);
  219. break;
  220. default:
  221. IWL_ERROR("illegal indirect type: 0x%X\n",
  222. address & INDIRECT_TYPE_MSK);
  223. break;
  224. }
  225. /* translate the offset from words to byte */
  226. return (address & ADDRESS_MSK) + (offset << 1);
  227. }
  228. static u16 iwl5000_eeprom_calib_version(struct iwl_priv *priv)
  229. {
  230. struct iwl_eeprom_calib_hdr {
  231. u8 version;
  232. u8 pa_type;
  233. u16 voltage;
  234. } *hdr;
  235. hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv,
  236. EEPROM_5000_CALIB_ALL);
  237. return hdr->version;
  238. }
  239. static void iwl5000_gain_computation(struct iwl_priv *priv,
  240. u32 average_noise[NUM_RX_CHAINS],
  241. u16 min_average_noise_antenna_i,
  242. u32 min_average_noise)
  243. {
  244. int i;
  245. s32 delta_g;
  246. struct iwl_chain_noise_data *data = &priv->chain_noise_data;
  247. /* Find Gain Code for the antennas B and C */
  248. for (i = 1; i < NUM_RX_CHAINS; i++) {
  249. if ((data->disconn_array[i])) {
  250. data->delta_gain_code[i] = 0;
  251. continue;
  252. }
  253. delta_g = (1000 * ((s32)average_noise[0] -
  254. (s32)average_noise[i])) / 1500;
  255. /* bound gain by 2 bits value max, 3rd bit is sign */
  256. data->delta_gain_code[i] =
  257. min(abs(delta_g), CHAIN_NOISE_MAX_DELTA_GAIN_CODE);
  258. if (delta_g < 0)
  259. /* set negative sign */
  260. data->delta_gain_code[i] |= (1 << 2);
  261. }
  262. IWL_DEBUG_CALIB("Delta gains: ANT_B = %d ANT_C = %d\n",
  263. data->delta_gain_code[1], data->delta_gain_code[2]);
  264. if (!data->radio_write) {
  265. struct iwl_calib_chain_noise_gain_cmd cmd;
  266. memset(&cmd, 0, sizeof(cmd));
  267. cmd.op_code = IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD;
  268. cmd.delta_gain_1 = data->delta_gain_code[1];
  269. cmd.delta_gain_2 = data->delta_gain_code[2];
  270. iwl_send_cmd_pdu_async(priv, REPLY_PHY_CALIBRATION_CMD,
  271. sizeof(cmd), &cmd, NULL);
  272. data->radio_write = 1;
  273. data->state = IWL_CHAIN_NOISE_CALIBRATED;
  274. }
  275. data->chain_noise_a = 0;
  276. data->chain_noise_b = 0;
  277. data->chain_noise_c = 0;
  278. data->chain_signal_a = 0;
  279. data->chain_signal_b = 0;
  280. data->chain_signal_c = 0;
  281. data->beacon_count = 0;
  282. }
  283. static void iwl5000_chain_noise_reset(struct iwl_priv *priv)
  284. {
  285. struct iwl_chain_noise_data *data = &priv->chain_noise_data;
  286. if ((data->state == IWL_CHAIN_NOISE_ALIVE) && iwl_is_associated(priv)) {
  287. struct iwl_calib_chain_noise_reset_cmd cmd;
  288. memset(&cmd, 0, sizeof(cmd));
  289. cmd.op_code = IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD;
  290. if (iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
  291. sizeof(cmd), &cmd))
  292. IWL_ERROR("Could not send REPLY_PHY_CALIBRATION_CMD\n");
  293. data->state = IWL_CHAIN_NOISE_ACCUMULATE;
  294. IWL_DEBUG_CALIB("Run chain_noise_calibrate\n");
  295. }
  296. }
  297. static void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
  298. __le32 *tx_flags)
  299. {
  300. if ((info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
  301. (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT))
  302. *tx_flags |= TX_CMD_FLG_RTS_CTS_MSK;
  303. else
  304. *tx_flags &= ~TX_CMD_FLG_RTS_CTS_MSK;
  305. }
  306. static struct iwl_sensitivity_ranges iwl5000_sensitivity = {
  307. .min_nrg_cck = 95,
  308. .max_nrg_cck = 0,
  309. .auto_corr_min_ofdm = 90,
  310. .auto_corr_min_ofdm_mrc = 170,
  311. .auto_corr_min_ofdm_x1 = 120,
  312. .auto_corr_min_ofdm_mrc_x1 = 240,
  313. .auto_corr_max_ofdm = 120,
  314. .auto_corr_max_ofdm_mrc = 210,
  315. .auto_corr_max_ofdm_x1 = 155,
  316. .auto_corr_max_ofdm_mrc_x1 = 290,
  317. .auto_corr_min_cck = 125,
  318. .auto_corr_max_cck = 200,
  319. .auto_corr_min_cck_mrc = 170,
  320. .auto_corr_max_cck_mrc = 400,
  321. .nrg_th_cck = 95,
  322. .nrg_th_ofdm = 95,
  323. };
  324. static const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv,
  325. size_t offset)
  326. {
  327. u32 address = eeprom_indirect_address(priv, offset);
  328. BUG_ON(address >= priv->cfg->eeprom_size);
  329. return &priv->eeprom[address];
  330. }
  331. /*
  332. * Calibration
  333. */
  334. static int iwl5000_set_Xtal_calib(struct iwl_priv *priv)
  335. {
  336. u8 data[sizeof(struct iwl_calib_hdr) +
  337. sizeof(struct iwl_cal_xtal_freq)];
  338. struct iwl_calib_cmd *cmd = (struct iwl_calib_cmd *)data;
  339. struct iwl_cal_xtal_freq *xtal = (struct iwl_cal_xtal_freq *)cmd->data;
  340. u16 *xtal_calib = (u16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL);
  341. cmd->hdr.op_code = IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD;
  342. xtal->cap_pin1 = (u8)xtal_calib[0];
  343. xtal->cap_pin2 = (u8)xtal_calib[1];
  344. return iwl_calib_set(&priv->calib_results[IWL_CALIB_XTAL],
  345. data, sizeof(data));
  346. }
  347. static int iwl5000_send_calib_cfg(struct iwl_priv *priv)
  348. {
  349. struct iwl_calib_cfg_cmd calib_cfg_cmd;
  350. struct iwl_host_cmd cmd = {
  351. .id = CALIBRATION_CFG_CMD,
  352. .len = sizeof(struct iwl_calib_cfg_cmd),
  353. .data = &calib_cfg_cmd,
  354. };
  355. memset(&calib_cfg_cmd, 0, sizeof(calib_cfg_cmd));
  356. calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL;
  357. calib_cfg_cmd.ucd_calib_cfg.once.start = IWL_CALIB_INIT_CFG_ALL;
  358. calib_cfg_cmd.ucd_calib_cfg.once.send_res = IWL_CALIB_INIT_CFG_ALL;
  359. calib_cfg_cmd.ucd_calib_cfg.flags = IWL_CALIB_INIT_CFG_ALL;
  360. return iwl_send_cmd(priv, &cmd);
  361. }
  362. static void iwl5000_rx_calib_result(struct iwl_priv *priv,
  363. struct iwl_rx_mem_buffer *rxb)
  364. {
  365. struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
  366. struct iwl_calib_hdr *hdr = (struct iwl_calib_hdr *)pkt->u.raw;
  367. int len = le32_to_cpu(pkt->len) & FH_RSCSR_FRAME_SIZE_MSK;
  368. int index;
  369. /* reduce the size of the length field itself */
  370. len -= 4;
  371. /* Define the order in which the results will be sent to the runtime
  372. * uCode. iwl_send_calib_results sends them in a row according to their
  373. * index. We sort them here */
  374. switch (hdr->op_code) {
  375. case IWL_PHY_CALIBRATE_LO_CMD:
  376. index = IWL_CALIB_LO;
  377. break;
  378. case IWL_PHY_CALIBRATE_TX_IQ_CMD:
  379. index = IWL_CALIB_TX_IQ;
  380. break;
  381. case IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD:
  382. index = IWL_CALIB_TX_IQ_PERD;
  383. break;
  384. case IWL_PHY_CALIBRATE_BASE_BAND_CMD:
  385. index = IWL_CALIB_BASE_BAND;
  386. break;
  387. default:
  388. IWL_ERROR("Unknown calibration notification %d\n",
  389. hdr->op_code);
  390. return;
  391. }
  392. iwl_calib_set(&priv->calib_results[index], pkt->u.raw, len);
  393. }
  394. static void iwl5000_rx_calib_complete(struct iwl_priv *priv,
  395. struct iwl_rx_mem_buffer *rxb)
  396. {
  397. IWL_DEBUG_INFO("Init. calibration is completed, restarting fw.\n");
  398. queue_work(priv->workqueue, &priv->restart);
  399. }
  400. /*
  401. * ucode
  402. */
  403. static int iwl5000_load_section(struct iwl_priv *priv,
  404. struct fw_desc *image,
  405. u32 dst_addr)
  406. {
  407. int ret = 0;
  408. unsigned long flags;
  409. dma_addr_t phy_addr = image->p_addr;
  410. u32 byte_cnt = image->len;
  411. spin_lock_irqsave(&priv->lock, flags);
  412. ret = iwl_grab_nic_access(priv);
  413. if (ret) {
  414. spin_unlock_irqrestore(&priv->lock, flags);
  415. return ret;
  416. }
  417. iwl_write_direct32(priv,
  418. FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
  419. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE);
  420. iwl_write_direct32(priv,
  421. FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr);
  422. iwl_write_direct32(priv,
  423. FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL),
  424. phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK);
  425. iwl_write_direct32(priv,
  426. FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL),
  427. (iwl_get_dma_hi_addr(phy_addr)
  428. << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt);
  429. iwl_write_direct32(priv,
  430. FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL),
  431. 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM |
  432. 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX |
  433. FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID);
  434. iwl_write_direct32(priv,
  435. FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
  436. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
  437. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE |
  438. FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD);
  439. iwl_release_nic_access(priv);
  440. spin_unlock_irqrestore(&priv->lock, flags);
  441. return 0;
  442. }
  443. static int iwl5000_load_given_ucode(struct iwl_priv *priv,
  444. struct fw_desc *inst_image,
  445. struct fw_desc *data_image)
  446. {
  447. int ret = 0;
  448. ret = iwl5000_load_section(priv, inst_image, RTC_INST_LOWER_BOUND);
  449. if (ret)
  450. return ret;
  451. IWL_DEBUG_INFO("INST uCode section being loaded...\n");
  452. ret = wait_event_interruptible_timeout(priv->wait_command_queue,
  453. priv->ucode_write_complete, 5 * HZ);
  454. if (ret == -ERESTARTSYS) {
  455. IWL_ERROR("Could not load the INST uCode section due "
  456. "to interrupt\n");
  457. return ret;
  458. }
  459. if (!ret) {
  460. IWL_ERROR("Could not load the INST uCode section\n");
  461. return -ETIMEDOUT;
  462. }
  463. priv->ucode_write_complete = 0;
  464. ret = iwl5000_load_section(
  465. priv, data_image, RTC_DATA_LOWER_BOUND);
  466. if (ret)
  467. return ret;
  468. IWL_DEBUG_INFO("DATA uCode section being loaded...\n");
  469. ret = wait_event_interruptible_timeout(priv->wait_command_queue,
  470. priv->ucode_write_complete, 5 * HZ);
  471. if (ret == -ERESTARTSYS) {
  472. IWL_ERROR("Could not load the INST uCode section due "
  473. "to interrupt\n");
  474. return ret;
  475. } else if (!ret) {
  476. IWL_ERROR("Could not load the DATA uCode section\n");
  477. return -ETIMEDOUT;
  478. } else
  479. ret = 0;
  480. priv->ucode_write_complete = 0;
  481. return ret;
  482. }
  483. static int iwl5000_load_ucode(struct iwl_priv *priv)
  484. {
  485. int ret = 0;
  486. /* check whether init ucode should be loaded, or rather runtime ucode */
  487. if (priv->ucode_init.len && (priv->ucode_type == UCODE_NONE)) {
  488. IWL_DEBUG_INFO("Init ucode found. Loading init ucode...\n");
  489. ret = iwl5000_load_given_ucode(priv,
  490. &priv->ucode_init, &priv->ucode_init_data);
  491. if (!ret) {
  492. IWL_DEBUG_INFO("Init ucode load complete.\n");
  493. priv->ucode_type = UCODE_INIT;
  494. }
  495. } else {
  496. IWL_DEBUG_INFO("Init ucode not found, or already loaded. "
  497. "Loading runtime ucode...\n");
  498. ret = iwl5000_load_given_ucode(priv,
  499. &priv->ucode_code, &priv->ucode_data);
  500. if (!ret) {
  501. IWL_DEBUG_INFO("Runtime ucode load complete.\n");
  502. priv->ucode_type = UCODE_RT;
  503. }
  504. }
  505. return ret;
  506. }
  507. static void iwl5000_init_alive_start(struct iwl_priv *priv)
  508. {
  509. int ret = 0;
  510. /* Check alive response for "valid" sign from uCode */
  511. if (priv->card_alive_init.is_valid != UCODE_VALID_OK) {
  512. /* We had an error bringing up the hardware, so take it
  513. * all the way back down so we can try again */
  514. IWL_DEBUG_INFO("Initialize Alive failed.\n");
  515. goto restart;
  516. }
  517. /* initialize uCode was loaded... verify inst image.
  518. * This is a paranoid check, because we would not have gotten the
  519. * "initialize" alive if code weren't properly loaded. */
  520. if (iwl_verify_ucode(priv)) {
  521. /* Runtime instruction load was bad;
  522. * take it all the way back down so we can try again */
  523. IWL_DEBUG_INFO("Bad \"initialize\" uCode load.\n");
  524. goto restart;
  525. }
  526. iwl_clear_stations_table(priv);
  527. ret = priv->cfg->ops->lib->alive_notify(priv);
  528. if (ret) {
  529. IWL_WARNING("Could not complete ALIVE transition: %d\n", ret);
  530. goto restart;
  531. }
  532. iwl5000_send_calib_cfg(priv);
  533. return;
  534. restart:
  535. /* real restart (first load init_ucode) */
  536. queue_work(priv->workqueue, &priv->restart);
  537. }
  538. static void iwl5000_set_wr_ptrs(struct iwl_priv *priv,
  539. int txq_id, u32 index)
  540. {
  541. iwl_write_direct32(priv, HBUS_TARG_WRPTR,
  542. (index & 0xff) | (txq_id << 8));
  543. iwl_write_prph(priv, IWL50_SCD_QUEUE_RDPTR(txq_id), index);
  544. }
  545. static void iwl5000_tx_queue_set_status(struct iwl_priv *priv,
  546. struct iwl_tx_queue *txq,
  547. int tx_fifo_id, int scd_retry)
  548. {
  549. int txq_id = txq->q.id;
  550. int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0;
  551. iwl_write_prph(priv, IWL50_SCD_QUEUE_STATUS_BITS(txq_id),
  552. (active << IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE) |
  553. (tx_fifo_id << IWL50_SCD_QUEUE_STTS_REG_POS_TXF) |
  554. (1 << IWL50_SCD_QUEUE_STTS_REG_POS_WSL) |
  555. IWL50_SCD_QUEUE_STTS_REG_MSK);
  556. txq->sched_retry = scd_retry;
  557. IWL_DEBUG_INFO("%s %s Queue %d on AC %d\n",
  558. active ? "Activate" : "Deactivate",
  559. scd_retry ? "BA" : "AC", txq_id, tx_fifo_id);
  560. }
  561. static int iwl5000_send_wimax_coex(struct iwl_priv *priv)
  562. {
  563. struct iwl_wimax_coex_cmd coex_cmd;
  564. memset(&coex_cmd, 0, sizeof(coex_cmd));
  565. return iwl_send_cmd_pdu(priv, COEX_PRIORITY_TABLE_CMD,
  566. sizeof(coex_cmd), &coex_cmd);
  567. }
  568. static int iwl5000_alive_notify(struct iwl_priv *priv)
  569. {
  570. u32 a;
  571. unsigned long flags;
  572. int ret;
  573. int i, chan;
  574. spin_lock_irqsave(&priv->lock, flags);
  575. ret = iwl_grab_nic_access(priv);
  576. if (ret) {
  577. spin_unlock_irqrestore(&priv->lock, flags);
  578. return ret;
  579. }
  580. priv->scd_base_addr = iwl_read_prph(priv, IWL50_SCD_SRAM_BASE_ADDR);
  581. a = priv->scd_base_addr + IWL50_SCD_CONTEXT_DATA_OFFSET;
  582. for (; a < priv->scd_base_addr + IWL50_SCD_TX_STTS_BITMAP_OFFSET;
  583. a += 4)
  584. iwl_write_targ_mem(priv, a, 0);
  585. for (; a < priv->scd_base_addr + IWL50_SCD_TRANSLATE_TBL_OFFSET;
  586. a += 4)
  587. iwl_write_targ_mem(priv, a, 0);
  588. for (; a < sizeof(u16) * priv->hw_params.max_txq_num; a += 4)
  589. iwl_write_targ_mem(priv, a, 0);
  590. iwl_write_prph(priv, IWL50_SCD_DRAM_BASE_ADDR,
  591. priv->scd_bc_tbls.dma >> 10);
  592. /* Enable DMA channel */
  593. for (chan = 0; chan < FH50_TCSR_CHNL_NUM ; chan++)
  594. iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(chan),
  595. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
  596. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE);
  597. iwl_write_prph(priv, IWL50_SCD_QUEUECHAIN_SEL,
  598. IWL50_SCD_QUEUECHAIN_SEL_ALL(priv->hw_params.max_txq_num));
  599. iwl_write_prph(priv, IWL50_SCD_AGGR_SEL, 0);
  600. /* initiate the queues */
  601. for (i = 0; i < priv->hw_params.max_txq_num; i++) {
  602. iwl_write_prph(priv, IWL50_SCD_QUEUE_RDPTR(i), 0);
  603. iwl_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8));
  604. iwl_write_targ_mem(priv, priv->scd_base_addr +
  605. IWL50_SCD_CONTEXT_QUEUE_OFFSET(i), 0);
  606. iwl_write_targ_mem(priv, priv->scd_base_addr +
  607. IWL50_SCD_CONTEXT_QUEUE_OFFSET(i) +
  608. sizeof(u32),
  609. ((SCD_WIN_SIZE <<
  610. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
  611. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
  612. ((SCD_FRAME_LIMIT <<
  613. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
  614. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
  615. }
  616. iwl_write_prph(priv, IWL50_SCD_INTERRUPT_MASK,
  617. IWL_MASK(0, priv->hw_params.max_txq_num));
  618. /* Activate all Tx DMA/FIFO channels */
  619. priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 7));
  620. iwl5000_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0);
  621. /* map qos queues to fifos one-to-one */
  622. for (i = 0; i < ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo); i++) {
  623. int ac = iwl5000_default_queue_to_tx_fifo[i];
  624. iwl_txq_ctx_activate(priv, i);
  625. iwl5000_tx_queue_set_status(priv, &priv->txq[i], ac, 0);
  626. }
  627. /* TODO - need to initialize those FIFOs inside the loop above,
  628. * not only mark them as active */
  629. iwl_txq_ctx_activate(priv, 4);
  630. iwl_txq_ctx_activate(priv, 7);
  631. iwl_txq_ctx_activate(priv, 8);
  632. iwl_txq_ctx_activate(priv, 9);
  633. iwl_release_nic_access(priv);
  634. spin_unlock_irqrestore(&priv->lock, flags);
  635. iwl5000_send_wimax_coex(priv);
  636. iwl5000_set_Xtal_calib(priv);
  637. iwl_send_calib_results(priv);
  638. return 0;
  639. }
  640. static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
  641. {
  642. if ((priv->cfg->mod_params->num_of_queues > IWL50_NUM_QUEUES) ||
  643. (priv->cfg->mod_params->num_of_queues < IWL_MIN_NUM_QUEUES)) {
  644. IWL_ERROR("invalid queues_num, should be between %d and %d\n",
  645. IWL_MIN_NUM_QUEUES, IWL50_NUM_QUEUES);
  646. return -EINVAL;
  647. }
  648. priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues;
  649. priv->hw_params.scd_bc_tbls_size =
  650. IWL50_NUM_QUEUES * sizeof(struct iwl5000_scd_bc_tbl);
  651. priv->hw_params.max_stations = IWL5000_STATION_COUNT;
  652. priv->hw_params.bcast_sta_id = IWL5000_BROADCAST_ID;
  653. priv->hw_params.max_data_size = IWL50_RTC_DATA_SIZE;
  654. priv->hw_params.max_inst_size = IWL50_RTC_INST_SIZE;
  655. priv->hw_params.max_bsm_size = 0;
  656. priv->hw_params.fat_channel = BIT(IEEE80211_BAND_2GHZ) |
  657. BIT(IEEE80211_BAND_5GHZ);
  658. priv->hw_params.sens = &iwl5000_sensitivity;
  659. switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
  660. case CSR_HW_REV_TYPE_5100:
  661. priv->hw_params.tx_chains_num = 1;
  662. priv->hw_params.rx_chains_num = 2;
  663. priv->hw_params.valid_tx_ant = ANT_B;
  664. priv->hw_params.valid_rx_ant = ANT_AB;
  665. break;
  666. case CSR_HW_REV_TYPE_5150:
  667. priv->hw_params.tx_chains_num = 1;
  668. priv->hw_params.rx_chains_num = 2;
  669. priv->hw_params.valid_tx_ant = ANT_A;
  670. priv->hw_params.valid_rx_ant = ANT_AB;
  671. break;
  672. case CSR_HW_REV_TYPE_5300:
  673. case CSR_HW_REV_TYPE_5350:
  674. priv->hw_params.tx_chains_num = 3;
  675. priv->hw_params.rx_chains_num = 3;
  676. priv->hw_params.valid_tx_ant = ANT_ABC;
  677. priv->hw_params.valid_rx_ant = ANT_ABC;
  678. break;
  679. }
  680. switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
  681. case CSR_HW_REV_TYPE_5100:
  682. case CSR_HW_REV_TYPE_5300:
  683. case CSR_HW_REV_TYPE_5350:
  684. /* 5X00 and 5350 wants in Celsius */
  685. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
  686. break;
  687. case CSR_HW_REV_TYPE_5150:
  688. /* 5150 wants in Kelvin */
  689. priv->hw_params.ct_kill_threshold =
  690. CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD);
  691. break;
  692. }
  693. /* Set initial calibration set */
  694. switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
  695. case CSR_HW_REV_TYPE_5100:
  696. case CSR_HW_REV_TYPE_5300:
  697. case CSR_HW_REV_TYPE_5350:
  698. priv->hw_params.calib_init_cfg =
  699. BIT(IWL_CALIB_XTAL) |
  700. BIT(IWL_CALIB_LO) |
  701. BIT(IWL_CALIB_TX_IQ) |
  702. BIT(IWL_CALIB_TX_IQ_PERD) |
  703. BIT(IWL_CALIB_BASE_BAND);
  704. break;
  705. case CSR_HW_REV_TYPE_5150:
  706. priv->hw_params.calib_init_cfg = 0;
  707. break;
  708. }
  709. return 0;
  710. }
  711. /**
  712. * iwl5000_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array
  713. */
  714. static void iwl5000_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
  715. struct iwl_tx_queue *txq,
  716. u16 byte_cnt)
  717. {
  718. struct iwl5000_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr;
  719. int write_ptr = txq->q.write_ptr;
  720. int txq_id = txq->q.id;
  721. u8 sec_ctl = 0;
  722. u8 sta_id = 0;
  723. u16 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
  724. __le16 bc_ent;
  725. WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX);
  726. if (txq_id != IWL_CMD_QUEUE_NUM) {
  727. sta_id = txq->cmd[txq->q.write_ptr]->cmd.tx.sta_id;
  728. sec_ctl = txq->cmd[txq->q.write_ptr]->cmd.tx.sec_ctl;
  729. switch (sec_ctl & TX_CMD_SEC_MSK) {
  730. case TX_CMD_SEC_CCM:
  731. len += CCMP_MIC_LEN;
  732. break;
  733. case TX_CMD_SEC_TKIP:
  734. len += TKIP_ICV_LEN;
  735. break;
  736. case TX_CMD_SEC_WEP:
  737. len += WEP_IV_LEN + WEP_ICV_LEN;
  738. break;
  739. }
  740. }
  741. bc_ent = cpu_to_le16((len & 0xFFF) | (sta_id << 12));
  742. scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent;
  743. if (txq->q.write_ptr < TFD_QUEUE_SIZE_BC_DUP)
  744. scd_bc_tbl[txq_id].
  745. tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent;
  746. }
  747. static void iwl5000_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
  748. struct iwl_tx_queue *txq)
  749. {
  750. struct iwl5000_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr;
  751. int txq_id = txq->q.id;
  752. int read_ptr = txq->q.read_ptr;
  753. u8 sta_id = 0;
  754. __le16 bc_ent;
  755. WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX);
  756. if (txq_id != IWL_CMD_QUEUE_NUM)
  757. sta_id = txq->cmd[read_ptr]->cmd.tx.sta_id;
  758. bc_ent = cpu_to_le16(1 | (sta_id << 12));
  759. scd_bc_tbl[txq_id].tfd_offset[read_ptr] = bc_ent;
  760. if (txq->q.write_ptr < TFD_QUEUE_SIZE_BC_DUP)
  761. scd_bc_tbl[txq_id].
  762. tfd_offset[TFD_QUEUE_SIZE_MAX + read_ptr] = bc_ent;
  763. }
  764. static int iwl5000_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid,
  765. u16 txq_id)
  766. {
  767. u32 tbl_dw_addr;
  768. u32 tbl_dw;
  769. u16 scd_q2ratid;
  770. scd_q2ratid = ra_tid & IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK;
  771. tbl_dw_addr = priv->scd_base_addr +
  772. IWL50_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id);
  773. tbl_dw = iwl_read_targ_mem(priv, tbl_dw_addr);
  774. if (txq_id & 0x1)
  775. tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF);
  776. else
  777. tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000);
  778. iwl_write_targ_mem(priv, tbl_dw_addr, tbl_dw);
  779. return 0;
  780. }
  781. static void iwl5000_tx_queue_stop_scheduler(struct iwl_priv *priv, u16 txq_id)
  782. {
  783. /* Simply stop the queue, but don't change any configuration;
  784. * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */
  785. iwl_write_prph(priv,
  786. IWL50_SCD_QUEUE_STATUS_BITS(txq_id),
  787. (0 << IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE)|
  788. (1 << IWL50_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN));
  789. }
  790. static int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id,
  791. int tx_fifo, int sta_id, int tid, u16 ssn_idx)
  792. {
  793. unsigned long flags;
  794. int ret;
  795. u16 ra_tid;
  796. if ((IWL50_FIRST_AMPDU_QUEUE > txq_id) ||
  797. (IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES <= txq_id)) {
  798. IWL_WARNING("queue number out of range: %d, must be %d to %d\n",
  799. txq_id, IWL50_FIRST_AMPDU_QUEUE,
  800. IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES - 1);
  801. return -EINVAL;
  802. }
  803. ra_tid = BUILD_RAxTID(sta_id, tid);
  804. /* Modify device's station table to Tx this TID */
  805. iwl_sta_tx_modify_enable_tid(priv, sta_id, tid);
  806. spin_lock_irqsave(&priv->lock, flags);
  807. ret = iwl_grab_nic_access(priv);
  808. if (ret) {
  809. spin_unlock_irqrestore(&priv->lock, flags);
  810. return ret;
  811. }
  812. /* Stop this Tx queue before configuring it */
  813. iwl5000_tx_queue_stop_scheduler(priv, txq_id);
  814. /* Map receiver-address / traffic-ID to this queue */
  815. iwl5000_tx_queue_set_q2ratid(priv, ra_tid, txq_id);
  816. /* Set this queue as a chain-building queue */
  817. iwl_set_bits_prph(priv, IWL50_SCD_QUEUECHAIN_SEL, (1<<txq_id));
  818. /* enable aggregations for the queue */
  819. iwl_set_bits_prph(priv, IWL50_SCD_AGGR_SEL, (1<<txq_id));
  820. /* Place first TFD at index corresponding to start sequence number.
  821. * Assumes that ssn_idx is valid (!= 0xFFF) */
  822. priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
  823. priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
  824. iwl5000_set_wr_ptrs(priv, txq_id, ssn_idx);
  825. /* Set up Tx window size and frame limit for this queue */
  826. iwl_write_targ_mem(priv, priv->scd_base_addr +
  827. IWL50_SCD_CONTEXT_QUEUE_OFFSET(txq_id) +
  828. sizeof(u32),
  829. ((SCD_WIN_SIZE <<
  830. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
  831. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
  832. ((SCD_FRAME_LIMIT <<
  833. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
  834. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
  835. iwl_set_bits_prph(priv, IWL50_SCD_INTERRUPT_MASK, (1 << txq_id));
  836. /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */
  837. iwl5000_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1);
  838. iwl_release_nic_access(priv);
  839. spin_unlock_irqrestore(&priv->lock, flags);
  840. return 0;
  841. }
  842. static int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
  843. u16 ssn_idx, u8 tx_fifo)
  844. {
  845. int ret;
  846. if ((IWL50_FIRST_AMPDU_QUEUE > txq_id) ||
  847. (IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES <= txq_id)) {
  848. IWL_WARNING("queue number out of range: %d, must be %d to %d\n",
  849. txq_id, IWL50_FIRST_AMPDU_QUEUE,
  850. IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES - 1);
  851. return -EINVAL;
  852. }
  853. ret = iwl_grab_nic_access(priv);
  854. if (ret)
  855. return ret;
  856. iwl5000_tx_queue_stop_scheduler(priv, txq_id);
  857. iwl_clear_bits_prph(priv, IWL50_SCD_AGGR_SEL, (1 << txq_id));
  858. priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
  859. priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
  860. /* supposes that ssn_idx is valid (!= 0xFFF) */
  861. iwl5000_set_wr_ptrs(priv, txq_id, ssn_idx);
  862. iwl_clear_bits_prph(priv, IWL50_SCD_INTERRUPT_MASK, (1 << txq_id));
  863. iwl_txq_ctx_deactivate(priv, txq_id);
  864. iwl5000_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0);
  865. iwl_release_nic_access(priv);
  866. return 0;
  867. }
  868. static u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
  869. {
  870. u16 size = (u16)sizeof(struct iwl_addsta_cmd);
  871. memcpy(data, cmd, size);
  872. return size;
  873. }
  874. /*
  875. * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask
  876. * must be called under priv->lock and mac access
  877. */
  878. static void iwl5000_txq_set_sched(struct iwl_priv *priv, u32 mask)
  879. {
  880. iwl_write_prph(priv, IWL50_SCD_TXFACT, mask);
  881. }
  882. static inline u32 iwl5000_get_scd_ssn(struct iwl5000_tx_resp *tx_resp)
  883. {
  884. return le32_to_cpup((__le32 *)&tx_resp->status +
  885. tx_resp->frame_count) & MAX_SN;
  886. }
  887. static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
  888. struct iwl_ht_agg *agg,
  889. struct iwl5000_tx_resp *tx_resp,
  890. int txq_id, u16 start_idx)
  891. {
  892. u16 status;
  893. struct agg_tx_status *frame_status = &tx_resp->status;
  894. struct ieee80211_tx_info *info = NULL;
  895. struct ieee80211_hdr *hdr = NULL;
  896. u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
  897. int i, sh, idx;
  898. u16 seq;
  899. if (agg->wait_for_ba)
  900. IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n");
  901. agg->frame_count = tx_resp->frame_count;
  902. agg->start_idx = start_idx;
  903. agg->rate_n_flags = rate_n_flags;
  904. agg->bitmap = 0;
  905. /* # frames attempted by Tx command */
  906. if (agg->frame_count == 1) {
  907. /* Only one frame was attempted; no block-ack will arrive */
  908. status = le16_to_cpu(frame_status[0].status);
  909. idx = start_idx;
  910. /* FIXME: code repetition */
  911. IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n",
  912. agg->frame_count, agg->start_idx, idx);
  913. info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
  914. info->status.rates[0].count = tx_resp->failure_frame + 1;
  915. info->flags &= ~IEEE80211_TX_CTL_AMPDU;
  916. info->flags |= iwl_is_tx_success(status) ?
  917. IEEE80211_TX_STAT_ACK : 0;
  918. iwl_hwrate_to_tx_control(priv, rate_n_flags, info);
  919. /* FIXME: code repetition end */
  920. IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n",
  921. status & 0xff, tx_resp->failure_frame);
  922. IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags);
  923. agg->wait_for_ba = 0;
  924. } else {
  925. /* Two or more frames were attempted; expect block-ack */
  926. u64 bitmap = 0;
  927. int start = agg->start_idx;
  928. /* Construct bit-map of pending frames within Tx window */
  929. for (i = 0; i < agg->frame_count; i++) {
  930. u16 sc;
  931. status = le16_to_cpu(frame_status[i].status);
  932. seq = le16_to_cpu(frame_status[i].sequence);
  933. idx = SEQ_TO_INDEX(seq);
  934. txq_id = SEQ_TO_QUEUE(seq);
  935. if (status & (AGG_TX_STATE_FEW_BYTES_MSK |
  936. AGG_TX_STATE_ABORT_MSK))
  937. continue;
  938. IWL_DEBUG_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n",
  939. agg->frame_count, txq_id, idx);
  940. hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx);
  941. sc = le16_to_cpu(hdr->seq_ctrl);
  942. if (idx != (SEQ_TO_SN(sc) & 0xff)) {
  943. IWL_ERROR("BUG_ON idx doesn't match seq control"
  944. " idx=%d, seq_idx=%d, seq=%d\n",
  945. idx, SEQ_TO_SN(sc),
  946. hdr->seq_ctrl);
  947. return -1;
  948. }
  949. IWL_DEBUG_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n",
  950. i, idx, SEQ_TO_SN(sc));
  951. sh = idx - start;
  952. if (sh > 64) {
  953. sh = (start - idx) + 0xff;
  954. bitmap = bitmap << sh;
  955. sh = 0;
  956. start = idx;
  957. } else if (sh < -64)
  958. sh = 0xff - (start - idx);
  959. else if (sh < 0) {
  960. sh = start - idx;
  961. start = idx;
  962. bitmap = bitmap << sh;
  963. sh = 0;
  964. }
  965. bitmap |= 1ULL << sh;
  966. IWL_DEBUG_TX_REPLY("start=%d bitmap=0x%llx\n",
  967. start, (unsigned long long)bitmap);
  968. }
  969. agg->bitmap = bitmap;
  970. agg->start_idx = start;
  971. IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n",
  972. agg->frame_count, agg->start_idx,
  973. (unsigned long long)agg->bitmap);
  974. if (bitmap)
  975. agg->wait_for_ba = 1;
  976. }
  977. return 0;
  978. }
  979. static void iwl5000_rx_reply_tx(struct iwl_priv *priv,
  980. struct iwl_rx_mem_buffer *rxb)
  981. {
  982. struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
  983. u16 sequence = le16_to_cpu(pkt->hdr.sequence);
  984. int txq_id = SEQ_TO_QUEUE(sequence);
  985. int index = SEQ_TO_INDEX(sequence);
  986. struct iwl_tx_queue *txq = &priv->txq[txq_id];
  987. struct ieee80211_tx_info *info;
  988. struct iwl5000_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
  989. u32 status = le16_to_cpu(tx_resp->status.status);
  990. int tid;
  991. int sta_id;
  992. int freed;
  993. if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) {
  994. IWL_ERROR("Read index for DMA queue txq_id (%d) index %d "
  995. "is out of range [0-%d] %d %d\n", txq_id,
  996. index, txq->q.n_bd, txq->q.write_ptr,
  997. txq->q.read_ptr);
  998. return;
  999. }
  1000. info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]);
  1001. memset(&info->status, 0, sizeof(info->status));
  1002. tid = (tx_resp->ra_tid & IWL50_TX_RES_TID_MSK) >> IWL50_TX_RES_TID_POS;
  1003. sta_id = (tx_resp->ra_tid & IWL50_TX_RES_RA_MSK) >> IWL50_TX_RES_RA_POS;
  1004. if (txq->sched_retry) {
  1005. const u32 scd_ssn = iwl5000_get_scd_ssn(tx_resp);
  1006. struct iwl_ht_agg *agg = NULL;
  1007. agg = &priv->stations[sta_id].tid[tid].agg;
  1008. iwl5000_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index);
  1009. /* check if BAR is needed */
  1010. if ((tx_resp->frame_count == 1) && !iwl_is_tx_success(status))
  1011. info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
  1012. if (txq->q.read_ptr != (scd_ssn & 0xff)) {
  1013. index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
  1014. IWL_DEBUG_TX_REPLY("Retry scheduler reclaim "
  1015. "scd_ssn=%d idx=%d txq=%d swq=%d\n",
  1016. scd_ssn , index, txq_id, txq->swq_id);
  1017. freed = iwl_tx_queue_reclaim(priv, txq_id, index);
  1018. priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
  1019. if (priv->mac80211_registered &&
  1020. (iwl_queue_space(&txq->q) > txq->q.low_mark) &&
  1021. (agg->state != IWL_EMPTYING_HW_QUEUE_DELBA)) {
  1022. if (agg->state == IWL_AGG_OFF)
  1023. ieee80211_wake_queue(priv->hw, txq_id);
  1024. else
  1025. ieee80211_wake_queue(priv->hw,
  1026. txq->swq_id);
  1027. }
  1028. }
  1029. } else {
  1030. BUG_ON(txq_id != txq->swq_id);
  1031. info->status.rates[0].count = tx_resp->failure_frame + 1;
  1032. info->flags |= iwl_is_tx_success(status) ?
  1033. IEEE80211_TX_STAT_ACK : 0;
  1034. iwl_hwrate_to_tx_control(priv,
  1035. le32_to_cpu(tx_resp->rate_n_flags),
  1036. info);
  1037. IWL_DEBUG_TX_REPLY("TXQ %d status %s (0x%08x) rate_n_flags "
  1038. "0x%x retries %d\n",
  1039. txq_id,
  1040. iwl_get_tx_fail_reason(status), status,
  1041. le32_to_cpu(tx_resp->rate_n_flags),
  1042. tx_resp->failure_frame);
  1043. freed = iwl_tx_queue_reclaim(priv, txq_id, index);
  1044. if (ieee80211_is_data_qos(tx_resp->frame_ctrl))
  1045. priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
  1046. if (priv->mac80211_registered &&
  1047. (iwl_queue_space(&txq->q) > txq->q.low_mark))
  1048. ieee80211_wake_queue(priv->hw, txq_id);
  1049. }
  1050. if (ieee80211_is_data_qos(tx_resp->frame_ctrl))
  1051. iwl_txq_check_empty(priv, sta_id, tid, txq_id);
  1052. if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
  1053. IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n");
  1054. }
  1055. /* Currently 5000 is the superset of everything */
  1056. static u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len)
  1057. {
  1058. return len;
  1059. }
  1060. static void iwl5000_setup_deferred_work(struct iwl_priv *priv)
  1061. {
  1062. /* in 5000 the tx power calibration is done in uCode */
  1063. priv->disable_tx_power_cal = 1;
  1064. }
  1065. static void iwl5000_rx_handler_setup(struct iwl_priv *priv)
  1066. {
  1067. /* init calibration handlers */
  1068. priv->rx_handlers[CALIBRATION_RES_NOTIFICATION] =
  1069. iwl5000_rx_calib_result;
  1070. priv->rx_handlers[CALIBRATION_COMPLETE_NOTIFICATION] =
  1071. iwl5000_rx_calib_complete;
  1072. priv->rx_handlers[REPLY_TX] = iwl5000_rx_reply_tx;
  1073. }
  1074. static int iwl5000_hw_valid_rtc_data_addr(u32 addr)
  1075. {
  1076. return (addr >= RTC_DATA_LOWER_BOUND) &&
  1077. (addr < IWL50_RTC_DATA_UPPER_BOUND);
  1078. }
  1079. static int iwl5000_send_rxon_assoc(struct iwl_priv *priv)
  1080. {
  1081. int ret = 0;
  1082. struct iwl5000_rxon_assoc_cmd rxon_assoc;
  1083. const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon;
  1084. const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon;
  1085. if ((rxon1->flags == rxon2->flags) &&
  1086. (rxon1->filter_flags == rxon2->filter_flags) &&
  1087. (rxon1->cck_basic_rates == rxon2->cck_basic_rates) &&
  1088. (rxon1->ofdm_ht_single_stream_basic_rates ==
  1089. rxon2->ofdm_ht_single_stream_basic_rates) &&
  1090. (rxon1->ofdm_ht_dual_stream_basic_rates ==
  1091. rxon2->ofdm_ht_dual_stream_basic_rates) &&
  1092. (rxon1->ofdm_ht_triple_stream_basic_rates ==
  1093. rxon2->ofdm_ht_triple_stream_basic_rates) &&
  1094. (rxon1->acquisition_data == rxon2->acquisition_data) &&
  1095. (rxon1->rx_chain == rxon2->rx_chain) &&
  1096. (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) {
  1097. IWL_DEBUG_INFO("Using current RXON_ASSOC. Not resending.\n");
  1098. return 0;
  1099. }
  1100. rxon_assoc.flags = priv->staging_rxon.flags;
  1101. rxon_assoc.filter_flags = priv->staging_rxon.filter_flags;
  1102. rxon_assoc.ofdm_basic_rates = priv->staging_rxon.ofdm_basic_rates;
  1103. rxon_assoc.cck_basic_rates = priv->staging_rxon.cck_basic_rates;
  1104. rxon_assoc.reserved1 = 0;
  1105. rxon_assoc.reserved2 = 0;
  1106. rxon_assoc.reserved3 = 0;
  1107. rxon_assoc.ofdm_ht_single_stream_basic_rates =
  1108. priv->staging_rxon.ofdm_ht_single_stream_basic_rates;
  1109. rxon_assoc.ofdm_ht_dual_stream_basic_rates =
  1110. priv->staging_rxon.ofdm_ht_dual_stream_basic_rates;
  1111. rxon_assoc.rx_chain_select_flags = priv->staging_rxon.rx_chain;
  1112. rxon_assoc.ofdm_ht_triple_stream_basic_rates =
  1113. priv->staging_rxon.ofdm_ht_triple_stream_basic_rates;
  1114. rxon_assoc.acquisition_data = priv->staging_rxon.acquisition_data;
  1115. ret = iwl_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC,
  1116. sizeof(rxon_assoc), &rxon_assoc, NULL);
  1117. if (ret)
  1118. return ret;
  1119. return ret;
  1120. }
  1121. static int iwl5000_send_tx_power(struct iwl_priv *priv)
  1122. {
  1123. struct iwl5000_tx_power_dbm_cmd tx_power_cmd;
  1124. /* half dBm need to multiply */
  1125. tx_power_cmd.global_lmt = (s8)(2 * priv->tx_power_user_lmt);
  1126. tx_power_cmd.flags = IWL50_TX_POWER_NO_CLOSED;
  1127. tx_power_cmd.srv_chan_lmt = IWL50_TX_POWER_AUTO;
  1128. return iwl_send_cmd_pdu_async(priv, REPLY_TX_POWER_DBM_CMD,
  1129. sizeof(tx_power_cmd), &tx_power_cmd,
  1130. NULL);
  1131. }
  1132. static void iwl5000_temperature(struct iwl_priv *priv)
  1133. {
  1134. /* store temperature from statistics (in Celsius) */
  1135. priv->temperature = le32_to_cpu(priv->statistics.general.temperature);
  1136. }
  1137. /* Calc max signal level (dBm) among 3 possible receivers */
  1138. static int iwl5000_calc_rssi(struct iwl_priv *priv,
  1139. struct iwl_rx_phy_res *rx_resp)
  1140. {
  1141. /* data from PHY/DSP regarding signal strength, etc.,
  1142. * contents are always there, not configurable by host
  1143. */
  1144. struct iwl5000_non_cfg_phy *ncphy =
  1145. (struct iwl5000_non_cfg_phy *)rx_resp->non_cfg_phy_buf;
  1146. u32 val, rssi_a, rssi_b, rssi_c, max_rssi;
  1147. u8 agc;
  1148. val = le32_to_cpu(ncphy->non_cfg_phy[IWL50_RX_RES_AGC_IDX]);
  1149. agc = (val & IWL50_OFDM_AGC_MSK) >> IWL50_OFDM_AGC_BIT_POS;
  1150. /* Find max rssi among 3 possible receivers.
  1151. * These values are measured by the digital signal processor (DSP).
  1152. * They should stay fairly constant even as the signal strength varies,
  1153. * if the radio's automatic gain control (AGC) is working right.
  1154. * AGC value (see below) will provide the "interesting" info.
  1155. */
  1156. val = le32_to_cpu(ncphy->non_cfg_phy[IWL50_RX_RES_RSSI_AB_IDX]);
  1157. rssi_a = (val & IWL50_OFDM_RSSI_A_MSK) >> IWL50_OFDM_RSSI_A_BIT_POS;
  1158. rssi_b = (val & IWL50_OFDM_RSSI_B_MSK) >> IWL50_OFDM_RSSI_B_BIT_POS;
  1159. val = le32_to_cpu(ncphy->non_cfg_phy[IWL50_RX_RES_RSSI_C_IDX]);
  1160. rssi_c = (val & IWL50_OFDM_RSSI_C_MSK) >> IWL50_OFDM_RSSI_C_BIT_POS;
  1161. max_rssi = max_t(u32, rssi_a, rssi_b);
  1162. max_rssi = max_t(u32, max_rssi, rssi_c);
  1163. IWL_DEBUG_STATS("Rssi In A %d B %d C %d Max %d AGC dB %d\n",
  1164. rssi_a, rssi_b, rssi_c, max_rssi, agc);
  1165. /* dBm = max_rssi dB - agc dB - constant.
  1166. * Higher AGC (higher radio gain) means lower signal. */
  1167. return max_rssi - agc - IWL_RSSI_OFFSET;
  1168. }
  1169. static struct iwl_hcmd_ops iwl5000_hcmd = {
  1170. .rxon_assoc = iwl5000_send_rxon_assoc,
  1171. };
  1172. static struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = {
  1173. .get_hcmd_size = iwl5000_get_hcmd_size,
  1174. .build_addsta_hcmd = iwl5000_build_addsta_hcmd,
  1175. .gain_computation = iwl5000_gain_computation,
  1176. .chain_noise_reset = iwl5000_chain_noise_reset,
  1177. .rts_tx_cmd_flag = iwl5000_rts_tx_cmd_flag,
  1178. .calc_rssi = iwl5000_calc_rssi,
  1179. };
  1180. static struct iwl_lib_ops iwl5000_lib = {
  1181. .set_hw_params = iwl5000_hw_set_hw_params,
  1182. .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl,
  1183. .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl,
  1184. .txq_set_sched = iwl5000_txq_set_sched,
  1185. .txq_agg_enable = iwl5000_txq_agg_enable,
  1186. .txq_agg_disable = iwl5000_txq_agg_disable,
  1187. .rx_handler_setup = iwl5000_rx_handler_setup,
  1188. .setup_deferred_work = iwl5000_setup_deferred_work,
  1189. .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
  1190. .load_ucode = iwl5000_load_ucode,
  1191. .init_alive_start = iwl5000_init_alive_start,
  1192. .alive_notify = iwl5000_alive_notify,
  1193. .send_tx_power = iwl5000_send_tx_power,
  1194. .temperature = iwl5000_temperature,
  1195. .update_chain_flags = iwl_update_chain_flags,
  1196. .apm_ops = {
  1197. .init = iwl5000_apm_init,
  1198. .reset = iwl5000_apm_reset,
  1199. .stop = iwl5000_apm_stop,
  1200. .config = iwl5000_nic_config,
  1201. .set_pwr_src = iwl_set_pwr_src,
  1202. },
  1203. .eeprom_ops = {
  1204. .regulatory_bands = {
  1205. EEPROM_5000_REG_BAND_1_CHANNELS,
  1206. EEPROM_5000_REG_BAND_2_CHANNELS,
  1207. EEPROM_5000_REG_BAND_3_CHANNELS,
  1208. EEPROM_5000_REG_BAND_4_CHANNELS,
  1209. EEPROM_5000_REG_BAND_5_CHANNELS,
  1210. EEPROM_5000_REG_BAND_24_FAT_CHANNELS,
  1211. EEPROM_5000_REG_BAND_52_FAT_CHANNELS
  1212. },
  1213. .verify_signature = iwlcore_eeprom_verify_signature,
  1214. .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
  1215. .release_semaphore = iwlcore_eeprom_release_semaphore,
  1216. .calib_version = iwl5000_eeprom_calib_version,
  1217. .query_addr = iwl5000_eeprom_query_addr,
  1218. },
  1219. };
  1220. static struct iwl_ops iwl5000_ops = {
  1221. .lib = &iwl5000_lib,
  1222. .hcmd = &iwl5000_hcmd,
  1223. .utils = &iwl5000_hcmd_utils,
  1224. };
  1225. static struct iwl_mod_params iwl50_mod_params = {
  1226. .num_of_queues = IWL50_NUM_QUEUES,
  1227. .num_of_ampdu_queues = IWL50_NUM_AMPDU_QUEUES,
  1228. .enable_qos = 1,
  1229. .amsdu_size_8K = 1,
  1230. .restart_fw = 1,
  1231. /* the rest are 0 by default */
  1232. };
  1233. struct iwl_cfg iwl5300_agn_cfg = {
  1234. .name = "5300AGN",
  1235. .fw_name = IWL5000_MODULE_FIRMWARE,
  1236. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  1237. .ops = &iwl5000_ops,
  1238. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1239. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  1240. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  1241. .mod_params = &iwl50_mod_params,
  1242. };
  1243. struct iwl_cfg iwl5100_bg_cfg = {
  1244. .name = "5100BG",
  1245. .fw_name = IWL5000_MODULE_FIRMWARE,
  1246. .sku = IWL_SKU_G,
  1247. .ops = &iwl5000_ops,
  1248. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1249. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  1250. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  1251. .mod_params = &iwl50_mod_params,
  1252. };
  1253. struct iwl_cfg iwl5100_abg_cfg = {
  1254. .name = "5100ABG",
  1255. .fw_name = IWL5000_MODULE_FIRMWARE,
  1256. .sku = IWL_SKU_A|IWL_SKU_G,
  1257. .ops = &iwl5000_ops,
  1258. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1259. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  1260. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  1261. .mod_params = &iwl50_mod_params,
  1262. };
  1263. struct iwl_cfg iwl5100_agn_cfg = {
  1264. .name = "5100AGN",
  1265. .fw_name = IWL5000_MODULE_FIRMWARE,
  1266. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  1267. .ops = &iwl5000_ops,
  1268. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1269. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  1270. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  1271. .mod_params = &iwl50_mod_params,
  1272. };
  1273. struct iwl_cfg iwl5350_agn_cfg = {
  1274. .name = "5350AGN",
  1275. .fw_name = IWL5000_MODULE_FIRMWARE,
  1276. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  1277. .ops = &iwl5000_ops,
  1278. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1279. .eeprom_ver = EEPROM_5050_EEPROM_VERSION,
  1280. .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION,
  1281. .mod_params = &iwl50_mod_params,
  1282. };
  1283. MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE);
  1284. module_param_named(disable50, iwl50_mod_params.disable, int, 0444);
  1285. MODULE_PARM_DESC(disable50,
  1286. "manually disable the 50XX radio (default 0 [radio on])");
  1287. module_param_named(swcrypto50, iwl50_mod_params.sw_crypto, bool, 0444);
  1288. MODULE_PARM_DESC(swcrypto50,
  1289. "using software crypto engine (default 0 [hardware])\n");
  1290. module_param_named(debug50, iwl50_mod_params.debug, int, 0444);
  1291. MODULE_PARM_DESC(debug50, "50XX debug output mask");
  1292. module_param_named(queues_num50, iwl50_mod_params.num_of_queues, int, 0444);
  1293. MODULE_PARM_DESC(queues_num50, "number of hw queues in 50xx series");
  1294. module_param_named(qos_enable50, iwl50_mod_params.enable_qos, int, 0444);
  1295. MODULE_PARM_DESC(qos_enable50, "enable all 50XX QoS functionality");
  1296. module_param_named(11n_disable50, iwl50_mod_params.disable_11n, int, 0444);
  1297. MODULE_PARM_DESC(11n_disable50, "disable 50XX 11n functionality");
  1298. module_param_named(amsdu_size_8K50, iwl50_mod_params.amsdu_size_8K, int, 0444);
  1299. MODULE_PARM_DESC(amsdu_size_8K50, "enable 8K amsdu size in 50XX series");
  1300. module_param_named(fw_restart50, iwl50_mod_params.restart_fw, int, 0444);
  1301. MODULE_PARM_DESC(fw_restart50, "restart firmware in case of error");