dma.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  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. * DMA and interrupt masking functions *
  20. \*************************************/
  21. /*
  22. * dma.c - DMA and interrupt masking functions
  23. *
  24. * Here we setup descriptor pointers (rxdp/txdp) start/stop dma engine and
  25. * handle queue setup for 5210 chipset (rest are handled on qcu.c).
  26. * Also we setup interrupt mask register (IMR) and read the various iterrupt
  27. * status registers (ISR).
  28. *
  29. * TODO: Handle SISR on 5211+ and introduce a function to return the queue
  30. * number that resulted the interrupt.
  31. */
  32. #include "ath5k.h"
  33. #include "reg.h"
  34. #include "debug.h"
  35. #include "base.h"
  36. /*********\
  37. * Receive *
  38. \*********/
  39. /**
  40. * ath5k_hw_start_rx_dma - Start DMA receive
  41. *
  42. * @ah: The &struct ath5k_hw
  43. */
  44. void ath5k_hw_start_rx_dma(struct ath5k_hw *ah)
  45. {
  46. ATH5K_TRACE(ah->ah_sc);
  47. ath5k_hw_reg_write(ah, AR5K_CR_RXE, AR5K_CR);
  48. ath5k_hw_reg_read(ah, AR5K_CR);
  49. }
  50. /**
  51. * ath5k_hw_stop_rx_dma - Stop DMA receive
  52. *
  53. * @ah: The &struct ath5k_hw
  54. */
  55. int ath5k_hw_stop_rx_dma(struct ath5k_hw *ah)
  56. {
  57. unsigned int i;
  58. ATH5K_TRACE(ah->ah_sc);
  59. ath5k_hw_reg_write(ah, AR5K_CR_RXD, AR5K_CR);
  60. /*
  61. * It may take some time to disable the DMA receive unit
  62. */
  63. for (i = 1000; i > 0 &&
  64. (ath5k_hw_reg_read(ah, AR5K_CR) & AR5K_CR_RXE) != 0;
  65. i--)
  66. udelay(10);
  67. return i ? 0 : -EBUSY;
  68. }
  69. /**
  70. * ath5k_hw_get_rxdp - Get RX Descriptor's address
  71. *
  72. * @ah: The &struct ath5k_hw
  73. *
  74. * XXX: Is RXDP read and clear ?
  75. */
  76. u32 ath5k_hw_get_rxdp(struct ath5k_hw *ah)
  77. {
  78. return ath5k_hw_reg_read(ah, AR5K_RXDP);
  79. }
  80. /**
  81. * ath5k_hw_set_rxdp - Set RX Descriptor's address
  82. *
  83. * @ah: The &struct ath5k_hw
  84. * @phys_addr: RX descriptor address
  85. *
  86. * XXX: Should we check if rx is enabled before setting rxdp ?
  87. */
  88. void ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr)
  89. {
  90. ATH5K_TRACE(ah->ah_sc);
  91. ath5k_hw_reg_write(ah, phys_addr, AR5K_RXDP);
  92. }
  93. /**********\
  94. * Transmit *
  95. \**********/
  96. /**
  97. * ath5k_hw_start_tx_dma - Start DMA transmit for a specific queue
  98. *
  99. * @ah: The &struct ath5k_hw
  100. * @queue: The hw queue number
  101. *
  102. * Start DMA transmit for a specific queue and since 5210 doesn't have
  103. * QCU/DCU, set up queue parameters for 5210 here based on queue type (one
  104. * queue for normal data and one queue for beacons). For queue setup
  105. * on newer chips check out qcu.c. Returns -EINVAL if queue number is out
  106. * of range or if queue is already disabled.
  107. *
  108. * NOTE: Must be called after setting up tx control descriptor for that
  109. * queue (see below).
  110. */
  111. int ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue)
  112. {
  113. u32 tx_queue;
  114. ATH5K_TRACE(ah->ah_sc);
  115. AR5K_ASSERT_ENTRY(queue, ah->ah_capabilities.cap_queues.q_tx_num);
  116. /* Return if queue is declared inactive */
  117. if (ah->ah_txq[queue].tqi_type == AR5K_TX_QUEUE_INACTIVE)
  118. return -EIO;
  119. if (ah->ah_version == AR5K_AR5210) {
  120. tx_queue = ath5k_hw_reg_read(ah, AR5K_CR);
  121. /*
  122. * Set the queue by type on 5210
  123. */
  124. switch (ah->ah_txq[queue].tqi_type) {
  125. case AR5K_TX_QUEUE_DATA:
  126. tx_queue |= AR5K_CR_TXE0 & ~AR5K_CR_TXD0;
  127. break;
  128. case AR5K_TX_QUEUE_BEACON:
  129. tx_queue |= AR5K_CR_TXE1 & ~AR5K_CR_TXD1;
  130. ath5k_hw_reg_write(ah, AR5K_BCR_TQ1V | AR5K_BCR_BDMAE,
  131. AR5K_BSR);
  132. break;
  133. case AR5K_TX_QUEUE_CAB:
  134. tx_queue |= AR5K_CR_TXE1 & ~AR5K_CR_TXD1;
  135. ath5k_hw_reg_write(ah, AR5K_BCR_TQ1FV | AR5K_BCR_TQ1V |
  136. AR5K_BCR_BDMAE, AR5K_BSR);
  137. break;
  138. default:
  139. return -EINVAL;
  140. }
  141. /* Start queue */
  142. ath5k_hw_reg_write(ah, tx_queue, AR5K_CR);
  143. ath5k_hw_reg_read(ah, AR5K_CR);
  144. } else {
  145. /* Return if queue is disabled */
  146. if (AR5K_REG_READ_Q(ah, AR5K_QCU_TXD, queue))
  147. return -EIO;
  148. /* Start queue */
  149. AR5K_REG_WRITE_Q(ah, AR5K_QCU_TXE, queue);
  150. }
  151. return 0;
  152. }
  153. /**
  154. * ath5k_hw_stop_tx_dma - Stop DMA transmit on a specific queue
  155. *
  156. * @ah: The &struct ath5k_hw
  157. * @queue: The hw queue number
  158. *
  159. * Stop DMA transmit on a specific hw queue and drain queue so we don't
  160. * have any pending frames. Returns -EBUSY if we still have pending frames,
  161. * -EINVAL if queue number is out of range.
  162. *
  163. */
  164. int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue)
  165. {
  166. unsigned int i = 40;
  167. u32 tx_queue, pending;
  168. ATH5K_TRACE(ah->ah_sc);
  169. AR5K_ASSERT_ENTRY(queue, ah->ah_capabilities.cap_queues.q_tx_num);
  170. /* Return if queue is declared inactive */
  171. if (ah->ah_txq[queue].tqi_type == AR5K_TX_QUEUE_INACTIVE)
  172. return -EIO;
  173. if (ah->ah_version == AR5K_AR5210) {
  174. tx_queue = ath5k_hw_reg_read(ah, AR5K_CR);
  175. /*
  176. * Set by queue type
  177. */
  178. switch (ah->ah_txq[queue].tqi_type) {
  179. case AR5K_TX_QUEUE_DATA:
  180. tx_queue |= AR5K_CR_TXD0 & ~AR5K_CR_TXE0;
  181. break;
  182. case AR5K_TX_QUEUE_BEACON:
  183. case AR5K_TX_QUEUE_CAB:
  184. /* XXX Fix me... */
  185. tx_queue |= AR5K_CR_TXD1 & ~AR5K_CR_TXD1;
  186. ath5k_hw_reg_write(ah, 0, AR5K_BSR);
  187. break;
  188. default:
  189. return -EINVAL;
  190. }
  191. /* Stop queue */
  192. ath5k_hw_reg_write(ah, tx_queue, AR5K_CR);
  193. ath5k_hw_reg_read(ah, AR5K_CR);
  194. } else {
  195. /*
  196. * Schedule TX disable and wait until queue is empty
  197. */
  198. AR5K_REG_WRITE_Q(ah, AR5K_QCU_TXD, queue);
  199. /*Check for pending frames*/
  200. do {
  201. pending = ath5k_hw_reg_read(ah,
  202. AR5K_QUEUE_STATUS(queue)) &
  203. AR5K_QCU_STS_FRMPENDCNT;
  204. udelay(100);
  205. } while (--i && pending);
  206. /* For 2413+ order PCU to drop packets using
  207. * QUIET mechanism */
  208. if (ah->ah_mac_version >= (AR5K_SREV_AR2414 >> 4) &&
  209. pending){
  210. /* Set periodicity and duration */
  211. ath5k_hw_reg_write(ah,
  212. AR5K_REG_SM(100, AR5K_QUIET_CTL2_QT_PER)|
  213. AR5K_REG_SM(10, AR5K_QUIET_CTL2_QT_DUR),
  214. AR5K_QUIET_CTL2);
  215. /* Enable quiet period for current TSF */
  216. ath5k_hw_reg_write(ah,
  217. AR5K_QUIET_CTL1_QT_EN |
  218. AR5K_REG_SM(ath5k_hw_reg_read(ah,
  219. AR5K_TSF_L32_5211) >> 10,
  220. AR5K_QUIET_CTL1_NEXT_QT_TSF),
  221. AR5K_QUIET_CTL1);
  222. /* Force channel idle high */
  223. AR5K_REG_ENABLE_BITS(ah, AR5K_DIAG_SW_5211,
  224. AR5K_DIAG_SW_CHANEL_IDLE_HIGH);
  225. /* Wait a while and disable mechanism */
  226. udelay(200);
  227. AR5K_REG_DISABLE_BITS(ah, AR5K_QUIET_CTL1,
  228. AR5K_QUIET_CTL1_QT_EN);
  229. /* Re-check for pending frames */
  230. i = 40;
  231. do {
  232. pending = ath5k_hw_reg_read(ah,
  233. AR5K_QUEUE_STATUS(queue)) &
  234. AR5K_QCU_STS_FRMPENDCNT;
  235. udelay(100);
  236. } while (--i && pending);
  237. AR5K_REG_DISABLE_BITS(ah, AR5K_DIAG_SW_5211,
  238. AR5K_DIAG_SW_CHANEL_IDLE_HIGH);
  239. }
  240. /* Clear register */
  241. ath5k_hw_reg_write(ah, 0, AR5K_QCU_TXD);
  242. if (pending)
  243. return -EBUSY;
  244. }
  245. /* TODO: Check for success on 5210 else return error */
  246. return 0;
  247. }
  248. /**
  249. * ath5k_hw_get_txdp - Get TX Descriptor's address for a specific queue
  250. *
  251. * @ah: The &struct ath5k_hw
  252. * @queue: The hw queue number
  253. *
  254. * Get TX descriptor's address for a specific queue. For 5210 we ignore
  255. * the queue number and use tx queue type since we only have 2 queues.
  256. * We use TXDP0 for normal data queue and TXDP1 for beacon queue.
  257. * For newer chips with QCU/DCU we just read the corresponding TXDP register.
  258. *
  259. * XXX: Is TXDP read and clear ?
  260. */
  261. u32 ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue)
  262. {
  263. u16 tx_reg;
  264. ATH5K_TRACE(ah->ah_sc);
  265. AR5K_ASSERT_ENTRY(queue, ah->ah_capabilities.cap_queues.q_tx_num);
  266. /*
  267. * Get the transmit queue descriptor pointer from the selected queue
  268. */
  269. /*5210 doesn't have QCU*/
  270. if (ah->ah_version == AR5K_AR5210) {
  271. switch (ah->ah_txq[queue].tqi_type) {
  272. case AR5K_TX_QUEUE_DATA:
  273. tx_reg = AR5K_NOQCU_TXDP0;
  274. break;
  275. case AR5K_TX_QUEUE_BEACON:
  276. case AR5K_TX_QUEUE_CAB:
  277. tx_reg = AR5K_NOQCU_TXDP1;
  278. break;
  279. default:
  280. return 0xffffffff;
  281. }
  282. } else {
  283. tx_reg = AR5K_QUEUE_TXDP(queue);
  284. }
  285. return ath5k_hw_reg_read(ah, tx_reg);
  286. }
  287. /**
  288. * ath5k_hw_set_txdp - Set TX Descriptor's address for a specific queue
  289. *
  290. * @ah: The &struct ath5k_hw
  291. * @queue: The hw queue number
  292. *
  293. * Set TX descriptor's address for a specific queue. For 5210 we ignore
  294. * the queue number and we use tx queue type since we only have 2 queues
  295. * so as above we use TXDP0 for normal data queue and TXDP1 for beacon queue.
  296. * For newer chips with QCU/DCU we just set the corresponding TXDP register.
  297. * Returns -EINVAL if queue type is invalid for 5210 and -EIO if queue is still
  298. * active.
  299. */
  300. int ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue, u32 phys_addr)
  301. {
  302. u16 tx_reg;
  303. ATH5K_TRACE(ah->ah_sc);
  304. AR5K_ASSERT_ENTRY(queue, ah->ah_capabilities.cap_queues.q_tx_num);
  305. /*
  306. * Set the transmit queue descriptor pointer register by type
  307. * on 5210
  308. */
  309. if (ah->ah_version == AR5K_AR5210) {
  310. switch (ah->ah_txq[queue].tqi_type) {
  311. case AR5K_TX_QUEUE_DATA:
  312. tx_reg = AR5K_NOQCU_TXDP0;
  313. break;
  314. case AR5K_TX_QUEUE_BEACON:
  315. case AR5K_TX_QUEUE_CAB:
  316. tx_reg = AR5K_NOQCU_TXDP1;
  317. break;
  318. default:
  319. return -EINVAL;
  320. }
  321. } else {
  322. /*
  323. * Set the transmit queue descriptor pointer for
  324. * the selected queue on QCU for 5211+
  325. * (this won't work if the queue is still active)
  326. */
  327. if (AR5K_REG_READ_Q(ah, AR5K_QCU_TXE, queue))
  328. return -EIO;
  329. tx_reg = AR5K_QUEUE_TXDP(queue);
  330. }
  331. /* Set descriptor pointer */
  332. ath5k_hw_reg_write(ah, phys_addr, tx_reg);
  333. return 0;
  334. }
  335. /**
  336. * ath5k_hw_update_tx_triglevel - Update tx trigger level
  337. *
  338. * @ah: The &struct ath5k_hw
  339. * @increase: Flag to force increase of trigger level
  340. *
  341. * This function increases/decreases the tx trigger level for the tx fifo
  342. * buffer (aka FIFO threshold) that is used to indicate when PCU flushes
  343. * the buffer and transmits it's data. Lowering this results sending small
  344. * frames more quickly but can lead to tx underruns, raising it a lot can
  345. * result other problems (i think bmiss is related). Right now we start with
  346. * the lowest possible (64Bytes) and if we get tx underrun we increase it using
  347. * the increase flag. Returns -EIO if we have have reached maximum/minimum.
  348. *
  349. * XXX: Link this with tx DMA size ?
  350. * XXX: Use it to save interrupts ?
  351. * TODO: Needs testing, i think it's related to bmiss...
  352. */
  353. int ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase)
  354. {
  355. u32 trigger_level, imr;
  356. int ret = -EIO;
  357. ATH5K_TRACE(ah->ah_sc);
  358. /*
  359. * Disable interrupts by setting the mask
  360. */
  361. imr = ath5k_hw_set_imr(ah, ah->ah_imr & ~AR5K_INT_GLOBAL);
  362. trigger_level = AR5K_REG_MS(ath5k_hw_reg_read(ah, AR5K_TXCFG),
  363. AR5K_TXCFG_TXFULL);
  364. if (!increase) {
  365. if (--trigger_level < AR5K_TUNE_MIN_TX_FIFO_THRES)
  366. goto done;
  367. } else
  368. trigger_level +=
  369. ((AR5K_TUNE_MAX_TX_FIFO_THRES - trigger_level) / 2);
  370. /*
  371. * Update trigger level on success
  372. */
  373. if (ah->ah_version == AR5K_AR5210)
  374. ath5k_hw_reg_write(ah, trigger_level, AR5K_TRIG_LVL);
  375. else
  376. AR5K_REG_WRITE_BITS(ah, AR5K_TXCFG,
  377. AR5K_TXCFG_TXFULL, trigger_level);
  378. ret = 0;
  379. done:
  380. /*
  381. * Restore interrupt mask
  382. */
  383. ath5k_hw_set_imr(ah, imr);
  384. return ret;
  385. }
  386. /*******************\
  387. * Interrupt masking *
  388. \*******************/
  389. /**
  390. * ath5k_hw_is_intr_pending - Check if we have pending interrupts
  391. *
  392. * @ah: The &struct ath5k_hw
  393. *
  394. * Check if we have pending interrupts to process. Returns 1 if we
  395. * have pending interrupts and 0 if we haven't.
  396. */
  397. bool ath5k_hw_is_intr_pending(struct ath5k_hw *ah)
  398. {
  399. ATH5K_TRACE(ah->ah_sc);
  400. return ath5k_hw_reg_read(ah, AR5K_INTPEND) == 1 ? 1 : 0;
  401. }
  402. /**
  403. * ath5k_hw_get_isr - Get interrupt status
  404. *
  405. * @ah: The @struct ath5k_hw
  406. * @interrupt_mask: Driver's interrupt mask used to filter out
  407. * interrupts in sw.
  408. *
  409. * This function is used inside our interrupt handler to determine the reason
  410. * for the interrupt by reading Primary Interrupt Status Register. Returns an
  411. * abstract interrupt status mask which is mostly ISR with some uncommon bits
  412. * being mapped on some standard non hw-specific positions
  413. * (check out &ath5k_int).
  414. *
  415. * NOTE: We use read-and-clear register, so after this function is called ISR
  416. * is zeroed.
  417. *
  418. * XXX: Why filter interrupts in sw with interrupt_mask ? No benefit at all
  419. * plus it can be misleading (one might thing that we save interrupts this way)
  420. */
  421. int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask)
  422. {
  423. u32 data;
  424. ATH5K_TRACE(ah->ah_sc);
  425. /*
  426. * Read interrupt status from the Interrupt Status register
  427. * on 5210
  428. */
  429. if (ah->ah_version == AR5K_AR5210) {
  430. data = ath5k_hw_reg_read(ah, AR5K_ISR);
  431. if (unlikely(data == AR5K_INT_NOCARD)) {
  432. *interrupt_mask = data;
  433. return -ENODEV;
  434. }
  435. } else {
  436. /*
  437. * Read interrupt status from the Read-And-Clear
  438. * shadow register.
  439. * Note: PISR/SISR Not available on 5210
  440. */
  441. data = ath5k_hw_reg_read(ah, AR5K_RAC_PISR);
  442. }
  443. /*
  444. * Get abstract interrupt mask (driver-compatible)
  445. */
  446. *interrupt_mask = (data & AR5K_INT_COMMON) & ah->ah_imr;
  447. if (unlikely(data == AR5K_INT_NOCARD))
  448. return -ENODEV;
  449. if (data & (AR5K_ISR_RXOK | AR5K_ISR_RXERR))
  450. *interrupt_mask |= AR5K_INT_RX;
  451. if (data & (AR5K_ISR_TXOK | AR5K_ISR_TXERR
  452. | AR5K_ISR_TXDESC | AR5K_ISR_TXEOL))
  453. *interrupt_mask |= AR5K_INT_TX;
  454. if (ah->ah_version != AR5K_AR5210) {
  455. /*HIU = Host Interface Unit (PCI etc)*/
  456. if (unlikely(data & (AR5K_ISR_HIUERR)))
  457. *interrupt_mask |= AR5K_INT_FATAL;
  458. /*Beacon Not Ready*/
  459. if (unlikely(data & (AR5K_ISR_BNR)))
  460. *interrupt_mask |= AR5K_INT_BNR;
  461. }
  462. /*
  463. * XXX: BMISS interrupts may occur after association.
  464. * I found this on 5210 code but it needs testing. If this is
  465. * true we should disable them before assoc and re-enable them
  466. * after a successfull assoc + some jiffies.
  467. */
  468. #if 0
  469. interrupt_mask &= ~AR5K_INT_BMISS;
  470. #endif
  471. /*
  472. * In case we didn't handle anything,
  473. * print the register value.
  474. */
  475. if (unlikely(*interrupt_mask == 0 && net_ratelimit()))
  476. ATH5K_PRINTF("0x%08x\n", data);
  477. return 0;
  478. }
  479. /**
  480. * ath5k_hw_set_imr - Set interrupt mask
  481. *
  482. * @ah: The &struct ath5k_hw
  483. * @new_mask: The new interrupt mask to be set
  484. *
  485. * Set the interrupt mask in hw to save interrupts. We do that by mapping
  486. * ath5k_int bits to hw-specific bits to remove abstraction and writing
  487. * Interrupt Mask Register.
  488. */
  489. enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask)
  490. {
  491. enum ath5k_int old_mask, int_mask;
  492. /*
  493. * Disable card interrupts to prevent any race conditions
  494. * (they will be re-enabled afterwards).
  495. */
  496. ath5k_hw_reg_write(ah, AR5K_IER_DISABLE, AR5K_IER);
  497. ath5k_hw_reg_read(ah, AR5K_IER);
  498. old_mask = ah->ah_imr;
  499. /*
  500. * Add additional, chipset-dependent interrupt mask flags
  501. * and write them to the IMR (interrupt mask register).
  502. */
  503. int_mask = new_mask & AR5K_INT_COMMON;
  504. if (new_mask & AR5K_INT_RX)
  505. int_mask |= AR5K_IMR_RXOK | AR5K_IMR_RXERR | AR5K_IMR_RXORN |
  506. AR5K_IMR_RXDESC;
  507. if (new_mask & AR5K_INT_TX)
  508. int_mask |= AR5K_IMR_TXOK | AR5K_IMR_TXERR | AR5K_IMR_TXDESC |
  509. AR5K_IMR_TXURN;
  510. if (ah->ah_version != AR5K_AR5210) {
  511. if (new_mask & AR5K_INT_FATAL) {
  512. int_mask |= AR5K_IMR_HIUERR;
  513. AR5K_REG_ENABLE_BITS(ah, AR5K_SIMR2, AR5K_SIMR2_MCABT |
  514. AR5K_SIMR2_SSERR | AR5K_SIMR2_DPERR);
  515. }
  516. }
  517. ath5k_hw_reg_write(ah, int_mask, AR5K_PIMR);
  518. /* Store new interrupt mask */
  519. ah->ah_imr = new_mask;
  520. /* ..re-enable interrupts */
  521. ath5k_hw_reg_write(ah, AR5K_IER_ENABLE, AR5K_IER);
  522. ath5k_hw_reg_read(ah, AR5K_IER);
  523. return old_mask;
  524. }