developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 1 | From 3fdeeee1f24b09fc0d08b6a386e06c6146e83d9c Mon Sep 17 00:00:00 2001 |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Tue, 23 May 2023 15:49:03 +0800 |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 4 | Subject: [PATCH 07/98] wifi: mt76: mt7996: make band capability init flexible |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 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 | --- |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 12 | mt7996/dma.c | 14 +++++++------- |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 13 | mt7996/init.c | 29 ++++++++++++++++++----------- |
| 14 | mt7996/mcu.c | 13 +++++-------- |
| 15 | mt7996/mt7996.h | 11 +++++++++++ |
| 16 | mt7996/regs.h | 3 +++ |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 17 | 5 files changed, 44 insertions(+), 26 deletions(-) |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 18 | |
| 19 | diff --git a/mt7996/dma.c b/mt7996/dma.c |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 20 | index 2221d22..3d04470 100644 |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 21 | --- a/mt7996/dma.c |
| 22 | +++ b/mt7996/dma.c |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 23 | @@ -222,13 +222,13 @@ void mt7996_dma_start(struct mt7996_dev *dev, bool reset, bool wed_reset) |
| 24 | /* enable interrupts for TX/RX rings */ |
| 25 | irq_mask = MT_INT_MCU_CMD | MT_INT_RX_DONE_MCU | MT_INT_TX_DONE_MCU; |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 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 | |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 39 | if (mtk_wed_device_active(wed) && wed_reset) { |
| 40 | @@ -354,7 +354,7 @@ int mt7996_dma_rro_init(struct mt7996_dev *dev) |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 41 | if (ret) |
| 42 | return ret; |
| 43 | |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 44 | - if (dev->dbdc_support) { |
| 45 | + if (mt7996_band_valid(dev, MT_BAND1)) { |
| 46 | /* rx msdu page queue for band1 */ |
| 47 | mdev->q_rx[MT_RXQ_MSDU_PAGE_BAND1].flags = |
| 48 | MT_WED_RRO_Q_MSDU_PG(1) | MT_QFLAG_WED_RRO_EN; |
| 49 | @@ -368,7 +368,7 @@ int mt7996_dma_rro_init(struct mt7996_dev *dev) |
| 50 | return ret; |
| 51 | } |
| 52 | |
| 53 | - if (dev->tbtc_support) { |
| 54 | + if (mt7996_band_valid(dev, MT_BAND2)) { |
| 55 | /* rx msdu page queue for band2 */ |
| 56 | mdev->q_rx[MT_RXQ_MSDU_PAGE_BAND2].flags = |
| 57 | MT_WED_RRO_Q_MSDU_PG(2) | MT_QFLAG_WED_RRO_EN; |
| 58 | @@ -488,7 +488,7 @@ int mt7996_dma_init(struct mt7996_dev *dev) |
| 59 | if (ret) |
| 60 | return ret; |
| 61 | |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 62 | - if (dev->tbtc_support || dev->mphy.band_idx == MT_BAND2) { |
| 63 | + if (mt7996_band_valid(dev, MT_BAND2)) { |
| 64 | /* rx data queue for band2 */ |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 65 | rx_base = MT_RXQ_RING_BASE(MT_RXQ_BAND2) + hif1_ofs; |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 66 | ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_BAND2], |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 67 | @@ -542,7 +542,7 @@ int mt7996_dma_init(struct mt7996_dev *dev) |
| 68 | if (ret) |
| 69 | return ret; |
| 70 | |
| 71 | - if (dev->tbtc_support || dev->mphy.band_idx == MT_BAND2) { |
| 72 | + if (mt7996_band_valid(dev, MT_BAND2)) { |
| 73 | /* rx rro data queue for band2 */ |
| 74 | dev->mt76.q_rx[MT_RXQ_RRO_BAND2].flags = |
| 75 | MT_WED_RRO_Q_DATA(1) | MT_QFLAG_WED_RRO_EN; |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 76 | diff --git a/mt7996/init.c b/mt7996/init.c |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 77 | index de4a5f7..2e6efc5 100644 |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 78 | --- a/mt7996/init.c |
| 79 | +++ b/mt7996/init.c |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 80 | @@ -539,11 +539,7 @@ static int mt7996_register_phy(struct mt7996_dev *dev, struct mt7996_phy *phy, |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 81 | int ret; |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 82 | struct mtk_wed_device *wed = &dev->mt76.mmio.wed; |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 83 | |
| 84 | - if (band != MT_BAND1 && band != MT_BAND2) |
| 85 | - return 0; |
| 86 | - |
| 87 | - if ((band == MT_BAND1 && !dev->dbdc_support) || |
| 88 | - (band == MT_BAND2 && !dev->tbtc_support)) |
| 89 | + if (!mt7996_band_valid(dev, band) || band == MT_BAND0) |
| 90 | return 0; |
| 91 | |
| 92 | if (phy) |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 93 | @@ -782,8 +778,10 @@ static int mt7996_init_hardware(struct mt7996_dev *dev) |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 94 | |
| 95 | INIT_WORK(&dev->init_work, mt7996_init_work); |
| 96 | |
| 97 | - dev->dbdc_support = true; |
| 98 | - dev->tbtc_support = true; |
| 99 | + dev->dbdc_support = mt7996_band_valid(dev, MT_BAND1) || |
| 100 | + mt7996_band_valid(dev, MT_BAND2); |
| 101 | + dev->tbtc_support = mt7996_band_valid(dev, MT_BAND1) && |
| 102 | + mt7996_band_valid(dev, MT_BAND2); |
| 103 | |
| 104 | ret = mt7996_dma_init(dev); |
| 105 | if (ret) |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 106 | @@ -1217,8 +1215,6 @@ int mt7996_register_device(struct mt7996_dev *dev) |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 107 | if (ret) |
| 108 | return ret; |
| 109 | |
| 110 | - ieee80211_queue_work(mt76_hw(dev), &dev->init_work); |
| 111 | - |
| 112 | ret = mt7996_register_phy(dev, mt7996_phy2(dev), MT_BAND1); |
| 113 | if (ret) |
| 114 | return ret; |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 115 | @@ -1227,13 +1223,24 @@ int mt7996_register_device(struct mt7996_dev *dev) |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 116 | if (ret) |
| 117 | return ret; |
| 118 | |
| 119 | + ieee80211_queue_work(mt76_hw(dev), &dev->init_work); |
| 120 | + |
| 121 | dev->recovery.hw_init_done = true; |
| 122 | |
| 123 | ret = mt7996_init_debugfs(&dev->phy); |
| 124 | if (ret) |
| 125 | - return ret; |
| 126 | + goto error; |
| 127 | |
| 128 | - return mt7996_coredump_register(dev); |
| 129 | + ret = mt7996_coredump_register(dev); |
| 130 | + if (ret) |
| 131 | + goto error; |
| 132 | + |
| 133 | + return 0; |
| 134 | + |
| 135 | +error: |
| 136 | + cancel_work_sync(&dev->init_work); |
| 137 | + |
| 138 | + return ret; |
| 139 | } |
| 140 | |
| 141 | void mt7996_unregister_device(struct mt7996_dev *dev) |
| 142 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 143 | index 8320c8c..84f362b 100644 |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 144 | --- a/mt7996/mcu.c |
| 145 | +++ b/mt7996/mcu.c |
developer | 36fe709 | 2023-09-27 12:24:47 +0800 | [diff] [blame] | 146 | @@ -2767,7 +2767,7 @@ mt7996_mcu_init_rx_airtime(struct mt7996_dev *dev) |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 147 | { |
| 148 | struct uni_header hdr = {}; |
| 149 | struct sk_buff *skb; |
| 150 | - int len, num; |
| 151 | + int len, num, i; |
| 152 | |
| 153 | num = 2 + 2 * (dev->dbdc_support + dev->tbtc_support); |
| 154 | len = sizeof(hdr) + num * sizeof(struct vow_rx_airtime); |
developer | 36fe709 | 2023-09-27 12:24:47 +0800 | [diff] [blame] | 155 | @@ -2777,13 +2777,10 @@ mt7996_mcu_init_rx_airtime(struct mt7996_dev *dev) |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 156 | |
| 157 | skb_put_data(skb, &hdr, sizeof(hdr)); |
| 158 | |
| 159 | - mt7996_add_rx_airtime_tlv(skb, dev->mt76.phy.band_idx); |
| 160 | - |
| 161 | - if (dev->dbdc_support) |
| 162 | - mt7996_add_rx_airtime_tlv(skb, MT_BAND1); |
| 163 | - |
| 164 | - if (dev->tbtc_support) |
| 165 | - mt7996_add_rx_airtime_tlv(skb, MT_BAND2); |
| 166 | + for (i = 0; i < __MT_MAX_BAND; i++) { |
| 167 | + if (mt7996_band_valid(dev, i)) |
| 168 | + mt7996_add_rx_airtime_tlv(skb, i); |
| 169 | + } |
| 170 | |
| 171 | return mt76_mcu_skb_send_msg(&dev->mt76, skb, |
| 172 | MCU_WM_UNI_CMD(VOW), true); |
| 173 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 174 | index e1972e9..137d5a2 100644 |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 175 | --- a/mt7996/mt7996.h |
| 176 | +++ b/mt7996/mt7996.h |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 177 | @@ -381,6 +381,17 @@ mt7996_phy3(struct mt7996_dev *dev) |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 178 | return __mt7996_phy(dev, MT_BAND2); |
| 179 | } |
| 180 | |
| 181 | +static inline bool |
| 182 | +mt7996_band_valid(struct mt7996_dev *dev, u8 band) |
| 183 | +{ |
| 184 | + /* tri-band support */ |
| 185 | + if (band <= MT_BAND2 && |
| 186 | + mt76_get_field(dev, MT_PAD_GPIO, MT_PAD_GPIO_ADIE_COMB) <= 1) |
| 187 | + return true; |
| 188 | + |
| 189 | + return band == MT_BAND0 || band == MT_BAND2; |
| 190 | +} |
| 191 | + |
| 192 | extern const struct ieee80211_ops mt7996_ops; |
| 193 | extern struct pci_driver mt7996_pci_driver; |
| 194 | extern struct pci_driver mt7996_hif_driver; |
| 195 | diff --git a/mt7996/regs.h b/mt7996/regs.h |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 196 | index 854390d..a4d5ad8 100644 |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 197 | --- a/mt7996/regs.h |
| 198 | +++ b/mt7996/regs.h |
developer | e35b8e4 | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 199 | @@ -602,6 +602,9 @@ enum base_rev { |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 200 | #define MT_TOP_MISC MT_TOP(0xf0) |
| 201 | #define MT_TOP_MISC_FW_STATE GENMASK(2, 0) |
| 202 | |
| 203 | +#define MT_PAD_GPIO 0x700056f0 |
| 204 | +#define MT_PAD_GPIO_ADIE_COMB GENMASK(16, 15) |
| 205 | + |
| 206 | #define MT_HW_REV 0x70010204 |
| 207 | #define MT_WF_SUBSYS_RST 0x70028600 |
| 208 | |
| 209 | -- |
developer | 36fe709 | 2023-09-27 12:24:47 +0800 | [diff] [blame] | 210 | 2.18.0 |
developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 211 | |