Skip to content

Commit

Permalink
LoongArch: Add CPUFreq driver support
Browse files Browse the repository at this point in the history
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
  • Loading branch information
chenhuacai authored and yetist committed Aug 3, 2023
1 parent fbc7e8f commit 9eed420
Show file tree
Hide file tree
Showing 6 changed files with 452 additions and 0 deletions.
6 changes: 6 additions & 0 deletions arch/loongarch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -667,4 +667,10 @@ source "drivers/acpi/Kconfig"

endmenu

menu "CPU Power Management"

source "drivers/cpufreq/Kconfig"

endmenu

source "drivers/firmware/Kconfig"
3 changes: 3 additions & 0 deletions arch/loongarch/include/asm/loongarch.h
Original file line number Diff line number Diff line change
Expand Up @@ -1075,11 +1075,14 @@ __asm__(".macro parse_r var r\n\t"
#define LOONGARCH_IOCSR_NODECNT 0x408

#define LOONGARCH_IOCSR_MISC_FUNC 0x420
#define IOCSR_MISC_FUNC_SOFT_INT BIT_ULL(10)
#define IOCSR_MISC_FUNC_TIMER_RESET BIT_ULL(21)
#define IOCSR_MISC_FUNC_EXT_IOI_EN BIT_ULL(48)

#define LOONGARCH_IOCSR_CPUTEMP 0x428

#define LOONGARCH_IOCSR_SMCMBX 0x51c

/* PerCore CSR, only accessible by local cores */
#define LOONGARCH_IOCSR_IPI_STATUS 0x1000
#define LOONGARCH_IOCSR_IPI_EN 0x1004
Expand Down
12 changes: 12 additions & 0 deletions arch/loongarch/power/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ void enable_pci_wakeup(void)
acpi_write_bit_register(ACPI_BITREG_PCIEXP_WAKE_DISABLE, 0);
}

static struct platform_device loongson3_cpufreq_device = {
.name = "loongson3_cpufreq",
.id = -1,
};

static int __init loongson_cpufreq_init(void)
{
return platform_device_register(&loongson3_cpufreq_device);
}

arch_initcall(loongson_cpufreq_init);

static int __init loongson3_acpi_suspend_init(void)
{
#ifdef CONFIG_ACPI
Expand Down
12 changes: 12 additions & 0 deletions drivers/cpufreq/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ config LOONGSON2_CPUFREQ
If in doubt, say N.
endif

if LOONGARCH
config LOONGSON3_CPUFREQ
tristate "Loongson3 CPUFreq Driver"
help
This option adds a CPUFreq driver for Loongson processors which
support software configurable cpu frequency.

Loongson-3 family processors support this feature.

If in doubt, say N.
endif

if SPARC64
config SPARC_US3_CPUFREQ
tristate "UltraSPARC-III CPU Frequency driver"
Expand Down
1 change: 1 addition & 0 deletions drivers/cpufreq/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ obj-$(CONFIG_POWERNV_CPUFREQ) += powernv-cpufreq.o
obj-$(CONFIG_BMIPS_CPUFREQ) += bmips-cpufreq.o
obj-$(CONFIG_IA64_ACPI_CPUFREQ) += ia64-acpi-cpufreq.o
obj-$(CONFIG_LOONGSON2_CPUFREQ) += loongson2_cpufreq.o
obj-$(CONFIG_LOONGSON3_CPUFREQ) += loongson3_cpufreq.o
obj-$(CONFIG_SH_CPU_FREQ) += sh-cpufreq.o
obj-$(CONFIG_SPARC_US2E_CPUFREQ) += sparc-us2e-cpufreq.o
obj-$(CONFIG_SPARC_US3_CPUFREQ) += sparc-us3-cpufreq.o

0 comments on commit 9eed420

Please sign in to comment.