FreeBSD kernel ATH device code
ar5210_interrupts.c
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: ISC
3 *
4 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
5 * Copyright (c) 2002-2004 Atheros Communications, Inc.
6 *
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 *
19 * $FreeBSD$
20 */
21#include "opt_ah.h"
22
23#include "ah.h"
24#include "ah_internal.h"
25
26#include "ar5210/ar5210.h"
27#include "ar5210/ar5210reg.h"
28
29/*
30 * Return non-zero if an interrupt is pending.
31 */
34{
35 return (OS_REG_READ(ah, AR_INTPEND) ? AH_TRUE : AH_FALSE);
36}
37
38/*
39 * Read the Interrupt Status Register value and return
40 * an abstracted bitmask of the data found in the ISR.
41 * Note that reading the ISR clear pending interrupts.
42 */
45{
46#define AR_FATAL_INT \
47 (AR_ISR_MCABT_INT | AR_ISR_SSERR_INT | AR_ISR_DPERR_INT | AR_ISR_RXORN_INT)
48 struct ath_hal_5210 *ahp = AH5210(ah);
49 uint32_t isr;
50
51 isr = OS_REG_READ(ah, AR_ISR);
52 if (isr == 0xffffffff) {
53 *masked = 0;
54 return AH_FALSE;
55 }
56
57 /*
58 * Mask interrupts that have no device-independent
59 * representation; these are added back below. We
60 * also masked with the abstracted IMR to insure no
61 * status bits leak through that weren't requested
62 * (e.g. RXNOFRM) and that might confuse the caller.
63 */
64 *masked = (isr & (HAL_INT_COMMON - HAL_INT_BNR)) & ahp->ah_maskReg;
65
66 if (isr & AR_FATAL_INT)
67 *masked |= HAL_INT_FATAL;
69 *masked |= HAL_INT_RX;
71 *masked |= HAL_INT_TX;
72
73 /*
74 * On fatal errors collect ISR state for debugging.
75 */
76 if (*masked & HAL_INT_FATAL) {
77 AH_PRIVATE(ah)->ah_fatalState[0] = isr;
78 }
79
80 return AH_TRUE;
81#undef AR_FATAL_INT
82}
83
86{
87 return AH5210(ah)->ah_maskReg;
88}
89
92{
93 struct ath_hal_5210 *ahp = AH5210(ah);
94 uint32_t omask = ahp->ah_maskReg;
95 uint32_t mask;
96
97 HALDEBUG(ah, HAL_DEBUG_INTERRUPT, "%s: 0x%x => 0x%x\n",
98 __func__, omask, ints);
99
100 /*
101 * Disable interrupts here before reading & modifying
102 * the mask so that the ISR does not modify the mask
103 * out from under us.
104 */
105 if (omask & HAL_INT_GLOBAL) {
106 HALDEBUG(ah, HAL_DEBUG_INTERRUPT, "%s: disable IER\n", __func__);
108 }
109
110 mask = ints & (HAL_INT_COMMON - HAL_INT_BNR);
111 if (ints & HAL_INT_RX)
113 if (ints & HAL_INT_TX) {
114 if (ahp->ah_txOkInterruptMask)
115 mask |= AR_IMR_TXOK_INT;
116 if (ahp->ah_txErrInterruptMask)
117 mask |= AR_IMR_TXERR_INT;
118 if (ahp->ah_txDescInterruptMask)
119 mask |= AR_IMR_TXDESC_INT;
120 if (ahp->ah_txEolInterruptMask)
121 mask |= AR_IMR_TXEOL_INT;
122 }
123
124 /* Write the new IMR and store off our SW copy. */
125 HALDEBUG(ah, HAL_DEBUG_INTERRUPT, "%s: new IMR 0x%x\n", __func__, mask);
126 OS_REG_WRITE(ah, AR_IMR, mask);
127 ahp->ah_maskReg = ints;
128
129 /* Re-enable interrupts as appropriate. */
130 if (ints & HAL_INT_GLOBAL) {
131 HALDEBUG(ah, HAL_DEBUG_INTERRUPT, "%s: enable IER\n", __func__);
133 }
134
135 return omask;
136}
#define HAL_INT_GLOBAL
Definition: ah.h:506
HAL_INT
Definition: ah.h:472
@ HAL_INT_BNR
Definition: ah.h:493
@ HAL_INT_COMMON
Definition: ah.h:514
@ HAL_INT_FATAL
Definition: ah.h:505
@ HAL_INT_TX
Definition: ah.h:481
@ HAL_INT_RX
Definition: ah.h:473
HAL_BOOL
Definition: ah.h:93
@ AH_FALSE
Definition: ah.h:94
@ AH_TRUE
Definition: ah.h:95
@ HAL_DEBUG_INTERRUPT
Definition: ah_debug.h:48
#define AH_PRIVATE(_ah)
Definition: ah_internal.h:442
#define HALDEBUG(_ah, __m,...)
Definition: ah_internal.h:658
#define OS_REG_WRITE(_ah, _reg, _val)
Definition: ah_osdep.h:139
#define OS_REG_READ(_ah, _reg)
Definition: ah_osdep.h:140
#define AH5210(ah)
Definition: ar5210.h:128
HAL_BOOL ar5210IsInterruptPending(struct ath_hal *ah)
HAL_BOOL ar5210GetPendingInterrupts(struct ath_hal *ah, HAL_INT *masked)
HAL_INT ar5210GetInterrupts(struct ath_hal *ah)
#define AR_FATAL_INT
HAL_INT ar5210SetInterrupts(struct ath_hal *ah, HAL_INT ints)
#define AR_INTPEND
Definition: ar5210reg.h:57
#define AR_ISR_TXDESC_INT
Definition: ar5210reg.h:140
#define AR_IMR_RXERR_INT
Definition: ar5210reg.h:163
#define AR_ISR_RXOK_INT
Definition: ar5210reg.h:133
#define AR_ISR
Definition: ar5210reg.h:41
#define AR_IER_ENABLE
Definition: ar5210reg.h:187
#define AR_ISR_TXOK_INT
Definition: ar5210reg.h:139
#define AR_IMR_TXDESC_INT
Definition: ar5210reg.h:168
#define AR_ISR_RXERR_INT
Definition: ar5210reg.h:135
#define AR_IMR_RXOK_INT
Definition: ar5210reg.h:161
#define AR_IER_DISABLE
Definition: ar5210reg.h:186
#define AR_IMR
Definition: ar5210reg.h:42
#define AR_IMR_TXEOL_INT
Definition: ar5210reg.h:171
#define AR_ISR_TXERR_INT
Definition: ar5210reg.h:141
#define AR_ISR_TXEOL_INT
Definition: ar5210reg.h:143
#define AR_IMR_TXOK_INT
Definition: ar5210reg.h:167
#define AR_IMR_TXERR_INT
Definition: ar5210reg.h:169
#define AR_IER
Definition: ar5210reg.h:43
uint32_t ah_txOkInterruptMask
Definition: ar5210.h:108
uint32_t ah_maskReg
Definition: ar5210.h:107
uint32_t ah_txErrInterruptMask
Definition: ar5210.h:109
uint32_t ah_txDescInterruptMask
Definition: ar5210.h:110
uint32_t ah_txEolInterruptMask
Definition: ar5210.h:111
Definition: ah.h:1219