blob: 9902ccbe30c95df0ffce2414377b90e268d10153 [file] [log] [blame]
developerd243af02023-12-21 14:49:33 +08001From 1f4de166ff558ddc2803ce0661ac212dd8e7ffe2 Mon Sep 17 00:00:00 2001
2From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Tue, 24 Oct 2023 15:59:18 +0800
4Subject: [PATCH 1029/1041] mtk: wifi: mt76: mt7996: add three wire pta support
5
6three wire enable bit 0 & 1 for EXT0 & EXT1, respectively
7
8Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
9---
10 mt76_connac_mcu.h | 1 +
11 mt7996/vendor.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++
12 mt7996/vendor.h | 12 ++++++++++++
13 3 files changed, 62 insertions(+)
14
15diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
16index b657ef39..615c42b1 100644
17--- a/mt76_connac_mcu.h
18+++ b/mt76_connac_mcu.h
19@@ -1274,6 +1274,7 @@ enum {
20 MCU_UNI_CMD_PER_STA_INFO = 0x6d,
21 MCU_UNI_CMD_ALL_STA_INFO = 0x6e,
22 MCU_UNI_CMD_ASSERT_DUMP = 0x6f,
23+ MCU_UNI_CMD_PTA_3WIRE_CTRL = 0x78,
24 };
25
26 enum {
27diff --git a/mt7996/vendor.c b/mt7996/vendor.c
28index dae3260a..9ba6f00a 100644
29--- a/mt7996/vendor.c
30+++ b/mt7996/vendor.c
31@@ -60,6 +60,11 @@ edcca_dump_policy[NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP] = {
32 [MTK_VENDOR_ATTR_EDCCA_DUMP_SEC160_VAL] = { .type = NLA_U8 },
33 };
34
35+static const struct nla_policy
36+three_wire_ctrl_policy[NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL] = {
37+ [MTK_VENDOR_ATTR_3WIRE_CTRL_MODE] = {.type = NLA_U8 },
38+};
39+
40 static const struct nla_policy
41 ibf_ctrl_policy[NUM_MTK_VENDOR_ATTRS_IBF_CTRL] = {
42 [MTK_VENDOR_ATTR_IBF_CTRL_ENABLE] = { .type = NLA_U8 },
43@@ -561,6 +566,39 @@ mt7996_vendor_edcca_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
44 return EDCCA_MAX_BW_NUM;
45 }
46
47+static int mt7996_vendor_3wire_ctrl(struct wiphy *wiphy, struct wireless_dev *wdev,
48+ const void *data, int data_len)
49+{
50+#define UNI_3WIRE_EXT_EN 0
51+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
52+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
53+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL];
54+ struct {
55+ u8 __rsv1[4];
56+
57+ __le16 tag;
58+ __le16 len;
59+ u8 three_wire_mode;
60+ } __packed req = {
61+ .tag = cpu_to_le16(UNI_3WIRE_EXT_EN),
62+ .len = cpu_to_le16(sizeof(req) - 4),
63+ };
64+ int err;
65+
66+ err = nla_parse(tb, MTK_VENDOR_ATTR_3WIRE_CTRL_MAX, data, data_len,
67+ three_wire_ctrl_policy, NULL);
68+ if (err)
69+ return err;
70+
71+ if (!tb[MTK_VENDOR_ATTR_3WIRE_CTRL_MODE])
72+ return -EINVAL;
73+
74+ req.three_wire_mode = nla_get_u8(tb[MTK_VENDOR_ATTR_3WIRE_CTRL_MODE]);
75+
76+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(PTA_3WIRE_CTRL), &req,
77+ sizeof(req), false);
78+}
79+
80 static int mt7996_vendor_ibf_ctrl(struct wiphy *wiphy,
81 struct wireless_dev *wdev,
82 const void *data,
83@@ -657,6 +695,17 @@ static const struct wiphy_vendor_command mt7996_vendor_commands[] = {
84 .policy = edcca_ctrl_policy,
85 .maxattr = MTK_VENDOR_ATTR_EDCCA_CTRL_MAX,
86 },
87+ {
88+ .info = {
89+ .vendor_id = MTK_NL80211_VENDOR_ID,
90+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL,
91+ },
92+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
93+ WIPHY_VENDOR_CMD_NEED_RUNNING,
94+ .doit = mt7996_vendor_3wire_ctrl,
95+ .policy = three_wire_ctrl_policy,
96+ .maxattr = MTK_VENDOR_ATTR_3WIRE_CTRL_MAX,
97+ },
98 {
99 .info = {
100 .vendor_id = MTK_NL80211_VENDOR_ID,
101diff --git a/mt7996/vendor.h b/mt7996/vendor.h
102index 49f46f25..29ccc050 100644
103--- a/mt7996/vendor.h
104+++ b/mt7996/vendor.h
105@@ -7,6 +7,7 @@ enum mtk_nl80211_vendor_subcmds {
106 MTK_NL80211_VENDOR_SUBCMD_AMNT_CTRL = 0xae,
107 MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
108 MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7,
109+ MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8,
110 MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL = 0xc9,
111 MTK_NL80211_VENDOR_SUBCMD_BSS_COLOR_CTRL = 0xca,
112 };
113@@ -43,6 +44,17 @@ enum mtk_vendor_attr_edcca_dump {
114 NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP - 1
115 };
116
117+enum mtk_vendor_attr_3wire_ctrl {
118+ MTK_VENDOR_ATTR_3WIRE_CTRL_UNSPEC,
119+
120+ MTK_VENDOR_ATTR_3WIRE_CTRL_MODE,
121+
122+ /* keep last */
123+ NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL,
124+ MTK_VENDOR_ATTR_3WIRE_CTRL_MAX =
125+ NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL - 1
126+};
127+
128 enum mtk_vendor_attr_mu_ctrl {
129 MTK_VENDOR_ATTR_MU_CTRL_UNSPEC,
130
131--
1322.18.0
133