developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 1 | From 7390e5db3745febd580026e723b2ca806e308008 Mon Sep 17 00:00:00 2001 |
| 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Fri, 14 Apr 2023 16:51:59 +0800 |
| 4 | Subject: [PATCH 30/39] wifi: mt76: mt7996: add support for auxiliary path |
| 5 | |
| 6 | Add support to correctly configure the setting of variants that have |
| 7 | additional TX or RX path. |
| 8 | |
| 9 | Change-Id: I1312c193beab5e16aae7161a7e3bdda100b72f8d |
| 10 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 11 | Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> |
| 12 | --- |
| 13 | mt7996/eeprom.c | 21 +++++++++++++++++---- |
| 14 | mt7996/eeprom.h | 3 +++ |
| 15 | mt7996/mcu.c | 2 +- |
| 16 | mt7996/mt7996.h | 14 ++++++++++++++ |
| 17 | 4 files changed, 35 insertions(+), 5 deletions(-) |
| 18 | |
| 19 | diff --git a/mt7996/eeprom.c b/mt7996/eeprom.c |
| 20 | index f5e9546..9840c77 100644 |
| 21 | --- a/mt7996/eeprom.c |
| 22 | +++ b/mt7996/eeprom.c |
| 23 | @@ -171,36 +171,49 @@ static int mt7996_eeprom_parse_band_config(struct mt7996_phy *phy) |
| 24 | |
| 25 | int mt7996_eeprom_parse_hw_cap(struct mt7996_dev *dev, struct mt7996_phy *phy) |
| 26 | { |
| 27 | - u8 path, nss, band_idx = phy->mt76->band_idx; |
| 28 | + u8 path, rx_path, nss, band_idx = phy->mt76->band_idx; |
| 29 | u8 *eeprom = dev->mt76.eeprom.data; |
| 30 | struct mt76_phy *mphy = phy->mt76; |
| 31 | + int max_path = 5, max_nss = 4; |
| 32 | int ret; |
| 33 | |
| 34 | switch (band_idx) { |
| 35 | case MT_BAND1: |
| 36 | path = FIELD_GET(MT_EE_WIFI_CONF2_TX_PATH_BAND1, |
| 37 | eeprom[MT_EE_WIFI_CONF + 2]); |
| 38 | + rx_path = FIELD_GET(MT_EE_WIFI_CONF3_RX_PATH_BAND1, |
| 39 | + eeprom[MT_EE_WIFI_CONF + 3]); |
| 40 | nss = FIELD_GET(MT_EE_WIFI_CONF5_STREAM_NUM_BAND1, |
| 41 | eeprom[MT_EE_WIFI_CONF + 5]); |
| 42 | break; |
| 43 | case MT_BAND2: |
| 44 | path = FIELD_GET(MT_EE_WIFI_CONF2_TX_PATH_BAND2, |
| 45 | eeprom[MT_EE_WIFI_CONF + 2]); |
| 46 | + rx_path = FIELD_GET(MT_EE_WIFI_CONF4_RX_PATH_BAND2, |
| 47 | + eeprom[MT_EE_WIFI_CONF + 4]); |
| 48 | nss = FIELD_GET(MT_EE_WIFI_CONF5_STREAM_NUM_BAND2, |
| 49 | eeprom[MT_EE_WIFI_CONF + 5]); |
| 50 | break; |
| 51 | default: |
| 52 | path = FIELD_GET(MT_EE_WIFI_CONF1_TX_PATH_BAND0, |
| 53 | eeprom[MT_EE_WIFI_CONF + 1]); |
| 54 | + rx_path = FIELD_GET(MT_EE_WIFI_CONF3_RX_PATH_BAND0, |
| 55 | + eeprom[MT_EE_WIFI_CONF + 3]); |
| 56 | nss = FIELD_GET(MT_EE_WIFI_CONF4_STREAM_NUM_BAND0, |
| 57 | eeprom[MT_EE_WIFI_CONF + 4]); |
| 58 | break; |
| 59 | } |
| 60 | |
| 61 | - if (!path || path > 4) |
| 62 | - path = 4; |
| 63 | + if (!path || path > max_path) |
| 64 | + path = max_path; |
| 65 | |
| 66 | - nss = min_t(u8, min_t(u8, 4, nss), path); |
| 67 | + if (!nss || nss > max_nss) |
| 68 | + nss = max_nss; |
| 69 | + |
| 70 | + nss = min_t(u8, nss, path); |
| 71 | + |
| 72 | + if (path != rx_path) |
| 73 | + phy->has_aux_rx = true; |
| 74 | |
| 75 | mphy->antenna_mask = BIT(nss) - 1; |
| 76 | mphy->chainmask = (BIT(path) - 1) << dev->chainshift[band_idx]; |
| 77 | diff --git a/mt7996/eeprom.h b/mt7996/eeprom.h |
| 78 | index 0f8f0cd..9ea3667 100644 |
| 79 | --- a/mt7996/eeprom.h |
| 80 | +++ b/mt7996/eeprom.h |
| 81 | @@ -34,6 +34,9 @@ enum mt7996_eeprom_field { |
| 82 | #define MT_EE_WIFI_CONF1_TX_PATH_BAND0 GENMASK(5, 3) |
| 83 | #define MT_EE_WIFI_CONF2_TX_PATH_BAND1 GENMASK(2, 0) |
| 84 | #define MT_EE_WIFI_CONF2_TX_PATH_BAND2 GENMASK(5, 3) |
| 85 | +#define MT_EE_WIFI_CONF3_RX_PATH_BAND0 GENMASK(2, 0) |
| 86 | +#define MT_EE_WIFI_CONF3_RX_PATH_BAND1 GENMASK(5, 3) |
| 87 | +#define MT_EE_WIFI_CONF4_RX_PATH_BAND2 GENMASK(2, 0) |
| 88 | #define MT_EE_WIFI_CONF4_STREAM_NUM_BAND0 GENMASK(5, 3) |
| 89 | #define MT_EE_WIFI_CONF5_STREAM_NUM_BAND1 GENMASK(2, 0) |
| 90 | #define MT_EE_WIFI_CONF5_STREAM_NUM_BAND2 GENMASK(5, 3) |
| 91 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
| 92 | index 7b8f883..a2c1e43 100644 |
| 93 | --- a/mt7996/mcu.c |
| 94 | +++ b/mt7996/mcu.c |
| 95 | @@ -3198,7 +3198,7 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag) |
| 96 | .center_ch = ieee80211_frequency_to_channel(freq1), |
| 97 | .bw = mt76_connac_chan_bw(chandef), |
| 98 | .tx_path_num = hweight16(phy->mt76->chainmask), |
| 99 | - .rx_path = phy->mt76->chainmask >> dev->chainshift[band_idx], |
| 100 | + .rx_path = mt7996_rx_chainmask(phy) >> dev->chainshift[band_idx], |
| 101 | .band_idx = band_idx, |
| 102 | .channel_band = ch_band[chandef->chan->band], |
| 103 | }; |
| 104 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
| 105 | index f7d6580..8e5b3c3 100644 |
| 106 | --- a/mt7996/mt7996.h |
| 107 | +++ b/mt7996/mt7996.h |
| 108 | @@ -248,6 +248,8 @@ struct mt7996_phy { |
| 109 | struct mib_stats mib; |
| 110 | struct mt76_channel_state state_ts; |
| 111 | |
| 112 | + bool has_aux_rx; |
| 113 | + |
| 114 | #ifdef CONFIG_NL80211_TESTMODE |
| 115 | struct { |
| 116 | u32 *reg_backup; |
| 117 | @@ -551,6 +553,18 @@ static inline void mt7996_irq_disable(struct mt7996_dev *dev, u32 mask) |
| 118 | void mt7996_memcpy_fromio(struct mt7996_dev *dev, void *buf, u32 offset, |
| 119 | size_t len); |
| 120 | |
| 121 | +static inline u16 mt7996_rx_chainmask(struct mt7996_phy *phy) |
| 122 | +{ |
| 123 | + int max_nss = hweight8(phy->mt76->hw->wiphy->available_antennas_tx); |
| 124 | + int cur_nss = hweight8(phy->mt76->antenna_mask); |
| 125 | + u16 tx_chainmask = phy->mt76->chainmask; |
| 126 | + |
| 127 | + if (cur_nss != max_nss) |
| 128 | + return tx_chainmask; |
| 129 | + |
| 130 | + return tx_chainmask | (BIT(fls(tx_chainmask)) * phy->has_aux_rx); |
| 131 | +} |
| 132 | + |
| 133 | void mt7996_mac_init(struct mt7996_dev *dev); |
| 134 | u32 mt7996_mac_wtbl_lmac_addr(struct mt7996_dev *dev, u16 wcid, u8 dw); |
| 135 | bool mt7996_mac_wtbl_update(struct mt7996_dev *dev, int idx, u32 mask); |
| 136 | -- |
| 137 | 2.18.0 |
| 138 | |