developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 1 | From 18ed969cf7bfdaa059ed946f5bacd62a2ebf9ffe Mon Sep 17 00:00:00 2001 |
| 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Tue, 23 May 2023 15:49:03 +0800 |
| 4 | Subject: [PATCH 35/39] wifi: mt76: mt7996: make band capability init flexible |
| 5 | |
| 6 | There're some variations of mt7996 chipset which only support two-band, |
| 7 | so parse the adie combination to correctly set band capability. |
| 8 | |
| 9 | Change-Id: Ifcb49504f02f5cc6a23c626e30b4f0e1360fe157 |
| 10 | Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> |
| 11 | --- |
| 12 | mt7996/dma.c | 8 ++++---- |
| 13 | mt7996/init.c | 29 ++++++++++++++++++----------- |
| 14 | mt7996/mcu.c | 13 +++++-------- |
| 15 | mt7996/mt7996.h | 11 +++++++++++ |
| 16 | mt7996/regs.h | 3 +++ |
| 17 | 5 files changed, 41 insertions(+), 23 deletions(-) |
| 18 | |
| 19 | diff --git a/mt7996/dma.c b/mt7996/dma.c |
| 20 | index 6a21e3e..f01cea5 100644 |
| 21 | --- a/mt7996/dma.c |
| 22 | +++ b/mt7996/dma.c |
| 23 | @@ -159,13 +159,13 @@ void __mt7996_dma_enable(struct mt7996_dev *dev, bool reset) |
| 24 | |
| 25 | irq_mask |= (MT_INT_RX_DONE_MCU | MT_INT_TX_DONE_MCU); |
| 26 | |
| 27 | - if (!dev->mphy.band_idx) |
| 28 | + if (mt7996_band_valid(dev, MT_BAND0)) |
| 29 | irq_mask |= MT_INT_BAND0_RX_DONE; |
| 30 | |
| 31 | - if (dev->dbdc_support) |
| 32 | + if (mt7996_band_valid(dev, MT_BAND1)) |
| 33 | irq_mask |= MT_INT_BAND1_RX_DONE; |
| 34 | |
| 35 | - if (dev->tbtc_support) |
| 36 | + if (mt7996_band_valid(dev, MT_BAND2)) |
| 37 | irq_mask |= MT_INT_BAND2_RX_DONE; |
| 38 | |
| 39 | done: |
| 40 | @@ -334,7 +334,7 @@ int mt7996_dma_init(struct mt7996_dev *dev) |
| 41 | if (ret) |
| 42 | return ret; |
| 43 | |
| 44 | - if (dev->tbtc_support || dev->mphy.band_idx == MT_BAND2) { |
| 45 | + if (mt7996_band_valid(dev, MT_BAND2)) { |
| 46 | /* rx data queue for band2 */ |
| 47 | ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_BAND2], |
| 48 | MT_RXQ_ID(MT_RXQ_BAND2), |
| 49 | diff --git a/mt7996/init.c b/mt7996/init.c |
| 50 | index 0562439..0825e0b 100644 |
| 51 | --- a/mt7996/init.c |
| 52 | +++ b/mt7996/init.c |
| 53 | @@ -529,11 +529,7 @@ static int mt7996_register_phy(struct mt7996_dev *dev, struct mt7996_phy *phy, |
| 54 | u32 mac_ofs, hif1_ofs = 0; |
| 55 | int ret; |
| 56 | |
| 57 | - if (band != MT_BAND1 && band != MT_BAND2) |
| 58 | - return 0; |
| 59 | - |
| 60 | - if ((band == MT_BAND1 && !dev->dbdc_support) || |
| 61 | - (band == MT_BAND2 && !dev->tbtc_support)) |
| 62 | + if (!mt7996_band_valid(dev, band) || band == MT_BAND0) |
| 63 | return 0; |
| 64 | |
| 65 | if (phy) |
| 66 | @@ -648,8 +644,10 @@ static int mt7996_init_hardware(struct mt7996_dev *dev) |
| 67 | |
| 68 | INIT_WORK(&dev->init_work, mt7996_init_work); |
| 69 | |
| 70 | - dev->dbdc_support = true; |
| 71 | - dev->tbtc_support = true; |
| 72 | + dev->dbdc_support = mt7996_band_valid(dev, MT_BAND1) || |
| 73 | + mt7996_band_valid(dev, MT_BAND2); |
| 74 | + dev->tbtc_support = mt7996_band_valid(dev, MT_BAND1) && |
| 75 | + mt7996_band_valid(dev, MT_BAND2); |
| 76 | |
| 77 | ret = mt7996_dma_init(dev); |
| 78 | if (ret) |
| 79 | @@ -1089,8 +1087,6 @@ int mt7996_register_device(struct mt7996_dev *dev) |
| 80 | if (ret) |
| 81 | return ret; |
| 82 | |
| 83 | - ieee80211_queue_work(mt76_hw(dev), &dev->init_work); |
| 84 | - |
| 85 | ret = mt7996_register_phy(dev, mt7996_phy2(dev), MT_BAND1); |
| 86 | if (ret) |
| 87 | return ret; |
| 88 | @@ -1099,13 +1095,24 @@ int mt7996_register_device(struct mt7996_dev *dev) |
| 89 | if (ret) |
| 90 | return ret; |
| 91 | |
| 92 | + ieee80211_queue_work(mt76_hw(dev), &dev->init_work); |
| 93 | + |
| 94 | dev->recovery.hw_init_done = true; |
| 95 | |
| 96 | ret = mt7996_init_debugfs(&dev->phy); |
| 97 | if (ret) |
| 98 | - return ret; |
| 99 | + goto error; |
| 100 | |
| 101 | - return mt7996_coredump_register(dev); |
| 102 | + ret = mt7996_coredump_register(dev); |
| 103 | + if (ret) |
| 104 | + goto error; |
| 105 | + |
| 106 | + return 0; |
| 107 | + |
| 108 | +error: |
| 109 | + cancel_work_sync(&dev->init_work); |
| 110 | + |
| 111 | + return ret; |
| 112 | } |
| 113 | |
| 114 | void mt7996_unregister_device(struct mt7996_dev *dev) |
| 115 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
| 116 | index c647979..9fb800a 100644 |
| 117 | --- a/mt7996/mcu.c |
| 118 | +++ b/mt7996/mcu.c |
| 119 | @@ -2767,7 +2767,7 @@ mt7996_mcu_init_rx_airtime(struct mt7996_dev *dev) |
| 120 | { |
| 121 | struct uni_header hdr = {}; |
| 122 | struct sk_buff *skb; |
| 123 | - int len, num; |
| 124 | + int len, num, i; |
| 125 | |
| 126 | num = 2 + 2 * (dev->dbdc_support + dev->tbtc_support); |
| 127 | len = sizeof(hdr) + num * sizeof(struct vow_rx_airtime); |
| 128 | @@ -2777,13 +2777,10 @@ mt7996_mcu_init_rx_airtime(struct mt7996_dev *dev) |
| 129 | |
| 130 | skb_put_data(skb, &hdr, sizeof(hdr)); |
| 131 | |
| 132 | - mt7996_add_rx_airtime_tlv(skb, dev->mt76.phy.band_idx); |
| 133 | - |
| 134 | - if (dev->dbdc_support) |
| 135 | - mt7996_add_rx_airtime_tlv(skb, MT_BAND1); |
| 136 | - |
| 137 | - if (dev->tbtc_support) |
| 138 | - mt7996_add_rx_airtime_tlv(skb, MT_BAND2); |
| 139 | + for (i = 0; i < __MT_MAX_BAND; i++) { |
| 140 | + if (mt7996_band_valid(dev, i)) |
| 141 | + mt7996_add_rx_airtime_tlv(skb, i); |
| 142 | + } |
| 143 | |
| 144 | return mt76_mcu_skb_send_msg(&dev->mt76, skb, |
| 145 | MCU_WM_UNI_CMD(VOW), true); |
| 146 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
| 147 | index f59dce7..488f59c 100644 |
| 148 | --- a/mt7996/mt7996.h |
| 149 | +++ b/mt7996/mt7996.h |
| 150 | @@ -431,6 +431,17 @@ mt7996_phy3(struct mt7996_dev *dev) |
| 151 | return __mt7996_phy(dev, MT_BAND2); |
| 152 | } |
| 153 | |
| 154 | +static inline bool |
| 155 | +mt7996_band_valid(struct mt7996_dev *dev, u8 band) |
| 156 | +{ |
| 157 | + /* tri-band support */ |
| 158 | + if (band <= MT_BAND2 && |
| 159 | + mt76_get_field(dev, MT_PAD_GPIO, MT_PAD_GPIO_ADIE_COMB) <= 1) |
| 160 | + return true; |
| 161 | + |
| 162 | + return band == MT_BAND0 || band == MT_BAND2; |
| 163 | +} |
| 164 | + |
| 165 | extern const struct ieee80211_ops mt7996_ops; |
| 166 | extern struct pci_driver mt7996_pci_driver; |
| 167 | extern struct pci_driver mt7996_hif_driver; |
| 168 | diff --git a/mt7996/regs.h b/mt7996/regs.h |
| 169 | index c054586..3a5914c 100644 |
| 170 | --- a/mt7996/regs.h |
| 171 | +++ b/mt7996/regs.h |
| 172 | @@ -546,6 +546,9 @@ enum base_rev { |
| 173 | #define MT_TOP_MISC MT_TOP(0xf0) |
| 174 | #define MT_TOP_MISC_FW_STATE GENMASK(2, 0) |
| 175 | |
| 176 | +#define MT_PAD_GPIO 0x700056f0 |
| 177 | +#define MT_PAD_GPIO_ADIE_COMB GENMASK(16, 15) |
| 178 | + |
| 179 | #define MT_HW_REV 0x70010204 |
| 180 | #define MT_WF_SUBSYS_RST 0x70028600 |
| 181 | |
| 182 | -- |
| 183 | 2.18.0 |
| 184 | |