blob: 92c5528886416c745bb4d1cd20d61c1e65483160 [file] [log] [blame]
From 338c73d96368002a889639c9b4d8af8ce5248dfe Mon Sep 17 00:00:00 2001
From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Date: Tue, 11 Jul 2023 17:06:04 +0800
Subject: [PATCH 1033/1034] wifi: mt76: mt7915: add txpower info dump support
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
---
mt7915/debugfs.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++
mt7915/mcu.c | 2 ++
mt7915/mcu.h | 3 +-
3 files changed, 91 insertions(+), 1 deletion(-)
diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
index ae291a3..2bf907c 100644
--- a/mt7915/debugfs.c
+++ b/mt7915/debugfs.c
@@ -1258,6 +1258,91 @@ mt7915_txpower_path_show(struct seq_file *file, void *data)
DEFINE_SHOW_ATTRIBUTE(mt7915_txpower_path);
+static int
+mt7915_txpower_info_show(struct seq_file *file, void *data)
+{
+ struct mt7915_phy *phy = file->private;
+ struct {
+ u8 category;
+ u8 rsv1;
+
+ /* basic info */
+ u8 band_idx;
+ u8 band;
+
+ /* board type info */
+ bool is_epa;
+ bool is_elna;
+
+ /* power percentage info */
+ bool percentage_ctrl_enable;
+ s8 power_drop_level;
+
+ /* frond-end loss TX info */
+ s8 front_end_loss_tx[4];
+
+ /* frond-end loss RX info */
+ s8 front_end_loss_rx[4];
+
+ /* thermal info */
+ bool thermal_compensate_enable;
+ s8 thermal_compensate_value;
+ u8 rsv2;
+
+ /* TX power max/min limit info */
+ s8 max_power_bound;
+ s8 min_power_bound;
+
+ /* power limit info */
+ bool sku_enable;
+ bool bf_backoff_enable;
+
+ /* MU TX power info */
+ bool mu_tx_power_manual_enable;
+ s8 mu_tx_power_auto;
+ s8 mu_tx_power_manual;
+ u8 rsv3;
+ } __packed basic_info = {};
+ int ret;
+
+ ret = mt7915_mcu_get_txpower_sku(phy, (s8 *)&basic_info, sizeof(basic_info),
+ TX_POWER_INFO_BASIC);
+ if (ret || basic_info.category != TX_POWER_INFO_BASIC)
+ goto out;
+
+ seq_puts(file, "======================== BASIC INFO ========================\n");
+ seq_printf(file, " Band Index: %d, Channel Band: %d\n",
+ basic_info.band_idx, basic_info.band);
+ seq_printf(file, " PA Type: %s\n", basic_info.is_epa ? "ePA" : "iPA");
+ seq_printf(file, " LNA Type: %s\n", basic_info.is_elna ? "eLNA" : "iLNA");
+ seq_puts(file, "------------------------------------------------------------\n");
+ seq_printf(file, " SKU: %s\n", basic_info.sku_enable ? "enable" : "disable");
+ seq_printf(file, " Percentage Control: %s\n",
+ basic_info.percentage_ctrl_enable ? "enable" : "disable");
+ seq_printf(file, " Power Drop: %d [dBm]\n", basic_info.power_drop_level >> 1);
+ seq_printf(file, " Backoff: %s\n",
+ basic_info.bf_backoff_enable ? "enable" : "disable");
+ seq_printf(file, " TX Front-end Loss: %d, %d, %d, %d\n",
+ basic_info.front_end_loss_tx[0], basic_info.front_end_loss_tx[1],
+ basic_info.front_end_loss_tx[2], basic_info.front_end_loss_tx[3]);
+ seq_printf(file, " RX Front-end Loss: %d, %d, %d, %d\n",
+ basic_info.front_end_loss_rx[0], basic_info.front_end_loss_rx[1],
+ basic_info.front_end_loss_rx[2], basic_info.front_end_loss_rx[3]);
+ seq_printf(file, " MU TX Power Mode: %s\n",
+ basic_info.mu_tx_power_manual_enable ? "manual" : "auto");
+ seq_printf(file, " MU TX Power (Auto / Manual): %d / %d [0.5 dBm]\n",
+ basic_info.mu_tx_power_auto, basic_info.mu_tx_power_manual);
+ seq_printf(file, " Thermal Compensation: %s\n",
+ basic_info.thermal_compensate_enable ? "enable" : "disable");
+ seq_printf(file, " Theraml Compensation Value: %d\n",
+ basic_info.thermal_compensate_value);
+
+out:
+ return ret;
+}
+
+DEFINE_SHOW_ATTRIBUTE(mt7915_txpower_info);
+
static int
mt7915_twt_stats(struct seq_file *s, void *data)
{
@@ -1347,6 +1432,8 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
&mt7915_txpower_fops);
debugfs_create_file("txpower_path", 0400, dir, phy,
&mt7915_txpower_path_fops);
+ debugfs_create_file("txpower_info", 0400, dir, phy,
+ &mt7915_txpower_info_fops);
debugfs_create_devm_seqfile(dev->mt76.dev, "twt_stats", dir,
mt7915_twt_stats);
debugfs_create_file("rf_regval", 0600, dir, dev, &fops_rf_regval);
diff --git a/mt7915/mcu.c b/mt7915/mcu.c
index a542031..d2e3e82 100644
--- a/mt7915/mcu.c
+++ b/mt7915/mcu.c
@@ -3473,6 +3473,8 @@ int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len,
txpower[i] = res[i][req.band_idx];
} else if (category == TX_POWER_INFO_PATH) {
memcpy(txpower, skb->data + 4, len);
+ } else if (category == TX_POWER_INFO_BASIC) {
+ memcpy(txpower, skb->data, len);
}
dev_kfree_skb(skb);
diff --git a/mt7915/mcu.h b/mt7915/mcu.h
index 583caca..6e6f320 100644
--- a/mt7915/mcu.h
+++ b/mt7915/mcu.h
@@ -510,7 +510,8 @@ enum {
};
enum {
- TX_POWER_INFO_PATH = 1,
+ TX_POWER_INFO_BASIC,
+ TX_POWER_INFO_PATH,
TX_POWER_INFO_RATE,
};
--
2.18.0