diff mbox series

cpufreq: amd-pstate: Add resume and suspend callback for amd-pstate

Message ID 20220623031509.555269-1-Jinzhou.Su@amd.com
State Accepted
Commit b376471fb47d4905e72fe73e9eeed228f8f2f230
Headers show
Series cpufreq: amd-pstate: Add resume and suspend callback for amd-pstate | expand

Commit Message

Jinzhou Su June 23, 2022, 3:15 a.m. UTC
When system resumes from S3, the CPPC enable register will be
cleared and reset to 0. So sets this bit to enable CPPC
interface by writing 1 to this register.

Signed-off-by: Jinzhou Su <Jinzhou.Su@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
diff mbox series

Patch

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 7be38bc6a673..9ac75c1cde9c 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -566,6 +566,28 @@  static int amd_pstate_cpu_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
+static int amd_pstate_cpu_resume(struct cpufreq_policy *policy)
+{
+	int ret;
+
+	ret = amd_pstate_enable(true);
+	if (ret)
+		pr_err("failed to enable amd-pstate during resume, return %d\n", ret);
+
+	return ret;
+}
+
+static int amd_pstate_cpu_suspend(struct cpufreq_policy *policy)
+{
+	int ret;
+
+	ret = amd_pstate_enable(false);
+	if (ret)
+		pr_err("failed to disable amd-pstate during suspend, return %d\n", ret);
+
+	return ret;
+}
+
 /* Sysfs attributes */
 
 /*
@@ -636,6 +658,8 @@  static struct cpufreq_driver amd_pstate_driver = {
 	.target		= amd_pstate_target,
 	.init		= amd_pstate_cpu_init,
 	.exit		= amd_pstate_cpu_exit,
+	.suspend	= amd_pstate_cpu_suspend,
+	.resume		= amd_pstate_cpu_resume,
 	.set_boost	= amd_pstate_set_boost,
 	.name		= "amd-pstate",
 	.attr           = amd_pstate_attr,