Skip to content

Commit

Permalink
mt76: move irq handler in mt76x02-lib moudle
Browse files Browse the repository at this point in the history
Move mt76x02_irq_handler handler in mt76x02_mmio.c in order to be
reused in mt76x0 driver. Move mt76x02_rx_poll_complete routine in
mt76x02-lib module. Moreover remove pci_core.c and mt76x2/trace.{c,h}
since are empty files

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Oct 5, 2018
1 parent 3d2cfe3 commit e61671e
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 177 deletions.
2 changes: 2 additions & 0 deletions mt76x02.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ void mt76x02_tx_complete(struct mt76_dev *dev, struct sk_buff *skb);
bool mt76x02_tx_status_data(struct mt76_dev *dev, u8 *update);
void mt76x02_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
struct sk_buff *skb);
void mt76x02_rx_poll_complete(struct mt76_dev *mdev, enum mt76_rxq_id q);
irqreturn_t mt76x02_irq_handler(int irq, void *dev_instance);
void mt76x02_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
struct sk_buff *skb);
int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi,
Expand Down
62 changes: 62 additions & 0 deletions mt76x02_mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
*/

#include <linux/kernel.h>
#include <linux/irq.h>

#include "mt76x02.h"
#include "mt76x02_trace.h"

static int
mt76x02_init_tx_queue(struct mt76x02_dev *dev, struct mt76_queue *q,
Expand Down Expand Up @@ -136,6 +138,66 @@ int mt76x02_dma_init(struct mt76x02_dev *dev)
}
EXPORT_SYMBOL_GPL(mt76x02_dma_init);

void mt76x02_rx_poll_complete(struct mt76_dev *mdev, enum mt76_rxq_id q)
{
struct mt76x02_dev *dev;

dev = container_of(mdev, struct mt76x02_dev, mt76);
mt76x02_irq_enable(dev, MT_INT_RX_DONE(q));
}
EXPORT_SYMBOL_GPL(mt76x02_rx_poll_complete);

irqreturn_t mt76x02_irq_handler(int irq, void *dev_instance)
{
struct mt76x02_dev *dev = dev_instance;
u32 intr;

intr = mt76_rr(dev, MT_INT_SOURCE_CSR);
mt76_wr(dev, MT_INT_SOURCE_CSR, intr);

if (!test_bit(MT76_STATE_INITIALIZED, &dev->mt76.state))
return IRQ_NONE;

trace_dev_irq(dev, intr, dev->mt76.mmio.irqmask);

intr &= dev->mt76.mmio.irqmask;

if (intr & MT_INT_TX_DONE_ALL) {
mt76x02_irq_disable(dev, MT_INT_TX_DONE_ALL);
tasklet_schedule(&dev->tx_tasklet);
}

if (intr & MT_INT_RX_DONE(0)) {
mt76x02_irq_disable(dev, MT_INT_RX_DONE(0));
napi_schedule(&dev->mt76.napi[0]);
}

if (intr & MT_INT_RX_DONE(1)) {
mt76x02_irq_disable(dev, MT_INT_RX_DONE(1));
napi_schedule(&dev->mt76.napi[1]);
}

if (intr & MT_INT_PRE_TBTT)
tasklet_schedule(&dev->pre_tbtt_tasklet);

/* send buffered multicast frames now */
if (intr & MT_INT_TBTT)
mt76_queue_kick(dev, &dev->mt76.q_tx[MT_TXQ_PSD]);

if (intr & MT_INT_TX_STAT) {
mt76x02_mac_poll_tx_status(dev, true);
tasklet_schedule(&dev->tx_tasklet);
}

if (intr & MT_INT_GPTIMER) {
mt76x02_irq_disable(dev, MT_INT_GPTIMER);
tasklet_schedule(&dev->dfs_pd.dfs_tasklet);
}

return IRQ_HANDLED;
}
EXPORT_SYMBOL_GPL(mt76x02_irq_handler);

void mt76x02_set_irq_mask(struct mt76x02_dev *dev, u32 clear, u32 set)
{
unsigned long flags;
Expand Down
23 changes: 23 additions & 0 deletions mt76x02_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,29 @@ TRACE_EVENT(mac_txstat_fetch,
)
);

