blob: 78dba5412fe4fc07e5aa852d68a981325c4f2950 [file] [log] [blame]
developere35b8e42023-10-16 11:04:00 +08001From a8a300579541b1e29f498d887e4711c481af1809 Mon Sep 17 00:00:00 2001
developer8bff6472023-07-17 11:11:44 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Tue, 11 Jul 2023 17:06:04 +0800
developere35b8e42023-10-16 11:04:00 +08004Subject: [PATCH 1033/1040] wifi: mt76: mt7915: add txpower info dump support
developer8bff6472023-07-17 11:11:44 +08005
6Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
7---
8 mt7915/debugfs.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++
9 mt7915/mcu.c | 2 ++
10 mt7915/mcu.h | 3 +-
11 3 files changed, 91 insertions(+), 1 deletion(-)
12
13diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
developere35b8e42023-10-16 11:04:00 +080014index ae291a3..2bf907c 100644
developer8bff6472023-07-17 11:11:44 +080015--- a/mt7915/debugfs.c
16+++ b/mt7915/debugfs.c
developer26d6cc52023-07-31 12:27:06 +080017@@ -1258,6 +1258,91 @@ mt7915_txpower_path_show(struct seq_file *file, void *data)
developer8bff6472023-07-17 11:11:44 +080018
19 DEFINE_SHOW_ATTRIBUTE(mt7915_txpower_path);
20
21+static int
22+mt7915_txpower_info_show(struct seq_file *file, void *data)
23+{
24+ struct mt7915_phy *phy = file->private;
25+ struct {
26+ u8 category;
27+ u8 rsv1;
28+
29+ /* basic info */
30+ u8 band_idx;
31+ u8 band;
32+
33+ /* board type info */
34+ bool is_epa;
35+ bool is_elna;
36+
37+ /* power percentage info */
38+ bool percentage_ctrl_enable;
39+ s8 power_drop_level;
40+
41+ /* frond-end loss TX info */
42+ s8 front_end_loss_tx[4];
43+
44+ /* frond-end loss RX info */
45+ s8 front_end_loss_rx[4];
46+
47+ /* thermal info */
48+ bool thermal_compensate_enable;
49+ s8 thermal_compensate_value;
50+ u8 rsv2;
51+
52+ /* TX power max/min limit info */
53+ s8 max_power_bound;
54+ s8 min_power_bound;
55+
56+ /* power limit info */
57+ bool sku_enable;
58+ bool bf_backoff_enable;
59+
60+ /* MU TX power info */
61+ bool mu_tx_power_manual_enable;
62+ s8 mu_tx_power_auto;
63+ s8 mu_tx_power_manual;
64+ u8 rsv3;
65+ } __packed basic_info = {};
66+ int ret;
67+
68+ ret = mt7915_mcu_get_txpower_sku(phy, (s8 *)&basic_info, sizeof(basic_info),
69+ TX_POWER_INFO_BASIC);
70+ if (ret || basic_info.category != TX_POWER_INFO_BASIC)
71+ goto out;
72+
73+ seq_puts(file, "======================== BASIC INFO ========================\n");
74+ seq_printf(file, " Band Index: %d, Channel Band: %d\n",
75+ basic_info.band_idx, basic_info.band);
76+ seq_printf(file, " PA Type: %s\n", basic_info.is_epa ? "ePA" : "iPA");
77+ seq_printf(file, " LNA Type: %s\n", basic_info.is_elna ? "eLNA" : "iLNA");
78+ seq_puts(file, "------------------------------------------------------------\n");
79+ seq_printf(file, " SKU: %s\n", basic_info.sku_enable ? "enable" : "disable");
80+ seq_printf(file, " Percentage Control: %s\n",
81+ basic_info.percentage_ctrl_enable ? "enable" : "disable");
82+ seq_printf(file, " Power Drop: %d [dBm]\n", basic_info.power_drop_level >> 1);
83+ seq_printf(file, " Backoff: %s\n",
84+ basic_info.bf_backoff_enable ? "enable" : "disable");
85+ seq_printf(file, " TX Front-end Loss: %d, %d, %d, %d\n",
86+ basic_info.front_end_loss_tx[0], basic_info.front_end_loss_tx[1],
87+ basic_info.front_end_loss_tx[2], basic_info.front_end_loss_tx[3]);
88+ seq_printf(file, " RX Front-end Loss: %d, %d, %d, %d\n",
89+ basic_info.front_end_loss_rx[0], basic_info.front_end_loss_rx[1],
90+ basic_info.front_end_loss_rx[2], basic_info.front_end_loss_rx[3]);
91+ seq_printf(file, " MU TX Power Mode: %s\n",
92+ basic_info.mu_tx_power_manual_enable ? "manual" : "auto");
93+ seq_printf(file, " MU TX Power (Auto / Manual): %d / %d [0.5 dBm]\n",
94+ basic_info.mu_tx_power_auto, basic_info.mu_tx_power_manual);
95+ seq_printf(file, " Thermal Compensation: %s\n",
96+ basic_info.thermal_compensate_enable ? "enable" : "disable");
97+ seq_printf(file, " Theraml Compensation Value: %d\n",
98+ basic_info.thermal_compensate_value);
99+
100+out:
101+ return ret;
102+}
103+
104+DEFINE_SHOW_ATTRIBUTE(mt7915_txpower_info);
105+
106 static int
107 mt7915_twt_stats(struct seq_file *s, void *data)
108 {
developer26d6cc52023-07-31 12:27:06 +0800109@@ -1347,6 +1432,8 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
developer8bff6472023-07-17 11:11:44 +0800110 &mt7915_txpower_fops);
111 debugfs_create_file("txpower_path", 0400, dir, phy,
112 &mt7915_txpower_path_fops);
113+ debugfs_create_file("txpower_info", 0400, dir, phy,
114+ &mt7915_txpower_info_fops);
115 debugfs_create_devm_seqfile(dev->mt76.dev, "twt_stats", dir,
116 mt7915_twt_stats);
117 debugfs_create_file("rf_regval", 0600, dir, dev, &fops_rf_regval);
118diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developere35b8e42023-10-16 11:04:00 +0800119index fe00519..344ba85 100644
developer8bff6472023-07-17 11:11:44 +0800120--- a/mt7915/mcu.c
121+++ b/mt7915/mcu.c
developere35b8e42023-10-16 11:04:00 +0800122@@ -3482,6 +3482,8 @@ int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len,
developer8bff6472023-07-17 11:11:44 +0800123 txpower[i] = res[i][req.band_idx];
124 } else if (category == TX_POWER_INFO_PATH) {
125 memcpy(txpower, skb->data + 4, len);
126+ } else if (category == TX_POWER_INFO_BASIC) {
127+ memcpy(txpower, skb->data, len);
128 }
129
130 dev_kfree_skb(skb);
131diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developere35b8e42023-10-16 11:04:00 +0800132index 583caca..6e6f320 100644
developer8bff6472023-07-17 11:11:44 +0800133--- a/mt7915/mcu.h
134+++ b/mt7915/mcu.h
135@@ -510,7 +510,8 @@ enum {
136 };
137
138 enum {
139- TX_POWER_INFO_PATH = 1,
140+ TX_POWER_INFO_BASIC,
141+ TX_POWER_INFO_PATH,
142 TX_POWER_INFO_RATE,
143 };
144
145--
developere35b8e42023-10-16 11:04:00 +08001462.18.0
developer8bff6472023-07-17 11:11:44 +0800147