blob: c657c5bb50068e55801c930a12088bffe47f1462 [file] [log] [blame]
developer7e2761e2023-10-12 08:11:13 +08001From 0d8aff6fa4ee351350dda83f8cc7ca2b557322ac Mon Sep 17 00:00:00 2001
developer064da3c2023-06-13 15:57:26 +08002From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Fri, 14 Apr 2023 16:51:59 +0800
developer7e2761e2023-10-12 08:11:13 +08004Subject: [PATCH 03/98] wifi: mt76: mt7996: add support for auxiliary path
developer064da3c2023-06-13 15:57:26 +08005
6Add support to correctly configure the setting of variants that have
7additional TX or RX path.
8
9Change-Id: I1312c193beab5e16aae7161a7e3bdda100b72f8d
10Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
11Signed-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
19diff --git a/mt7996/eeprom.c b/mt7996/eeprom.c
developer7e2761e2023-10-12 08:11:13 +080020index 544b6c6..9db7e53 100644
developer064da3c2023-06-13 15:57:26 +080021--- a/mt7996/eeprom.c
22+++ b/mt7996/eeprom.c
developerc2cfe0f2023-09-22 04:11:09 +080023@@ -148,36 +148,49 @@ static int mt7996_eeprom_parse_band_config(struct mt7996_phy *phy)
developer064da3c2023-06-13 15:57:26 +080024
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];
77diff --git a/mt7996/eeprom.h b/mt7996/eeprom.h
developer7e2761e2023-10-12 08:11:13 +080078index 0c74977..412d6e2 100644
developer064da3c2023-06-13 15:57:26 +080079--- a/mt7996/eeprom.h
80+++ b/mt7996/eeprom.h
developerc2cfe0f2023-09-22 04:11:09 +080081@@ -33,6 +33,9 @@ enum mt7996_eeprom_field {
developer064da3c2023-06-13 15:57:26 +080082 #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)
91diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developer7e2761e2023-10-12 08:11:13 +080092index 3ff70c6..328bea9 100644
developer064da3c2023-06-13 15:57:26 +080093--- a/mt7996/mcu.c
94+++ b/mt7996/mcu.c
developer7e2761e2023-10-12 08:11:13 +080095@@ -3178,7 +3178,7 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag)
developer064da3c2023-06-13 15:57:26 +080096 .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 };
104diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
developer7e2761e2023-10-12 08:11:13 +0800105index c541eaa..ef84173 100644
developer064da3c2023-06-13 15:57:26 +0800106--- a/mt7996/mt7996.h
107+++ b/mt7996/mt7996.h
developer7e2761e2023-10-12 08:11:13 +0800108@@ -206,6 +206,8 @@ struct mt7996_phy {
developer064da3c2023-06-13 15:57:26 +0800109
developerc2cfe0f2023-09-22 04:11:09 +0800110 struct mt76_mib_stats mib;
111 struct mt76_channel_state state_ts;
developer064da3c2023-06-13 15:57:26 +0800112+
developerc2cfe0f2023-09-22 04:11:09 +0800113+ bool has_aux_rx;
114 };
115
116 struct mt7996_dev {
developer7e2761e2023-10-12 08:11:13 +0800117@@ -491,6 +493,18 @@ static inline void mt7996_irq_disable(struct mt7996_dev *dev, u32 mask)
developer064da3c2023-06-13 15:57:26 +0800118 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--
developer7e2761e2023-10-12 08:11:13 +08001372.18.0
developer064da3c2023-06-13 15:57:26 +0800138