diff mbox series

[2/7] mt76: introduce mcu_reset function pointer in mt76_mcu_ops structure

Message ID 7b006e8eb99445b2efcdd7c7b726ba4a1aee0991.1615140875.git.lorenzo@kernel.org
State New
Headers show
Series mt7921: introduce wifi chip reset support | expand

Commit Message

Lorenzo Bianconi March 7, 2021, 6:20 p.m. UTC
Introduce mcu_reset function pointer in mt76_mcu_ops structure in order
to run hw related reset function for the mcu running on the chipset.
This is a preliminary patch to introduce chip reset for mt7921 devices.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/mcu.c  | 4 ++++
 drivers/net/wireless/mediatek/mt76/mt76.h | 1 +
 2 files changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mcu.c b/drivers/net/wireless/mediatek/mt76/mcu.c
index d3a5e2c4f12a..70624cd07449 100644
--- a/drivers/net/wireless/mediatek/mt76/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mcu.c
@@ -99,6 +99,10 @@  int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
 			dev_kfree_skb(skb);
 	} while (ret == -EAGAIN);
 
+	/* notify driver code to reset the mcu */
+	if (ret == -ETIMEDOUT && dev->mcu_ops->mcu_reset)
+		dev->mcu_ops->mcu_reset(dev);
+
 out:
 	mutex_unlock(&dev->mcu.mutex);
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 5d3438d86d2a..bbe6a70851c8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -166,6 +166,7 @@  struct mt76_mcu_ops {
 	int (*mcu_rd_rp)(struct mt76_dev *dev, u32 base,
 			 struct mt76_reg_pair *rp, int len);
 	int (*mcu_restart)(struct mt76_dev *dev);
+	void (*mcu_reset)(struct mt76_dev *dev);
 };
 
 struct mt76_queue_ops {