iwl-5000.c 46 KB

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