iwl-5000.c 45 KB

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