| From 290608dad38eb923465018470bb587153db96b8d 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 1046/1048] 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 5be93f6..4e1006d 100644 |
| --- a/mt76_connac_mcu.h |
| +++ b/mt76_connac_mcu.h |
| @@ -1224,6 +1224,7 @@ enum { |
| MCU_EXT_CMD_CAL_CACHE = 0x67, |
| MCU_EXT_CMD_RED_ENABLE = 0x68, |
| MCU_EXT_CMD_PKT_BUDGET_CTRL = 0x6c, |
| + 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 5672e44..7e0e277 100644 |
| --- a/mt7915/mcu.c |
| +++ b/mt7915/mcu.c |
| @@ -5363,3 +5363,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 05a3bd5..38a9db4 100644 |
| --- a/mt7915/mt7915.h |
| +++ b/mt7915/mt7915.h |
| @@ -802,6 +802,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 64e9d59..9da6328 100644 |
| --- a/mt7915/mtk_debugfs.c |
| +++ b/mt7915/mtk_debugfs.c |
| @@ -3820,6 +3820,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; |
| @@ -3913,6 +3929,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 |
| |