2 * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
3 * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
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.
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.
19 /*************************************\
20 * DMA and interrupt masking functions *
21 \*************************************/
24 * dma.c - DMA and interrupt masking functions
26 * Here we setup descriptor pointers (rxdp/txdp) start/stop dma engine and
27 * handle queue setup for 5210 chipset (rest are handled on qcu.c).
28 * Also we setup interrupt mask register (IMR) and read the various iterrupt
29 * status registers (ISR).
31 * TODO: Handle SISR on 5211+ and introduce a function to return the queue
32 * number that resulted the interrupt.
46 * ath5k_hw_start_rx_dma - Start DMA receive
48 * @ah: The &struct ath5k_hw
50 void ath5k_hw_start_rx_dma(struct ath5k_hw
*ah
)
52 ath5k_hw_reg_write(ah
, AR5K_CR_RXE
, AR5K_CR
);
53 ath5k_hw_reg_read(ah
, AR5K_CR
);
57 * ath5k_hw_stop_rx_dma - Stop DMA receive
59 * @ah: The &struct ath5k_hw
61 int ath5k_hw_stop_rx_dma(struct ath5k_hw
*ah
)
65 ath5k_hw_reg_write(ah
, AR5K_CR_RXD
, AR5K_CR
);
68 * It may take some time to disable the DMA receive unit
70 for (i
= 1000; i
> 0 &&
71 (ath5k_hw_reg_read(ah
, AR5K_CR
) & AR5K_CR_RXE
) != 0;
75 return i
? 0 : -EBUSY
;
79 * ath5k_hw_get_rxdp - Get RX Descriptor's address
81 * @ah: The &struct ath5k_hw
83 u32
ath5k_hw_get_rxdp(struct ath5k_hw
*ah
)
85 return ath5k_hw_reg_read(ah
, AR5K_RXDP
);
89 * ath5k_hw_set_rxdp - Set RX Descriptor's address
91 * @ah: The &struct ath5k_hw
92 * @phys_addr: RX descriptor address
94 * XXX: Should we check if rx is enabled before setting rxdp ?
96 void ath5k_hw_set_rxdp(struct ath5k_hw
*ah
, u32 phys_addr
)
98 ath5k_hw_reg_write(ah
, phys_addr
, AR5K_RXDP
);
107 * ath5k_hw_start_tx_dma - Start DMA transmit for a specific queue
109 * @ah: The &struct ath5k_hw
110 * @queue: The hw queue number
112 * Start DMA transmit for a specific queue and since 5210 doesn't have
113 * QCU/DCU, set up queue parameters for 5210 here based on queue type (one
114 * queue for normal data and one queue for beacons). For queue setup
115 * on newer chips check out qcu.c. Returns -EINVAL if queue number is out
116 * of range or if queue is already disabled.
118 * NOTE: Must be called after setting up tx control descriptor for that
121 int ath5k_hw_start_tx_dma(struct ath5k_hw
*ah
, unsigned int queue
)
125 AR5K_ASSERT_ENTRY(queue
, ah
->ah_capabilities
.cap_queues
.q_tx_num
);
127 /* Return if queue is declared inactive */
128 if (ah
->ah_txq
[queue
].tqi_type
== AR5K_TX_QUEUE_INACTIVE
)
131 if (ah
->ah_version
== AR5K_AR5210
) {
132 tx_queue
= ath5k_hw_reg_read(ah
, AR5K_CR
);
135 * Set the queue by type on 5210
137 switch (ah
->ah_txq
[queue
].tqi_type
) {
138 case AR5K_TX_QUEUE_DATA
:
139 tx_queue
|= AR5K_CR_TXE0
& ~AR5K_CR_TXD0
;
141 case AR5K_TX_QUEUE_BEACON
:
142 tx_queue
|= AR5K_CR_TXE1
& ~AR5K_CR_TXD1
;
143 ath5k_hw_reg_write(ah
, AR5K_BCR_TQ1V
| AR5K_BCR_BDMAE
,
146 case AR5K_TX_QUEUE_CAB
:
147 tx_queue
|= AR5K_CR_TXE1
& ~AR5K_CR_TXD1
;
148 ath5k_hw_reg_write(ah
, AR5K_BCR_TQ1FV
| AR5K_BCR_TQ1V
|
149 AR5K_BCR_BDMAE
, AR5K_BSR
);
155 ath5k_hw_reg_write(ah
, tx_queue
, AR5K_CR
);
156 ath5k_hw_reg_read(ah
, AR5K_CR
);
158 /* Return if queue is disabled */
159 if (AR5K_REG_READ_Q(ah
, AR5K_QCU_TXD
, queue
))
163 AR5K_REG_WRITE_Q(ah
, AR5K_QCU_TXE
, queue
);
170 * ath5k_hw_stop_tx_dma - Stop DMA transmit on a specific queue
172 * @ah: The &struct ath5k_hw
173 * @queue: The hw queue number
175 * Stop DMA transmit on a specific hw queue and drain queue so we don't
176 * have any pending frames. Returns -EBUSY if we still have pending frames,
177 * -EINVAL if queue number is out of range or inactive.
180 int ath5k_hw_stop_tx_dma(struct ath5k_hw
*ah
, unsigned int queue
)
183 u32 tx_queue
, pending
;
185 AR5K_ASSERT_ENTRY(queue
, ah
->ah_capabilities
.cap_queues
.q_tx_num
);
187 /* Return if queue is declared inactive */
188 if (ah
->ah_txq
[queue
].tqi_type
== AR5K_TX_QUEUE_INACTIVE
)
191 if (ah
->ah_version
== AR5K_AR5210
) {
192 tx_queue
= ath5k_hw_reg_read(ah
, AR5K_CR
);
197 switch (ah
->ah_txq
[queue
].tqi_type
) {
198 case AR5K_TX_QUEUE_DATA
:
199 tx_queue
|= AR5K_CR_TXD0
& ~AR5K_CR_TXE0
;
201 case AR5K_TX_QUEUE_BEACON
:
202 case AR5K_TX_QUEUE_CAB
:
204 tx_queue
|= AR5K_CR_TXD1
& ~AR5K_CR_TXD1
;
205 ath5k_hw_reg_write(ah
, 0, AR5K_BSR
);
212 ath5k_hw_reg_write(ah
, tx_queue
, AR5K_CR
);
213 ath5k_hw_reg_read(ah
, AR5K_CR
);
216 * Schedule TX disable and wait until queue is empty
218 AR5K_REG_WRITE_Q(ah
, AR5K_QCU_TXD
, queue
);
220 /*Check for pending frames*/
222 pending
= ath5k_hw_reg_read(ah
,
223 AR5K_QUEUE_STATUS(queue
)) &
224 AR5K_QCU_STS_FRMPENDCNT
;
226 } while (--i
&& pending
);
228 /* For 2413+ order PCU to drop packets using
230 if (ah
->ah_mac_version
>= (AR5K_SREV_AR2414
>> 4) &&
232 /* Set periodicity and duration */
233 ath5k_hw_reg_write(ah
,
234 AR5K_REG_SM(100, AR5K_QUIET_CTL2_QT_PER
)|
235 AR5K_REG_SM(10, AR5K_QUIET_CTL2_QT_DUR
),
238 /* Enable quiet period for current TSF */
239 ath5k_hw_reg_write(ah
,
240 AR5K_QUIET_CTL1_QT_EN
|
241 AR5K_REG_SM(ath5k_hw_reg_read(ah
,
242 AR5K_TSF_L32_5211
) >> 10,
243 AR5K_QUIET_CTL1_NEXT_QT_TSF
),
246 /* Force channel idle high */
247 AR5K_REG_ENABLE_BITS(ah
, AR5K_DIAG_SW_5211
,
248 AR5K_DIAG_SW_CHANNEL_IDLE_HIGH
);
250 /* Wait a while and disable mechanism */
252 AR5K_REG_DISABLE_BITS(ah
, AR5K_QUIET_CTL1
,
253 AR5K_QUIET_CTL1_QT_EN
);
255 /* Re-check for pending frames */
258 pending
= ath5k_hw_reg_read(ah
,
259 AR5K_QUEUE_STATUS(queue
)) &
260 AR5K_QCU_STS_FRMPENDCNT
;
262 } while (--i
&& pending
);
264 AR5K_REG_DISABLE_BITS(ah
, AR5K_DIAG_SW_5211
,
265 AR5K_DIAG_SW_CHANNEL_IDLE_HIGH
);
269 ath5k_hw_reg_write(ah
, 0, AR5K_QCU_TXD
);
274 /* TODO: Check for success on 5210 else return error */
279 * ath5k_hw_get_txdp - Get TX Descriptor's address for a specific queue
281 * @ah: The &struct ath5k_hw
282 * @queue: The hw queue number
284 * Get TX descriptor's address for a specific queue. For 5210 we ignore
285 * the queue number and use tx queue type since we only have 2 queues.
286 * We use TXDP0 for normal data queue and TXDP1 for beacon queue.
287 * For newer chips with QCU/DCU we just read the corresponding TXDP register.
289 * XXX: Is TXDP read and clear ?
291 u32
ath5k_hw_get_txdp(struct ath5k_hw
*ah
, unsigned int queue
)
295 AR5K_ASSERT_ENTRY(queue
, ah
->ah_capabilities
.cap_queues
.q_tx_num
);
298 * Get the transmit queue descriptor pointer from the selected queue
300 /*5210 doesn't have QCU*/
301 if (ah
->ah_version
== AR5K_AR5210
) {
302 switch (ah
->ah_txq
[queue
].tqi_type
) {
303 case AR5K_TX_QUEUE_DATA
:
304 tx_reg
= AR5K_NOQCU_TXDP0
;
306 case AR5K_TX_QUEUE_BEACON
:
307 case AR5K_TX_QUEUE_CAB
:
308 tx_reg
= AR5K_NOQCU_TXDP1
;
314 tx_reg
= AR5K_QUEUE_TXDP(queue
);
317 return ath5k_hw_reg_read(ah
, tx_reg
);
321 * ath5k_hw_set_txdp - Set TX Descriptor's address for a specific queue
323 * @ah: The &struct ath5k_hw
324 * @queue: The hw queue number
326 * Set TX descriptor's address for a specific queue. For 5210 we ignore
327 * the queue number and we use tx queue type since we only have 2 queues
328 * so as above we use TXDP0 for normal data queue and TXDP1 for beacon queue.
329 * For newer chips with QCU/DCU we just set the corresponding TXDP register.
330 * Returns -EINVAL if queue type is invalid for 5210 and -EIO if queue is still
333 int ath5k_hw_set_txdp(struct ath5k_hw
*ah
, unsigned int queue
, u32 phys_addr
)
337 AR5K_ASSERT_ENTRY(queue
, ah
->ah_capabilities
.cap_queues
.q_tx_num
);
340 * Set the transmit queue descriptor pointer register by type
343 if (ah
->ah_version
== AR5K_AR5210
) {
344 switch (ah
->ah_txq
[queue
].tqi_type
) {
345 case AR5K_TX_QUEUE_DATA
:
346 tx_reg
= AR5K_NOQCU_TXDP0
;
348 case AR5K_TX_QUEUE_BEACON
:
349 case AR5K_TX_QUEUE_CAB
:
350 tx_reg
= AR5K_NOQCU_TXDP1
;
357 * Set the transmit queue descriptor pointer for
358 * the selected queue on QCU for 5211+
359 * (this won't work if the queue is still active)
361 if (AR5K_REG_READ_Q(ah
, AR5K_QCU_TXE
, queue
))
364 tx_reg
= AR5K_QUEUE_TXDP(queue
);
367 /* Set descriptor pointer */
368 ath5k_hw_reg_write(ah
, phys_addr
, tx_reg
);
374 * ath5k_hw_update_tx_triglevel - Update tx trigger level
376 * @ah: The &struct ath5k_hw
377 * @increase: Flag to force increase of trigger level
379 * This function increases/decreases the tx trigger level for the tx fifo
380 * buffer (aka FIFO threshold) that is used to indicate when PCU flushes
381 * the buffer and transmits its data. Lowering this results sending small
382 * frames more quickly but can lead to tx underruns, raising it a lot can
383 * result other problems (i think bmiss is related). Right now we start with
384 * the lowest possible (64Bytes) and if we get tx underrun we increase it using
385 * the increase flag. Returns -EIO if we have reached maximum/minimum.
387 * XXX: Link this with tx DMA size ?
388 * XXX: Use it to save interrupts ?
389 * TODO: Needs testing, i think it's related to bmiss...
391 int ath5k_hw_update_tx_triglevel(struct ath5k_hw
*ah
, bool increase
)
393 u32 trigger_level
, imr
;
397 * Disable interrupts by setting the mask
399 imr
= ath5k_hw_set_imr(ah
, ah
->ah_imr
& ~AR5K_INT_GLOBAL
);
401 trigger_level
= AR5K_REG_MS(ath5k_hw_reg_read(ah
, AR5K_TXCFG
),
405 if (--trigger_level
< AR5K_TUNE_MIN_TX_FIFO_THRES
)
409 ((AR5K_TUNE_MAX_TX_FIFO_THRES
- trigger_level
) / 2);
412 * Update trigger level on success
414 if (ah
->ah_version
== AR5K_AR5210
)
415 ath5k_hw_reg_write(ah
, trigger_level
, AR5K_TRIG_LVL
);
417 AR5K_REG_WRITE_BITS(ah
, AR5K_TXCFG
,
418 AR5K_TXCFG_TXFULL
, trigger_level
);
424 * Restore interrupt mask
426 ath5k_hw_set_imr(ah
, imr
);
432 /*******************\
433 * Interrupt masking *
434 \*******************/
437 * ath5k_hw_is_intr_pending - Check if we have pending interrupts
439 * @ah: The &struct ath5k_hw
441 * Check if we have pending interrupts to process. Returns 1 if we
442 * have pending interrupts and 0 if we haven't.
444 bool ath5k_hw_is_intr_pending(struct ath5k_hw
*ah
)
446 return ath5k_hw_reg_read(ah
, AR5K_INTPEND
) == 1 ? 1 : 0;
450 * ath5k_hw_get_isr - Get interrupt status
452 * @ah: The @struct ath5k_hw
453 * @interrupt_mask: Driver's interrupt mask used to filter out
456 * This function is used inside our interrupt handler to determine the reason
457 * for the interrupt by reading Primary Interrupt Status Register. Returns an
458 * abstract interrupt status mask which is mostly ISR with some uncommon bits
459 * being mapped on some standard non hw-specific positions
460 * (check out &ath5k_int).
462 * NOTE: We use read-and-clear register, so after this function is called ISR
465 int ath5k_hw_get_isr(struct ath5k_hw
*ah
, enum ath5k_int
*interrupt_mask
)
470 * Read interrupt status from the Interrupt Status register
473 if (ah
->ah_version
== AR5K_AR5210
) {
474 data
= ath5k_hw_reg_read(ah
, AR5K_ISR
);
475 if (unlikely(data
== AR5K_INT_NOCARD
)) {
476 *interrupt_mask
= data
;
481 * Read interrupt status from Interrupt
482 * Status Register shadow copy (Read And Clear)
484 * Note: PISR/SISR Not available on 5210
486 data
= ath5k_hw_reg_read(ah
, AR5K_RAC_PISR
);
487 if (unlikely(data
== AR5K_INT_NOCARD
)) {
488 *interrupt_mask
= data
;
494 * Get abstract interrupt mask (driver-compatible)
496 *interrupt_mask
= (data
& AR5K_INT_COMMON
) & ah
->ah_imr
;
498 if (ah
->ah_version
!= AR5K_AR5210
) {
499 u32 sisr2
= ath5k_hw_reg_read(ah
, AR5K_RAC_SISR2
);
501 /*HIU = Host Interface Unit (PCI etc)*/
502 if (unlikely(data
& (AR5K_ISR_HIUERR
)))
503 *interrupt_mask
|= AR5K_INT_FATAL
;
506 if (unlikely(data
& (AR5K_ISR_BNR
)))
507 *interrupt_mask
|= AR5K_INT_BNR
;
509 if (unlikely(sisr2
& (AR5K_SISR2_SSERR
|
512 *interrupt_mask
|= AR5K_INT_FATAL
;
514 if (data
& AR5K_ISR_TIM
)
515 *interrupt_mask
|= AR5K_INT_TIM
;
517 if (data
& AR5K_ISR_BCNMISC
) {
518 if (sisr2
& AR5K_SISR2_TIM
)
519 *interrupt_mask
|= AR5K_INT_TIM
;
520 if (sisr2
& AR5K_SISR2_DTIM
)
521 *interrupt_mask
|= AR5K_INT_DTIM
;
522 if (sisr2
& AR5K_SISR2_DTIM_SYNC
)
523 *interrupt_mask
|= AR5K_INT_DTIM_SYNC
;
524 if (sisr2
& AR5K_SISR2_BCN_TIMEOUT
)
525 *interrupt_mask
|= AR5K_INT_BCN_TIMEOUT
;
526 if (sisr2
& AR5K_SISR2_CAB_TIMEOUT
)
527 *interrupt_mask
|= AR5K_INT_CAB_TIMEOUT
;
530 if (data
& AR5K_ISR_RXDOPPLER
)
531 *interrupt_mask
|= AR5K_INT_RX_DOPPLER
;
532 if (data
& AR5K_ISR_QCBRORN
) {
533 *interrupt_mask
|= AR5K_INT_QCBRORN
;
534 ah
->ah_txq_isr
|= AR5K_REG_MS(
535 ath5k_hw_reg_read(ah
, AR5K_RAC_SISR3
),
538 if (data
& AR5K_ISR_QCBRURN
) {
539 *interrupt_mask
|= AR5K_INT_QCBRURN
;
540 ah
->ah_txq_isr
|= AR5K_REG_MS(
541 ath5k_hw_reg_read(ah
, AR5K_RAC_SISR3
),
544 if (data
& AR5K_ISR_QTRIG
) {
545 *interrupt_mask
|= AR5K_INT_QTRIG
;
546 ah
->ah_txq_isr
|= AR5K_REG_MS(
547 ath5k_hw_reg_read(ah
, AR5K_RAC_SISR4
),
551 if (data
& AR5K_ISR_TXOK
)
552 ah
->ah_txq_isr
|= AR5K_REG_MS(
553 ath5k_hw_reg_read(ah
, AR5K_RAC_SISR0
),
554 AR5K_SISR0_QCU_TXOK
);
556 if (data
& AR5K_ISR_TXDESC
)
557 ah
->ah_txq_isr
|= AR5K_REG_MS(
558 ath5k_hw_reg_read(ah
, AR5K_RAC_SISR0
),
559 AR5K_SISR0_QCU_TXDESC
);
561 if (data
& AR5K_ISR_TXERR
)
562 ah
->ah_txq_isr
|= AR5K_REG_MS(
563 ath5k_hw_reg_read(ah
, AR5K_RAC_SISR1
),
564 AR5K_SISR1_QCU_TXERR
);
566 if (data
& AR5K_ISR_TXEOL
)
567 ah
->ah_txq_isr
|= AR5K_REG_MS(
568 ath5k_hw_reg_read(ah
, AR5K_RAC_SISR1
),
569 AR5K_SISR1_QCU_TXEOL
);
571 if (data
& AR5K_ISR_TXURN
)
572 ah
->ah_txq_isr
|= AR5K_REG_MS(
573 ath5k_hw_reg_read(ah
, AR5K_RAC_SISR2
),
574 AR5K_SISR2_QCU_TXURN
);
576 if (unlikely(data
& (AR5K_ISR_SSERR
| AR5K_ISR_MCABT
577 | AR5K_ISR_HIUERR
| AR5K_ISR_DPERR
)))
578 *interrupt_mask
|= AR5K_INT_FATAL
;
581 * XXX: BMISS interrupts may occur after association.
582 * I found this on 5210 code but it needs testing. If this is
583 * true we should disable them before assoc and re-enable them
584 * after a successful assoc + some jiffies.
585 interrupt_mask &= ~AR5K_INT_BMISS;
590 * In case we didn't handle anything,
591 * print the register value.
593 if (unlikely(*interrupt_mask
== 0 && net_ratelimit()))
594 ATH5K_PRINTF("ISR: 0x%08x IMR: 0x%08x\n", data
, ah
->ah_imr
);
600 * ath5k_hw_set_imr - Set interrupt mask
602 * @ah: The &struct ath5k_hw
603 * @new_mask: The new interrupt mask to be set
605 * Set the interrupt mask in hw to save interrupts. We do that by mapping
606 * ath5k_int bits to hw-specific bits to remove abstraction and writing
607 * Interrupt Mask Register.
609 enum ath5k_int
ath5k_hw_set_imr(struct ath5k_hw
*ah
, enum ath5k_int new_mask
)
611 enum ath5k_int old_mask
, int_mask
;
613 old_mask
= ah
->ah_imr
;
616 * Disable card interrupts to prevent any race conditions
617 * (they will be re-enabled afterwards if AR5K_INT GLOBAL
618 * is set again on the new mask).
620 if (old_mask
& AR5K_INT_GLOBAL
) {
621 ath5k_hw_reg_write(ah
, AR5K_IER_DISABLE
, AR5K_IER
);
622 ath5k_hw_reg_read(ah
, AR5K_IER
);
626 * Add additional, chipset-dependent interrupt mask flags
627 * and write them to the IMR (interrupt mask register).
629 int_mask
= new_mask
& AR5K_INT_COMMON
;
631 if (ah
->ah_version
!= AR5K_AR5210
) {
632 /* Preserve per queue TXURN interrupt mask */
633 u32 simr2
= ath5k_hw_reg_read(ah
, AR5K_SIMR2
)
634 & AR5K_SIMR2_QCU_TXURN
;
636 if (new_mask
& AR5K_INT_FATAL
) {
637 int_mask
|= AR5K_IMR_HIUERR
;
638 simr2
|= (AR5K_SIMR2_MCABT
| AR5K_SIMR2_SSERR
643 if (new_mask
& AR5K_INT_BNR
)
644 int_mask
|= AR5K_INT_BNR
;
646 if (new_mask
& AR5K_INT_TIM
)
647 int_mask
|= AR5K_IMR_TIM
;
649 if (new_mask
& AR5K_INT_TIM
)
650 simr2
|= AR5K_SISR2_TIM
;
651 if (new_mask
& AR5K_INT_DTIM
)
652 simr2
|= AR5K_SISR2_DTIM
;
653 if (new_mask
& AR5K_INT_DTIM_SYNC
)
654 simr2
|= AR5K_SISR2_DTIM_SYNC
;
655 if (new_mask
& AR5K_INT_BCN_TIMEOUT
)
656 simr2
|= AR5K_SISR2_BCN_TIMEOUT
;
657 if (new_mask
& AR5K_INT_CAB_TIMEOUT
)
658 simr2
|= AR5K_SISR2_CAB_TIMEOUT
;
660 if (new_mask
& AR5K_INT_RX_DOPPLER
)
661 int_mask
|= AR5K_IMR_RXDOPPLER
;
663 /* Note: Per queue interrupt masks
664 * are set via reset_tx_queue (qcu.c) */
665 ath5k_hw_reg_write(ah
, int_mask
, AR5K_PIMR
);
666 ath5k_hw_reg_write(ah
, simr2
, AR5K_SIMR2
);
669 if (new_mask
& AR5K_INT_FATAL
)
670 int_mask
|= (AR5K_IMR_SSERR
| AR5K_IMR_MCABT
671 | AR5K_IMR_HIUERR
| AR5K_IMR_DPERR
);
673 ath5k_hw_reg_write(ah
, int_mask
, AR5K_IMR
);
676 /* If RXNOFRM interrupt is masked disable it
677 * by setting AR5K_RXNOFRM to zero */
678 if (!(new_mask
& AR5K_INT_RXNOFRM
))
679 ath5k_hw_reg_write(ah
, 0, AR5K_RXNOFRM
);
681 /* Store new interrupt mask */
682 ah
->ah_imr
= new_mask
;
684 /* ..re-enable interrupts if AR5K_INT_GLOBAL is set */
685 if (new_mask
& AR5K_INT_GLOBAL
) {
686 ath5k_hw_reg_write(ah
, AR5K_IER_ENABLE
, AR5K_IER
);
687 ath5k_hw_reg_read(ah
, AR5K_IER
);
694 /********************\
696 \********************/
699 * ath5k_hw_dma_init - Initialize DMA unit
701 * @ah: The &struct ath5k_hw
703 * Set DMA size and pre-enable interrupts
704 * (driver handles tx/rx buffer setup and
707 * XXX: Save/restore RXDP/TXDP registers ?
709 void ath5k_hw_dma_init(struct ath5k_hw
*ah
)
712 * Set Rx/Tx DMA Configuration
714 * Set standard DMA size (128). Note that
715 * a DMA size of 512 causes rx overruns and tx errors
716 * on pci-e cards (tested on 5424 but since rx overruns
717 * also occur on 5416/5418 with madwifi we set 128
718 * for all PCI-E cards to be safe).
720 * XXX: need to check 5210 for this
721 * TODO: Check out tx triger level, it's always 64 on dumps but I
722 * guess we can tweak it and see how it goes ;-)
724 if (ah
->ah_version
!= AR5K_AR5210
) {
725 AR5K_REG_WRITE_BITS(ah
, AR5K_TXCFG
,
726 AR5K_TXCFG_SDMAMR
, AR5K_DMASIZE_128B
);
727 AR5K_REG_WRITE_BITS(ah
, AR5K_RXCFG
,
728 AR5K_RXCFG_SDMAMW
, AR5K_DMASIZE_128B
);
731 /* Pre-enable interrupts on 5211/5212*/
732 if (ah
->ah_version
!= AR5K_AR5210
)
733 ath5k_hw_set_imr(ah
, ah
->ah_imr
);
738 * ath5k_hw_dma_stop - stop DMA unit
740 * @ah: The &struct ath5k_hw
742 * Stop tx/rx DMA and interrupts. Returns
743 * -EBUSY if tx or rx dma failed to stop.
745 * XXX: Sometimes DMA unit hangs and we have
746 * stuck frames on tx queues, only a reset
749 int ath5k_hw_dma_stop(struct ath5k_hw
*ah
)
754 /* Disable interrupts */
755 ath5k_hw_set_imr(ah
, 0);
758 err
= ath5k_hw_stop_rx_dma(ah
);
762 /* Clear any pending interrupts
763 * and disable tx dma */
764 if (ah
->ah_version
!= AR5K_AR5210
) {
765 ath5k_hw_reg_write(ah
, 0xffffffff, AR5K_PISR
);
766 qmax
= AR5K_NUM_TX_QUEUES
;
768 /* PISR/SISR Not available on 5210 */
769 ath5k_hw_reg_read(ah
, AR5K_ISR
);
770 qmax
= AR5K_NUM_TX_QUEUES_NOQCU
;
773 for (i
= 0; i
< qmax
; i
++) {
774 err
= ath5k_hw_stop_tx_dma(ah
, i
);
775 /* -EINVAL -> queue inactive */