iwl-5000.c 48 KB

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