Commit f7bbb80f authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: introduce mmio data structure in mt76_dev

Introduce mt76_mmio data structure in mt76_dev and
move mt76x2_mcu in mt76_mmio. This is a preliminary
patch to unify mcu code between mt76x02{e,u} drivers
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 8db5ec77
...@@ -57,5 +57,9 @@ void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs) ...@@ -57,5 +57,9 @@ void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs)
dev->bus = &mt76_mmio_ops; dev->bus = &mt76_mmio_ops;
dev->regs = regs; dev->regs = regs;
skb_queue_head_init(&dev->mmio.mcu.res_q);
init_waitqueue_head(&dev->mmio.mcu.wait);
mutex_init(&dev->mmio.mcu.mutex);
} }
EXPORT_SYMBOL_GPL(mt76_mmio_init); EXPORT_SYMBOL_GPL(mt76_mmio_init);
...@@ -338,6 +338,17 @@ struct mt76_usb { ...@@ -338,6 +338,17 @@ struct mt76_usb {
} mcu; } mcu;
}; };
struct mt76_mmio {
struct mt76e_mcu {
struct mutex mutex;
wait_queue_head_t wait;
struct sk_buff_head res_q;
u32 msg_seq;
} mcu;
};
struct mt76_dev { struct mt76_dev {
struct ieee80211_hw *hw; struct ieee80211_hw *hw;
struct cfg80211_chan_def chandef; struct cfg80211_chan_def chandef;
...@@ -392,7 +403,10 @@ struct mt76_dev { ...@@ -392,7 +403,10 @@ struct mt76_dev {
u32 rxfilter; u32 rxfilter;
union {
struct mt76_mmio mmio;
struct mt76_usb usb; struct mt76_usb usb;
};
}; };
enum mt76_phy_type { enum mt76_phy_type {
......
...@@ -47,15 +47,6 @@ ...@@ -47,15 +47,6 @@
#include "mt76x2_mac.h" #include "mt76x2_mac.h"
#include "mt76x2_dfs.h" #include "mt76x2_dfs.h"
struct mt76x2_mcu {
struct mutex mutex;
wait_queue_head_t wait;
struct sk_buff_head res_q;
u32 msg_seq;
};
struct mt76x2_rx_freq_cal { struct mt76x2_rx_freq_cal {
s8 high_gain[MT_MAX_CHAINS]; s8 high_gain[MT_MAX_CHAINS];
s8 rssi_offset[MT_MAX_CHAINS]; s8 rssi_offset[MT_MAX_CHAINS];
...@@ -97,7 +88,6 @@ struct mt76x2_dev { ...@@ -97,7 +88,6 @@ struct mt76x2_dev {
u8 txdone_seq; u8 txdone_seq;
DECLARE_KFIFO_PTR(txstatus_fifo, struct mt76x02_tx_status); DECLARE_KFIFO_PTR(txstatus_fifo, struct mt76x02_tx_status);
struct mt76x2_mcu mcu;
struct sk_buff *rx_head; struct sk_buff *rx_head;
struct tasklet_struct tx_tasklet; struct tasklet_struct tx_tasklet;
......
...@@ -25,8 +25,9 @@ void mt76x2_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, ...@@ -25,8 +25,9 @@ void mt76x2_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
void *rxwi = skb->data; void *rxwi = skb->data;
if (q == MT_RXQ_MCU) { if (q == MT_RXQ_MCU) {
skb_queue_tail(&dev->mcu.res_q, skb); /* this is used just by mmio code */
wake_up(&dev->mcu.wait); skb_queue_tail(&mdev->mmio.mcu.res_q, skb);
wake_up(&mdev->mmio.mcu.wait);
return; return;
} }
......
...@@ -112,9 +112,6 @@ int mt76x2_dma_init(struct mt76x2_dev *dev) ...@@ -112,9 +112,6 @@ int mt76x2_dma_init(struct mt76x2_dev *dev)
mt76_dma_attach(&dev->mt76); mt76_dma_attach(&dev->mt76);
init_waitqueue_head(&dev->mcu.wait);
skb_queue_head_init(&dev->mcu.res_q);
tasklet_init(&dev->tx_tasklet, mt76x2_tx_tasklet, (unsigned long) dev); tasklet_init(&dev->tx_tasklet, mt76x2_tx_tasklet, (unsigned long) dev);
mt76_wr(dev, MT_WPDMA_RST_IDX, ~0); mt76_wr(dev, MT_WPDMA_RST_IDX, ~0);
......
...@@ -44,9 +44,10 @@ mt76x2_mcu_get_response(struct mt76x2_dev *dev, unsigned long expires) ...@@ -44,9 +44,10 @@ mt76x2_mcu_get_response(struct mt76x2_dev *dev, unsigned long expires)
return NULL; return NULL;
timeout = expires - jiffies; timeout = expires - jiffies;
wait_event_timeout(dev->mcu.wait, !skb_queue_empty(&dev->mcu.res_q), wait_event_timeout(dev->mt76.mmio.mcu.wait,
!skb_queue_empty(&dev->mt76.mmio.mcu.res_q),
timeout); timeout);
return skb_dequeue(&dev->mcu.res_q); return skb_dequeue(&dev->mt76.mmio.mcu.res_q);
} }
static int static int
...@@ -60,11 +61,11 @@ mt76x2_mcu_msg_send(struct mt76x2_dev *dev, struct sk_buff *skb, ...@@ -60,11 +61,11 @@ mt76x2_mcu_msg_send(struct mt76x2_dev *dev, struct sk_buff *skb,
if (!skb) if (!skb)
return -EINVAL; return -EINVAL;
mutex_lock(&dev->mcu.mutex); mutex_lock(&dev->mt76.mmio.mcu.mutex);
seq = ++dev->mcu.msg_seq & 0xf; seq = ++dev->mt76.mmio.mcu.msg_seq & 0xf;
if (!seq) if (!seq)
seq = ++dev->mcu.msg_seq & 0xf; seq = ++dev->mt76.mmio.mcu.msg_seq & 0xf;
ret = mt76x2_tx_queue_mcu(&dev->mt76, MT_TXQ_MCU, skb, cmd, seq); ret = mt76x2_tx_queue_mcu(&dev->mt76, MT_TXQ_MCU, skb, cmd, seq);
if (ret) if (ret)
...@@ -94,7 +95,7 @@ mt76x2_mcu_msg_send(struct mt76x2_dev *dev, struct sk_buff *skb, ...@@ -94,7 +95,7 @@ mt76x2_mcu_msg_send(struct mt76x2_dev *dev, struct sk_buff *skb,
} }
out: out:
mutex_unlock(&dev->mcu.mutex); mutex_unlock(&dev->mt76.mmio.mcu.mutex);
return ret; return ret;
} }
...@@ -399,8 +400,6 @@ int mt76x2_mcu_init(struct mt76x2_dev *dev) ...@@ -399,8 +400,6 @@ int mt76x2_mcu_init(struct mt76x2_dev *dev)
{ {
int ret; int ret;
mutex_init(&dev->mcu.mutex);
ret = mt76pci_load_rom_patch(dev); ret = mt76pci_load_rom_patch(dev);
if (ret) if (ret)
return ret; return ret;
...@@ -420,7 +419,7 @@ int mt76x2_mcu_cleanup(struct mt76x2_dev *dev) ...@@ -420,7 +419,7 @@ int mt76x2_mcu_cleanup(struct mt76x2_dev *dev)
mt76_wr(dev, MT_MCU_INT_LEVEL, 1); mt76_wr(dev, MT_MCU_INT_LEVEL, 1);
usleep_range(20000, 30000); usleep_range(20000, 30000);
while ((skb = skb_dequeue(&dev->mcu.res_q)) != NULL) while ((skb = skb_dequeue(&dev->mt76.mmio.mcu.res_q)) != NULL)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment