developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 1 | From 290608dad38eb923465018470bb587153db96b8d Mon Sep 17 00:00:00 2001 |
developer | eb15569 | 2024-01-11 14:08:37 +0800 | [diff] [blame] | 2 | From: Howard Hsu <howard-yh.hsu@mediatek.com> |
| 3 | Date: Thu, 21 Dec 2023 20:35:36 +0800 |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 1046/1048] wifi: mt76: mt7915: support thermal recal debug |
| 5 | commnad |
developer | eb15569 | 2024-01-11 14:08:37 +0800 | [diff] [blame] | 6 | |
| 7 | Add thermal recal debug command: |
| 8 | $ echo val > debugfs/thermal_recal |
| 9 | |
| 10 | The val can be the following values: |
| 11 | 0 = disable |
| 12 | 1 = enable |
| 13 | 2 = manual trigger |
| 14 | |
| 15 | Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com> |
| 16 | --- |
| 17 | mt76_connac_mcu.h | 1 + |
| 18 | mt7915/mcu.c | 15 +++++++++++++++ |
| 19 | mt7915/mt7915.h | 1 + |
| 20 | mt7915/mtk_debugfs.c | 18 ++++++++++++++++++ |
| 21 | 4 files changed, 35 insertions(+) |
| 22 | |
| 23 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 24 | index 5be93f6..4e1006d 100644 |
developer | eb15569 | 2024-01-11 14:08:37 +0800 | [diff] [blame] | 25 | --- a/mt76_connac_mcu.h |
| 26 | +++ b/mt76_connac_mcu.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 27 | @@ -1224,6 +1224,7 @@ enum { |
developer | eb15569 | 2024-01-11 14:08:37 +0800 | [diff] [blame] | 28 | MCU_EXT_CMD_CAL_CACHE = 0x67, |
| 29 | MCU_EXT_CMD_RED_ENABLE = 0x68, |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 30 | MCU_EXT_CMD_PKT_BUDGET_CTRL = 0x6c, |
developer | eb15569 | 2024-01-11 14:08:37 +0800 | [diff] [blame] | 31 | + MCU_EXT_CMD_THERMAL_DEBUG = 0x79, |
| 32 | MCU_EXT_CMD_SET_RADAR_TH = 0x7c, |
| 33 | MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d, |
| 34 | MCU_EXT_CMD_MWDS_SUPPORT = 0x80, |
| 35 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 36 | index 5672e44..7e0e277 100644 |
developer | eb15569 | 2024-01-11 14:08:37 +0800 | [diff] [blame] | 37 | --- a/mt7915/mcu.c |
| 38 | +++ b/mt7915/mcu.c |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 39 | @@ -5363,3 +5363,18 @@ void mt7915_mcu_scs_sta_poll(struct work_struct *work) |
developer | eb15569 | 2024-01-11 14:08:37 +0800 | [diff] [blame] | 40 | if (scs_enable_flag) |
| 41 | ieee80211_queue_delayed_work(mt76_hw(dev), &dev->scs_work, HZ); |
| 42 | } |
| 43 | + |
| 44 | +int mt7915_mcu_thermal_debug(struct mt7915_dev *dev, u8 mode, u8 action) |
| 45 | +{ |
| 46 | + struct { |
| 47 | + u8 mode; |
| 48 | + u8 action; |
| 49 | + u8 rsv[2]; |
| 50 | + } req = { |
| 51 | + .mode = mode, |
| 52 | + .action = action, |
| 53 | + }; |
| 54 | + |
| 55 | + return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_DEBUG), &req, |
| 56 | + sizeof(req), true); |
| 57 | +} |
| 58 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 59 | index 05a3bd5..38a9db4 100644 |
developer | eb15569 | 2024-01-11 14:08:37 +0800 | [diff] [blame] | 60 | --- a/mt7915/mt7915.h |
| 61 | +++ b/mt7915/mt7915.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 62 | @@ -802,6 +802,7 @@ int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool w |
developer | eb15569 | 2024-01-11 14:08:37 +0800 | [diff] [blame] | 63 | int mt7915_mcu_enable_obss_spr(struct mt7915_phy *phy, u8 action, u8 val); |
| 64 | int mt7915_mcu_set_scs_en(struct mt7915_phy *phy, u8 enable); |
| 65 | void mt7915_mcu_scs_sta_poll(struct work_struct *work); |
| 66 | +int mt7915_mcu_thermal_debug(struct mt7915_dev *dev, u8 mode, u8 action); |
| 67 | |
| 68 | #ifdef MTK_DEBUG |
| 69 | int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir); |
| 70 | diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c |
| 71 | index 64e9d59..9da6328 100644 |
| 72 | --- a/mt7915/mtk_debugfs.c |
| 73 | +++ b/mt7915/mtk_debugfs.c |
| 74 | @@ -3820,6 +3820,22 @@ mt7915_scs_enable_set(void *data, u64 val) |
| 75 | DEFINE_DEBUGFS_ATTRIBUTE(fops_scs_enable, NULL, |
| 76 | mt7915_scs_enable_set, "%lld\n"); |
| 77 | |
| 78 | +static int |
| 79 | +mt7915_thermal_recal_set(void *data, u64 val) |
| 80 | +{ |
| 81 | +#define THERMAL_DEBUG_OPERATION_MANUAL_TRIGGER 2 |
| 82 | +#define THERMAL_DEBUG_MODE_RECAL 1 |
| 83 | + struct mt7915_dev *dev = data; |
| 84 | + |
| 85 | + if (val > THERMAL_DEBUG_OPERATION_MANUAL_TRIGGER) |
| 86 | + return -EINVAL; |
| 87 | + |
| 88 | + return mt7915_mcu_thermal_debug(dev, THERMAL_DEBUG_MODE_RECAL, val); |
| 89 | +} |
| 90 | + |
| 91 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_thermal_recal, NULL, |
| 92 | + mt7915_thermal_recal_set, "%llu\n"); |
| 93 | + |
| 94 | int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir) |
| 95 | { |
| 96 | struct mt7915_dev *dev = phy->dev; |
| 97 | @@ -3913,6 +3929,8 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir) |
| 98 | &fops_sw_aci); |
| 99 | debugfs_create_file("sr_enable", 0200, dir, phy, &fops_sr_enable); |
| 100 | debugfs_create_file("scs_enable", 0200, dir, phy, &fops_scs_enable); |
| 101 | + debugfs_create_file("thermal_recal", 0200, dir, dev, &fops_thermal_recal); |
| 102 | + |
| 103 | return 0; |
| 104 | } |
| 105 | #endif |
| 106 | -- |
| 107 | 2.18.0 |
| 108 | |