2 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
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.
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.
17 #include <linux/delay.h>
19 #include "mt76x2_trace.h"
21 void mt76x2_set_irq_mask(struct mt76x2_dev
*dev
, u32 clear
, u32 set
)
25 spin_lock_irqsave(&dev
->irq_lock
, flags
);
26 dev
->irqmask
&= ~clear
;
28 mt76_wr(dev
, MT_INT_MASK_CSR
, dev
->irqmask
);
29 spin_unlock_irqrestore(&dev
->irq_lock
, flags
);
32 void mt76x2_rx_poll_complete(struct mt76_dev
*mdev
, enum mt76_rxq_id q
)
34 struct mt76x2_dev
*dev
= container_of(mdev
, struct mt76x2_dev
, mt76
);
36 mt76x2_irq_enable(dev
, MT_INT_RX_DONE(q
));
39 irqreturn_t
mt76x2_irq_handler(int irq
, void *dev_instance
)
41 struct mt76x2_dev
*dev
= dev_instance
;
44 intr
= mt76_rr(dev
, MT_INT_SOURCE_CSR
);
45 mt76_wr(dev
, MT_INT_SOURCE_CSR
, intr
);
47 if (!test_bit(MT76_STATE_INITIALIZED
, &dev
->mt76
.state
))
50 trace_dev_irq(dev
, intr
, dev
->irqmask
);
54 if (intr
& MT_INT_TX_DONE_ALL
) {
55 mt76x2_irq_disable(dev
, MT_INT_TX_DONE_ALL
);
56 tasklet_schedule(&dev
->tx_tasklet
);
59 if (intr
& MT_INT_RX_DONE(0)) {
60 mt76x2_irq_disable(dev
, MT_INT_RX_DONE(0));
61 napi_schedule(&dev
->mt76
.napi
[0]);
64 if (intr
& MT_INT_RX_DONE(1)) {
65 mt76x2_irq_disable(dev
, MT_INT_RX_DONE(1));
66 napi_schedule(&dev
->mt76
.napi
[1]);
69 if (intr
& MT_INT_PRE_TBTT
)
70 tasklet_schedule(&dev
->pre_tbtt_tasklet
);
72 /* send buffered multicast frames now */
73 if (intr
& MT_INT_TBTT
)
74 mt76_queue_kick(dev
, &dev
->mt76
.q_tx
[MT_TXQ_PSD
]);
76 if (intr
& MT_INT_TX_STAT
) {
77 mt76x2_mac_poll_tx_status(dev
, true);
78 tasklet_schedule(&dev
->tx_tasklet
);
81 if (intr
& MT_INT_GPTIMER
) {
82 mt76x2_irq_disable(dev
, MT_INT_GPTIMER
);
83 tasklet_schedule(&dev
->dfs_pd
.dfs_tasklet
);