mac.c 26 KB

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