From b49c6eb3aef0701ba87a17a783a12e1d1931eb73 Mon Sep 17 00:00:00 2001
From: "a@b.com"
Date: Thu, 27 Apr 2023 15:47:49 +0800
Subject: [PATCH] fix cpufreq
Signed-off-by: a@b.com
---
drivers/cpufreq/Kconfig.arm | 6 ++++++
drivers/cpufreq/Makefile | 1 +
drivers/cpufreq/ft2004-cpufreq.c | 4 ++--
lib/classtypes.c | 7 ++++++-
4 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 1f73fa75b1a0..3d2be874c091 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -340,3 +340,9 @@ config ARM_PXA2xx_CPUFREQ
This add the CPUFreq driver support for Intel PXA2xx SOCs.
If in doubt, say N.
+config ARM64_PHYTIUM_CPUFREQ
+ bool "Phytium CPUFreq support"
+ depends on CPUFREQ_DT && CPUFREQ_DT_PLATDEV
+ default y
+ help
+ This add the CPUFreq driver support for Ft2004
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index f1b7e3dd6e5d..139e5780623f 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -86,6 +86,7 @@ obj-$(CONFIG_ARM_TEGRA186_CPUFREQ) += tegra186-cpufreq.o
obj-$(CONFIG_ARM_TEGRA194_CPUFREQ) += tegra194-cpufreq.o
obj-$(CONFIG_ARM_TI_CPUFREQ) += ti-cpufreq.o
obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o
+obj-$(CONFIG_ARM64_PHYTIUM_CPUFREQ) += ft2004-cpufreq.o
##################################################################################
diff --git a/drivers/cpufreq/ft2004-cpufreq.c b/drivers/cpufreq/ft2004-cpufreq.c
index 95a12382b308..3eb4caaf1fbb 100644
--- a/drivers/cpufreq/ft2004-cpufreq.c
+++ b/drivers/cpufreq/ft2004-cpufreq.c
@@ -153,6 +153,7 @@ static struct cpufreq_driver ft2004_freq_driver = {
.attr = cpufreq_generic_attr,
};
+extern bool cpu_is_phytium(void);
static int __init ft2004_freq_init(void)
{
int ret;
@@ -177,13 +178,12 @@ static int __init ft2004_freq_init(void)
return ret;
}
-
static void __exit ft2004_freq_exit(void)
{
int i;
if (!cpu_is_phytium()) {
- return -EPERM;
+ return ;
}
cpufreq_unregister_driver(&ft2004_freq_driver);
diff --git a/lib/classtypes.c b/lib/classtypes.c
index f869548e1b99..d7028fdc2ff4 100644
--- a/lib/classtypes.c
+++ b/lib/classtypes.c
@@ -47,8 +47,13 @@ char *get_cpu_name(void)
dmi_walk(get_cpuname_by_dmi, cpu_name);
if(cpu_name == NULL) {
+#ifdef CONFIG_ARCH_PHYTIUM
+ pr_info("Q cpu_name null, change\n");
+ return "FT-2000/4";
+#else
/* Some BIOS don't support getting CPU name from DMI */
return "UNKNOWN-CPU";
+#endif
}
return cpu_name;
@@ -148,4 +153,4 @@ bool os_run_evn_is_virt(void)
return false;
}
-EXPORT_SYMBOL(os_run_evn_is_virt);
\ No newline at end of file
+EXPORT_SYMBOL(os_run_evn_is_virt);