iwl-5000.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576
  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. u32 reg_val;
  575. spin_lock_irqsave(&priv->lock, flags);
  576. ret = iwl_grab_nic_access(priv);
  577. if (ret) {
  578. spin_unlock_irqrestore(&priv->lock, flags);
  579. return ret;
  580. }
  581. priv->scd_base_addr = iwl_read_prph(priv, IWL50_SCD_SRAM_BASE_ADDR);
  582. a = priv->scd_base_addr + IWL50_SCD_CONTEXT_DATA_OFFSET;
  583. for (; a < priv->scd_base_addr + IWL50_SCD_TX_STTS_BITMAP_OFFSET;
  584. a += 4)
  585. iwl_write_targ_mem(priv, a, 0);
  586. for (; a < priv->scd_base_addr + IWL50_SCD_TRANSLATE_TBL_OFFSET;
  587. a += 4)
  588. iwl_write_targ_mem(priv, a, 0);
  589. for (; a < sizeof(u16) * priv->hw_params.max_txq_num; a += 4)
  590. iwl_write_targ_mem(priv, a, 0);
  591. iwl_write_prph(priv, IWL50_SCD_DRAM_BASE_ADDR,
  592. priv->scd_bc_tbls.dma >> 10);
  593. /* Enable DMA channel */
  594. for (chan = 0; chan < FH50_TCSR_CHNL_NUM ; chan++)
  595. iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(chan),
  596. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
  597. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE);
  598. /* Update FH chicken bits */
  599. reg_val = iwl_read_direct32(priv, FH_TX_CHICKEN_BITS_REG);
  600. iwl_write_direct32(priv, FH_TX_CHICKEN_BITS_REG,
  601. reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN);
  602. iwl_write_prph(priv, IWL50_SCD_QUEUECHAIN_SEL,
  603. IWL50_SCD_QUEUECHAIN_SEL_ALL(priv->hw_params.max_txq_num));
  604. iwl_write_prph(priv, IWL50_SCD_AGGR_SEL, 0);
  605. /* initiate the queues */
  606. for (i = 0; i < priv->hw_params.max_txq_num; i++) {
  607. iwl_write_prph(priv, IWL50_SCD_QUEUE_RDPTR(i), 0);
  608. iwl_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8));
  609. iwl_write_targ_mem(priv, priv->scd_base_addr +
  610. IWL50_SCD_CONTEXT_QUEUE_OFFSET(i), 0);
  611. iwl_write_targ_mem(priv, priv->scd_base_addr +
  612. IWL50_SCD_CONTEXT_QUEUE_OFFSET(i) +
  613. sizeof(u32),
  614. ((SCD_WIN_SIZE <<
  615. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
  616. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
  617. ((SCD_FRAME_LIMIT <<
  618. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
  619. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
  620. }
  621. iwl_write_prph(priv, IWL50_SCD_INTERRUPT_MASK,
  622. IWL_MASK(0, priv->hw_params.max_txq_num));
  623. /* Activate all Tx DMA/FIFO channels */
  624. priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 7));
  625. iwl5000_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0);
  626. /* map qos queues to fifos one-to-one */
  627. for (i = 0; i < ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo); i++) {
  628. int ac = iwl5000_default_queue_to_tx_fifo[i];
  629. iwl_txq_ctx_activate(priv, i);
  630. iwl5000_tx_queue_set_status(priv, &priv->txq[i], ac, 0);
  631. }
  632. /* TODO - need to initialize those FIFOs inside the loop above,
  633. * not only mark them as active */
  634. iwl_txq_ctx_activate(priv, 4);
  635. iwl_txq_ctx_activate(priv, 7);
  636. iwl_txq_ctx_activate(priv, 8);
  637. iwl_txq_ctx_activate(priv, 9);
  638. iwl_release_nic_access(priv);
  639. spin_unlock_irqrestore(&priv->lock, flags);
  640. iwl5000_send_wimax_coex(priv);
  641. iwl5000_set_Xtal_calib(priv);
  642. iwl_send_calib_results(priv);
  643. return 0;
  644. }
  645. static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
  646. {
  647. if ((priv->cfg->mod_params->num_of_queues > IWL50_NUM_QUEUES) ||
  648. (priv->cfg->mod_params->num_of_queues < IWL_MIN_NUM_QUEUES)) {
  649. IWL_ERROR("invalid queues_num, should be between %d and %d\n",
  650. IWL_MIN_NUM_QUEUES, IWL50_NUM_QUEUES);
  651. return -EINVAL;
  652. }
  653. priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues;
  654. priv->hw_params.scd_bc_tbls_size =
  655. IWL50_NUM_QUEUES * sizeof(struct iwl5000_scd_bc_tbl);
  656. priv->hw_params.max_stations = IWL5000_STATION_COUNT;
  657. priv->hw_params.bcast_sta_id = IWL5000_BROADCAST_ID;
  658. priv->hw_params.max_data_size = IWL50_RTC_DATA_SIZE;
  659. priv->hw_params.max_inst_size = IWL50_RTC_INST_SIZE;
  660. priv->hw_params.max_bsm_size = 0;
  661. priv->hw_params.fat_channel = BIT(IEEE80211_BAND_2GHZ) |
  662. BIT(IEEE80211_BAND_5GHZ);
  663. priv->hw_params.sens = &iwl5000_sensitivity;
  664. switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
  665. case CSR_HW_REV_TYPE_5100:
  666. priv->hw_params.tx_chains_num = 1;
  667. priv->hw_params.rx_chains_num = 2;
  668. priv->hw_params.valid_tx_ant = ANT_B;
  669. priv->hw_params.valid_rx_ant = ANT_AB;
  670. break;
  671. case CSR_HW_REV_TYPE_5150:
  672. priv->hw_params.tx_chains_num = 1;
  673. priv->hw_params.rx_chains_num = 2;
  674. priv->hw_params.valid_tx_ant = ANT_A;
  675. priv->hw_params.valid_rx_ant = ANT_AB;
  676. break;
  677. case CSR_HW_REV_TYPE_5300:
  678. case CSR_HW_REV_TYPE_5350:
  679. priv->hw_params.tx_chains_num = 3;
  680. priv->hw_params.rx_chains_num = 3;
  681. priv->hw_params.valid_tx_ant = ANT_ABC;
  682. priv->hw_params.valid_rx_ant = ANT_ABC;
  683. break;
  684. }
  685. switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
  686. case CSR_HW_REV_TYPE_5100:
  687. case CSR_HW_REV_TYPE_5300:
  688. case CSR_HW_REV_TYPE_5350:
  689. /* 5X00 and 5350 wants in Celsius */
  690. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
  691. break;
  692. case CSR_HW_REV_TYPE_5150:
  693. /* 5150 wants in Kelvin */
  694. priv->hw_params.ct_kill_threshold =
  695. CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD);
  696. break;
  697. }
  698. /* Set initial calibration set */
  699. switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
  700. case CSR_HW_REV_TYPE_5100:
  701. case CSR_HW_REV_TYPE_5300:
  702. case CSR_HW_REV_TYPE_5350:
  703. priv->hw_params.calib_init_cfg =
  704. BIT(IWL_CALIB_XTAL) |
  705. BIT(IWL_CALIB_LO) |
  706. BIT(IWL_CALIB_TX_IQ) |
  707. BIT(IWL_CALIB_TX_IQ_PERD) |
  708. BIT(IWL_CALIB_BASE_BAND);
  709. break;
  710. case CSR_HW_REV_TYPE_5150:
  711. priv->hw_params.calib_init_cfg = 0;
  712. break;
  713. }
  714. return 0;
  715. }
  716. /**
  717. * iwl5000_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array
  718. */
  719. static void iwl5000_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
  720. struct iwl_tx_queue *txq,
  721. u16 byte_cnt)
  722. {
  723. struct iwl5000_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr;
  724. int write_ptr = txq->q.write_ptr;
  725. int txq_id = txq->q.id;
  726. u8 sec_ctl = 0;
  727. u8 sta_id = 0;
  728. u16 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
  729. __le16 bc_ent;
  730. WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX);
  731. if (txq_id != IWL_CMD_QUEUE_NUM) {
  732. sta_id = txq->cmd[txq->q.write_ptr]->cmd.tx.sta_id;
  733. sec_ctl = txq->cmd[txq->q.write_ptr]->cmd.tx.sec_ctl;
  734. switch (sec_ctl & TX_CMD_SEC_MSK) {
  735. case TX_CMD_SEC_CCM:
  736. len += CCMP_MIC_LEN;
  737. break;
  738. case TX_CMD_SEC_TKIP:
  739. len += TKIP_ICV_LEN;
  740. break;
  741. case TX_CMD_SEC_WEP:
  742. len += WEP_IV_LEN + WEP_ICV_LEN;
  743. break;
  744. }
  745. }
  746. bc_ent = cpu_to_le16((len & 0xFFF) | (sta_id << 12));
  747. scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent;
  748. if (txq->q.write_ptr < TFD_QUEUE_SIZE_BC_DUP)
  749. scd_bc_tbl[txq_id].
  750. tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent;
  751. }
  752. static void iwl5000_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
  753. struct iwl_tx_queue *txq)
  754. {
  755. struct iwl5000_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr;
  756. int txq_id = txq->q.id;
  757. int read_ptr = txq->q.read_ptr;
  758. u8 sta_id = 0;
  759. __le16 bc_ent;
  760. WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX);
  761. if (txq_id != IWL_CMD_QUEUE_NUM)
  762. sta_id = txq->cmd[read_ptr]->cmd.tx.sta_id;
  763. bc_ent = cpu_to_le16(1 | (sta_id << 12));
  764. scd_bc_tbl[txq_id].tfd_offset[read_ptr] = bc_ent;
  765. if (txq->q.write_ptr < TFD_QUEUE_SIZE_BC_DUP)
  766. scd_bc_tbl[txq_id].
  767. tfd_offset[TFD_QUEUE_SIZE_MAX + read_ptr] = bc_ent;
  768. }
  769. static int iwl5000_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid,
  770. u16 txq_id)
  771. {
  772. u32 tbl_dw_addr;
  773. u32 tbl_dw;
  774. u16 scd_q2ratid;
  775. scd_q2ratid = ra_tid & IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK;
  776. tbl_dw_addr = priv->scd_base_addr +
  777. IWL50_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id);
  778. tbl_dw = iwl_read_targ_mem(priv, tbl_dw_addr);
  779. if (txq_id & 0x1)
  780. tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF);
  781. else
  782. tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000);
  783. iwl_write_targ_mem(priv, tbl_dw_addr, tbl_dw);
  784. return 0;
  785. }
  786. static void iwl5000_tx_queue_stop_scheduler(struct iwl_priv *priv, u16 txq_id)
  787. {
  788. /* Simply stop the queue, but don't change any configuration;
  789. * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */
  790. iwl_write_prph(priv,
  791. IWL50_SCD_QUEUE_STATUS_BITS(txq_id),
  792. (0 << IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE)|
  793. (1 << IWL50_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN));
  794. }
  795. static int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id,
  796. int tx_fifo, int sta_id, int tid, u16 ssn_idx)
  797. {
  798. unsigned long flags;
  799. int ret;
  800. u16 ra_tid;
  801. if ((IWL50_FIRST_AMPDU_QUEUE > txq_id) ||
  802. (IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES <= txq_id)) {
  803. IWL_WARNING("queue number out of range: %d, must be %d to %d\n",
  804. txq_id, IWL50_FIRST_AMPDU_QUEUE,
  805. IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES - 1);
  806. return -EINVAL;
  807. }
  808. ra_tid = BUILD_RAxTID(sta_id, tid);
  809. /* Modify device's station table to Tx this TID */
  810. iwl_sta_tx_modify_enable_tid(priv, sta_id, tid);
  811. spin_lock_irqsave(&priv->lock, flags);
  812. ret = iwl_grab_nic_access(priv);
  813. if (ret) {
  814. spin_unlock_irqrestore(&priv->lock, flags);
  815. return ret;
  816. }
  817. /* Stop this Tx queue before configuring it */
  818. iwl5000_tx_queue_stop_scheduler(priv, txq_id);
  819. /* Map receiver-address / traffic-ID to this queue */
  820. iwl5000_tx_queue_set_q2ratid(priv, ra_tid, txq_id);
  821. /* Set this queue as a chain-building queue */
  822. iwl_set_bits_prph(priv, IWL50_SCD_QUEUECHAIN_SEL, (1<<txq_id));
  823. /* enable aggregations for the queue */
  824. iwl_set_bits_prph(priv, IWL50_SCD_AGGR_SEL, (1<<txq_id));
  825. /* Place first TFD at index corresponding to start sequence number.
  826. * Assumes that ssn_idx is valid (!= 0xFFF) */
  827. priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
  828. priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
  829. iwl5000_set_wr_ptrs(priv, txq_id, ssn_idx);
  830. /* Set up Tx window size and frame limit for this queue */
  831. iwl_write_targ_mem(priv, priv->scd_base_addr +
  832. IWL50_SCD_CONTEXT_QUEUE_OFFSET(txq_id) +
  833. sizeof(u32),
  834. ((SCD_WIN_SIZE <<
  835. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
  836. IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
  837. ((SCD_FRAME_LIMIT <<
  838. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
  839. IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
  840. iwl_set_bits_prph(priv, IWL50_SCD_INTERRUPT_MASK, (1 << txq_id));
  841. /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */
  842. iwl5000_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1);
  843. iwl_release_nic_access(priv);
  844. spin_unlock_irqrestore(&priv->lock, flags);
  845. return 0;
  846. }
  847. static int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
  848. u16 ssn_idx, u8 tx_fifo)
  849. {
  850. int ret;
  851. if ((IWL50_FIRST_AMPDU_QUEUE > txq_id) ||
  852. (IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES <= txq_id)) {
  853. IWL_WARNING("queue number out of range: %d, must be %d to %d\n",
  854. txq_id, IWL50_FIRST_AMPDU_QUEUE,
  855. IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES - 1);
  856. return -EINVAL;
  857. }
  858. ret = iwl_grab_nic_access(priv);
  859. if (ret)
  860. return ret;
  861. iwl5000_tx_queue_stop_scheduler(priv, txq_id);
  862. iwl_clear_bits_prph(priv, IWL50_SCD_AGGR_SEL, (1 << txq_id));
  863. priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
  864. priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
  865. /* supposes that ssn_idx is valid (!= 0xFFF) */
  866. iwl5000_set_wr_ptrs(priv, txq_id, ssn_idx);
  867. iwl_clear_bits_prph(priv, IWL50_SCD_INTERRUPT_MASK, (1 << txq_id));
  868. iwl_txq_ctx_deactivate(priv, txq_id);
  869. iwl5000_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0);
  870. iwl_release_nic_access(priv);
  871. return 0;
  872. }
  873. static u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
  874. {
  875. u16 size = (u16)sizeof(struct iwl_addsta_cmd);
  876. memcpy(data, cmd, size);
  877. return size;
  878. }
  879. /*
  880. * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask
  881. * must be called under priv->lock and mac access
  882. */
  883. static void iwl5000_txq_set_sched(struct iwl_priv *priv, u32 mask)
  884. {
  885. iwl_write_prph(priv, IWL50_SCD_TXFACT, mask);
  886. }
  887. static inline u32 iwl5000_get_scd_ssn(struct iwl5000_tx_resp *tx_resp)
  888. {
  889. return le32_to_cpup((__le32 *)&tx_resp->status +
  890. tx_resp->frame_count) & MAX_SN;
  891. }
  892. static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
  893. struct iwl_ht_agg *agg,
  894. struct iwl5000_tx_resp *tx_resp,
  895. int txq_id, u16 start_idx)
  896. {
  897. u16 status;
  898. struct agg_tx_status *frame_status = &tx_resp->status;
  899. struct ieee80211_tx_info *info = NULL;
  900. struct ieee80211_hdr *hdr = NULL;
  901. u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
  902. int i, sh, idx;
  903. u16 seq;
  904. if (agg->wait_for_ba)
  905. IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n");
  906. agg->frame_count = tx_resp->frame_count;
  907. agg->start_idx = start_idx;
  908. agg->rate_n_flags = rate_n_flags;
  909. agg->bitmap = 0;
  910. /* # frames attempted by Tx command */
  911. if (agg->frame_count == 1) {
  912. /* Only one frame was attempted; no block-ack will arrive */
  913. status = le16_to_cpu(frame_status[0].status);
  914. idx = start_idx;
  915. /* FIXME: code repetition */
  916. IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n",
  917. agg->frame_count, agg->start_idx, idx);
  918. info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
  919. info->status.rates[0].count = tx_resp->failure_frame + 1;
  920. info->flags &= ~IEEE80211_TX_CTL_AMPDU;
  921. info->flags |= iwl_is_tx_success(status) ?
  922. IEEE80211_TX_STAT_ACK : 0;
  923. iwl_hwrate_to_tx_control(priv, rate_n_flags, info);
  924. /* FIXME: code repetition end */
  925. IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n",
  926. status & 0xff, tx_resp->failure_frame);
  927. IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags);
  928. agg->wait_for_ba = 0;
  929. } else {
  930. /* Two or more frames were attempted; expect block-ack */
  931. u64 bitmap = 0;
  932. int start = agg->start_idx;
  933. /* Construct bit-map of pending frames within Tx window */
  934. for (i = 0; i < agg->frame_count; i++) {
  935. u16 sc;
  936. status = le16_to_cpu(frame_status[i].status);
  937. seq = le16_to_cpu(frame_status[i].sequence);
  938. idx = SEQ_TO_INDEX(seq);
  939. txq_id = SEQ_TO_QUEUE(seq);
  940. if (status & (AGG_TX_STATE_FEW_BYTES_MSK |
  941. AGG_TX_STATE_ABORT_MSK))
  942. continue;
  943. IWL_DEBUG_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n",
  944. agg->frame_count, txq_id, idx);
  945. hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx);
  946. sc = le16_to_cpu(hdr->seq_ctrl);
  947. if (idx != (SEQ_TO_SN(sc) & 0xff)) {
  948. IWL_ERROR("BUG_ON idx doesn't match seq control"
  949. " idx=%d, seq_idx=%d, seq=%d\n",
  950. idx, SEQ_TO_SN(sc),
  951. hdr->seq_ctrl);
  952. return -1;
  953. }
  954. IWL_DEBUG_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n",
  955. i, idx, SEQ_TO_SN(sc));
  956. sh = idx - start;
  957. if (sh > 64) {
  958. sh = (start - idx) + 0xff;
  959. bitmap = bitmap << sh;
  960. sh = 0;
  961. start = idx;
  962. } else if (sh < -64)
  963. sh = 0xff - (start - idx);
  964. else if (sh < 0) {
  965. sh = start - idx;
  966. start = idx;
  967. bitmap = bitmap << sh;
  968. sh = 0;
  969. }
  970. bitmap |= 1ULL << sh;
  971. IWL_DEBUG_TX_REPLY("start=%d bitmap=0x%llx\n",
  972. start, (unsigned long long)bitmap);
  973. }
  974. agg->bitmap = bitmap;
  975. agg->start_idx = start;
  976. IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n",
  977. agg->frame_count, agg->start_idx,
  978. (unsigned long long)agg->bitmap);
  979. if (bitmap)
  980. agg->wait_for_ba = 1;
  981. }
  982. return 0;
  983. }
  984. static void iwl5000_rx_reply_tx(struct iwl_priv *priv,
  985. struct iwl_rx_mem_buffer *rxb)
  986. {
  987. struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
  988. u16 sequence = le16_to_cpu(pkt->hdr.sequence);
  989. int txq_id = SEQ_TO_QUEUE(sequence);
  990. int index = SEQ_TO_INDEX(sequence);
  991. struct iwl_tx_queue *txq = &priv->txq[txq_id];
  992. struct ieee80211_tx_info *info;
  993. struct iwl5000_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
  994. u32 status = le16_to_cpu(tx_resp->status.status);
  995. int tid;
  996. int sta_id;
  997. int freed;
  998. if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) {
  999. IWL_ERROR("Read index for DMA queue txq_id (%d) index %d "
  1000. "is out of range [0-%d] %d %d\n", txq_id,
  1001. index, txq->q.n_bd, txq->q.write_ptr,
  1002. txq->q.read_ptr);
  1003. return;
  1004. }
  1005. info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]);
  1006. memset(&info->status, 0, sizeof(info->status));
  1007. tid = (tx_resp->ra_tid & IWL50_TX_RES_TID_MSK) >> IWL50_TX_RES_TID_POS;
  1008. sta_id = (tx_resp->ra_tid & IWL50_TX_RES_RA_MSK) >> IWL50_TX_RES_RA_POS;
  1009. if (txq->sched_retry) {
  1010. const u32 scd_ssn = iwl5000_get_scd_ssn(tx_resp);
  1011. struct iwl_ht_agg *agg = NULL;
  1012. agg = &priv->stations[sta_id].tid[tid].agg;
  1013. iwl5000_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index);
  1014. /* check if BAR is needed */
  1015. if ((tx_resp->frame_count == 1) && !iwl_is_tx_success(status))
  1016. info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
  1017. if (txq->q.read_ptr != (scd_ssn & 0xff)) {
  1018. index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
  1019. IWL_DEBUG_TX_REPLY("Retry scheduler reclaim "
  1020. "scd_ssn=%d idx=%d txq=%d swq=%d\n",
  1021. scd_ssn , index, txq_id, txq->swq_id);
  1022. freed = iwl_tx_queue_reclaim(priv, txq_id, index);
  1023. priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
  1024. if (priv->mac80211_registered &&
  1025. (iwl_queue_space(&txq->q) > txq->q.low_mark) &&
  1026. (agg->state != IWL_EMPTYING_HW_QUEUE_DELBA)) {
  1027. if (agg->state == IWL_AGG_OFF)
  1028. ieee80211_wake_queue(priv->hw, txq_id);
  1029. else
  1030. ieee80211_wake_queue(priv->hw,
  1031. txq->swq_id);
  1032. }
  1033. }
  1034. } else {
  1035. BUG_ON(txq_id != txq->swq_id);
  1036. info->status.rates[0].count = tx_resp->failure_frame + 1;
  1037. info->flags |= iwl_is_tx_success(status) ?
  1038. IEEE80211_TX_STAT_ACK : 0;
  1039. iwl_hwrate_to_tx_control(priv,
  1040. le32_to_cpu(tx_resp->rate_n_flags),
  1041. info);
  1042. IWL_DEBUG_TX_REPLY("TXQ %d status %s (0x%08x) rate_n_flags "
  1043. "0x%x retries %d\n",
  1044. txq_id,
  1045. iwl_get_tx_fail_reason(status), status,
  1046. le32_to_cpu(tx_resp->rate_n_flags),
  1047. tx_resp->failure_frame);
  1048. freed = iwl_tx_queue_reclaim(priv, txq_id, index);
  1049. if (ieee80211_is_data_qos(tx_resp->frame_ctrl))
  1050. priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
  1051. if (priv->mac80211_registered &&
  1052. (iwl_queue_space(&txq->q) > txq->q.low_mark))
  1053. ieee80211_wake_queue(priv->hw, txq_id);
  1054. }
  1055. if (ieee80211_is_data_qos(tx_resp->frame_ctrl))
  1056. iwl_txq_check_empty(priv, sta_id, tid, txq_id);
  1057. if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
  1058. IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n");
  1059. }
  1060. /* Currently 5000 is the superset of everything */
  1061. static u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len)
  1062. {
  1063. return len;
  1064. }
  1065. static void iwl5000_setup_deferred_work(struct iwl_priv *priv)
  1066. {
  1067. /* in 5000 the tx power calibration is done in uCode */
  1068. priv->disable_tx_power_cal = 1;
  1069. }
  1070. static void iwl5000_rx_handler_setup(struct iwl_priv *priv)
  1071. {
  1072. /* init calibration handlers */
  1073. priv->rx_handlers[CALIBRATION_RES_NOTIFICATION] =
  1074. iwl5000_rx_calib_result;
  1075. priv->rx_handlers[CALIBRATION_COMPLETE_NOTIFICATION] =
  1076. iwl5000_rx_calib_complete;
  1077. priv->rx_handlers[REPLY_TX] = iwl5000_rx_reply_tx;
  1078. }
  1079. static int iwl5000_hw_valid_rtc_data_addr(u32 addr)
  1080. {
  1081. return (addr >= RTC_DATA_LOWER_BOUND) &&
  1082. (addr < IWL50_RTC_DATA_UPPER_BOUND);
  1083. }
  1084. static int iwl5000_send_rxon_assoc(struct iwl_priv *priv)
  1085. {
  1086. int ret = 0;
  1087. struct iwl5000_rxon_assoc_cmd rxon_assoc;
  1088. const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon;
  1089. const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon;
  1090. if ((rxon1->flags == rxon2->flags) &&
  1091. (rxon1->filter_flags == rxon2->filter_flags) &&
  1092. (rxon1->cck_basic_rates == rxon2->cck_basic_rates) &&
  1093. (rxon1->ofdm_ht_single_stream_basic_rates ==
  1094. rxon2->ofdm_ht_single_stream_basic_rates) &&
  1095. (rxon1->ofdm_ht_dual_stream_basic_rates ==
  1096. rxon2->ofdm_ht_dual_stream_basic_rates) &&
  1097. (rxon1->ofdm_ht_triple_stream_basic_rates ==
  1098. rxon2->ofdm_ht_triple_stream_basic_rates) &&
  1099. (rxon1->acquisition_data == rxon2->acquisition_data) &&
  1100. (rxon1->rx_chain == rxon2->rx_chain) &&
  1101. (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) {
  1102. IWL_DEBUG_INFO("Using current RXON_ASSOC. Not resending.\n");
  1103. return 0;
  1104. }
  1105. rxon_assoc.flags = priv->staging_rxon.flags;
  1106. rxon_assoc.filter_flags = priv->staging_rxon.filter_flags;
  1107. rxon_assoc.ofdm_basic_rates = priv->staging_rxon.ofdm_basic_rates;
  1108. rxon_assoc.cck_basic_rates = priv->staging_rxon.cck_basic_rates;
  1109. rxon_assoc.reserved1 = 0;
  1110. rxon_assoc.reserved2 = 0;
  1111. rxon_assoc.reserved3 = 0;
  1112. rxon_assoc.ofdm_ht_single_stream_basic_rates =
  1113. priv->staging_rxon.ofdm_ht_single_stream_basic_rates;
  1114. rxon_assoc.ofdm_ht_dual_stream_basic_rates =
  1115. priv->staging_rxon.ofdm_ht_dual_stream_basic_rates;
  1116. rxon_assoc.rx_chain_select_flags = priv->staging_rxon.rx_chain;
  1117. rxon_assoc.ofdm_ht_triple_stream_basic_rates =
  1118. priv->staging_rxon.ofdm_ht_triple_stream_basic_rates;
  1119. rxon_assoc.acquisition_data = priv->staging_rxon.acquisition_data;
  1120. ret = iwl_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC,
  1121. sizeof(rxon_assoc), &rxon_assoc, NULL);
  1122. if (ret)
  1123. return ret;
  1124. return ret;
  1125. }
  1126. static int iwl5000_send_tx_power(struct iwl_priv *priv)
  1127. {
  1128. struct iwl5000_tx_power_dbm_cmd tx_power_cmd;
  1129. /* half dBm need to multiply */
  1130. tx_power_cmd.global_lmt = (s8)(2 * priv->tx_power_user_lmt);
  1131. tx_power_cmd.flags = IWL50_TX_POWER_NO_CLOSED;
  1132. tx_power_cmd.srv_chan_lmt = IWL50_TX_POWER_AUTO;
  1133. return iwl_send_cmd_pdu_async(priv, REPLY_TX_POWER_DBM_CMD,
  1134. sizeof(tx_power_cmd), &tx_power_cmd,
  1135. NULL);
  1136. }
  1137. static void iwl5000_temperature(struct iwl_priv *priv)
  1138. {
  1139. /* store temperature from statistics (in Celsius) */
  1140. priv->temperature = le32_to_cpu(priv->statistics.general.temperature);
  1141. }
  1142. /* Calc max signal level (dBm) among 3 possible receivers */
  1143. static int iwl5000_calc_rssi(struct iwl_priv *priv,
  1144. struct iwl_rx_phy_res *rx_resp)
  1145. {
  1146. /* data from PHY/DSP regarding signal strength, etc.,
  1147. * contents are always there, not configurable by host
  1148. */
  1149. struct iwl5000_non_cfg_phy *ncphy =
  1150. (struct iwl5000_non_cfg_phy *)rx_resp->non_cfg_phy_buf;
  1151. u32 val, rssi_a, rssi_b, rssi_c, max_rssi;
  1152. u8 agc;
  1153. val = le32_to_cpu(ncphy->non_cfg_phy[IWL50_RX_RES_AGC_IDX]);
  1154. agc = (val & IWL50_OFDM_AGC_MSK) >> IWL50_OFDM_AGC_BIT_POS;
  1155. /* Find max rssi among 3 possible receivers.
  1156. * These values are measured by the digital signal processor (DSP).
  1157. * They should stay fairly constant even as the signal strength varies,
  1158. * if the radio's automatic gain control (AGC) is working right.
  1159. * AGC value (see below) will provide the "interesting" info.
  1160. */
  1161. val = le32_to_cpu(ncphy->non_cfg_phy[IWL50_RX_RES_RSSI_AB_IDX]);
  1162. rssi_a = (val & IWL50_OFDM_RSSI_A_MSK) >> IWL50_OFDM_RSSI_A_BIT_POS;
  1163. rssi_b = (val & IWL50_OFDM_RSSI_B_MSK) >> IWL50_OFDM_RSSI_B_BIT_POS;
  1164. val = le32_to_cpu(ncphy->non_cfg_phy[IWL50_RX_RES_RSSI_C_IDX]);
  1165. rssi_c = (val & IWL50_OFDM_RSSI_C_MSK) >> IWL50_OFDM_RSSI_C_BIT_POS;
  1166. max_rssi = max_t(u32, rssi_a, rssi_b);
  1167. max_rssi = max_t(u32, max_rssi, rssi_c);
  1168. IWL_DEBUG_STATS("Rssi In A %d B %d C %d Max %d AGC dB %d\n",
  1169. rssi_a, rssi_b, rssi_c, max_rssi, agc);
  1170. /* dBm = max_rssi dB - agc dB - constant.
  1171. * Higher AGC (higher radio gain) means lower signal. */
  1172. return max_rssi - agc - IWL_RSSI_OFFSET;
  1173. }
  1174. static struct iwl_hcmd_ops iwl5000_hcmd = {
  1175. .rxon_assoc = iwl5000_send_rxon_assoc,
  1176. };
  1177. static struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = {
  1178. .get_hcmd_size = iwl5000_get_hcmd_size,
  1179. .build_addsta_hcmd = iwl5000_build_addsta_hcmd,
  1180. .gain_computation = iwl5000_gain_computation,
  1181. .chain_noise_reset = iwl5000_chain_noise_reset,
  1182. .rts_tx_cmd_flag = iwl5000_rts_tx_cmd_flag,
  1183. .calc_rssi = iwl5000_calc_rssi,
  1184. };
  1185. static struct iwl_lib_ops iwl5000_lib = {
  1186. .set_hw_params = iwl5000_hw_set_hw_params,
  1187. .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl,
  1188. .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl,
  1189. .txq_set_sched = iwl5000_txq_set_sched,
  1190. .txq_agg_enable = iwl5000_txq_agg_enable,
  1191. .txq_agg_disable = iwl5000_txq_agg_disable,
  1192. .rx_handler_setup = iwl5000_rx_handler_setup,
  1193. .setup_deferred_work = iwl5000_setup_deferred_work,
  1194. .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
  1195. .load_ucode = iwl5000_load_ucode,
  1196. .init_alive_start = iwl5000_init_alive_start,
  1197. .alive_notify = iwl5000_alive_notify,
  1198. .send_tx_power = iwl5000_send_tx_power,
  1199. .temperature = iwl5000_temperature,
  1200. .update_chain_flags = iwl_update_chain_flags,
  1201. .apm_ops = {
  1202. .init = iwl5000_apm_init,
  1203. .reset = iwl5000_apm_reset,
  1204. .stop = iwl5000_apm_stop,
  1205. .config = iwl5000_nic_config,
  1206. .set_pwr_src = iwl_set_pwr_src,
  1207. },
  1208. .eeprom_ops = {
  1209. .regulatory_bands = {
  1210. EEPROM_5000_REG_BAND_1_CHANNELS,
  1211. EEPROM_5000_REG_BAND_2_CHANNELS,
  1212. EEPROM_5000_REG_BAND_3_CHANNELS,
  1213. EEPROM_5000_REG_BAND_4_CHANNELS,
  1214. EEPROM_5000_REG_BAND_5_CHANNELS,
  1215. EEPROM_5000_REG_BAND_24_FAT_CHANNELS,
  1216. EEPROM_5000_REG_BAND_52_FAT_CHANNELS
  1217. },
  1218. .verify_signature = iwlcore_eeprom_verify_signature,
  1219. .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
  1220. .release_semaphore = iwlcore_eeprom_release_semaphore,
  1221. .calib_version = iwl5000_eeprom_calib_version,
  1222. .query_addr = iwl5000_eeprom_query_addr,
  1223. },
  1224. };
  1225. static struct iwl_ops iwl5000_ops = {
  1226. .lib = &iwl5000_lib,
  1227. .hcmd = &iwl5000_hcmd,
  1228. .utils = &iwl5000_hcmd_utils,
  1229. };
  1230. static struct iwl_mod_params iwl50_mod_params = {
  1231. .num_of_queues = IWL50_NUM_QUEUES,
  1232. .num_of_ampdu_queues = IWL50_NUM_AMPDU_QUEUES,
  1233. .enable_qos = 1,
  1234. .amsdu_size_8K = 1,
  1235. .restart_fw = 1,
  1236. /* the rest are 0 by default */
  1237. };
  1238. struct iwl_cfg iwl5300_agn_cfg = {
  1239. .name = "5300AGN",
  1240. .fw_name = IWL5000_MODULE_FIRMWARE,
  1241. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  1242. .ops = &iwl5000_ops,
  1243. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1244. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  1245. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  1246. .mod_params = &iwl50_mod_params,
  1247. };
  1248. struct iwl_cfg iwl5100_bg_cfg = {
  1249. .name = "5100BG",
  1250. .fw_name = IWL5000_MODULE_FIRMWARE,
  1251. .sku = IWL_SKU_G,
  1252. .ops = &iwl5000_ops,
  1253. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1254. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  1255. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  1256. .mod_params = &iwl50_mod_params,
  1257. };
  1258. struct iwl_cfg iwl5100_abg_cfg = {
  1259. .name = "5100ABG",
  1260. .fw_name = IWL5000_MODULE_FIRMWARE,
  1261. .sku = IWL_SKU_A|IWL_SKU_G,
  1262. .ops = &iwl5000_ops,
  1263. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1264. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  1265. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  1266. .mod_params = &iwl50_mod_params,
  1267. };
  1268. struct iwl_cfg iwl5100_agn_cfg = {
  1269. .name = "5100AGN",
  1270. .fw_name = IWL5000_MODULE_FIRMWARE,
  1271. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  1272. .ops = &iwl5000_ops,
  1273. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1274. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  1275. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  1276. .mod_params = &iwl50_mod_params,
  1277. };
  1278. struct iwl_cfg iwl5350_agn_cfg = {
  1279. .name = "5350AGN",
  1280. .fw_name = IWL5000_MODULE_FIRMWARE,
  1281. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  1282. .ops = &iwl5000_ops,
  1283. .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
  1284. .eeprom_ver = EEPROM_5050_EEPROM_VERSION,
  1285. .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION,
  1286. .mod_params = &iwl50_mod_params,
  1287. };
  1288. MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE);
  1289. module_param_named(disable50, iwl50_mod_params.disable, int, 0444);
  1290. MODULE_PARM_DESC(disable50,
  1291. "manually disable the 50XX radio (default 0 [radio on])");
  1292. module_param_named(swcrypto50, iwl50_mod_params.sw_crypto, bool, 0444);
  1293. MODULE_PARM_DESC(swcrypto50,
  1294. "using software crypto engine (default 0 [hardware])\n");
  1295. module_param_named(debug50, iwl50_mod_params.debug, int, 0444);
  1296. MODULE_PARM_DESC(debug50, "50XX debug output mask");
  1297. module_param_named(queues_num50, iwl50_mod_params.num_of_queues, int, 0444);
  1298. MODULE_PARM_DESC(queues_num50, "number of hw queues in 50xx series");
  1299. module_param_named(qos_enable50, iwl50_mod_params.enable_qos, int, 0444);
  1300. MODULE_PARM_DESC(qos_enable50, "enable all 50XX QoS functionality");
  1301. module_param_named(11n_disable50, iwl50_mod_params.disable_11n, int, 0444);
  1302. MODULE_PARM_DESC(11n_disable50, "disable 50XX 11n functionality");
  1303. module_param_named(amsdu_size_8K50, iwl50_mod_params.amsdu_size_8K, int, 0444);
  1304. MODULE_PARM_DESC(amsdu_size_8K50, "enable 8K amsdu size in 50XX series");
  1305. module_param_named(fw_restart50, iwl50_mod_params.restart_fw, int, 0444);
  1306. MODULE_PARM_DESC(fw_restart50, "restart firmware in case of error");