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