TRACE_EVENT(dev_irq,
TP_PROTO(struct mt76x02_dev *dev, u32 val, u32 mask),

TP_ARGS(dev, val, mask),

TP_STRUCT__entry(
DEV_ENTRY
__field(u32, val)
__field(u32, mask)
),

TP_fast_assign(
DEV_ASSIGN;
__entry->val = val;
__entry->mask = mask;
),

TP_printk(
DEV_PR_FMT " %08x & %08x",
DEV_PR_ARG, __entry->val, __entry->mask
)
);

#endif

#undef TRACE_INCLUDE_PATH
Expand Down
3 changes: 1 addition & 2 deletions mt76x2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ mt76x2-common-y := \

mt76x2e-y := \
pci.o pci_main.o pci_init.o pci_tx.o \
pci_core.o pci_mac.o pci_mcu.o pci_phy.o \
pci_dfs.o pci_trace.o
pci_mac.o pci_mcu.o pci_phy.o pci_dfs.o

mt76x2u-y := \
usb.o usb_init.o usb_main.o usb_mac.o usb_mcu.o \
Expand Down
3 changes: 0 additions & 3 deletions mt76x2/mt76x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ int mt76x2_register_device(struct mt76x02_dev *dev);
void mt76x2_init_debugfs(struct mt76x02_dev *dev);
void mt76x2_init_device(struct mt76x02_dev *dev);

irqreturn_t mt76x2_irq_handler(int irq, void *dev_instance);
void mt76x2_phy_power_on(struct mt76x02_dev *dev);
int mt76x2_init_hardware(struct mt76x02_dev *dev);
void mt76x2_stop_hardware(struct mt76x02_dev *dev);
Expand All @@ -87,8 +86,6 @@ void mt76x2_mac_set_tx_protection(struct mt76x02_dev *dev, u32 val);

void mt76x2_pre_tbtt_tasklet(unsigned long arg);

void mt76x2_rx_poll_complete(struct mt76_dev *mdev, enum mt76_rxq_id q);

void mt76x2_sta_ps(struct mt76_dev *dev, struct ieee80211_sta *sta, bool ps);

void mt76x2_update_channel(struct mt76_dev *mdev);
Expand Down
3 changes: 1 addition & 2 deletions mt76x2/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <linux/pci.h>

#include "mt76x2.h"
#include "trace.h"

static const struct pci_device_id mt76pci_device_table[] = {
{ PCI_DEVICE(0x14c3, 0x7662) },
Expand Down Expand Up @@ -58,7 +57,7 @@ mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
dev->mt76.rev = mt76_rr(dev, MT_ASIC_VERSION);
dev_info(dev->mt76.dev, "ASIC revision: %08x\n", dev->mt76.rev);

ret = devm_request_irq(dev->mt76.dev, pdev->irq, mt76x2_irq_handler,
ret = devm_request_irq(dev->mt76.dev, pdev->irq, mt76x02_irq_handler,
IRQF_SHARED, KBUILD_MODNAME, dev);
if (ret)
goto error;
Expand Down
78 changes: 0 additions & 78 deletions mt76x2/pci_core.c

This file was deleted.

2 changes: 1 addition & 1 deletion mt76x2/pci_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev)
.tx_prepare_skb = mt76x02_tx_prepare_skb,
.tx_complete_skb = mt76x02_tx_complete_skb,
.rx_skb = mt76x02_queue_rx_skb,
.rx_poll_complete = mt76x2_rx_poll_complete,
.rx_poll_complete = mt76x02_rx_poll_complete,
.sta_ps = mt76x2_sta_ps,
};
struct mt76x02_dev *dev;
Expand Down
1 change: 0 additions & 1 deletion mt76x2/pci_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "mt76x2.h"
#include "mcu.h"
#include "eeprom.h"
#include "trace.h"

void mt76x2_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 *addr)
{
Expand Down
23 changes: 0 additions & 23 deletions mt76x2/pci_trace.c

This file was deleted.

67 changes: 0 additions & 67 deletions mt76x2/trace.h

This file was deleted.

0 comments on commit e61671e

Please sign in to comment.