developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 1 | From 2327076bc0ae52d057204b337d7b1503f097dfbf Mon Sep 17 00:00:00 2001 |
developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Fri, 14 Apr 2023 16:51:59 +0800 |
developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 4 | Subject: [PATCH 02/22] wifi: mt76: mt7996: add support for auxiliary path |
developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 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 |
developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 20 | index 544b6c6f1..9db7e5310 100644 |
developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 21 | --- a/mt7996/eeprom.c |
| 22 | +++ b/mt7996/eeprom.c |
developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 23 | @@ -148,36 +148,49 @@ static int mt7996_eeprom_parse_band_config(struct mt7996_phy *phy) |
developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 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 |
developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 78 | index 0c749774f..412d6e2f8 100644 |
developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 79 | --- a/mt7996/eeprom.h |
| 80 | +++ b/mt7996/eeprom.h |
developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 81 | @@ -33,6 +33,9 @@ enum mt7996_eeprom_field { |
developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 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 |
developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 92 | index 12bf4e503..d422214e2 100644 |
developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 93 | --- a/mt7996/mcu.c |
| 94 | +++ b/mt7996/mcu.c |
developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 95 | @@ -3179,7 +3179,7 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag) |
developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 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 |
developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 105 | index 7354e5cf8..25a563f74 100644 |
developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 106 | --- a/mt7996/mt7996.h |
| 107 | +++ b/mt7996/mt7996.h |
developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 108 | @@ -170,6 +170,8 @@ struct mt7996_phy { |
developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 109 | |
developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 110 | struct mt76_mib_stats mib; |
| 111 | struct mt76_channel_state state_ts; |
developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 112 | + |
developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 113 | + bool has_aux_rx; |
| 114 | }; |
| 115 | |
| 116 | struct mt7996_dev { |
| 117 | @@ -437,6 +439,18 @@ static inline void mt7996_irq_disable(struct mt7996_dev *dev, u32 mask) |
developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 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 | -- |
developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 137 | 2.39.2 |
developer | 064da3c | 2023-06-13 15:57:26 +0800 | [diff] [blame] | 138 | |