iwl-5000.c 47 KB

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