mac.c 27 KB

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