iwl-5000.c 46 KB

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