| From 71385726a0af02c6cb650a6be60511e6f0f1b3a4 Mon Sep 17 00:00:00 2001 |
| From: Howard Hsu <howard-yh.hsu@mediatek.com> |
| Date: Thu, 21 Dec 2023 20:35:36 +0800 |
| Subject: [PATCH 1041/1052] wifi: mt76: mt7915: support thermal recal debug |
| commnad |
| |
| Add thermal recal debug command: |
| $ echo val > debugfs/thermal_recal |
| |
| The val can be the following values: |
| 0 = disable |
| 1 = enable |
| 2 = manual trigger |
| |
| Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com> |
| --- |
| mt76_connac_mcu.h | 1 + |
| mt7915/mcu.c | 15 +++++++++++++++ |
| mt7915/mt7915.h | 1 + |
| mt7915/mtk_debugfs.c | 18 ++++++++++++++++++ |
| 4 files changed, 35 insertions(+) |
| |
| diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
| index febe3ed4..8a0f5bea 100644 |
| --- a/mt76_connac_mcu.h |
| +++ b/mt76_connac_mcu.h |
| @@ -1234,6 +1234,7 @@ enum { |
| MCU_EXT_CMD_RED_ENABLE = 0x68, |
| MCU_EXT_CMD_PKT_BUDGET_CTRL = 0x6c, |
| MCU_EXT_CMD_CP_SUPPORT = 0x75, |
| + MCU_EXT_CMD_THERMAL_DEBUG = 0x79, |
| MCU_EXT_CMD_SET_RADAR_TH = 0x7c, |
| MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d, |
| MCU_EXT_CMD_MWDS_SUPPORT = 0x80, |
| diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
| index fcbe4da4..2b653bfb 100644 |
| --- a/mt7915/mcu.c |
| +++ b/mt7915/mcu.c |
| @@ -5356,3 +5356,18 @@ void mt7915_mcu_scs_sta_poll(struct work_struct *work) |
| if (scs_enable_flag) |
| ieee80211_queue_delayed_work(mt76_hw(dev), &dev->scs_work, HZ); |
| } |
| + |
| +int mt7915_mcu_thermal_debug(struct mt7915_dev *dev, u8 mode, u8 action) |
| +{ |
| + struct { |
| + u8 mode; |
| + u8 action; |
| + u8 rsv[2]; |
| + } req = { |
| + .mode = mode, |
| + .action = action, |
| + }; |
| + |
| + return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_DEBUG), &req, |
| + sizeof(req), true); |
| +} |
| diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
| index 6b27be9c..496ccd94 100644 |
| --- a/mt7915/mt7915.h |
| +++ b/mt7915/mt7915.h |
| @@ -835,6 +835,7 @@ int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool w |
| int mt7915_mcu_enable_obss_spr(struct mt7915_phy *phy, u8 action, u8 val); |
| int mt7915_mcu_set_scs_en(struct mt7915_phy *phy, u8 enable); |
| void mt7915_mcu_scs_sta_poll(struct work_struct *work); |
| +int mt7915_mcu_thermal_debug(struct mt7915_dev *dev, u8 mode, u8 action); |
| |
| #ifdef MTK_DEBUG |
| int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir); |
| diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c |
| index e60dc850..0677495c 100644 |
| --- a/mt7915/mtk_debugfs.c |
| +++ b/mt7915/mtk_debugfs.c |
| @@ -3843,6 +3843,22 @@ mt7915_scs_enable_set(void *data, u64 val) |
| DEFINE_DEBUGFS_ATTRIBUTE(fops_scs_enable, NULL, |
| mt7915_scs_enable_set, "%lld\n"); |
| |
| +static int |
| +mt7915_thermal_recal_set(void *data, u64 val) |
| +{ |
| +#define THERMAL_DEBUG_OPERATION_MANUAL_TRIGGER 2 |
| +#define THERMAL_DEBUG_MODE_RECAL 1 |
| + struct mt7915_dev *dev = data; |
| + |
| + if (val > THERMAL_DEBUG_OPERATION_MANUAL_TRIGGER) |
| + return -EINVAL; |
| + |
| + return mt7915_mcu_thermal_debug(dev, THERMAL_DEBUG_MODE_RECAL, val); |
| +} |
| + |
| +DEFINE_DEBUGFS_ATTRIBUTE(fops_thermal_recal, NULL, |
| + mt7915_thermal_recal_set, "%llu\n"); |
| + |
| int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir) |
| { |
| struct mt7915_dev *dev = phy->dev; |
| @@ -3936,6 +3952,8 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir) |
| &fops_sw_aci); |
| debugfs_create_file("sr_enable", 0200, dir, phy, &fops_sr_enable); |
| debugfs_create_file("scs_enable", 0200, dir, phy, &fops_scs_enable); |
| + debugfs_create_file("thermal_recal", 0200, dir, dev, &fops_thermal_recal); |
| + |
| return 0; |
| } |
| #endif |
| -- |
| 2.18.0 |
| |