iwl-5000.c 46 KB

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