mac.c 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  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->enc_flags = 0;
  450. rs->bw = RATE_INFO_BW_20;
  451. rs->rs_datalen = ads.ds_rxstatus1 & AR_DataLen;
  452. rs->rs_tstamp = ads.AR_RcvTimestamp;
  453. if (ads.ds_rxstatus8 & AR_PostDelimCRCErr) {
  454. rs->rs_rssi = ATH9K_RSSI_BAD;
  455. rs->rs_rssi_ctl[0] = ATH9K_RSSI_BAD;
  456. rs->rs_rssi_ctl[1] = ATH9K_RSSI_BAD;
  457. rs->rs_rssi_ctl[2] = ATH9K_RSSI_BAD;
  458. rs->rs_rssi_ext[0] = ATH9K_RSSI_BAD;
  459. rs->rs_rssi_ext[1] = ATH9K_RSSI_BAD;
  460. rs->rs_rssi_ext[2] = ATH9K_RSSI_BAD;
  461. } else {
  462. rs->rs_rssi = MS(ads.ds_rxstatus4, AR_RxRSSICombined);
  463. rs->rs_rssi_ctl[0] = MS(ads.ds_rxstatus0,
  464. AR_RxRSSIAnt00);
  465. rs->rs_rssi_ctl[1] = MS(ads.ds_rxstatus0,
  466. AR_RxRSSIAnt01);
  467. rs->rs_rssi_ctl[2] = MS(ads.ds_rxstatus0,
  468. AR_RxRSSIAnt02);
  469. rs->rs_rssi_ext[0] = MS(ads.ds_rxstatus4,
  470. AR_RxRSSIAnt10);
  471. rs->rs_rssi_ext[1] = MS(ads.ds_rxstatus4,
  472. AR_RxRSSIAnt11);
  473. rs->rs_rssi_ext[2] = MS(ads.ds_rxstatus4,
  474. AR_RxRSSIAnt12);
  475. }
  476. if (ads.ds_rxstatus8 & AR_RxKeyIdxValid)
  477. rs->rs_keyix = MS(ads.ds_rxstatus8, AR_KeyIdx);
  478. else
  479. rs->rs_keyix = ATH9K_RXKEYIX_INVALID;
  480. rs->rs_rate = MS(ads.ds_rxstatus0, AR_RxRate);
  481. rs->rs_more = (ads.ds_rxstatus1 & AR_RxMore) ? 1 : 0;
  482. rs->rs_firstaggr = (ads.ds_rxstatus8 & AR_RxFirstAggr) ? 1 : 0;
  483. rs->rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ? 1 : 0;
  484. rs->rs_moreaggr = (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0;
  485. rs->rs_antenna = MS(ads.ds_rxstatus3, AR_RxAntenna);
  486. /* directly mapped flags for ieee80211_rx_status */
  487. rs->enc_flags |=
  488. (ads.ds_rxstatus3 & AR_GI) ? RX_ENC_FLAG_SHORT_GI : 0;
  489. rs->bw = (ads.ds_rxstatus3 & AR_2040) ? RATE_INFO_BW_40 :
  490. RATE_INFO_BW_20;
  491. if (AR_SREV_9280_20_OR_LATER(ah))
  492. rs->enc_flags |=
  493. (ads.ds_rxstatus3 & AR_STBC) ?
  494. /* we can only Nss=1 STBC */
  495. (1 << RX_ENC_FLAG_STBC_SHIFT) : 0;
  496. if (ads.ds_rxstatus8 & AR_PreDelimCRCErr)
  497. rs->rs_flags |= ATH9K_RX_DELIM_CRC_PRE;
  498. if (ads.ds_rxstatus8 & AR_PostDelimCRCErr)
  499. rs->rs_flags |= ATH9K_RX_DELIM_CRC_POST;
  500. if (ads.ds_rxstatus8 & AR_DecryptBusyErr)
  501. rs->rs_flags |= ATH9K_RX_DECRYPT_BUSY;
  502. if ((ads.ds_rxstatus8 & AR_RxFrameOK) == 0) {
  503. /*
  504. * Treat these errors as mutually exclusive to avoid spurious
  505. * extra error reports from the hardware. If a CRC error is
  506. * reported, then decryption and MIC errors are irrelevant,
  507. * the frame is going to be dropped either way
  508. */
  509. if (ads.ds_rxstatus8 & AR_PHYErr) {
  510. rs->rs_status |= ATH9K_RXERR_PHY;
  511. phyerr = MS(ads.ds_rxstatus8, AR_PHYErrCode);
  512. rs->rs_phyerr = phyerr;
  513. } else if (ads.ds_rxstatus8 & AR_CRCErr)
  514. rs->rs_status |= ATH9K_RXERR_CRC;
  515. else if (ads.ds_rxstatus8 & AR_DecryptCRCErr)
  516. rs->rs_status |= ATH9K_RXERR_DECRYPT;
  517. else if (ads.ds_rxstatus8 & AR_MichaelErr)
  518. rs->rs_status |= ATH9K_RXERR_MIC;
  519. } else {
  520. if (ads.ds_rxstatus8 &
  521. (AR_CRCErr | AR_PHYErr | AR_DecryptCRCErr | AR_MichaelErr))
  522. rs->rs_status |= ATH9K_RXERR_CORRUPT_DESC;
  523. /* Only up to MCS16 supported, everything above is invalid */
  524. if (rs->rs_rate >= 0x90)
  525. rs->rs_status |= ATH9K_RXERR_CORRUPT_DESC;
  526. }
  527. if (ads.ds_rxstatus8 & AR_KeyMiss)
  528. rs->rs_status |= ATH9K_RXERR_KEYMISS;
  529. return 0;
  530. }
  531. EXPORT_SYMBOL(ath9k_hw_rxprocdesc);
  532. /*
  533. * This can stop or re-enables RX.
  534. *
  535. * If bool is set this will kill any frame which is currently being
  536. * transferred between the MAC and baseband and also prevent any new
  537. * frames from getting started.
  538. */
  539. bool ath9k_hw_setrxabort(struct ath_hw *ah, bool set)
  540. {
  541. u32 reg;
  542. if (set) {
  543. REG_SET_BIT(ah, AR_DIAG_SW,
  544. (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
  545. if (!ath9k_hw_wait(ah, AR_OBS_BUS_1, AR_OBS_BUS_1_RX_STATE,
  546. 0, AH_WAIT_TIMEOUT)) {
  547. REG_CLR_BIT(ah, AR_DIAG_SW,
  548. (AR_DIAG_RX_DIS |
  549. AR_DIAG_RX_ABORT));
  550. reg = REG_READ(ah, AR_OBS_BUS_1);
  551. ath_err(ath9k_hw_common(ah),
  552. "RX failed to go idle in 10 ms RXSM=0x%x\n",
  553. reg);
  554. return false;
  555. }
  556. } else {
  557. REG_CLR_BIT(ah, AR_DIAG_SW,
  558. (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
  559. }
  560. return true;
  561. }
  562. EXPORT_SYMBOL(ath9k_hw_setrxabort);
  563. void ath9k_hw_putrxbuf(struct ath_hw *ah, u32 rxdp)
  564. {
  565. REG_WRITE(ah, AR_RXDP, rxdp);
  566. }
  567. EXPORT_SYMBOL(ath9k_hw_putrxbuf);
  568. void ath9k_hw_startpcureceive(struct ath_hw *ah, bool is_scanning)
  569. {
  570. ath9k_enable_mib_counters(ah);
  571. ath9k_ani_reset(ah, is_scanning);
  572. REG_CLR_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
  573. }
  574. EXPORT_SYMBOL(ath9k_hw_startpcureceive);
  575. void ath9k_hw_abortpcurecv(struct ath_hw *ah)
  576. {
  577. REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_ABORT | AR_DIAG_RX_DIS);
  578. ath9k_hw_disable_mib_counters(ah);
  579. }
  580. EXPORT_SYMBOL(ath9k_hw_abortpcurecv);
  581. bool ath9k_hw_stopdmarecv(struct ath_hw *ah, bool *reset)
  582. {
  583. #define AH_RX_STOP_DMA_TIMEOUT 10000 /* usec */
  584. struct ath_common *common = ath9k_hw_common(ah);
  585. u32 mac_status, last_mac_status = 0;
  586. int i;
  587. /* Enable access to the DMA observation bus */
  588. REG_WRITE(ah, AR_MACMISC,
  589. ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
  590. (AR_MACMISC_MISC_OBS_BUS_1 <<
  591. AR_MACMISC_MISC_OBS_BUS_MSB_S)));
  592. REG_WRITE(ah, AR_CR, AR_CR_RXD);
  593. /* Wait for rx enable bit to go low */
  594. for (i = AH_RX_STOP_DMA_TIMEOUT / AH_TIME_QUANTUM; i != 0; i--) {
  595. if ((REG_READ(ah, AR_CR) & AR_CR_RXE) == 0)
  596. break;
  597. if (!AR_SREV_9300_20_OR_LATER(ah)) {
  598. mac_status = REG_READ(ah, AR_DMADBG_7) & 0x7f0;
  599. if (mac_status == 0x1c0 && mac_status == last_mac_status) {
  600. *reset = true;
  601. break;
  602. }
  603. last_mac_status = mac_status;
  604. }
  605. udelay(AH_TIME_QUANTUM);
  606. }
  607. if (i == 0) {
  608. ath_err(common,
  609. "DMA failed to stop in %d ms AR_CR=0x%08x AR_DIAG_SW=0x%08x DMADBG_7=0x%08x\n",
  610. AH_RX_STOP_DMA_TIMEOUT / 1000,
  611. REG_READ(ah, AR_CR),
  612. REG_READ(ah, AR_DIAG_SW),
  613. REG_READ(ah, AR_DMADBG_7));
  614. return false;
  615. } else {
  616. return true;
  617. }
  618. #undef AH_RX_STOP_DMA_TIMEOUT
  619. }
  620. EXPORT_SYMBOL(ath9k_hw_stopdmarecv);
  621. int ath9k_hw_beaconq_setup(struct ath_hw *ah)
  622. {
  623. struct ath9k_tx_queue_info qi;
  624. memset(&qi, 0, sizeof(qi));
  625. qi.tqi_aifs = 1;
  626. qi.tqi_cwmin = 0;
  627. qi.tqi_cwmax = 0;
  628. if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
  629. qi.tqi_qflags = TXQ_FLAG_TXINT_ENABLE;
  630. return ath9k_hw_setuptxqueue(ah, ATH9K_TX_QUEUE_BEACON, &qi);
  631. }
  632. EXPORT_SYMBOL(ath9k_hw_beaconq_setup);
  633. bool ath9k_hw_intrpend(struct ath_hw *ah)
  634. {
  635. u32 host_isr;
  636. if (AR_SREV_9100(ah))
  637. return true;
  638. host_isr = REG_READ(ah, AR_INTR_ASYNC_CAUSE);
  639. if (((host_isr & AR_INTR_MAC_IRQ) ||
  640. (host_isr & AR_INTR_ASYNC_MASK_MCI)) &&
  641. (host_isr != AR_INTR_SPURIOUS))
  642. return true;
  643. host_isr = REG_READ(ah, AR_INTR_SYNC_CAUSE);
  644. if ((host_isr & AR_INTR_SYNC_DEFAULT)
  645. && (host_isr != AR_INTR_SPURIOUS))
  646. return true;
  647. return false;
  648. }
  649. EXPORT_SYMBOL(ath9k_hw_intrpend);
  650. void ath9k_hw_kill_interrupts(struct ath_hw *ah)
  651. {
  652. struct ath_common *common = ath9k_hw_common(ah);
  653. ath_dbg(common, INTERRUPT, "disable IER\n");
  654. REG_WRITE(ah, AR_IER, AR_IER_DISABLE);
  655. (void) REG_READ(ah, AR_IER);
  656. if (!AR_SREV_9100(ah)) {
  657. REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, 0);
  658. (void) REG_READ(ah, AR_INTR_ASYNC_ENABLE);
  659. REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0);
  660. (void) REG_READ(ah, AR_INTR_SYNC_ENABLE);
  661. }
  662. }
  663. EXPORT_SYMBOL(ath9k_hw_kill_interrupts);
  664. void ath9k_hw_disable_interrupts(struct ath_hw *ah)
  665. {
  666. if (!(ah->imask & ATH9K_INT_GLOBAL))
  667. atomic_set(&ah->intr_ref_cnt, -1);
  668. else
  669. atomic_dec(&ah->intr_ref_cnt);
  670. ath9k_hw_kill_interrupts(ah);
  671. }
  672. EXPORT_SYMBOL(ath9k_hw_disable_interrupts);
  673. static void __ath9k_hw_enable_interrupts(struct ath_hw *ah)
  674. {
  675. struct ath_common *common = ath9k_hw_common(ah);
  676. u32 sync_default = AR_INTR_SYNC_DEFAULT;
  677. u32 async_mask;
  678. if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah) ||
  679. AR_SREV_9561(ah))
  680. sync_default &= ~AR_INTR_SYNC_HOST1_FATAL;
  681. async_mask = AR_INTR_MAC_IRQ;
  682. if (ah->imask & ATH9K_INT_MCI)
  683. async_mask |= AR_INTR_ASYNC_MASK_MCI;
  684. ath_dbg(common, INTERRUPT, "enable IER\n");
  685. REG_WRITE(ah, AR_IER, AR_IER_ENABLE);
  686. if (!AR_SREV_9100(ah)) {
  687. REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, async_mask);
  688. REG_WRITE(ah, AR_INTR_ASYNC_MASK, async_mask);
  689. REG_WRITE(ah, AR_INTR_SYNC_ENABLE, sync_default);
  690. REG_WRITE(ah, AR_INTR_SYNC_MASK, sync_default);
  691. }
  692. ath_dbg(common, INTERRUPT, "AR_IMR 0x%x IER 0x%x\n",
  693. REG_READ(ah, AR_IMR), REG_READ(ah, AR_IER));
  694. }
  695. void ath9k_hw_resume_interrupts(struct ath_hw *ah)
  696. {
  697. struct ath_common *common = ath9k_hw_common(ah);
  698. if (!(ah->imask & ATH9K_INT_GLOBAL))
  699. return;
  700. if (atomic_read(&ah->intr_ref_cnt) != 0) {
  701. ath_dbg(common, INTERRUPT, "Do not enable IER ref count %d\n",
  702. atomic_read(&ah->intr_ref_cnt));
  703. return;
  704. }
  705. __ath9k_hw_enable_interrupts(ah);
  706. }
  707. EXPORT_SYMBOL(ath9k_hw_resume_interrupts);
  708. void ath9k_hw_enable_interrupts(struct ath_hw *ah)
  709. {
  710. struct ath_common *common = ath9k_hw_common(ah);
  711. if (!(ah->imask & ATH9K_INT_GLOBAL))
  712. return;
  713. if (!atomic_inc_and_test(&ah->intr_ref_cnt)) {
  714. ath_dbg(common, INTERRUPT, "Do not enable IER ref count %d\n",
  715. atomic_read(&ah->intr_ref_cnt));
  716. return;
  717. }
  718. __ath9k_hw_enable_interrupts(ah);
  719. }
  720. EXPORT_SYMBOL(ath9k_hw_enable_interrupts);
  721. void ath9k_hw_set_interrupts(struct ath_hw *ah)
  722. {
  723. enum ath9k_int ints = ah->imask;
  724. u32 mask, mask2;
  725. struct ath9k_hw_capabilities *pCap = &ah->caps;
  726. struct ath_common *common = ath9k_hw_common(ah);
  727. if (!(ints & ATH9K_INT_GLOBAL))
  728. ath9k_hw_disable_interrupts(ah);
  729. ath_dbg(common, INTERRUPT, "New interrupt mask 0x%x\n", ints);
  730. mask = ints & ATH9K_INT_COMMON;
  731. mask2 = 0;
  732. if (ints & ATH9K_INT_TX) {
  733. if (ah->config.tx_intr_mitigation)
  734. mask |= AR_IMR_TXMINTR | AR_IMR_TXINTM;
  735. else {
  736. if (ah->txok_interrupt_mask)
  737. mask |= AR_IMR_TXOK;
  738. if (ah->txdesc_interrupt_mask)
  739. mask |= AR_IMR_TXDESC;
  740. }
  741. if (ah->txerr_interrupt_mask)
  742. mask |= AR_IMR_TXERR;
  743. if (ah->txeol_interrupt_mask)
  744. mask |= AR_IMR_TXEOL;
  745. }
  746. if (ints & ATH9K_INT_RX) {
  747. if (AR_SREV_9300_20_OR_LATER(ah)) {
  748. mask |= AR_IMR_RXERR | AR_IMR_RXOK_HP;
  749. if (ah->config.rx_intr_mitigation) {
  750. mask &= ~AR_IMR_RXOK_LP;
  751. mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM;
  752. } else {
  753. mask |= AR_IMR_RXOK_LP;
  754. }
  755. } else {
  756. if (ah->config.rx_intr_mitigation)
  757. mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM;
  758. else
  759. mask |= AR_IMR_RXOK | AR_IMR_RXDESC;
  760. }
  761. if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
  762. mask |= AR_IMR_GENTMR;
  763. }
  764. if (ints & ATH9K_INT_GENTIMER)
  765. mask |= AR_IMR_GENTMR;
  766. if (ints & (ATH9K_INT_BMISC)) {
  767. mask |= AR_IMR_BCNMISC;
  768. if (ints & ATH9K_INT_TIM)
  769. mask2 |= AR_IMR_S2_TIM;
  770. if (ints & ATH9K_INT_DTIM)
  771. mask2 |= AR_IMR_S2_DTIM;
  772. if (ints & ATH9K_INT_DTIMSYNC)
  773. mask2 |= AR_IMR_S2_DTIMSYNC;
  774. if (ints & ATH9K_INT_CABEND)
  775. mask2 |= AR_IMR_S2_CABEND;
  776. if (ints & ATH9K_INT_TSFOOR)
  777. mask2 |= AR_IMR_S2_TSFOOR;
  778. }
  779. if (ints & (ATH9K_INT_GTT | ATH9K_INT_CST)) {
  780. mask |= AR_IMR_BCNMISC;
  781. if (ints & ATH9K_INT_GTT)
  782. mask2 |= AR_IMR_S2_GTT;
  783. if (ints & ATH9K_INT_CST)
  784. mask2 |= AR_IMR_S2_CST;
  785. }
  786. if (ah->config.hw_hang_checks & HW_BB_WATCHDOG) {
  787. if (ints & ATH9K_INT_BB_WATCHDOG) {
  788. mask |= AR_IMR_BCNMISC;
  789. mask2 |= AR_IMR_S2_BB_WATCHDOG;
  790. }
  791. }
  792. ath_dbg(common, INTERRUPT, "new IMR 0x%x\n", mask);
  793. REG_WRITE(ah, AR_IMR, mask);
  794. ah->imrs2_reg &= ~(AR_IMR_S2_TIM |
  795. AR_IMR_S2_DTIM |
  796. AR_IMR_S2_DTIMSYNC |
  797. AR_IMR_S2_CABEND |
  798. AR_IMR_S2_CABTO |
  799. AR_IMR_S2_TSFOOR |
  800. AR_IMR_S2_GTT |
  801. AR_IMR_S2_CST);
  802. if (ah->config.hw_hang_checks & HW_BB_WATCHDOG) {
  803. if (ints & ATH9K_INT_BB_WATCHDOG)
  804. ah->imrs2_reg &= ~AR_IMR_S2_BB_WATCHDOG;
  805. }
  806. ah->imrs2_reg |= mask2;
  807. REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg);
  808. if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
  809. if (ints & ATH9K_INT_TIM_TIMER)
  810. REG_SET_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER);
  811. else
  812. REG_CLR_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER);
  813. }
  814. return;
  815. }
  816. EXPORT_SYMBOL(ath9k_hw_set_interrupts);
  817. #define ATH9K_HW_MAX_DCU 10
  818. #define ATH9K_HW_SLICE_PER_DCU 16
  819. #define ATH9K_HW_BIT_IN_SLICE 16
  820. void ath9k_hw_set_tx_filter(struct ath_hw *ah, u8 destidx, bool set)
  821. {
  822. int dcu_idx;
  823. u32 filter;
  824. for (dcu_idx = 0; dcu_idx < 10; dcu_idx++) {
  825. filter = SM(set, AR_D_TXBLK_WRITE_COMMAND);
  826. filter |= SM(dcu_idx, AR_D_TXBLK_WRITE_DCU);
  827. filter |= SM((destidx / ATH9K_HW_SLICE_PER_DCU),
  828. AR_D_TXBLK_WRITE_SLICE);
  829. filter |= BIT(destidx % ATH9K_HW_BIT_IN_SLICE);
  830. ath_dbg(ath9k_hw_common(ah), PS,
  831. "DCU%d staid %d set %d txfilter %08x\n",
  832. dcu_idx, destidx, set, filter);
  833. REG_WRITE(ah, AR_D_TXBLK_BASE, filter);
  834. }
  835. }
  836. EXPORT_SYMBOL(ath9k_hw_set_tx_filter);