mac.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983
  1. /*
  2. * Copyright (c) 2008-2009 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "hw.h"
  17. #include "hw-ops.h"
  18. static void ath9k_hw_set_txq_interrupts(struct ath_hw *ah,
  19. struct ath9k_tx_queue_info *qi)
  20. {
  21. ath_print(ath9k_hw_common(ah), ATH_DBG_INTERRUPT,
  22. "tx ok 0x%x err 0x%x desc 0x%x eol 0x%x urn 0x%x\n",
  23. ah->txok_interrupt_mask, ah->txerr_interrupt_mask,
  24. ah->txdesc_interrupt_mask, ah->txeol_interrupt_mask,
  25. ah->txurn_interrupt_mask);
  26. ENABLE_REGWRITE_BUFFER(ah);
  27. REG_WRITE(ah, AR_IMR_S0,
  28. SM(ah->txok_interrupt_mask, AR_IMR_S0_QCU_TXOK)
  29. | SM(ah->txdesc_interrupt_mask, AR_IMR_S0_QCU_TXDESC));
  30. REG_WRITE(ah, AR_IMR_S1,
  31. SM(ah->txerr_interrupt_mask, AR_IMR_S1_QCU_TXERR)
  32. | SM(ah->txeol_interrupt_mask, AR_IMR_S1_QCU_TXEOL));
  33. ah->imrs2_reg &= ~AR_IMR_S2_QCU_TXURN;
  34. ah->imrs2_reg |= (ah->txurn_interrupt_mask & AR_IMR_S2_QCU_TXURN);
  35. REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg);
  36. REGWRITE_BUFFER_FLUSH(ah);
  37. }
  38. u32 ath9k_hw_gettxbuf(struct ath_hw *ah, u32 q)
  39. {
  40. return REG_READ(ah, AR_QTXDP(q));
  41. }
  42. EXPORT_SYMBOL(ath9k_hw_gettxbuf);
  43. void ath9k_hw_puttxbuf(struct ath_hw *ah, u32 q, u32 txdp)
  44. {
  45. REG_WRITE(ah, AR_QTXDP(q), txdp);
  46. }
  47. EXPORT_SYMBOL(ath9k_hw_puttxbuf);
  48. void ath9k_hw_txstart(struct ath_hw *ah, u32 q)
  49. {
  50. ath_print(ath9k_hw_common(ah), ATH_DBG_QUEUE,
  51. "Enable TXE on queue: %u\n", q);
  52. REG_WRITE(ah, AR_Q_TXE, 1 << q);
  53. }
  54. EXPORT_SYMBOL(ath9k_hw_txstart);
  55. void ath9k_hw_cleartxdesc(struct ath_hw *ah, void *ds)
  56. {
  57. struct ar5416_desc *ads = AR5416DESC(ds);
  58. ads->ds_txstatus0 = ads->ds_txstatus1 = 0;
  59. ads->ds_txstatus2 = ads->ds_txstatus3 = 0;
  60. ads->ds_txstatus4 = ads->ds_txstatus5 = 0;
  61. ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
  62. ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
  63. }
  64. EXPORT_SYMBOL(ath9k_hw_cleartxdesc);
  65. u32 ath9k_hw_numtxpending(struct ath_hw *ah, u32 q)
  66. {
  67. u32 npend;
  68. npend = REG_READ(ah, AR_QSTS(q)) & AR_Q_STS_PEND_FR_CNT;
  69. if (npend == 0) {
  70. if (REG_READ(ah, AR_Q_TXE) & (1 << q))
  71. npend = 1;
  72. }
  73. return npend;
  74. }
  75. EXPORT_SYMBOL(ath9k_hw_numtxpending);
  76. /**
  77. * ath9k_hw_updatetxtriglevel - adjusts the frame trigger level
  78. *
  79. * @ah: atheros hardware struct
  80. * @bIncTrigLevel: whether or not the frame trigger level should be updated
  81. *
  82. * The frame trigger level specifies the minimum number of bytes,
  83. * in units of 64 bytes, that must be DMA'ed into the PCU TX FIFO
  84. * before the PCU will initiate sending the frame on the air. This can
  85. * mean we initiate transmit before a full frame is on the PCU TX FIFO.
  86. * Resets to 0x1 (meaning 64 bytes or a full frame, whichever occurs
  87. * first)
  88. *
  89. * Caution must be taken to ensure to set the frame trigger level based
  90. * on the DMA request size. For example if the DMA request size is set to
  91. * 128 bytes the trigger level cannot exceed 6 * 64 = 384. This is because
  92. * there need to be enough space in the tx FIFO for the requested transfer
  93. * size. Hence the tx FIFO will stop with 512 - 128 = 384 bytes. If we set
  94. * the threshold to a value beyond 6, then the transmit will hang.
  95. *
  96. * Current dual stream devices have a PCU TX FIFO size of 8 KB.
  97. * Current single stream devices have a PCU TX FIFO size of 4 KB, however,
  98. * there is a hardware issue which forces us to use 2 KB instead so the
  99. * frame trigger level must not exceed 2 KB for these chipsets.
  100. */
  101. bool ath9k_hw_updatetxtriglevel(struct ath_hw *ah, bool bIncTrigLevel)
  102. {
  103. u32 txcfg, curLevel, newLevel;
  104. if (ah->tx_trig_level >= ah->config.max_txtrig_level)
  105. return false;
  106. ath9k_hw_disable_interrupts(ah);
  107. txcfg = REG_READ(ah, AR_TXCFG);
  108. curLevel = MS(txcfg, AR_FTRIG);
  109. newLevel = curLevel;
  110. if (bIncTrigLevel) {
  111. if (curLevel < ah->config.max_txtrig_level)
  112. newLevel++;
  113. } else if (curLevel > MIN_TX_FIFO_THRESHOLD)
  114. newLevel--;
  115. if (newLevel != curLevel)
  116. REG_WRITE(ah, AR_TXCFG,
  117. (txcfg & ~AR_FTRIG) | SM(newLevel, AR_FTRIG));
  118. ath9k_hw_enable_interrupts(ah);
  119. ah->tx_trig_level = newLevel;
  120. return newLevel != curLevel;
  121. }
  122. EXPORT_SYMBOL(ath9k_hw_updatetxtriglevel);
  123. bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q)
  124. {
  125. #define ATH9K_TX_STOP_DMA_TIMEOUT 4000 /* usec */
  126. #define ATH9K_TIME_QUANTUM 100 /* usec */
  127. struct ath_common *common = ath9k_hw_common(ah);
  128. struct ath9k_hw_capabilities *pCap = &ah->caps;
  129. struct ath9k_tx_queue_info *qi;
  130. u32 tsfLow, j, wait;
  131. u32 wait_time = ATH9K_TX_STOP_DMA_TIMEOUT / ATH9K_TIME_QUANTUM;
  132. if (q >= pCap->total_queues) {
  133. ath_print(common, ATH_DBG_QUEUE, "Stopping TX DMA, "
  134. "invalid queue: %u\n", q);
  135. return false;
  136. }
  137. qi = &ah->txq[q];
  138. if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
  139. ath_print(common, ATH_DBG_QUEUE, "Stopping TX DMA, "
  140. "inactive queue: %u\n", q);
  141. return false;
  142. }
  143. REG_WRITE(ah, AR_Q_TXD, 1 << q);
  144. for (wait = wait_time; wait != 0; wait--) {
  145. if (ath9k_hw_numtxpending(ah, q) == 0)
  146. break;
  147. udelay(ATH9K_TIME_QUANTUM);
  148. }
  149. if (ath9k_hw_numtxpending(ah, q)) {
  150. ath_print(common, ATH_DBG_QUEUE,
  151. "%s: Num of pending TX Frames %d on Q %d\n",
  152. __func__, ath9k_hw_numtxpending(ah, q), q);
  153. for (j = 0; j < 2; j++) {
  154. tsfLow = REG_READ(ah, AR_TSF_L32);
  155. REG_WRITE(ah, AR_QUIET2,
  156. SM(10, AR_QUIET2_QUIET_DUR));
  157. REG_WRITE(ah, AR_QUIET_PERIOD, 100);
  158. REG_WRITE(ah, AR_NEXT_QUIET_TIMER, tsfLow >> 10);
  159. REG_SET_BIT(ah, AR_TIMER_MODE,
  160. AR_QUIET_TIMER_EN);
  161. if ((REG_READ(ah, AR_TSF_L32) >> 10) == (tsfLow >> 10))
  162. break;
  163. ath_print(common, ATH_DBG_QUEUE,
  164. "TSF has moved while trying to set "
  165. "quiet time TSF: 0x%08x\n", tsfLow);
  166. }
  167. REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
  168. udelay(200);
  169. REG_CLR_BIT(ah, AR_TIMER_MODE, AR_QUIET_TIMER_EN);
  170. wait = wait_time;
  171. while (ath9k_hw_numtxpending(ah, q)) {
  172. if ((--wait) == 0) {
  173. ath_print(common, ATH_DBG_FATAL,
  174. "Failed to stop TX DMA in 100 "
  175. "msec after killing last frame\n");
  176. break;
  177. }
  178. udelay(ATH9K_TIME_QUANTUM);
  179. }
  180. REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
  181. }
  182. REG_WRITE(ah, AR_Q_TXD, 0);
  183. return wait != 0;
  184. #undef ATH9K_TX_STOP_DMA_TIMEOUT
  185. #undef ATH9K_TIME_QUANTUM
  186. }
  187. EXPORT_SYMBOL(ath9k_hw_stoptxdma);
  188. void ath9k_hw_gettxintrtxqs(struct ath_hw *ah, u32 *txqs)
  189. {
  190. *txqs &= ah->intr_txqs;
  191. ah->intr_txqs &= ~(*txqs);
  192. }
  193. EXPORT_SYMBOL(ath9k_hw_gettxintrtxqs);
  194. bool ath9k_hw_set_txq_props(struct ath_hw *ah, int q,
  195. const struct ath9k_tx_queue_info *qinfo)
  196. {
  197. u32 cw;
  198. struct ath_common *common = ath9k_hw_common(ah);
  199. struct ath9k_hw_capabilities *pCap = &ah->caps;
  200. struct ath9k_tx_queue_info *qi;
  201. if (q >= pCap->total_queues) {
  202. ath_print(common, ATH_DBG_QUEUE, "Set TXQ properties, "
  203. "invalid queue: %u\n", q);
  204. return false;
  205. }
  206. qi = &ah->txq[q];
  207. if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
  208. ath_print(common, ATH_DBG_QUEUE, "Set TXQ properties, "
  209. "inactive queue: %u\n", q);
  210. return false;
  211. }
  212. ath_print(common, ATH_DBG_QUEUE, "Set queue properties for: %u\n", q);
  213. qi->tqi_ver = qinfo->tqi_ver;
  214. qi->tqi_subtype = qinfo->tqi_subtype;
  215. qi->tqi_qflags = qinfo->tqi_qflags;
  216. qi->tqi_priority = qinfo->tqi_priority;
  217. if (qinfo->tqi_aifs != ATH9K_TXQ_USEDEFAULT)
  218. qi->tqi_aifs = min(qinfo->tqi_aifs, 255U);
  219. else
  220. qi->tqi_aifs = INIT_AIFS;
  221. if (qinfo->tqi_cwmin != ATH9K_TXQ_USEDEFAULT) {
  222. cw = min(qinfo->tqi_cwmin, 1024U);
  223. qi->tqi_cwmin = 1;
  224. while (qi->tqi_cwmin < cw)
  225. qi->tqi_cwmin = (qi->tqi_cwmin << 1) | 1;
  226. } else
  227. qi->tqi_cwmin = qinfo->tqi_cwmin;
  228. if (qinfo->tqi_cwmax != ATH9K_TXQ_USEDEFAULT) {
  229. cw = min(qinfo->tqi_cwmax, 1024U);
  230. qi->tqi_cwmax = 1;
  231. while (qi->tqi_cwmax < cw)
  232. qi->tqi_cwmax = (qi->tqi_cwmax << 1) | 1;
  233. } else
  234. qi->tqi_cwmax = INIT_CWMAX;
  235. if (qinfo->tqi_shretry != 0)
  236. qi->tqi_shretry = min((u32) qinfo->tqi_shretry, 15U);
  237. else
  238. qi->tqi_shretry = INIT_SH_RETRY;
  239. if (qinfo->tqi_lgretry != 0)
  240. qi->tqi_lgretry = min((u32) qinfo->tqi_lgretry, 15U);
  241. else
  242. qi->tqi_lgretry = INIT_LG_RETRY;
  243. qi->tqi_cbrPeriod = qinfo->tqi_cbrPeriod;
  244. qi->tqi_cbrOverflowLimit = qinfo->tqi_cbrOverflowLimit;
  245. qi->tqi_burstTime = qinfo->tqi_burstTime;
  246. qi->tqi_readyTime = qinfo->tqi_readyTime;
  247. switch (qinfo->tqi_subtype) {
  248. case ATH9K_WME_UPSD:
  249. if (qi->tqi_type == ATH9K_TX_QUEUE_DATA)
  250. qi->tqi_intFlags = ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS;
  251. break;
  252. default:
  253. break;
  254. }
  255. return true;
  256. }
  257. EXPORT_SYMBOL(ath9k_hw_set_txq_props);
  258. bool ath9k_hw_get_txq_props(struct ath_hw *ah, int q,
  259. struct ath9k_tx_queue_info *qinfo)
  260. {
  261. struct ath_common *common = ath9k_hw_common(ah);
  262. struct ath9k_hw_capabilities *pCap = &ah->caps;
  263. struct ath9k_tx_queue_info *qi;
  264. if (q >= pCap->total_queues) {
  265. ath_print(common, ATH_DBG_QUEUE, "Get TXQ properties, "
  266. "invalid queue: %u\n", q);
  267. return false;
  268. }
  269. qi = &ah->txq[q];
  270. if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
  271. ath_print(common, ATH_DBG_QUEUE, "Get TXQ properties, "
  272. "inactive queue: %u\n", q);
  273. return false;
  274. }
  275. qinfo->tqi_qflags = qi->tqi_qflags;
  276. qinfo->tqi_ver = qi->tqi_ver;
  277. qinfo->tqi_subtype = qi->tqi_subtype;
  278. qinfo->tqi_qflags = qi->tqi_qflags;
  279. qinfo->tqi_priority = qi->tqi_priority;
  280. qinfo->tqi_aifs = qi->tqi_aifs;
  281. qinfo->tqi_cwmin = qi->tqi_cwmin;
  282. qinfo->tqi_cwmax = qi->tqi_cwmax;
  283. qinfo->tqi_shretry = qi->tqi_shretry;
  284. qinfo->tqi_lgretry = qi->tqi_lgretry;
  285. qinfo->tqi_cbrPeriod = qi->tqi_cbrPeriod;
  286. qinfo->tqi_cbrOverflowLimit = qi->tqi_cbrOverflowLimit;
  287. qinfo->tqi_burstTime = qi->tqi_burstTime;
  288. qinfo->tqi_readyTime = qi->tqi_readyTime;
  289. return true;
  290. }
  291. EXPORT_SYMBOL(ath9k_hw_get_txq_props);
  292. int ath9k_hw_setuptxqueue(struct ath_hw *ah, enum ath9k_tx_queue type,
  293. const struct ath9k_tx_queue_info *qinfo)
  294. {
  295. struct ath_common *common = ath9k_hw_common(ah);
  296. struct ath9k_tx_queue_info *qi;
  297. struct ath9k_hw_capabilities *pCap = &ah->caps;
  298. int q;
  299. switch (type) {
  300. case ATH9K_TX_QUEUE_BEACON:
  301. q = pCap->total_queues - 1;
  302. break;
  303. case ATH9K_TX_QUEUE_CAB:
  304. q = pCap->total_queues - 2;
  305. break;
  306. case ATH9K_TX_QUEUE_PSPOLL:
  307. q = 1;
  308. break;
  309. case ATH9K_TX_QUEUE_UAPSD:
  310. q = pCap->total_queues - 3;
  311. break;
  312. case ATH9K_TX_QUEUE_DATA:
  313. for (q = 0; q < pCap->total_queues; q++)
  314. if (ah->txq[q].tqi_type ==
  315. ATH9K_TX_QUEUE_INACTIVE)
  316. break;
  317. if (q == pCap->total_queues) {
  318. ath_print(common, ATH_DBG_FATAL,
  319. "No available TX queue\n");
  320. return -1;
  321. }
  322. break;
  323. default:
  324. ath_print(common, ATH_DBG_FATAL,
  325. "Invalid TX queue type: %u\n", type);
  326. return -1;
  327. }
  328. ath_print(common, ATH_DBG_QUEUE, "Setup TX queue: %u\n", q);
  329. qi = &ah->txq[q];
  330. if (qi->tqi_type != ATH9K_TX_QUEUE_INACTIVE) {
  331. ath_print(common, ATH_DBG_FATAL,
  332. "TX queue: %u already active\n", q);
  333. return -1;
  334. }
  335. memset(qi, 0, sizeof(struct ath9k_tx_queue_info));
  336. qi->tqi_type = type;
  337. if (qinfo == NULL) {
  338. qi->tqi_qflags =
  339. TXQ_FLAG_TXOKINT_ENABLE
  340. | TXQ_FLAG_TXERRINT_ENABLE
  341. | TXQ_FLAG_TXDESCINT_ENABLE | TXQ_FLAG_TXURNINT_ENABLE;
  342. qi->tqi_aifs = INIT_AIFS;
  343. qi->tqi_cwmin = ATH9K_TXQ_USEDEFAULT;
  344. qi->tqi_cwmax = INIT_CWMAX;
  345. qi->tqi_shretry = INIT_SH_RETRY;
  346. qi->tqi_lgretry = INIT_LG_RETRY;
  347. qi->tqi_physCompBuf = 0;
  348. } else {
  349. qi->tqi_physCompBuf = qinfo->tqi_physCompBuf;
  350. (void) ath9k_hw_set_txq_props(ah, q, qinfo);
  351. }
  352. return q;
  353. }
  354. EXPORT_SYMBOL(ath9k_hw_setuptxqueue);
  355. bool ath9k_hw_releasetxqueue(struct ath_hw *ah, u32 q)
  356. {
  357. struct ath9k_hw_capabilities *pCap = &ah->caps;
  358. struct ath_common *common = ath9k_hw_common(ah);
  359. struct ath9k_tx_queue_info *qi;
  360. if (q >= pCap->total_queues) {
  361. ath_print(common, ATH_DBG_QUEUE, "Release TXQ, "
  362. "invalid queue: %u\n", q);
  363. return false;
  364. }
  365. qi = &ah->txq[q];
  366. if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
  367. ath_print(common, ATH_DBG_QUEUE, "Release TXQ, "
  368. "inactive queue: %u\n", q);
  369. return false;
  370. }
  371. ath_print(common, ATH_DBG_QUEUE, "Release TX queue: %u\n", q);
  372. qi->tqi_type = ATH9K_TX_QUEUE_INACTIVE;
  373. ah->txok_interrupt_mask &= ~(1 << q);
  374. ah->txerr_interrupt_mask &= ~(1 << q);
  375. ah->txdesc_interrupt_mask &= ~(1 << q);
  376. ah->txeol_interrupt_mask &= ~(1 << q);
  377. ah->txurn_interrupt_mask &= ~(1 << q);
  378. ath9k_hw_set_txq_interrupts(ah, qi);
  379. return true;
  380. }
  381. EXPORT_SYMBOL(ath9k_hw_releasetxqueue);
  382. bool ath9k_hw_resettxqueue(struct ath_hw *ah, u32 q)
  383. {
  384. struct ath9k_hw_capabilities *pCap = &ah->caps;
  385. struct ath_common *common = ath9k_hw_common(ah);
  386. struct ath9k_channel *chan = ah->curchan;
  387. struct ath9k_tx_queue_info *qi;
  388. u32 cwMin, chanCwMin, value;
  389. if (q >= pCap->total_queues) {
  390. ath_print(common, ATH_DBG_QUEUE, "Reset TXQ, "
  391. "invalid queue: %u\n", q);
  392. return false;
  393. }
  394. qi = &ah->txq[q];
  395. if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
  396. ath_print(common, ATH_DBG_QUEUE, "Reset TXQ, "
  397. "inactive queue: %u\n", q);
  398. return true;
  399. }
  400. ath_print(common, ATH_DBG_QUEUE, "Reset TX queue: %u\n", q);
  401. if (qi->tqi_cwmin == ATH9K_TXQ_USEDEFAULT) {
  402. if (chan && IS_CHAN_B(chan))
  403. chanCwMin = INIT_CWMIN_11B;
  404. else
  405. chanCwMin = INIT_CWMIN;
  406. for (cwMin = 1; cwMin < chanCwMin; cwMin = (cwMin << 1) | 1);
  407. } else
  408. cwMin = qi->tqi_cwmin;
  409. ENABLE_REGWRITE_BUFFER(ah);
  410. REG_WRITE(ah, AR_DLCL_IFS(q),
  411. SM(cwMin, AR_D_LCL_IFS_CWMIN) |
  412. SM(qi->tqi_cwmax, AR_D_LCL_IFS_CWMAX) |
  413. SM(qi->tqi_aifs, AR_D_LCL_IFS_AIFS));
  414. REG_WRITE(ah, AR_DRETRY_LIMIT(q),
  415. SM(INIT_SSH_RETRY, AR_D_RETRY_LIMIT_STA_SH) |
  416. SM(INIT_SLG_RETRY, AR_D_RETRY_LIMIT_STA_LG) |
  417. SM(qi->tqi_shretry, AR_D_RETRY_LIMIT_FR_SH));
  418. REG_WRITE(ah, AR_QMISC(q), AR_Q_MISC_DCU_EARLY_TERM_REQ);
  419. REG_WRITE(ah, AR_DMISC(q),
  420. AR_D_MISC_CW_BKOFF_EN | AR_D_MISC_FRAG_WAIT_EN | 0x2);
  421. if (qi->tqi_cbrPeriod) {
  422. REG_WRITE(ah, AR_QCBRCFG(q),
  423. SM(qi->tqi_cbrPeriod, AR_Q_CBRCFG_INTERVAL) |
  424. SM(qi->tqi_cbrOverflowLimit, AR_Q_CBRCFG_OVF_THRESH));
  425. REG_WRITE(ah, AR_QMISC(q),
  426. REG_READ(ah, AR_QMISC(q)) | AR_Q_MISC_FSP_CBR |
  427. (qi->tqi_cbrOverflowLimit ?
  428. AR_Q_MISC_CBR_EXP_CNTR_LIMIT_EN : 0));
  429. }
  430. if (qi->tqi_readyTime && (qi->tqi_type != ATH9K_TX_QUEUE_CAB)) {
  431. REG_WRITE(ah, AR_QRDYTIMECFG(q),
  432. SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_DURATION) |
  433. AR_Q_RDYTIMECFG_EN);
  434. }
  435. REG_WRITE(ah, AR_DCHNTIME(q),
  436. SM(qi->tqi_burstTime, AR_D_CHNTIME_DUR) |
  437. (qi->tqi_burstTime ? AR_D_CHNTIME_EN : 0));
  438. if (qi->tqi_burstTime
  439. && (qi->tqi_qflags & TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE)) {
  440. REG_WRITE(ah, AR_QMISC(q),
  441. REG_READ(ah, AR_QMISC(q)) |
  442. AR_Q_MISC_RDYTIME_EXP_POLICY);
  443. }
  444. if (qi->tqi_qflags & TXQ_FLAG_BACKOFF_DISABLE) {
  445. REG_WRITE(ah, AR_DMISC(q),
  446. REG_READ(ah, AR_DMISC(q)) |
  447. AR_D_MISC_POST_FR_BKOFF_DIS);
  448. }
  449. REGWRITE_BUFFER_FLUSH(ah);
  450. if (qi->tqi_qflags & TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE) {
  451. REG_WRITE(ah, AR_DMISC(q),
  452. REG_READ(ah, AR_DMISC(q)) |
  453. AR_D_MISC_FRAG_BKOFF_EN);
  454. }
  455. switch (qi->tqi_type) {
  456. case ATH9K_TX_QUEUE_BEACON:
  457. ENABLE_REGWRITE_BUFFER(ah);
  458. REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q))
  459. | AR_Q_MISC_FSP_DBA_GATED
  460. | AR_Q_MISC_BEACON_USE
  461. | AR_Q_MISC_CBR_INCR_DIS1);
  462. REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q))
  463. | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
  464. AR_D_MISC_ARB_LOCKOUT_CNTRL_S)
  465. | AR_D_MISC_BEACON_USE
  466. | AR_D_MISC_POST_FR_BKOFF_DIS);
  467. REGWRITE_BUFFER_FLUSH(ah);
  468. /*
  469. * cwmin and cwmax should be 0 for beacon queue
  470. * but not for IBSS as we would create an imbalance
  471. * on beaconing fairness for participating nodes.
  472. */
  473. if (AR_SREV_9300_20_OR_LATER(ah) &&
  474. ah->opmode != NL80211_IFTYPE_ADHOC) {
  475. REG_WRITE(ah, AR_DLCL_IFS(q), SM(0, AR_D_LCL_IFS_CWMIN)
  476. | SM(0, AR_D_LCL_IFS_CWMAX)
  477. | SM(qi->tqi_aifs, AR_D_LCL_IFS_AIFS));
  478. }
  479. break;
  480. case ATH9K_TX_QUEUE_CAB:
  481. ENABLE_REGWRITE_BUFFER(ah);
  482. REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q))
  483. | AR_Q_MISC_FSP_DBA_GATED
  484. | AR_Q_MISC_CBR_INCR_DIS1
  485. | AR_Q_MISC_CBR_INCR_DIS0);
  486. value = (qi->tqi_readyTime -
  487. (ah->config.sw_beacon_response_time -
  488. ah->config.dma_beacon_response_time) -
  489. ah->config.additional_swba_backoff) * 1024;
  490. REG_WRITE(ah, AR_QRDYTIMECFG(q),
  491. value | AR_Q_RDYTIMECFG_EN);
  492. REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q))
  493. | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
  494. AR_D_MISC_ARB_LOCKOUT_CNTRL_S));
  495. REGWRITE_BUFFER_FLUSH(ah);
  496. break;
  497. case ATH9K_TX_QUEUE_PSPOLL:
  498. REG_WRITE(ah, AR_QMISC(q),
  499. REG_READ(ah, AR_QMISC(q)) | AR_Q_MISC_CBR_INCR_DIS1);
  500. break;
  501. case ATH9K_TX_QUEUE_UAPSD:
  502. REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q)) |
  503. AR_D_MISC_POST_FR_BKOFF_DIS);
  504. break;
  505. default:
  506. break;
  507. }
  508. if (qi->tqi_intFlags & ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS) {
  509. REG_WRITE(ah, AR_DMISC(q),
  510. REG_READ(ah, AR_DMISC(q)) |
  511. SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL,
  512. AR_D_MISC_ARB_LOCKOUT_CNTRL) |
  513. AR_D_MISC_POST_FR_BKOFF_DIS);
  514. }
  515. if (AR_SREV_9300_20_OR_LATER(ah))
  516. REG_WRITE(ah, AR_Q_DESC_CRCCHK, AR_Q_DESC_CRCCHK_EN);
  517. if (qi->tqi_qflags & TXQ_FLAG_TXOKINT_ENABLE)
  518. ah->txok_interrupt_mask |= 1 << q;
  519. else
  520. ah->txok_interrupt_mask &= ~(1 << q);
  521. if (qi->tqi_qflags & TXQ_FLAG_TXERRINT_ENABLE)
  522. ah->txerr_interrupt_mask |= 1 << q;
  523. else
  524. ah->txerr_interrupt_mask &= ~(1 << q);
  525. if (qi->tqi_qflags & TXQ_FLAG_TXDESCINT_ENABLE)
  526. ah->txdesc_interrupt_mask |= 1 << q;
  527. else
  528. ah->txdesc_interrupt_mask &= ~(1 << q);
  529. if (qi->tqi_qflags & TXQ_FLAG_TXEOLINT_ENABLE)
  530. ah->txeol_interrupt_mask |= 1 << q;
  531. else
  532. ah->txeol_interrupt_mask &= ~(1 << q);
  533. if (qi->tqi_qflags & TXQ_FLAG_TXURNINT_ENABLE)
  534. ah->txurn_interrupt_mask |= 1 << q;
  535. else
  536. ah->txurn_interrupt_mask &= ~(1 << q);
  537. ath9k_hw_set_txq_interrupts(ah, qi);
  538. return true;
  539. }
  540. EXPORT_SYMBOL(ath9k_hw_resettxqueue);
  541. int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds,
  542. struct ath_rx_status *rs, u64 tsf)
  543. {
  544. struct ar5416_desc ads;
  545. struct ar5416_desc *adsp = AR5416DESC(ds);
  546. u32 phyerr;
  547. if ((adsp->ds_rxstatus8 & AR_RxDone) == 0)
  548. return -EINPROGRESS;
  549. ads.u.rx = adsp->u.rx;
  550. rs->rs_status = 0;
  551. rs->rs_flags = 0;
  552. rs->rs_datalen = ads.ds_rxstatus1 & AR_DataLen;
  553. rs->rs_tstamp = ads.AR_RcvTimestamp;
  554. if (ads.ds_rxstatus8 & AR_PostDelimCRCErr) {
  555. rs->rs_rssi = ATH9K_RSSI_BAD;
  556. rs->rs_rssi_ctl0 = ATH9K_RSSI_BAD;
  557. rs->rs_rssi_ctl1 = ATH9K_RSSI_BAD;
  558. rs->rs_rssi_ctl2 = ATH9K_RSSI_BAD;
  559. rs->rs_rssi_ext0 = ATH9K_RSSI_BAD;
  560. rs->rs_rssi_ext1 = ATH9K_RSSI_BAD;
  561. rs->rs_rssi_ext2 = ATH9K_RSSI_BAD;
  562. } else {
  563. rs->rs_rssi = MS(ads.ds_rxstatus4, AR_RxRSSICombined);
  564. rs->rs_rssi_ctl0 = MS(ads.ds_rxstatus0,
  565. AR_RxRSSIAnt00);
  566. rs->rs_rssi_ctl1 = MS(ads.ds_rxstatus0,
  567. AR_RxRSSIAnt01);
  568. rs->rs_rssi_ctl2 = MS(ads.ds_rxstatus0,
  569. AR_RxRSSIAnt02);
  570. rs->rs_rssi_ext0 = MS(ads.ds_rxstatus4,
  571. AR_RxRSSIAnt10);
  572. rs->rs_rssi_ext1 = MS(ads.ds_rxstatus4,
  573. AR_RxRSSIAnt11);
  574. rs->rs_rssi_ext2 = MS(ads.ds_rxstatus4,
  575. AR_RxRSSIAnt12);
  576. }
  577. if (ads.ds_rxstatus8 & AR_RxKeyIdxValid)
  578. rs->rs_keyix = MS(ads.ds_rxstatus8, AR_KeyIdx);
  579. else
  580. rs->rs_keyix = ATH9K_RXKEYIX_INVALID;
  581. rs->rs_rate = RXSTATUS_RATE(ah, (&ads));
  582. rs->rs_more = (ads.ds_rxstatus1 & AR_RxMore) ? 1 : 0;
  583. rs->rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ? 1 : 0;
  584. rs->rs_moreaggr =
  585. (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0;
  586. rs->rs_antenna = MS(ads.ds_rxstatus3, AR_RxAntenna);
  587. rs->rs_flags =
  588. (ads.ds_rxstatus3 & AR_GI) ? ATH9K_RX_GI : 0;
  589. rs->rs_flags |=
  590. (ads.ds_rxstatus3 & AR_2040) ? ATH9K_RX_2040 : 0;
  591. if (ads.ds_rxstatus8 & AR_PreDelimCRCErr)
  592. rs->rs_flags |= ATH9K_RX_DELIM_CRC_PRE;
  593. if (ads.ds_rxstatus8 & AR_PostDelimCRCErr)
  594. rs->rs_flags |= ATH9K_RX_DELIM_CRC_POST;
  595. if (ads.ds_rxstatus8 & AR_DecryptBusyErr)
  596. rs->rs_flags |= ATH9K_RX_DECRYPT_BUSY;
  597. if ((ads.ds_rxstatus8 & AR_RxFrameOK) == 0) {
  598. if (ads.ds_rxstatus8 & AR_CRCErr)
  599. rs->rs_status |= ATH9K_RXERR_CRC;
  600. else if (ads.ds_rxstatus8 & AR_PHYErr) {
  601. rs->rs_status |= ATH9K_RXERR_PHY;
  602. phyerr = MS(ads.ds_rxstatus8, AR_PHYErrCode);
  603. rs->rs_phyerr = phyerr;
  604. } else if (ads.ds_rxstatus8 & AR_DecryptCRCErr)
  605. rs->rs_status |= ATH9K_RXERR_DECRYPT;
  606. else if ((ads.ds_rxstatus8 & AR_MichaelErr) &&
  607. rs->rs_keyix != ATH9K_RXKEYIX_INVALID)
  608. rs->rs_status |= ATH9K_RXERR_MIC;
  609. else if (ads.ds_rxstatus8 & AR_KeyMiss)
  610. rs->rs_status |= ATH9K_RXERR_DECRYPT;
  611. }
  612. return 0;
  613. }
  614. EXPORT_SYMBOL(ath9k_hw_rxprocdesc);
  615. /*
  616. * This can stop or re-enables RX.
  617. *
  618. * If bool is set this will kill any frame which is currently being
  619. * transferred between the MAC and baseband and also prevent any new
  620. * frames from getting started.
  621. */
  622. bool ath9k_hw_setrxabort(struct ath_hw *ah, bool set)
  623. {
  624. u32 reg;
  625. if (set) {
  626. REG_SET_BIT(ah, AR_DIAG_SW,
  627. (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
  628. if (!ath9k_hw_wait(ah, AR_OBS_BUS_1, AR_OBS_BUS_1_RX_STATE,
  629. 0, AH_WAIT_TIMEOUT)) {
  630. REG_CLR_BIT(ah, AR_DIAG_SW,
  631. (AR_DIAG_RX_DIS |
  632. AR_DIAG_RX_ABORT));
  633. reg = REG_READ(ah, AR_OBS_BUS_1);
  634. ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
  635. "RX failed to go idle in 10 ms RXSM=0x%x\n",
  636. reg);
  637. return false;
  638. }
  639. } else {
  640. REG_CLR_BIT(ah, AR_DIAG_SW,
  641. (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
  642. }
  643. return true;
  644. }
  645. EXPORT_SYMBOL(ath9k_hw_setrxabort);
  646. void ath9k_hw_putrxbuf(struct ath_hw *ah, u32 rxdp)
  647. {
  648. REG_WRITE(ah, AR_RXDP, rxdp);
  649. }
  650. EXPORT_SYMBOL(ath9k_hw_putrxbuf);
  651. void ath9k_hw_startpcureceive(struct ath_hw *ah, bool is_scanning)
  652. {
  653. ath9k_enable_mib_counters(ah);
  654. ath9k_ani_reset(ah, is_scanning);
  655. REG_CLR_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
  656. }
  657. EXPORT_SYMBOL(ath9k_hw_startpcureceive);
  658. void ath9k_hw_stoppcurecv(struct ath_hw *ah)
  659. {
  660. REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
  661. ath9k_hw_disable_mib_counters(ah);
  662. }
  663. EXPORT_SYMBOL(ath9k_hw_stoppcurecv);
  664. void ath9k_hw_abortpcurecv(struct ath_hw *ah)
  665. {
  666. REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_ABORT | AR_DIAG_RX_DIS);
  667. ath9k_hw_disable_mib_counters(ah);
  668. }
  669. EXPORT_SYMBOL(ath9k_hw_abortpcurecv);
  670. bool ath9k_hw_stopdmarecv(struct ath_hw *ah)
  671. {
  672. #define AH_RX_STOP_DMA_TIMEOUT 10000 /* usec */
  673. #define AH_RX_TIME_QUANTUM 100 /* usec */
  674. struct ath_common *common = ath9k_hw_common(ah);
  675. int i;
  676. REG_WRITE(ah, AR_CR, AR_CR_RXD);
  677. /* Wait for rx enable bit to go low */
  678. for (i = AH_RX_STOP_DMA_TIMEOUT / AH_TIME_QUANTUM; i != 0; i--) {
  679. if ((REG_READ(ah, AR_CR) & AR_CR_RXE) == 0)
  680. break;
  681. udelay(AH_TIME_QUANTUM);
  682. }
  683. if (i == 0) {
  684. ath_print(common, ATH_DBG_FATAL,
  685. "DMA failed to stop in %d ms "
  686. "AR_CR=0x%08x AR_DIAG_SW=0x%08x\n",
  687. AH_RX_STOP_DMA_TIMEOUT / 1000,
  688. REG_READ(ah, AR_CR),
  689. REG_READ(ah, AR_DIAG_SW));
  690. return false;
  691. } else {
  692. return true;
  693. }
  694. #undef AH_RX_TIME_QUANTUM
  695. #undef AH_RX_STOP_DMA_TIMEOUT
  696. }
  697. EXPORT_SYMBOL(ath9k_hw_stopdmarecv);
  698. int ath9k_hw_beaconq_setup(struct ath_hw *ah)
  699. {
  700. struct ath9k_tx_queue_info qi;
  701. memset(&qi, 0, sizeof(qi));
  702. qi.tqi_aifs = 1;
  703. qi.tqi_cwmin = 0;
  704. qi.tqi_cwmax = 0;
  705. /* NB: don't enable any interrupts */
  706. return ath9k_hw_setuptxqueue(ah, ATH9K_TX_QUEUE_BEACON, &qi);
  707. }
  708. EXPORT_SYMBOL(ath9k_hw_beaconq_setup);
  709. bool ath9k_hw_intrpend(struct ath_hw *ah)
  710. {
  711. u32 host_isr;
  712. if (AR_SREV_9100(ah))
  713. return true;
  714. host_isr = REG_READ(ah, AR_INTR_ASYNC_CAUSE);
  715. if ((host_isr & AR_INTR_MAC_IRQ) && (host_isr != AR_INTR_SPURIOUS))
  716. return true;
  717. host_isr = REG_READ(ah, AR_INTR_SYNC_CAUSE);
  718. if ((host_isr & AR_INTR_SYNC_DEFAULT)
  719. && (host_isr != AR_INTR_SPURIOUS))
  720. return true;
  721. return false;
  722. }
  723. EXPORT_SYMBOL(ath9k_hw_intrpend);
  724. void ath9k_hw_disable_interrupts(struct ath_hw *ah)
  725. {
  726. struct ath_common *common = ath9k_hw_common(ah);
  727. ath_print(common, ATH_DBG_INTERRUPT, "disable IER\n");
  728. REG_WRITE(ah, AR_IER, AR_IER_DISABLE);
  729. (void) REG_READ(ah, AR_IER);
  730. if (!AR_SREV_9100(ah)) {
  731. REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, 0);
  732. (void) REG_READ(ah, AR_INTR_ASYNC_ENABLE);
  733. REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0);
  734. (void) REG_READ(ah, AR_INTR_SYNC_ENABLE);
  735. }
  736. }
  737. EXPORT_SYMBOL(ath9k_hw_disable_interrupts);
  738. void ath9k_hw_enable_interrupts(struct ath_hw *ah)
  739. {
  740. struct ath_common *common = ath9k_hw_common(ah);
  741. if (!(ah->imask & ATH9K_INT_GLOBAL))
  742. return;
  743. ath_print(common, ATH_DBG_INTERRUPT, "enable IER\n");
  744. REG_WRITE(ah, AR_IER, AR_IER_ENABLE);
  745. if (!AR_SREV_9100(ah)) {
  746. REG_WRITE(ah, AR_INTR_ASYNC_ENABLE,
  747. AR_INTR_MAC_IRQ);
  748. REG_WRITE(ah, AR_INTR_ASYNC_MASK, AR_INTR_MAC_IRQ);
  749. REG_WRITE(ah, AR_INTR_SYNC_ENABLE,
  750. AR_INTR_SYNC_DEFAULT);
  751. REG_WRITE(ah, AR_INTR_SYNC_MASK,
  752. AR_INTR_SYNC_DEFAULT);
  753. }
  754. ath_print(common, ATH_DBG_INTERRUPT, "AR_IMR 0x%x IER 0x%x\n",
  755. REG_READ(ah, AR_IMR), REG_READ(ah, AR_IER));
  756. }
  757. EXPORT_SYMBOL(ath9k_hw_enable_interrupts);
  758. void ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints)
  759. {
  760. enum ath9k_int omask = ah->imask;
  761. u32 mask, mask2;
  762. struct ath9k_hw_capabilities *pCap = &ah->caps;
  763. struct ath_common *common = ath9k_hw_common(ah);
  764. if (!(ints & ATH9K_INT_GLOBAL))
  765. ath9k_hw_enable_interrupts(ah);
  766. ath_print(common, ATH_DBG_INTERRUPT, "0x%x => 0x%x\n", omask, ints);
  767. /* TODO: global int Ref count */
  768. mask = ints & ATH9K_INT_COMMON;
  769. mask2 = 0;
  770. if (ints & ATH9K_INT_TX) {
  771. if (ah->config.tx_intr_mitigation)
  772. mask |= AR_IMR_TXMINTR | AR_IMR_TXINTM;
  773. else {
  774. if (ah->txok_interrupt_mask)
  775. mask |= AR_IMR_TXOK;
  776. if (ah->txdesc_interrupt_mask)
  777. mask |= AR_IMR_TXDESC;
  778. }
  779. if (ah->txerr_interrupt_mask)
  780. mask |= AR_IMR_TXERR;
  781. if (ah->txeol_interrupt_mask)
  782. mask |= AR_IMR_TXEOL;
  783. }
  784. if (ints & ATH9K_INT_RX) {
  785. if (AR_SREV_9300_20_OR_LATER(ah)) {
  786. mask |= AR_IMR_RXERR | AR_IMR_RXOK_HP;
  787. if (ah->config.rx_intr_mitigation) {
  788. mask &= ~AR_IMR_RXOK_LP;
  789. mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM;
  790. } else {
  791. mask |= AR_IMR_RXOK_LP;
  792. }
  793. } else {
  794. if (ah->config.rx_intr_mitigation)
  795. mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM;
  796. else
  797. mask |= AR_IMR_RXOK | AR_IMR_RXDESC;
  798. }
  799. if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
  800. mask |= AR_IMR_GENTMR;
  801. }
  802. if (ints & (ATH9K_INT_BMISC)) {
  803. mask |= AR_IMR_BCNMISC;
  804. if (ints & ATH9K_INT_TIM)
  805. mask2 |= AR_IMR_S2_TIM;
  806. if (ints & ATH9K_INT_DTIM)
  807. mask2 |= AR_IMR_S2_DTIM;
  808. if (ints & ATH9K_INT_DTIMSYNC)
  809. mask2 |= AR_IMR_S2_DTIMSYNC;
  810. if (ints & ATH9K_INT_CABEND)
  811. mask2 |= AR_IMR_S2_CABEND;
  812. if (ints & ATH9K_INT_TSFOOR)
  813. mask2 |= AR_IMR_S2_TSFOOR;
  814. }
  815. if (ints & (ATH9K_INT_GTT | ATH9K_INT_CST)) {
  816. mask |= AR_IMR_BCNMISC;
  817. if (ints & ATH9K_INT_GTT)
  818. mask2 |= AR_IMR_S2_GTT;
  819. if (ints & ATH9K_INT_CST)
  820. mask2 |= AR_IMR_S2_CST;
  821. }
  822. ath_print(common, ATH_DBG_INTERRUPT, "new IMR 0x%x\n", mask);
  823. REG_WRITE(ah, AR_IMR, mask);
  824. ah->imrs2_reg &= ~(AR_IMR_S2_TIM | AR_IMR_S2_DTIM | AR_IMR_S2_DTIMSYNC |
  825. AR_IMR_S2_CABEND | AR_IMR_S2_CABTO |
  826. AR_IMR_S2_TSFOOR | AR_IMR_S2_GTT | AR_IMR_S2_CST);
  827. ah->imrs2_reg |= mask2;
  828. REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg);
  829. if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
  830. if (ints & ATH9K_INT_TIM_TIMER)
  831. REG_SET_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER);
  832. else
  833. REG_CLR_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER);
  834. }
  835. ath9k_hw_enable_interrupts(ah);
  836. return;
  837. }
  838. EXPORT_SYMBOL(ath9k_hw_set_interrupts);