mac.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976
  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_dbg(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_dbg(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_dbg(common, ATH_DBG_QUEUE,
  134. "Stopping TX DMA, 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_dbg(common, ATH_DBG_QUEUE,
  140. "Stopping TX DMA, 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_dbg(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_dbg(common, ATH_DBG_QUEUE,
  164. "TSF has moved while trying to set quiet time TSF: 0x%08x\n",
  165. 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_err(common,
  174. "Failed to stop TX DMA in 100 msec after killing last frame\n");
  175. break;
  176. }
  177. udelay(ATH9K_TIME_QUANTUM);
  178. }
  179. REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
  180. }
  181. REG_WRITE(ah, AR_Q_TXD, 0);
  182. return wait != 0;
  183. #undef ATH9K_TX_STOP_DMA_TIMEOUT
  184. #undef ATH9K_TIME_QUANTUM
  185. }
  186. EXPORT_SYMBOL(ath9k_hw_stoptxdma);
  187. void ath9k_hw_gettxintrtxqs(struct ath_hw *ah, u32 *txqs)
  188. {
  189. *txqs &= ah->intr_txqs;
  190. ah->intr_txqs &= ~(*txqs);
  191. }
  192. EXPORT_SYMBOL(ath9k_hw_gettxintrtxqs);
  193. bool ath9k_hw_set_txq_props(struct ath_hw *ah, int q,
  194. const struct ath9k_tx_queue_info *qinfo)
  195. {
  196. u32 cw;
  197. struct ath_common *common = ath9k_hw_common(ah);
  198. struct ath9k_hw_capabilities *pCap = &ah->caps;
  199. struct ath9k_tx_queue_info *qi;
  200. if (q >= pCap->total_queues) {
  201. ath_dbg(common, ATH_DBG_QUEUE,
  202. "Set TXQ properties, invalid queue: %u\n", q);
  203. return false;
  204. }
  205. qi = &ah->txq[q];
  206. if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
  207. ath_dbg(common, ATH_DBG_QUEUE,
  208. "Set TXQ properties, inactive queue: %u\n", q);
  209. return false;
  210. }
  211. ath_dbg(common, ATH_DBG_QUEUE, "Set queue properties for: %u\n", q);
  212. qi->tqi_ver = qinfo->tqi_ver;
  213. qi->tqi_subtype = qinfo->tqi_subtype;
  214. qi->tqi_qflags = qinfo->tqi_qflags;
  215. qi->tqi_priority = qinfo->tqi_priority;
  216. if (qinfo->tqi_aifs != ATH9K_TXQ_USEDEFAULT)
  217. qi->tqi_aifs = min(qinfo->tqi_aifs, 255U);
  218. else
  219. qi->tqi_aifs = INIT_AIFS;
  220. if (qinfo->tqi_cwmin != ATH9K_TXQ_USEDEFAULT) {
  221. cw = min(qinfo->tqi_cwmin, 1024U);
  222. qi->tqi_cwmin = 1;
  223. while (qi->tqi_cwmin < cw)
  224. qi->tqi_cwmin = (qi->tqi_cwmin << 1) | 1;
  225. } else
  226. qi->tqi_cwmin = qinfo->tqi_cwmin;
  227. if (qinfo->tqi_cwmax != ATH9K_TXQ_USEDEFAULT) {
  228. cw = min(qinfo->tqi_cwmax, 1024U);
  229. qi->tqi_cwmax = 1;
  230. while (qi->tqi_cwmax < cw)
  231. qi->tqi_cwmax = (qi->tqi_cwmax << 1) | 1;
  232. } else
  233. qi->tqi_cwmax = INIT_CWMAX;
  234. if (qinfo->tqi_shretry != 0)
  235. qi->tqi_shretry = min((u32) qinfo->tqi_shretry, 15U);
  236. else
  237. qi->tqi_shretry = INIT_SH_RETRY;
  238. if (qinfo->tqi_lgretry != 0)
  239. qi->tqi_lgretry = min((u32) qinfo->tqi_lgretry, 15U);
  240. else
  241. qi->tqi_lgretry = INIT_LG_RETRY;
  242. qi->tqi_cbrPeriod = qinfo->tqi_cbrPeriod;
  243. qi->tqi_cbrOverflowLimit = qinfo->tqi_cbrOverflowLimit;
  244. qi->tqi_burstTime = qinfo->tqi_burstTime;
  245. qi->tqi_readyTime = qinfo->tqi_readyTime;
  246. switch (qinfo->tqi_subtype) {
  247. case ATH9K_WME_UPSD:
  248. if (qi->tqi_type == ATH9K_TX_QUEUE_DATA)
  249. qi->tqi_intFlags = ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS;
  250. break;
  251. default:
  252. break;
  253. }
  254. return true;
  255. }
  256. EXPORT_SYMBOL(ath9k_hw_set_txq_props);
  257. bool ath9k_hw_get_txq_props(struct ath_hw *ah, int q,
  258. struct ath9k_tx_queue_info *qinfo)
  259. {
  260. struct ath_common *common = ath9k_hw_common(ah);
  261. struct ath9k_hw_capabilities *pCap = &ah->caps;
  262. struct ath9k_tx_queue_info *qi;
  263. if (q >= pCap->total_queues) {
  264. ath_dbg(common, ATH_DBG_QUEUE,
  265. "Get TXQ properties, invalid queue: %u\n", q);
  266. return false;
  267. }
  268. qi = &ah->txq[q];
  269. if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
  270. ath_dbg(common, ATH_DBG_QUEUE,
  271. "Get TXQ properties, inactive queue: %u\n", q);
  272. return false;
  273. }
  274. qinfo->tqi_qflags = qi->tqi_qflags;
  275. qinfo->tqi_ver = qi->tqi_ver;
  276. qinfo->tqi_subtype = qi->tqi_subtype;
  277. qinfo->tqi_qflags = qi->tqi_qflags;
  278. qinfo->tqi_priority = qi->tqi_priority;
  279. qinfo->tqi_aifs = qi->tqi_aifs;
  280. qinfo->tqi_cwmin = qi->tqi_cwmin;
  281. qinfo->tqi_cwmax = qi->tqi_cwmax;
  282. qinfo->tqi_shretry = qi->tqi_shretry;
  283. qinfo->tqi_lgretry = qi->tqi_lgretry;
  284. qinfo->tqi_cbrPeriod = qi->tqi_cbrPeriod;
  285. qinfo->tqi_cbrOverflowLimit = qi->tqi_cbrOverflowLimit;
  286. qinfo->tqi_burstTime = qi->tqi_burstTime;
  287. qinfo->tqi_readyTime = qi->tqi_readyTime;
  288. return true;
  289. }
  290. EXPORT_SYMBOL(ath9k_hw_get_txq_props);
  291. int ath9k_hw_setuptxqueue(struct ath_hw *ah, enum ath9k_tx_queue type,
  292. const struct ath9k_tx_queue_info *qinfo)
  293. {
  294. struct ath_common *common = ath9k_hw_common(ah);
  295. struct ath9k_tx_queue_info *qi;
  296. struct ath9k_hw_capabilities *pCap = &ah->caps;
  297. int q;
  298. switch (type) {
  299. case ATH9K_TX_QUEUE_BEACON:
  300. q = pCap->total_queues - 1;
  301. break;
  302. case ATH9K_TX_QUEUE_CAB:
  303. q = pCap->total_queues - 2;
  304. break;
  305. case ATH9K_TX_QUEUE_PSPOLL:
  306. q = 1;
  307. break;
  308. case ATH9K_TX_QUEUE_UAPSD:
  309. q = pCap->total_queues - 3;
  310. break;
  311. case ATH9K_TX_QUEUE_DATA:
  312. for (q = 0; q < pCap->total_queues; q++)
  313. if (ah->txq[q].tqi_type ==
  314. ATH9K_TX_QUEUE_INACTIVE)
  315. break;
  316. if (q == pCap->total_queues) {
  317. ath_err(common, "No available TX queue\n");
  318. return -1;
  319. }
  320. break;
  321. default:
  322. ath_err(common, "Invalid TX queue type: %u\n", type);
  323. return -1;
  324. }
  325. ath_dbg(common, ATH_DBG_QUEUE, "Setup TX queue: %u\n", q);
  326. qi = &ah->txq[q];
  327. if (qi->tqi_type != ATH9K_TX_QUEUE_INACTIVE) {
  328. ath_err(common, "TX queue: %u already active\n", q);
  329. return -1;
  330. }
  331. memset(qi, 0, sizeof(struct ath9k_tx_queue_info));
  332. qi->tqi_type = type;
  333. if (qinfo == NULL) {
  334. qi->tqi_qflags =
  335. TXQ_FLAG_TXOKINT_ENABLE
  336. | TXQ_FLAG_TXERRINT_ENABLE
  337. | TXQ_FLAG_TXDESCINT_ENABLE | TXQ_FLAG_TXURNINT_ENABLE;
  338. qi->tqi_aifs = INIT_AIFS;
  339. qi->tqi_cwmin = ATH9K_TXQ_USEDEFAULT;
  340. qi->tqi_cwmax = INIT_CWMAX;
  341. qi->tqi_shretry = INIT_SH_RETRY;
  342. qi->tqi_lgretry = INIT_LG_RETRY;
  343. qi->tqi_physCompBuf = 0;
  344. } else {
  345. qi->tqi_physCompBuf = qinfo->tqi_physCompBuf;
  346. (void) ath9k_hw_set_txq_props(ah, q, qinfo);
  347. }
  348. return q;
  349. }
  350. EXPORT_SYMBOL(ath9k_hw_setuptxqueue);
  351. bool ath9k_hw_releasetxqueue(struct ath_hw *ah, u32 q)
  352. {
  353. struct ath9k_hw_capabilities *pCap = &ah->caps;
  354. struct ath_common *common = ath9k_hw_common(ah);
  355. struct ath9k_tx_queue_info *qi;
  356. if (q >= pCap->total_queues) {
  357. ath_dbg(common, ATH_DBG_QUEUE,
  358. "Release TXQ, invalid queue: %u\n", q);
  359. return false;
  360. }
  361. qi = &ah->txq[q];
  362. if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
  363. ath_dbg(common, ATH_DBG_QUEUE,
  364. "Release TXQ, inactive queue: %u\n", q);
  365. return false;
  366. }
  367. ath_dbg(common, ATH_DBG_QUEUE, "Release TX queue: %u\n", q);
  368. qi->tqi_type = ATH9K_TX_QUEUE_INACTIVE;
  369. ah->txok_interrupt_mask &= ~(1 << q);
  370. ah->txerr_interrupt_mask &= ~(1 << q);
  371. ah->txdesc_interrupt_mask &= ~(1 << q);
  372. ah->txeol_interrupt_mask &= ~(1 << q);
  373. ah->txurn_interrupt_mask &= ~(1 << q);
  374. ath9k_hw_set_txq_interrupts(ah, qi);
  375. return true;
  376. }
  377. EXPORT_SYMBOL(ath9k_hw_releasetxqueue);
  378. bool ath9k_hw_resettxqueue(struct ath_hw *ah, u32 q)
  379. {
  380. struct ath9k_hw_capabilities *pCap = &ah->caps;
  381. struct ath_common *common = ath9k_hw_common(ah);
  382. struct ath9k_channel *chan = ah->curchan;
  383. struct ath9k_tx_queue_info *qi;
  384. u32 cwMin, chanCwMin, value;
  385. if (q >= pCap->total_queues) {
  386. ath_dbg(common, ATH_DBG_QUEUE,
  387. "Reset TXQ, invalid queue: %u\n", q);
  388. return false;
  389. }
  390. qi = &ah->txq[q];
  391. if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
  392. ath_dbg(common, ATH_DBG_QUEUE,
  393. "Reset TXQ, inactive queue: %u\n", q);
  394. return true;
  395. }
  396. ath_dbg(common, ATH_DBG_QUEUE, "Reset TX queue: %u\n", q);
  397. if (qi->tqi_cwmin == ATH9K_TXQ_USEDEFAULT) {
  398. if (chan && IS_CHAN_B(chan))
  399. chanCwMin = INIT_CWMIN_11B;
  400. else
  401. chanCwMin = INIT_CWMIN;
  402. for (cwMin = 1; cwMin < chanCwMin; cwMin = (cwMin << 1) | 1);
  403. } else
  404. cwMin = qi->tqi_cwmin;
  405. ENABLE_REGWRITE_BUFFER(ah);
  406. REG_WRITE(ah, AR_DLCL_IFS(q),
  407. SM(cwMin, AR_D_LCL_IFS_CWMIN) |
  408. SM(qi->tqi_cwmax, AR_D_LCL_IFS_CWMAX) |
  409. SM(qi->tqi_aifs, AR_D_LCL_IFS_AIFS));
  410. REG_WRITE(ah, AR_DRETRY_LIMIT(q),
  411. SM(INIT_SSH_RETRY, AR_D_RETRY_LIMIT_STA_SH) |
  412. SM(INIT_SLG_RETRY, AR_D_RETRY_LIMIT_STA_LG) |
  413. SM(qi->tqi_shretry, AR_D_RETRY_LIMIT_FR_SH));
  414. REG_WRITE(ah, AR_QMISC(q), AR_Q_MISC_DCU_EARLY_TERM_REQ);
  415. REG_WRITE(ah, AR_DMISC(q),
  416. AR_D_MISC_CW_BKOFF_EN | AR_D_MISC_FRAG_WAIT_EN | 0x2);
  417. if (qi->tqi_cbrPeriod) {
  418. REG_WRITE(ah, AR_QCBRCFG(q),
  419. SM(qi->tqi_cbrPeriod, AR_Q_CBRCFG_INTERVAL) |
  420. SM(qi->tqi_cbrOverflowLimit, AR_Q_CBRCFG_OVF_THRESH));
  421. REG_WRITE(ah, AR_QMISC(q),
  422. REG_READ(ah, AR_QMISC(q)) | AR_Q_MISC_FSP_CBR |
  423. (qi->tqi_cbrOverflowLimit ?
  424. AR_Q_MISC_CBR_EXP_CNTR_LIMIT_EN : 0));
  425. }
  426. if (qi->tqi_readyTime && (qi->tqi_type != ATH9K_TX_QUEUE_CAB)) {
  427. REG_WRITE(ah, AR_QRDYTIMECFG(q),
  428. SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_DURATION) |
  429. AR_Q_RDYTIMECFG_EN);
  430. }
  431. REG_WRITE(ah, AR_DCHNTIME(q),
  432. SM(qi->tqi_burstTime, AR_D_CHNTIME_DUR) |
  433. (qi->tqi_burstTime ? AR_D_CHNTIME_EN : 0));
  434. if (qi->tqi_burstTime
  435. && (qi->tqi_qflags & TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE)) {
  436. REG_WRITE(ah, AR_QMISC(q),
  437. REG_READ(ah, AR_QMISC(q)) |
  438. AR_Q_MISC_RDYTIME_EXP_POLICY);
  439. }
  440. if (qi->tqi_qflags & TXQ_FLAG_BACKOFF_DISABLE) {
  441. REG_WRITE(ah, AR_DMISC(q),
  442. REG_READ(ah, AR_DMISC(q)) |
  443. AR_D_MISC_POST_FR_BKOFF_DIS);
  444. }
  445. REGWRITE_BUFFER_FLUSH(ah);
  446. if (qi->tqi_qflags & TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE) {
  447. REG_WRITE(ah, AR_DMISC(q),
  448. REG_READ(ah, AR_DMISC(q)) |
  449. AR_D_MISC_FRAG_BKOFF_EN);
  450. }
  451. switch (qi->tqi_type) {
  452. case ATH9K_TX_QUEUE_BEACON:
  453. ENABLE_REGWRITE_BUFFER(ah);
  454. REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q))
  455. | AR_Q_MISC_FSP_DBA_GATED
  456. | AR_Q_MISC_BEACON_USE
  457. | AR_Q_MISC_CBR_INCR_DIS1);
  458. REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q))
  459. | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
  460. AR_D_MISC_ARB_LOCKOUT_CNTRL_S)
  461. | AR_D_MISC_BEACON_USE
  462. | AR_D_MISC_POST_FR_BKOFF_DIS);
  463. REGWRITE_BUFFER_FLUSH(ah);
  464. /*
  465. * cwmin and cwmax should be 0 for beacon queue
  466. * but not for IBSS as we would create an imbalance
  467. * on beaconing fairness for participating nodes.
  468. */
  469. if (AR_SREV_9300_20_OR_LATER(ah) &&
  470. ah->opmode != NL80211_IFTYPE_ADHOC) {
  471. REG_WRITE(ah, AR_DLCL_IFS(q), SM(0, AR_D_LCL_IFS_CWMIN)
  472. | SM(0, AR_D_LCL_IFS_CWMAX)
  473. | SM(qi->tqi_aifs, AR_D_LCL_IFS_AIFS));
  474. }
  475. break;
  476. case ATH9K_TX_QUEUE_CAB:
  477. ENABLE_REGWRITE_BUFFER(ah);
  478. REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q))
  479. | AR_Q_MISC_FSP_DBA_GATED
  480. | AR_Q_MISC_CBR_INCR_DIS1
  481. | AR_Q_MISC_CBR_INCR_DIS0);
  482. value = (qi->tqi_readyTime -
  483. (ah->config.sw_beacon_response_time -
  484. ah->config.dma_beacon_response_time) -
  485. ah->config.additional_swba_backoff) * 1024;
  486. REG_WRITE(ah, AR_QRDYTIMECFG(q),
  487. value | AR_Q_RDYTIMECFG_EN);
  488. REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q))
  489. | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
  490. AR_D_MISC_ARB_LOCKOUT_CNTRL_S));
  491. REGWRITE_BUFFER_FLUSH(ah);
  492. break;
  493. case ATH9K_TX_QUEUE_PSPOLL:
  494. REG_WRITE(ah, AR_QMISC(q),
  495. REG_READ(ah, AR_QMISC(q)) | AR_Q_MISC_CBR_INCR_DIS1);
  496. break;
  497. case ATH9K_TX_QUEUE_UAPSD:
  498. REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q)) |
  499. AR_D_MISC_POST_FR_BKOFF_DIS);
  500. break;
  501. default:
  502. break;
  503. }
  504. if (qi->tqi_intFlags & ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS) {
  505. REG_WRITE(ah, AR_DMISC(q),
  506. REG_READ(ah, AR_DMISC(q)) |
  507. SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL,
  508. AR_D_MISC_ARB_LOCKOUT_CNTRL) |
  509. AR_D_MISC_POST_FR_BKOFF_DIS);
  510. }
  511. if (AR_SREV_9300_20_OR_LATER(ah))
  512. REG_WRITE(ah, AR_Q_DESC_CRCCHK, AR_Q_DESC_CRCCHK_EN);
  513. if (qi->tqi_qflags & TXQ_FLAG_TXOKINT_ENABLE)
  514. ah->txok_interrupt_mask |= 1 << q;
  515. else
  516. ah->txok_interrupt_mask &= ~(1 << q);
  517. if (qi->tqi_qflags & TXQ_FLAG_TXERRINT_ENABLE)
  518. ah->txerr_interrupt_mask |= 1 << q;
  519. else
  520. ah->txerr_interrupt_mask &= ~(1 << q);
  521. if (qi->tqi_qflags & TXQ_FLAG_TXDESCINT_ENABLE)
  522. ah->txdesc_interrupt_mask |= 1 << q;
  523. else
  524. ah->txdesc_interrupt_mask &= ~(1 << q);
  525. if (qi->tqi_qflags & TXQ_FLAG_TXEOLINT_ENABLE)
  526. ah->txeol_interrupt_mask |= 1 << q;
  527. else
  528. ah->txeol_interrupt_mask &= ~(1 << q);
  529. if (qi->tqi_qflags & TXQ_FLAG_TXURNINT_ENABLE)
  530. ah->txurn_interrupt_mask |= 1 << q;
  531. else
  532. ah->txurn_interrupt_mask &= ~(1 << q);
  533. ath9k_hw_set_txq_interrupts(ah, qi);
  534. return true;
  535. }
  536. EXPORT_SYMBOL(ath9k_hw_resettxqueue);
  537. int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds,
  538. struct ath_rx_status *rs, u64 tsf)
  539. {
  540. struct ar5416_desc ads;
  541. struct ar5416_desc *adsp = AR5416DESC(ds);
  542. u32 phyerr;
  543. if ((adsp->ds_rxstatus8 & AR_RxDone) == 0)
  544. return -EINPROGRESS;
  545. ads.u.rx = adsp->u.rx;
  546. rs->rs_status = 0;
  547. rs->rs_flags = 0;
  548. rs->rs_datalen = ads.ds_rxstatus1 & AR_DataLen;
  549. rs->rs_tstamp = ads.AR_RcvTimestamp;
  550. if (ads.ds_rxstatus8 & AR_PostDelimCRCErr) {
  551. rs->rs_rssi = ATH9K_RSSI_BAD;
  552. rs->rs_rssi_ctl0 = ATH9K_RSSI_BAD;
  553. rs->rs_rssi_ctl1 = ATH9K_RSSI_BAD;
  554. rs->rs_rssi_ctl2 = ATH9K_RSSI_BAD;
  555. rs->rs_rssi_ext0 = ATH9K_RSSI_BAD;
  556. rs->rs_rssi_ext1 = ATH9K_RSSI_BAD;
  557. rs->rs_rssi_ext2 = ATH9K_RSSI_BAD;
  558. } else {
  559. rs->rs_rssi = MS(ads.ds_rxstatus4, AR_RxRSSICombined);
  560. rs->rs_rssi_ctl0 = MS(ads.ds_rxstatus0,
  561. AR_RxRSSIAnt00);
  562. rs->rs_rssi_ctl1 = MS(ads.ds_rxstatus0,
  563. AR_RxRSSIAnt01);
  564. rs->rs_rssi_ctl2 = MS(ads.ds_rxstatus0,
  565. AR_RxRSSIAnt02);
  566. rs->rs_rssi_ext0 = MS(ads.ds_rxstatus4,
  567. AR_RxRSSIAnt10);
  568. rs->rs_rssi_ext1 = MS(ads.ds_rxstatus4,
  569. AR_RxRSSIAnt11);
  570. rs->rs_rssi_ext2 = MS(ads.ds_rxstatus4,
  571. AR_RxRSSIAnt12);
  572. }
  573. if (ads.ds_rxstatus8 & AR_RxKeyIdxValid)
  574. rs->rs_keyix = MS(ads.ds_rxstatus8, AR_KeyIdx);
  575. else
  576. rs->rs_keyix = ATH9K_RXKEYIX_INVALID;
  577. rs->rs_rate = RXSTATUS_RATE(ah, (&ads));
  578. rs->rs_more = (ads.ds_rxstatus1 & AR_RxMore) ? 1 : 0;
  579. rs->rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ? 1 : 0;
  580. rs->rs_moreaggr =
  581. (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0;
  582. rs->rs_antenna = MS(ads.ds_rxstatus3, AR_RxAntenna);
  583. rs->rs_flags =
  584. (ads.ds_rxstatus3 & AR_GI) ? ATH9K_RX_GI : 0;
  585. rs->rs_flags |=
  586. (ads.ds_rxstatus3 & AR_2040) ? ATH9K_RX_2040 : 0;
  587. if (ads.ds_rxstatus8 & AR_PreDelimCRCErr)
  588. rs->rs_flags |= ATH9K_RX_DELIM_CRC_PRE;
  589. if (ads.ds_rxstatus8 & AR_PostDelimCRCErr)
  590. rs->rs_flags |= ATH9K_RX_DELIM_CRC_POST;
  591. if (ads.ds_rxstatus8 & AR_DecryptBusyErr)
  592. rs->rs_flags |= ATH9K_RX_DECRYPT_BUSY;
  593. if ((ads.ds_rxstatus8 & AR_RxFrameOK) == 0) {
  594. /*
  595. * Treat these errors as mutually exclusive to avoid spurious
  596. * extra error reports from the hardware. If a CRC error is
  597. * reported, then decryption and MIC errors are irrelevant,
  598. * the frame is going to be dropped either way
  599. */
  600. if (ads.ds_rxstatus8 & AR_CRCErr)
  601. rs->rs_status |= ATH9K_RXERR_CRC;
  602. else if (ads.ds_rxstatus8 & AR_PHYErr) {
  603. rs->rs_status |= ATH9K_RXERR_PHY;
  604. phyerr = MS(ads.ds_rxstatus8, AR_PHYErrCode);
  605. rs->rs_phyerr = phyerr;
  606. } else if (ads.ds_rxstatus8 & AR_DecryptCRCErr)
  607. rs->rs_status |= ATH9K_RXERR_DECRYPT;
  608. else if (ads.ds_rxstatus8 & AR_MichaelErr)
  609. rs->rs_status |= ATH9K_RXERR_MIC;
  610. if (ads.ds_rxstatus8 & AR_KeyMiss)
  611. rs->rs_status |= ATH9K_RXERR_DECRYPT;
  612. }
  613. return 0;
  614. }
  615. EXPORT_SYMBOL(ath9k_hw_rxprocdesc);
  616. /*
  617. * This can stop or re-enables RX.
  618. *
  619. * If bool is set this will kill any frame which is currently being
  620. * transferred between the MAC and baseband and also prevent any new
  621. * frames from getting started.
  622. */
  623. bool ath9k_hw_setrxabort(struct ath_hw *ah, bool set)
  624. {
  625. u32 reg;
  626. if (set) {
  627. REG_SET_BIT(ah, AR_DIAG_SW,
  628. (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
  629. if (!ath9k_hw_wait(ah, AR_OBS_BUS_1, AR_OBS_BUS_1_RX_STATE,
  630. 0, AH_WAIT_TIMEOUT)) {
  631. REG_CLR_BIT(ah, AR_DIAG_SW,
  632. (AR_DIAG_RX_DIS |
  633. AR_DIAG_RX_ABORT));
  634. reg = REG_READ(ah, AR_OBS_BUS_1);
  635. ath_err(ath9k_hw_common(ah),
  636. "RX failed to go idle in 10 ms RXSM=0x%x\n",
  637. reg);
  638. return false;
  639. }
  640. } else {
  641. REG_CLR_BIT(ah, AR_DIAG_SW,
  642. (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
  643. }
  644. return true;
  645. }
  646. EXPORT_SYMBOL(ath9k_hw_setrxabort);
  647. void ath9k_hw_putrxbuf(struct ath_hw *ah, u32 rxdp)
  648. {
  649. REG_WRITE(ah, AR_RXDP, rxdp);
  650. }
  651. EXPORT_SYMBOL(ath9k_hw_putrxbuf);
  652. void ath9k_hw_startpcureceive(struct ath_hw *ah, bool is_scanning)
  653. {
  654. ath9k_enable_mib_counters(ah);
  655. ath9k_ani_reset(ah, is_scanning);
  656. REG_CLR_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
  657. }
  658. EXPORT_SYMBOL(ath9k_hw_startpcureceive);
  659. void ath9k_hw_abortpcurecv(struct ath_hw *ah)
  660. {
  661. REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_ABORT | AR_DIAG_RX_DIS);
  662. ath9k_hw_disable_mib_counters(ah);
  663. }
  664. EXPORT_SYMBOL(ath9k_hw_abortpcurecv);
  665. bool ath9k_hw_stopdmarecv(struct ath_hw *ah)
  666. {
  667. #define AH_RX_STOP_DMA_TIMEOUT 10000 /* usec */
  668. #define AH_RX_TIME_QUANTUM 100 /* usec */
  669. struct ath_common *common = ath9k_hw_common(ah);
  670. int i;
  671. REG_WRITE(ah, AR_CR, AR_CR_RXD);
  672. /* Wait for rx enable bit to go low */
  673. for (i = AH_RX_STOP_DMA_TIMEOUT / AH_TIME_QUANTUM; i != 0; i--) {
  674. if ((REG_READ(ah, AR_CR) & AR_CR_RXE) == 0)
  675. break;
  676. udelay(AH_TIME_QUANTUM);
  677. }
  678. if (i == 0) {
  679. ath_err(common,
  680. "DMA failed to stop in %d ms AR_CR=0x%08x AR_DIAG_SW=0x%08x\n",
  681. AH_RX_STOP_DMA_TIMEOUT / 1000,
  682. REG_READ(ah, AR_CR),
  683. REG_READ(ah, AR_DIAG_SW));
  684. return false;
  685. } else {
  686. return true;
  687. }
  688. #undef AH_RX_TIME_QUANTUM
  689. #undef AH_RX_STOP_DMA_TIMEOUT
  690. }
  691. EXPORT_SYMBOL(ath9k_hw_stopdmarecv);
  692. int ath9k_hw_beaconq_setup(struct ath_hw *ah)
  693. {
  694. struct ath9k_tx_queue_info qi;
  695. memset(&qi, 0, sizeof(qi));
  696. qi.tqi_aifs = 1;
  697. qi.tqi_cwmin = 0;
  698. qi.tqi_cwmax = 0;
  699. /* NB: don't enable any interrupts */
  700. return ath9k_hw_setuptxqueue(ah, ATH9K_TX_QUEUE_BEACON, &qi);
  701. }
  702. EXPORT_SYMBOL(ath9k_hw_beaconq_setup);
  703. bool ath9k_hw_intrpend(struct ath_hw *ah)
  704. {
  705. u32 host_isr;
  706. if (AR_SREV_9100(ah))
  707. return true;
  708. host_isr = REG_READ(ah, AR_INTR_ASYNC_CAUSE);
  709. if ((host_isr & AR_INTR_MAC_IRQ) && (host_isr != AR_INTR_SPURIOUS))
  710. return true;
  711. host_isr = REG_READ(ah, AR_INTR_SYNC_CAUSE);
  712. if ((host_isr & AR_INTR_SYNC_DEFAULT)
  713. && (host_isr != AR_INTR_SPURIOUS))
  714. return true;
  715. return false;
  716. }
  717. EXPORT_SYMBOL(ath9k_hw_intrpend);
  718. void ath9k_hw_disable_interrupts(struct ath_hw *ah)
  719. {
  720. struct ath_common *common = ath9k_hw_common(ah);
  721. ath_dbg(common, ATH_DBG_INTERRUPT, "disable IER\n");
  722. REG_WRITE(ah, AR_IER, AR_IER_DISABLE);
  723. (void) REG_READ(ah, AR_IER);
  724. if (!AR_SREV_9100(ah)) {
  725. REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, 0);
  726. (void) REG_READ(ah, AR_INTR_ASYNC_ENABLE);
  727. REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0);
  728. (void) REG_READ(ah, AR_INTR_SYNC_ENABLE);
  729. }
  730. }
  731. EXPORT_SYMBOL(ath9k_hw_disable_interrupts);
  732. void ath9k_hw_enable_interrupts(struct ath_hw *ah)
  733. {
  734. struct ath_common *common = ath9k_hw_common(ah);
  735. if (!(ah->imask & ATH9K_INT_GLOBAL))
  736. return;
  737. ath_dbg(common, ATH_DBG_INTERRUPT, "enable IER\n");
  738. REG_WRITE(ah, AR_IER, AR_IER_ENABLE);
  739. if (!AR_SREV_9100(ah)) {
  740. REG_WRITE(ah, AR_INTR_ASYNC_ENABLE,
  741. AR_INTR_MAC_IRQ);
  742. REG_WRITE(ah, AR_INTR_ASYNC_MASK, AR_INTR_MAC_IRQ);
  743. REG_WRITE(ah, AR_INTR_SYNC_ENABLE,
  744. AR_INTR_SYNC_DEFAULT);
  745. REG_WRITE(ah, AR_INTR_SYNC_MASK,
  746. AR_INTR_SYNC_DEFAULT);
  747. }
  748. ath_dbg(common, ATH_DBG_INTERRUPT, "AR_IMR 0x%x IER 0x%x\n",
  749. REG_READ(ah, AR_IMR), REG_READ(ah, AR_IER));
  750. }
  751. EXPORT_SYMBOL(ath9k_hw_enable_interrupts);
  752. void ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints)
  753. {
  754. enum ath9k_int omask = ah->imask;
  755. u32 mask, mask2;
  756. struct ath9k_hw_capabilities *pCap = &ah->caps;
  757. struct ath_common *common = ath9k_hw_common(ah);
  758. if (!(ints & ATH9K_INT_GLOBAL))
  759. ath9k_hw_enable_interrupts(ah);
  760. ath_dbg(common, ATH_DBG_INTERRUPT, "0x%x => 0x%x\n", omask, ints);
  761. /* TODO: global int Ref count */
  762. mask = ints & ATH9K_INT_COMMON;
  763. mask2 = 0;
  764. if (ints & ATH9K_INT_TX) {
  765. if (ah->config.tx_intr_mitigation)
  766. mask |= AR_IMR_TXMINTR | AR_IMR_TXINTM;
  767. else {
  768. if (ah->txok_interrupt_mask)
  769. mask |= AR_IMR_TXOK;
  770. if (ah->txdesc_interrupt_mask)
  771. mask |= AR_IMR_TXDESC;
  772. }
  773. if (ah->txerr_interrupt_mask)
  774. mask |= AR_IMR_TXERR;
  775. if (ah->txeol_interrupt_mask)
  776. mask |= AR_IMR_TXEOL;
  777. }
  778. if (ints & ATH9K_INT_RX) {
  779. if (AR_SREV_9300_20_OR_LATER(ah)) {
  780. mask |= AR_IMR_RXERR | AR_IMR_RXOK_HP;
  781. if (ah->config.rx_intr_mitigation) {
  782. mask &= ~AR_IMR_RXOK_LP;
  783. mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM;
  784. } else {
  785. mask |= AR_IMR_RXOK_LP;
  786. }
  787. } else {
  788. if (ah->config.rx_intr_mitigation)
  789. mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM;
  790. else
  791. mask |= AR_IMR_RXOK | AR_IMR_RXDESC;
  792. }
  793. if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
  794. mask |= AR_IMR_GENTMR;
  795. }
  796. if (ints & (ATH9K_INT_BMISC)) {
  797. mask |= AR_IMR_BCNMISC;
  798. if (ints & ATH9K_INT_TIM)
  799. mask2 |= AR_IMR_S2_TIM;
  800. if (ints & ATH9K_INT_DTIM)
  801. mask2 |= AR_IMR_S2_DTIM;
  802. if (ints & ATH9K_INT_DTIMSYNC)
  803. mask2 |= AR_IMR_S2_DTIMSYNC;
  804. if (ints & ATH9K_INT_CABEND)
  805. mask2 |= AR_IMR_S2_CABEND;
  806. if (ints & ATH9K_INT_TSFOOR)
  807. mask2 |= AR_IMR_S2_TSFOOR;
  808. }
  809. if (ints & (ATH9K_INT_GTT | ATH9K_INT_CST)) {
  810. mask |= AR_IMR_BCNMISC;
  811. if (ints & ATH9K_INT_GTT)
  812. mask2 |= AR_IMR_S2_GTT;
  813. if (ints & ATH9K_INT_CST)
  814. mask2 |= AR_IMR_S2_CST;
  815. }
  816. ath_dbg(common, ATH_DBG_INTERRUPT, "new IMR 0x%x\n", mask);
  817. REG_WRITE(ah, AR_IMR, mask);
  818. ah->imrs2_reg &= ~(AR_IMR_S2_TIM | AR_IMR_S2_DTIM | AR_IMR_S2_DTIMSYNC |
  819. AR_IMR_S2_CABEND | AR_IMR_S2_CABTO |
  820. AR_IMR_S2_TSFOOR | AR_IMR_S2_GTT | AR_IMR_S2_CST);
  821. ah->imrs2_reg |= mask2;
  822. REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg);
  823. if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
  824. if (ints & ATH9K_INT_TIM_TIMER)
  825. REG_SET_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER);
  826. else
  827. REG_CLR_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER);
  828. }
  829. ath9k_hw_enable_interrupts(ah);
  830. return;
  831. }
  832. EXPORT_SYMBOL(ath9k_hw_set_interrupts);