mac.c 27 KB

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