]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
wifi: mt76: mt7915: add basedband Txpower info into debugfs
authorRyder Lee <ryder.lee@mediatek.com>
Tue, 22 Nov 2022 07:53:10 +0000 (15:53 +0800)
committerFelix Fietkau <nbd@nbd.name>
Thu, 1 Dec 2022 16:29:14 +0000 (17:29 +0100)
This helps user to debug Txpower propagation path easily.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
drivers/net/wireless/mediatek/mt76/mt7915/regs.h

index 096cb8a4db3d3ce6f6379162f8a275cc7473f2ce..c322fcc19d67fb165b8c46df4e9eb3fd66983f03 100644 (file)
@@ -967,11 +967,18 @@ mt7915_rate_txpower_show(struct seq_file *file, void *data)
                "RU484/SU40", "RU996/SU80", "RU2x996/SU160"
        };
        struct mt7915_phy *phy = file->private;
+       struct mt7915_dev *dev = phy->dev;
        s8 txpower[MT7915_SKU_RATE_NUM], *buf;
-       int i;
+       u32 reg;
+       int i, ret;
+
+       ret = mt7915_mcu_get_txpower_sku(phy, txpower, sizeof(txpower));
+       if (ret)
+               return ret;
+
+       /* Txpower propagation path: TMAC -> TXV -> BBP */
+       seq_printf(file, "\nPhy %d\n", phy != &dev->phy);
 
-       seq_printf(file, "\nBand %d\n", phy != &phy->dev->phy);
-       mt7915_mcu_get_txpower_sku(phy, txpower, sizeof(txpower));
        for (i = 0, buf = txpower; i < ARRAY_SIZE(mt7915_sku_group_len); i++) {
                u8 mcs_num = mt7915_sku_group_len[i];
 
@@ -982,6 +989,12 @@ mt7915_rate_txpower_show(struct seq_file *file, void *data)
                buf += mt7915_sku_group_len[i];
        }
 
+       reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_TPC_CTRL_STAT(phy->band_idx) :
+             MT_WF_PHY_TPC_CTRL_STAT_MT7916(phy->band_idx);
+
+       seq_printf(file, "\nBaseband transmit power %ld\n",
+                  mt76_get_field(dev, reg, MT_WF_PHY_TPC_POWER));
+
        return 0;
 }
 
index 42a19e7b95d6cc0cfe243e899c6a68b3bd76c904..aca1b2f1e9e3bc405ba8f40aee7ce828bd90a7ec 100644 (file)
@@ -1186,6 +1186,10 @@ enum offs_rev {
 #define MT_WF_PHY_RXTD12_IRPI_SW_CLR_ONLY      BIT(18)
 #define MT_WF_PHY_RXTD12_IRPI_SW_CLR           BIT(29)
 
+#define MT_WF_PHY_TPC_CTRL_STAT(_phy)          MT_WF_PHY(0xe7a0 + ((_phy) << 16))
+#define MT_WF_PHY_TPC_CTRL_STAT_MT7916(_phy)   MT_WF_PHY(0xe7a0 + ((_phy) << 20))
+#define MT_WF_PHY_TPC_POWER                    GENMASK(15, 8)
+
 #define MT_MCU_WM_CIRQ_BASE                    0x89010000
 #define MT_MCU_WM_CIRQ(ofs)                    (MT_MCU_WM_CIRQ_BASE + (ofs))
 #define MT_MCU_WM_CIRQ_IRQ_MASK_CLR_ADDR       MT_MCU_WM_CIRQ(0x80)