Skip to content

Commit ccf5145

Browse files
chenhuacaivireshk
authored andcommitted
cpufreq: Add Loongson-3 CPUFreq driver support
Some of LoongArch processors (Loongson-3 series) support DVFS, their IOCSR.FEATURES has IOCSRF_FREQSCALE set. And they has a micro-core in the package called SMC (System Management Controller), which can be used to detect temperature, control fans, scale frequency and voltage, etc. The Loongson-3 CPUFreq driver is very simple now, it communicate with SMC, get DVFS info, set target frequency from CPUFreq core, and so on. There is a command list to interact with SMC, widely-used commands in the CPUFreq driver include: CMD_GET_VERSION: Get SMC firmware version. CMD_GET_FEATURE: Get enabled SMC features. CMD_SET_FEATURE: Enable SMC features, such as basic DVFS, BOOST. CMD_GET_FREQ_LEVEL_NUM: Get the number of all frequency levels. CMD_GET_FREQ_BOOST_LEVEL: Get the first boost frequency level. CMD_GET_FREQ_LEVEL_INFO: Get the detail info of a frequency level. CMD_GET_FREQ_INFO: Get the current frequency. CMD_SET_FREQ_INFO: Set the target frequency. In future we will add automatic frequency scaling, which is similar to Intel's HWP (HardWare P-State). Signed-off-by: Binbin Zhou <[email protected]> Signed-off-by: Huacai Chen <[email protected]> [ Viresh: Minor formatting cleanups, change return type of exit() to void and use devm_mutex_init() ] Signed-off-by: Viresh Kumar <[email protected]>
1 parent b4b1ddc commit ccf5145

File tree

4 files changed

+409
-0
lines changed

4 files changed

+409
-0
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12969,6 +12969,7 @@ F: Documentation/arch/loongarch/
1296912969
F: Documentation/translations/zh_CN/arch/loongarch/
1297012970
F: arch/loongarch/
1297112971
F: drivers/*/*loongarch*
12972+
F: drivers/cpufreq/loongson3_cpufreq.c
1297212973

1297312974
LOONGSON GPIO DRIVER
1297412975
M: Yinbo Zhu <[email protected]>

drivers/cpufreq/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,18 @@ config LOONGSON2_CPUFREQ
262262
If in doubt, say N.
263263
endif
264264

265+
if LOONGARCH
266+
config LOONGSON3_CPUFREQ
267+
tristate "Loongson3 CPUFreq Driver"
268+
help
269+
This option adds a CPUFreq driver for Loongson processors which
270+
support software configurable cpu frequency.
271+
272+
Loongson-3 family processors support this feature.
273+
274+
If in doubt, say N.
275+
endif
276+
265277
if SPARC64
266278
config SPARC_US3_CPUFREQ
267279
tristate "UltraSPARC-III CPU Frequency driver"

drivers/cpufreq/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ obj-$(CONFIG_POWERNV_CPUFREQ) += powernv-cpufreq.o
103103
# Other platform drivers
104104
obj-$(CONFIG_BMIPS_CPUFREQ) += bmips-cpufreq.o
105105
obj-$(CONFIG_LOONGSON2_CPUFREQ) += loongson2_cpufreq.o
106+
obj-$(CONFIG_LOONGSON3_CPUFREQ) += loongson3_cpufreq.o
106107
obj-$(CONFIG_SH_CPU_FREQ) += sh-cpufreq.o
107108
obj-$(CONFIG_SPARC_US2E_CPUFREQ) += sparc-us2e-cpufreq.o
108109
obj-$(CONFIG_SPARC_US3_CPUFREQ) += sparc-us3-cpufreq.o

0 commit comments

Comments
 (0)