| From 3fdeeee1f24b09fc0d08b6a386e06c6146e83d9c Mon Sep 17 00:00:00 2001 |
| From: Shayne Chen <shayne.chen@mediatek.com> |
| Date: Tue, 23 May 2023 15:49:03 +0800 |
| Subject: [PATCH 07/98] wifi: mt76: mt7996: make band capability init flexible |
| |
| There're some variations of mt7996 chipset which only support two-band, |
| so parse the adie combination to correctly set band capability. |
| |
| Change-Id: Ifcb49504f02f5cc6a23c626e30b4f0e1360fe157 |
| Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> |
| --- |
| mt7996/dma.c | 14 +++++++------- |
| mt7996/init.c | 29 ++++++++++++++++++----------- |
| mt7996/mcu.c | 13 +++++-------- |
| mt7996/mt7996.h | 11 +++++++++++ |
| mt7996/regs.h | 3 +++ |
| 5 files changed, 44 insertions(+), 26 deletions(-) |
| |
| diff --git a/mt7996/dma.c b/mt7996/dma.c |
| index 2221d22..3d04470 100644 |
| --- a/mt7996/dma.c |
| +++ b/mt7996/dma.c |
| @@ -222,13 +222,13 @@ void mt7996_dma_start(struct mt7996_dev *dev, bool reset, bool wed_reset) |
| /* enable interrupts for TX/RX rings */ |
| irq_mask = MT_INT_MCU_CMD | MT_INT_RX_DONE_MCU | MT_INT_TX_DONE_MCU; |
| |
| - if (!dev->mphy.band_idx) |
| + if (mt7996_band_valid(dev, MT_BAND0)) |
| irq_mask |= MT_INT_BAND0_RX_DONE; |
| |
| - if (dev->dbdc_support) |
| + if (mt7996_band_valid(dev, MT_BAND1)) |
| irq_mask |= MT_INT_BAND1_RX_DONE; |
| |
| - if (dev->tbtc_support) |
| + if (mt7996_band_valid(dev, MT_BAND2)) |
| irq_mask |= MT_INT_BAND2_RX_DONE; |
| |
| if (mtk_wed_device_active(wed) && wed_reset) { |
| @@ -354,7 +354,7 @@ int mt7996_dma_rro_init(struct mt7996_dev *dev) |
| if (ret) |
| return ret; |
| |
| - if (dev->dbdc_support) { |
| + if (mt7996_band_valid(dev, MT_BAND1)) { |
| /* rx msdu page queue for band1 */ |
| mdev->q_rx[MT_RXQ_MSDU_PAGE_BAND1].flags = |
| MT_WED_RRO_Q_MSDU_PG(1) | MT_QFLAG_WED_RRO_EN; |
| @@ -368,7 +368,7 @@ int mt7996_dma_rro_init(struct mt7996_dev *dev) |
| return ret; |
| } |
| |
| - if (dev->tbtc_support) { |
| + if (mt7996_band_valid(dev, MT_BAND2)) { |
| /* rx msdu page queue for band2 */ |
| mdev->q_rx[MT_RXQ_MSDU_PAGE_BAND2].flags = |
| MT_WED_RRO_Q_MSDU_PG(2) | MT_QFLAG_WED_RRO_EN; |
| @@ -488,7 +488,7 @@ int mt7996_dma_init(struct mt7996_dev *dev) |
| if (ret) |
| return ret; |
| |
| - if (dev->tbtc_support || dev->mphy.band_idx == MT_BAND2) { |
| + if (mt7996_band_valid(dev, MT_BAND2)) { |
| /* rx data queue for band2 */ |
| rx_base = MT_RXQ_RING_BASE(MT_RXQ_BAND2) + hif1_ofs; |
| ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_BAND2], |
| @@ -542,7 +542,7 @@ int mt7996_dma_init(struct mt7996_dev *dev) |
| if (ret) |
| return ret; |
| |
| - if (dev->tbtc_support || dev->mphy.band_idx == MT_BAND2) { |
| + if (mt7996_band_valid(dev, MT_BAND2)) { |
| /* rx rro data queue for band2 */ |
| dev->mt76.q_rx[MT_RXQ_RRO_BAND2].flags = |
| MT_WED_RRO_Q_DATA(1) | MT_QFLAG_WED_RRO_EN; |
| diff --git a/mt7996/init.c b/mt7996/init.c |
| index de4a5f7..2e6efc5 100644 |
| --- a/mt7996/init.c |
| +++ b/mt7996/init.c |
| @@ -539,11 +539,7 @@ static int mt7996_register_phy(struct mt7996_dev *dev, struct mt7996_phy *phy, |
| int ret; |
| struct mtk_wed_device *wed = &dev->mt76.mmio.wed; |
| |
| - if (band != MT_BAND1 && band != MT_BAND2) |
| - return 0; |
| - |
| - if ((band == MT_BAND1 && !dev->dbdc_support) || |
| - (band == MT_BAND2 && !dev->tbtc_support)) |
| + if (!mt7996_band_valid(dev, band) || band == MT_BAND0) |
| return 0; |
| |
| if (phy) |
| @@ -782,8 +778,10 @@ static int mt7996_init_hardware(struct mt7996_dev *dev) |
| |
| INIT_WORK(&dev->init_work, mt7996_init_work); |
| |
| - dev->dbdc_support = true; |
| - dev->tbtc_support = true; |
| + dev->dbdc_support = mt7996_band_valid(dev, MT_BAND1) || |
| + mt7996_band_valid(dev, MT_BAND2); |
| + dev->tbtc_support = mt7996_band_valid(dev, MT_BAND1) && |
| + mt7996_band_valid(dev, MT_BAND2); |
| |
| ret = mt7996_dma_init(dev); |
| if (ret) |
| @@ -1217,8 +1215,6 @@ int mt7996_register_device(struct mt7996_dev *dev) |
| if (ret) |
| return ret; |
| |
| - ieee80211_queue_work(mt76_hw(dev), &dev->init_work); |
| - |
| ret = mt7996_register_phy(dev, mt7996_phy2(dev), MT_BAND1); |
| if (ret) |
| return ret; |
| @@ -1227,13 +1223,24 @@ int mt7996_register_device(struct mt7996_dev *dev) |
| if (ret) |
| return ret; |
| |
| + ieee80211_queue_work(mt76_hw(dev), &dev->init_work); |
| + |
| dev->recovery.hw_init_done = true; |
| |
| ret = mt7996_init_debugfs(&dev->phy); |
| if (ret) |
| - return ret; |
| + goto error; |
| |
| - return mt7996_coredump_register(dev); |
| + ret = mt7996_coredump_register(dev); |
| + if (ret) |
| + goto error; |
| + |
| + return 0; |
| + |
| +error: |
| + cancel_work_sync(&dev->init_work); |
| + |
| + return ret; |
| } |
| |
| void mt7996_unregister_device(struct mt7996_dev *dev) |
| diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
| index 8320c8c..84f362b 100644 |
| --- a/mt7996/mcu.c |
| +++ b/mt7996/mcu.c |
| @@ -2767,7 +2767,7 @@ mt7996_mcu_init_rx_airtime(struct mt7996_dev *dev) |
| { |
| struct uni_header hdr = {}; |
| struct sk_buff *skb; |
| - int len, num; |
| + int len, num, i; |
| |
| num = 2 + 2 * (dev->dbdc_support + dev->tbtc_support); |
| len = sizeof(hdr) + num * sizeof(struct vow_rx_airtime); |
| @@ -2777,13 +2777,10 @@ mt7996_mcu_init_rx_airtime(struct mt7996_dev *dev) |
| |
| skb_put_data(skb, &hdr, sizeof(hdr)); |
| |
| - mt7996_add_rx_airtime_tlv(skb, dev->mt76.phy.band_idx); |
| - |
| - if (dev->dbdc_support) |
| - mt7996_add_rx_airtime_tlv(skb, MT_BAND1); |
| - |
| - if (dev->tbtc_support) |
| - mt7996_add_rx_airtime_tlv(skb, MT_BAND2); |
| + for (i = 0; i < __MT_MAX_BAND; i++) { |
| + if (mt7996_band_valid(dev, i)) |
| + mt7996_add_rx_airtime_tlv(skb, i); |
| + } |
| |
| return mt76_mcu_skb_send_msg(&dev->mt76, skb, |
| MCU_WM_UNI_CMD(VOW), true); |
| diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
| index e1972e9..137d5a2 100644 |
| --- a/mt7996/mt7996.h |
| +++ b/mt7996/mt7996.h |
| @@ -381,6 +381,17 @@ mt7996_phy3(struct mt7996_dev *dev) |
| return __mt7996_phy(dev, MT_BAND2); |
| } |
| |
| +static inline bool |
| +mt7996_band_valid(struct mt7996_dev *dev, u8 band) |
| +{ |
| + /* tri-band support */ |
| + if (band <= MT_BAND2 && |
| + mt76_get_field(dev, MT_PAD_GPIO, MT_PAD_GPIO_ADIE_COMB) <= 1) |
| + return true; |
| + |
| + return band == MT_BAND0 || band == MT_BAND2; |
| +} |
| + |
| extern const struct ieee80211_ops mt7996_ops; |
| extern struct pci_driver mt7996_pci_driver; |
| extern struct pci_driver mt7996_hif_driver; |
| diff --git a/mt7996/regs.h b/mt7996/regs.h |
| index 854390d..a4d5ad8 100644 |
| --- a/mt7996/regs.h |
| +++ b/mt7996/regs.h |
| @@ -602,6 +602,9 @@ enum base_rev { |
| #define MT_TOP_MISC MT_TOP(0xf0) |
| #define MT_TOP_MISC_FW_STATE GENMASK(2, 0) |
| |
| +#define MT_PAD_GPIO 0x700056f0 |
| +#define MT_PAD_GPIO_ADIE_COMB GENMASK(16, 15) |
| + |
| #define MT_HW_REV 0x70010204 |
| #define MT_WF_SUBSYS_RST 0x70028600 |
| |
| -- |
| 2.18.0 |
| |