qcu.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. /*
  2. * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
  3. * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
  4. *
  5. * Permission to use, copy, modify, and distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. *
  17. */
  18. /********************************************\
  19. Queue Control Unit, DFS Control Unit Functions
  20. \********************************************/
  21. #include "ath5k.h"
  22. #include "reg.h"
  23. #include "debug.h"
  24. #include "base.h"
  25. /*
  26. * Get properties for a transmit queue
  27. */
  28. int ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue,
  29. struct ath5k_txq_info *queue_info)
  30. {
  31. memcpy(queue_info, &ah->ah_txq[queue], sizeof(struct ath5k_txq_info));
  32. return 0;
  33. }
  34. /*
  35. * Set properties for a transmit queue
  36. */
  37. int ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, int queue,
  38. const struct ath5k_txq_info *queue_info)
  39. {
  40. AR5K_ASSERT_ENTRY(queue, ah->ah_capabilities.cap_queues.q_tx_num);
  41. if (ah->ah_txq[queue].tqi_type == AR5K_TX_QUEUE_INACTIVE)
  42. return -EIO;
  43. memcpy(&ah->ah_txq[queue], queue_info, sizeof(struct ath5k_txq_info));
  44. /*XXX: Is this supported on 5210 ?*/
  45. if ((queue_info->tqi_type == AR5K_TX_QUEUE_DATA &&
  46. ((queue_info->tqi_subtype == AR5K_WME_AC_VI) ||
  47. (queue_info->tqi_subtype == AR5K_WME_AC_VO))) ||
  48. queue_info->tqi_type == AR5K_TX_QUEUE_UAPSD)
  49. ah->ah_txq[queue].tqi_flags |= AR5K_TXQ_FLAG_POST_FR_BKOFF_DIS;
  50. return 0;
  51. }
  52. /*
  53. * Initialize a transmit queue
  54. */
  55. int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, enum ath5k_tx_queue queue_type,
  56. struct ath5k_txq_info *queue_info)
  57. {
  58. unsigned int queue;
  59. int ret;
  60. /*
  61. * Get queue by type
  62. */
  63. /*5210 only has 2 queues*/
  64. if (ah->ah_version == AR5K_AR5210) {
  65. switch (queue_type) {
  66. case AR5K_TX_QUEUE_DATA:
  67. queue = AR5K_TX_QUEUE_ID_NOQCU_DATA;
  68. break;
  69. case AR5K_TX_QUEUE_BEACON:
  70. case AR5K_TX_QUEUE_CAB:
  71. queue = AR5K_TX_QUEUE_ID_NOQCU_BEACON;
  72. break;
  73. default:
  74. return -EINVAL;
  75. }
  76. } else {
  77. switch (queue_type) {
  78. case AR5K_TX_QUEUE_DATA:
  79. for (queue = AR5K_TX_QUEUE_ID_DATA_MIN;
  80. ah->ah_txq[queue].tqi_type !=
  81. AR5K_TX_QUEUE_INACTIVE; queue++) {
  82. if (queue > AR5K_TX_QUEUE_ID_DATA_MAX)
  83. return -EINVAL;
  84. }
  85. break;
  86. case AR5K_TX_QUEUE_UAPSD:
  87. queue = AR5K_TX_QUEUE_ID_UAPSD;
  88. break;
  89. case AR5K_TX_QUEUE_BEACON:
  90. queue = AR5K_TX_QUEUE_ID_BEACON;
  91. break;
  92. case AR5K_TX_QUEUE_CAB:
  93. queue = AR5K_TX_QUEUE_ID_CAB;
  94. break;
  95. case AR5K_TX_QUEUE_XR_DATA:
  96. if (ah->ah_version != AR5K_AR5212)
  97. ATH5K_ERR(ah->ah_sc,
  98. "XR data queues only supported in"
  99. " 5212!\n");
  100. queue = AR5K_TX_QUEUE_ID_XR_DATA;
  101. break;
  102. default:
  103. return -EINVAL;
  104. }
  105. }
  106. /*
  107. * Setup internal queue structure
  108. */
  109. memset(&ah->ah_txq[queue], 0, sizeof(struct ath5k_txq_info));
  110. ah->ah_txq[queue].tqi_type = queue_type;
  111. if (queue_info != NULL) {
  112. queue_info->tqi_type = queue_type;
  113. ret = ath5k_hw_set_tx_queueprops(ah, queue, queue_info);
  114. if (ret)
  115. return ret;
  116. }
  117. /*
  118. * We use ah_txq_status to hold a temp value for
  119. * the Secondary interrupt mask registers on 5211+
  120. * check out ath5k_hw_reset_tx_queue
  121. */
  122. AR5K_Q_ENABLE_BITS(ah->ah_txq_status, queue);
  123. return queue;
  124. }
  125. /*
  126. * Get number of pending frames
  127. * for a specific queue [5211+]
  128. */
  129. u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue)
  130. {
  131. u32 pending;
  132. AR5K_ASSERT_ENTRY(queue, ah->ah_capabilities.cap_queues.q_tx_num);
  133. /* Return if queue is declared inactive */
  134. if (ah->ah_txq[queue].tqi_type == AR5K_TX_QUEUE_INACTIVE)
  135. return false;
  136. /* XXX: How about AR5K_CFG_TXCNT ? */
  137. if (ah->ah_version == AR5K_AR5210)
  138. return false;
  139. pending = ath5k_hw_reg_read(ah, AR5K_QUEUE_STATUS(queue));
  140. pending &= AR5K_QCU_STS_FRMPENDCNT;
  141. /* It's possible to have no frames pending even if TXE
  142. * is set. To indicate that q has not stopped return
  143. * true */
  144. if (!pending && AR5K_REG_READ_Q(ah, AR5K_QCU_TXE, queue))
  145. return true;
  146. return pending;
  147. }
  148. /*
  149. * Set a transmit queue inactive
  150. */
  151. void ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue)
  152. {
  153. if (WARN_ON(queue >= ah->ah_capabilities.cap_queues.q_tx_num))
  154. return;
  155. /* This queue will be skipped in further operations */
  156. ah->ah_txq[queue].tqi_type = AR5K_TX_QUEUE_INACTIVE;
  157. /*For SIMR setup*/
  158. AR5K_Q_DISABLE_BITS(ah->ah_txq_status, queue);
  159. }
  160. /*
  161. * Set DFS properties for a transmit queue on DCU
  162. */
  163. int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue)
  164. {
  165. u32 cw_min, cw_max, retry_lg, retry_sh;
  166. struct ath5k_txq_info *tq = &ah->ah_txq[queue];
  167. AR5K_ASSERT_ENTRY(queue, ah->ah_capabilities.cap_queues.q_tx_num);
  168. tq = &ah->ah_txq[queue];
  169. if (tq->tqi_type == AR5K_TX_QUEUE_INACTIVE)
  170. return 0;
  171. if (ah->ah_version == AR5K_AR5210) {
  172. /* Only handle data queues, others will be ignored */
  173. if (tq->tqi_type != AR5K_TX_QUEUE_DATA)
  174. return 0;
  175. /* Set Slot time */
  176. ath5k_hw_reg_write(ah, ah->ah_turbo ?
  177. AR5K_INIT_SLOT_TIME_TURBO : AR5K_INIT_SLOT_TIME,
  178. AR5K_SLOT_TIME);
  179. /* Set ACK_CTS timeout */
  180. ath5k_hw_reg_write(ah, ah->ah_turbo ?
  181. AR5K_INIT_ACK_CTS_TIMEOUT_TURBO :
  182. AR5K_INIT_ACK_CTS_TIMEOUT, AR5K_SLOT_TIME);
  183. /* Set Transmit Latency */
  184. ath5k_hw_reg_write(ah, ah->ah_turbo ?
  185. AR5K_INIT_TRANSMIT_LATENCY_TURBO :
  186. AR5K_INIT_TRANSMIT_LATENCY, AR5K_USEC_5210);
  187. /* Set IFS0 */
  188. if (ah->ah_turbo) {
  189. ath5k_hw_reg_write(ah, ((AR5K_INIT_SIFS_TURBO +
  190. (ah->ah_aifs + tq->tqi_aifs) *
  191. AR5K_INIT_SLOT_TIME_TURBO) <<
  192. AR5K_IFS0_DIFS_S) | AR5K_INIT_SIFS_TURBO,
  193. AR5K_IFS0);
  194. } else {
  195. ath5k_hw_reg_write(ah, ((AR5K_INIT_SIFS +
  196. (ah->ah_aifs + tq->tqi_aifs) *
  197. AR5K_INIT_SLOT_TIME) << AR5K_IFS0_DIFS_S) |
  198. AR5K_INIT_SIFS, AR5K_IFS0);
  199. }
  200. /* Set IFS1 */
  201. ath5k_hw_reg_write(ah, ah->ah_turbo ?
  202. AR5K_INIT_PROTO_TIME_CNTRL_TURBO :
  203. AR5K_INIT_PROTO_TIME_CNTRL, AR5K_IFS1);
  204. /* Set AR5K_PHY_SETTLING */
  205. ath5k_hw_reg_write(ah, ah->ah_turbo ?
  206. (ath5k_hw_reg_read(ah, AR5K_PHY_SETTLING) & ~0x7F)
  207. | 0x38 :
  208. (ath5k_hw_reg_read(ah, AR5K_PHY_SETTLING) & ~0x7F)
  209. | 0x1C,
  210. AR5K_PHY_SETTLING);
  211. /* Set Frame Control Register */
  212. ath5k_hw_reg_write(ah, ah->ah_turbo ?
  213. (AR5K_PHY_FRAME_CTL_INI | AR5K_PHY_TURBO_MODE |
  214. AR5K_PHY_TURBO_SHORT | 0x2020) :
  215. (AR5K_PHY_FRAME_CTL_INI | 0x1020),
  216. AR5K_PHY_FRAME_CTL_5210);
  217. }
  218. /*
  219. * Calculate cwmin/max by channel mode
  220. */
  221. cw_min = ah->ah_cw_min = AR5K_TUNE_CWMIN;
  222. cw_max = ah->ah_cw_max = AR5K_TUNE_CWMAX;
  223. ah->ah_aifs = AR5K_TUNE_AIFS;
  224. /*XR is only supported on 5212*/
  225. if (IS_CHAN_XR(ah->ah_current_channel) &&
  226. ah->ah_version == AR5K_AR5212) {
  227. cw_min = ah->ah_cw_min = AR5K_TUNE_CWMIN_XR;
  228. cw_max = ah->ah_cw_max = AR5K_TUNE_CWMAX_XR;
  229. ah->ah_aifs = AR5K_TUNE_AIFS_XR;
  230. /*B mode is not supported on 5210*/
  231. } else if (IS_CHAN_B(ah->ah_current_channel) &&
  232. ah->ah_version != AR5K_AR5210) {
  233. cw_min = ah->ah_cw_min = AR5K_TUNE_CWMIN_11B;
  234. cw_max = ah->ah_cw_max = AR5K_TUNE_CWMAX_11B;
  235. ah->ah_aifs = AR5K_TUNE_AIFS_11B;
  236. }
  237. cw_min = 1;
  238. while (cw_min < ah->ah_cw_min)
  239. cw_min = (cw_min << 1) | 1;
  240. cw_min = tq->tqi_cw_min < 0 ? (cw_min >> (-tq->tqi_cw_min)) :
  241. ((cw_min << tq->tqi_cw_min) + (1 << tq->tqi_cw_min) - 1);
  242. cw_max = tq->tqi_cw_max < 0 ? (cw_max >> (-tq->tqi_cw_max)) :
  243. ((cw_max << tq->tqi_cw_max) + (1 << tq->tqi_cw_max) - 1);
  244. /*
  245. * Calculate and set retry limits
  246. */
  247. if (ah->ah_software_retry) {
  248. /* XXX Need to test this */
  249. retry_lg = ah->ah_limit_tx_retries;
  250. retry_sh = retry_lg = retry_lg > AR5K_DCU_RETRY_LMT_SH_RETRY ?
  251. AR5K_DCU_RETRY_LMT_SH_RETRY : retry_lg;
  252. } else {
  253. retry_lg = AR5K_INIT_LG_RETRY;
  254. retry_sh = AR5K_INIT_SH_RETRY;
  255. }
  256. /*No QCU/DCU [5210]*/
  257. if (ah->ah_version == AR5K_AR5210) {
  258. ath5k_hw_reg_write(ah,
  259. (cw_min << AR5K_NODCU_RETRY_LMT_CW_MIN_S)
  260. | AR5K_REG_SM(AR5K_INIT_SLG_RETRY,
  261. AR5K_NODCU_RETRY_LMT_SLG_RETRY)
  262. | AR5K_REG_SM(AR5K_INIT_SSH_RETRY,
  263. AR5K_NODCU_RETRY_LMT_SSH_RETRY)
  264. | AR5K_REG_SM(retry_lg, AR5K_NODCU_RETRY_LMT_LG_RETRY)
  265. | AR5K_REG_SM(retry_sh, AR5K_NODCU_RETRY_LMT_SH_RETRY),
  266. AR5K_NODCU_RETRY_LMT);
  267. } else {
  268. /*QCU/DCU [5211+]*/
  269. ath5k_hw_reg_write(ah,
  270. AR5K_REG_SM(AR5K_INIT_SLG_RETRY,
  271. AR5K_DCU_RETRY_LMT_SLG_RETRY) |
  272. AR5K_REG_SM(AR5K_INIT_SSH_RETRY,
  273. AR5K_DCU_RETRY_LMT_SSH_RETRY) |
  274. AR5K_REG_SM(retry_lg, AR5K_DCU_RETRY_LMT_LG_RETRY) |
  275. AR5K_REG_SM(retry_sh, AR5K_DCU_RETRY_LMT_SH_RETRY),
  276. AR5K_QUEUE_DFS_RETRY_LIMIT(queue));
  277. /*===Rest is also for QCU/DCU only [5211+]===*/
  278. /*
  279. * Set initial content window (cw_min/cw_max)
  280. * and arbitrated interframe space (aifs)...
  281. */
  282. ath5k_hw_reg_write(ah,
  283. AR5K_REG_SM(cw_min, AR5K_DCU_LCL_IFS_CW_MIN) |
  284. AR5K_REG_SM(cw_max, AR5K_DCU_LCL_IFS_CW_MAX) |
  285. AR5K_REG_SM(ah->ah_aifs + tq->tqi_aifs,
  286. AR5K_DCU_LCL_IFS_AIFS),
  287. AR5K_QUEUE_DFS_LOCAL_IFS(queue));
  288. /*
  289. * Set misc registers
  290. */
  291. /* Enable DCU early termination for this queue */
  292. AR5K_REG_ENABLE_BITS(ah, AR5K_QUEUE_MISC(queue),
  293. AR5K_QCU_MISC_DCU_EARLY);
  294. /* Enable DCU to wait for next fragment from QCU */
  295. AR5K_REG_ENABLE_BITS(ah, AR5K_QUEUE_DFS_MISC(queue),
  296. AR5K_DCU_MISC_FRAG_WAIT);
  297. /* On Maui and Spirit use the global seqnum on DCU */
  298. if (ah->ah_mac_version < AR5K_SREV_AR5211)
  299. AR5K_REG_ENABLE_BITS(ah, AR5K_QUEUE_DFS_MISC(queue),
  300. AR5K_DCU_MISC_SEQNUM_CTL);
  301. if (tq->tqi_cbr_period) {
  302. ath5k_hw_reg_write(ah, AR5K_REG_SM(tq->tqi_cbr_period,
  303. AR5K_QCU_CBRCFG_INTVAL) |
  304. AR5K_REG_SM(tq->tqi_cbr_overflow_limit,
  305. AR5K_QCU_CBRCFG_ORN_THRES),
  306. AR5K_QUEUE_CBRCFG(queue));
  307. AR5K_REG_ENABLE_BITS(ah, AR5K_QUEUE_MISC(queue),
  308. AR5K_QCU_MISC_FRSHED_CBR);
  309. if (tq->tqi_cbr_overflow_limit)
  310. AR5K_REG_ENABLE_BITS(ah,
  311. AR5K_QUEUE_MISC(queue),
  312. AR5K_QCU_MISC_CBR_THRES_ENABLE);
  313. }
  314. if (tq->tqi_ready_time &&
  315. (tq->tqi_type != AR5K_TX_QUEUE_CAB))
  316. ath5k_hw_reg_write(ah, AR5K_REG_SM(tq->tqi_ready_time,
  317. AR5K_QCU_RDYTIMECFG_INTVAL) |
  318. AR5K_QCU_RDYTIMECFG_ENABLE,
  319. AR5K_QUEUE_RDYTIMECFG(queue));
  320. if (tq->tqi_burst_time) {
  321. ath5k_hw_reg_write(ah, AR5K_REG_SM(tq->tqi_burst_time,
  322. AR5K_DCU_CHAN_TIME_DUR) |
  323. AR5K_DCU_CHAN_TIME_ENABLE,
  324. AR5K_QUEUE_DFS_CHANNEL_TIME(queue));
  325. if (tq->tqi_flags
  326. & AR5K_TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE)
  327. AR5K_REG_ENABLE_BITS(ah,
  328. AR5K_QUEUE_MISC(queue),
  329. AR5K_QCU_MISC_RDY_VEOL_POLICY);
  330. }
  331. if (tq->tqi_flags & AR5K_TXQ_FLAG_BACKOFF_DISABLE)
  332. ath5k_hw_reg_write(ah, AR5K_DCU_MISC_POST_FR_BKOFF_DIS,
  333. AR5K_QUEUE_DFS_MISC(queue));
  334. if (tq->tqi_flags & AR5K_TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE)
  335. ath5k_hw_reg_write(ah, AR5K_DCU_MISC_BACKOFF_FRAG,
  336. AR5K_QUEUE_DFS_MISC(queue));
  337. /*
  338. * Set registers by queue type
  339. */
  340. switch (tq->tqi_type) {
  341. case AR5K_TX_QUEUE_BEACON:
  342. AR5K_REG_ENABLE_BITS(ah, AR5K_QUEUE_MISC(queue),
  343. AR5K_QCU_MISC_FRSHED_DBA_GT |
  344. AR5K_QCU_MISC_CBREXP_BCN_DIS |
  345. AR5K_QCU_MISC_BCN_ENABLE);
  346. AR5K_REG_ENABLE_BITS(ah, AR5K_QUEUE_DFS_MISC(queue),
  347. (AR5K_DCU_MISC_ARBLOCK_CTL_GLOBAL <<
  348. AR5K_DCU_MISC_ARBLOCK_CTL_S) |
  349. AR5K_DCU_MISC_ARBLOCK_IGNORE |
  350. AR5K_DCU_MISC_POST_FR_BKOFF_DIS |
  351. AR5K_DCU_MISC_BCN_ENABLE);
  352. break;
  353. case AR5K_TX_QUEUE_CAB:
  354. /* XXX: use BCN_SENT_GT, if we can figure out how */
  355. AR5K_REG_ENABLE_BITS(ah, AR5K_QUEUE_MISC(queue),
  356. AR5K_QCU_MISC_FRSHED_DBA_GT |
  357. AR5K_QCU_MISC_CBREXP_DIS |
  358. AR5K_QCU_MISC_CBREXP_BCN_DIS);
  359. ath5k_hw_reg_write(ah, ((tq->tqi_ready_time -
  360. (AR5K_TUNE_SW_BEACON_RESP -
  361. AR5K_TUNE_DMA_BEACON_RESP) -
  362. AR5K_TUNE_ADDITIONAL_SWBA_BACKOFF) * 1024) |
  363. AR5K_QCU_RDYTIMECFG_ENABLE,
  364. AR5K_QUEUE_RDYTIMECFG(queue));
  365. AR5K_REG_ENABLE_BITS(ah, AR5K_QUEUE_DFS_MISC(queue),
  366. (AR5K_DCU_MISC_ARBLOCK_CTL_GLOBAL <<
  367. AR5K_DCU_MISC_ARBLOCK_CTL_S));
  368. break;
  369. case AR5K_TX_QUEUE_UAPSD:
  370. AR5K_REG_ENABLE_BITS(ah, AR5K_QUEUE_MISC(queue),
  371. AR5K_QCU_MISC_CBREXP_DIS);
  372. break;
  373. case AR5K_TX_QUEUE_DATA:
  374. default:
  375. break;
  376. }
  377. /* TODO: Handle frame compression */
  378. /*
  379. * Enable interrupts for this tx queue
  380. * in the secondary interrupt mask registers
  381. */
  382. if (tq->tqi_flags & AR5K_TXQ_FLAG_TXOKINT_ENABLE)
  383. AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_txok, queue);
  384. if (tq->tqi_flags & AR5K_TXQ_FLAG_TXERRINT_ENABLE)
  385. AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_txerr, queue);
  386. if (tq->tqi_flags & AR5K_TXQ_FLAG_TXURNINT_ENABLE)
  387. AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_txurn, queue);
  388. if (tq->tqi_flags & AR5K_TXQ_FLAG_TXDESCINT_ENABLE)
  389. AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_txdesc, queue);
  390. if (tq->tqi_flags & AR5K_TXQ_FLAG_TXEOLINT_ENABLE)
  391. AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_txeol, queue);
  392. if (tq->tqi_flags & AR5K_TXQ_FLAG_CBRORNINT_ENABLE)
  393. AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_cbrorn, queue);
  394. if (tq->tqi_flags & AR5K_TXQ_FLAG_CBRURNINT_ENABLE)
  395. AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_cbrurn, queue);
  396. if (tq->tqi_flags & AR5K_TXQ_FLAG_QTRIGINT_ENABLE)
  397. AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_qtrig, queue);
  398. if (tq->tqi_flags & AR5K_TXQ_FLAG_TXNOFRMINT_ENABLE)
  399. AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_nofrm, queue);
  400. /* Update secondary interrupt mask registers */
  401. /* Filter out inactive queues */
  402. ah->ah_txq_imr_txok &= ah->ah_txq_status;
  403. ah->ah_txq_imr_txerr &= ah->ah_txq_status;
  404. ah->ah_txq_imr_txurn &= ah->ah_txq_status;
  405. ah->ah_txq_imr_txdesc &= ah->ah_txq_status;
  406. ah->ah_txq_imr_txeol &= ah->ah_txq_status;
  407. ah->ah_txq_imr_cbrorn &= ah->ah_txq_status;
  408. ah->ah_txq_imr_cbrurn &= ah->ah_txq_status;
  409. ah->ah_txq_imr_qtrig &= ah->ah_txq_status;
  410. ah->ah_txq_imr_nofrm &= ah->ah_txq_status;
  411. ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_txok,
  412. AR5K_SIMR0_QCU_TXOK) |
  413. AR5K_REG_SM(ah->ah_txq_imr_txdesc,
  414. AR5K_SIMR0_QCU_TXDESC), AR5K_SIMR0);
  415. ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_txerr,
  416. AR5K_SIMR1_QCU_TXERR) |
  417. AR5K_REG_SM(ah->ah_txq_imr_txeol,
  418. AR5K_SIMR1_QCU_TXEOL), AR5K_SIMR1);
  419. /* Update simr2 but don't overwrite rest simr2 settings */
  420. AR5K_REG_DISABLE_BITS(ah, AR5K_SIMR2, AR5K_SIMR2_QCU_TXURN);
  421. AR5K_REG_ENABLE_BITS(ah, AR5K_SIMR2,
  422. AR5K_REG_SM(ah->ah_txq_imr_txurn,
  423. AR5K_SIMR2_QCU_TXURN));
  424. ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_cbrorn,
  425. AR5K_SIMR3_QCBRORN) |
  426. AR5K_REG_SM(ah->ah_txq_imr_cbrurn,
  427. AR5K_SIMR3_QCBRURN), AR5K_SIMR3);
  428. ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_qtrig,
  429. AR5K_SIMR4_QTRIG), AR5K_SIMR4);
  430. /* Set TXNOFRM_QCU for the queues with TXNOFRM enabled */
  431. ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_nofrm,
  432. AR5K_TXNOFRM_QCU), AR5K_TXNOFRM);
  433. /* No queue has TXNOFRM enabled, disable the interrupt
  434. * by setting AR5K_TXNOFRM to zero */
  435. if (ah->ah_txq_imr_nofrm == 0)
  436. ath5k_hw_reg_write(ah, 0, AR5K_TXNOFRM);
  437. /* Set QCU mask for this DCU to save power */
  438. AR5K_REG_WRITE_Q(ah, AR5K_QUEUE_QCUMASK(queue), queue);
  439. }
  440. return 0;
  441. }
  442. /*
  443. * Set slot time on DCU
  444. */
  445. int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time)
  446. {
  447. u32 slot_time_clock = ath5k_hw_htoclock(ah, slot_time);
  448. if (slot_time < 6 || slot_time_clock > AR5K_SLOT_TIME_MAX)
  449. return -EINVAL;
  450. if (ah->ah_version == AR5K_AR5210)
  451. ath5k_hw_reg_write(ah, slot_time_clock, AR5K_SLOT_TIME);
  452. else
  453. ath5k_hw_reg_write(ah, slot_time_clock, AR5K_DCU_GBL_IFS_SLOT);
  454. return 0;
  455. }