MIPS: Loongson: Make CPUFreq usable for Loongson-3
PATCH 1/1 MIPS: Loongson: Make CPUFreq usable for Loongson-3
Loongson-3A/3B support frequency scaling. But due to hardware limitation, Loongson-3A R1's frequency scaling is not independent for each core, we suggest enable Loongson-3A's CPUFreq only when there is one core online. Loongson-3B and newer processors can adjust frequency independently for each core, so it can be always enabled.
Each package has only one register (ChipConfig or FreqCtrl) to control frequency, so we need spinlocks to protect register access for multi- cores.
arch/mips/kernel/smp.c is modified to guarantee udelay_val has the correct value while both CPU hotplug and CPUFreq are enabled.
Signed-off-by Huacai Chen <[email protected]>
--- arch/mips/include/asm/mach-loongson64/loongson.h | 1 + arch/mips/kernel/smp.c | 3 +- arch/mips/loongson64/Kconfig | 1 + arch/mips/loongson64/common/platform.c | 13 +- arch/mips/loongson64/loongson-3/Makefile | 2 +- arch/mips/loongson64/loongson-3/clock.c | 191 +++++++++++++++++++++++ drivers/cpufreq/Kconfig | 13 ++ drivers/cpufreq/Makefile | 1 + drivers/cpufreq/loongson3_cpufreq.c | 190 ++++++++++++++++++++++ 9 files changed, 410 insertions(+), 5 deletions(-) create mode 100644 arch/mips/loongson64/loongson-3/clock.c create mode 100644 drivers/cpufreq/loongson3_cpufreq.c
arch/mips/include/asm/mach-loongson64/loongson.h +1 -0
@@ -277,6 +277,7 @@ extern u64 loongson_freqctrl[MAX_PACKAGES];#ifdef CONFIG_CPU_SUPPORTS_CPUFREQ #include <linux/cpufreq.h> extern struct cpufreq_frequency_table loongson2_clockmod_table[]; +extern struct cpufreq_frequency_table loongson3_clockmod_table[];#endif /*
arch/mips/kernel/smp.c +2 -1
@@ -371,7 +371,8 @@ asmlinkage void start_secondary(void)calibrate_delay ();preempt_disable (); cpu =smp_processor_id (); - cpu_data[cpu].udelay_val = loops_per_jiffy; +if (!cpu_data[cpu].udelay_val) + cpu_data[cpu].udelay_val = loops_per_jiffy;cpumask_set_cpu (cpu, &cpu_coherent_mask);notify_cpu_starting (cpu);
arch/mips/loongson64/Kconfig +1 -0
@@ -74,6 +74,7 @@ config LOONGSON_MACH3X select CSRC_R4K select CEVT_R4K select CPU_HAS_WB + select HAVE_CLK select FORCE_PCI select ISA select I8259
arch/mips/loongson64/common/platform.c +10 -3
@@ -17,15 +17,22 @@ static struct platform_device loongson2_cpufreq_device = { .id = -1, }; -static int __init loongson2_cpufreq_init (void ) +static struct platform_device loongson3_cpufreq_device = { + .name ="loongson3_cpufreq" , + .id =-1 , +}; + +static int __init loongson_cpufreq_init (void ) {struct cpuinfo_mips *c = ¤t_cpu_data;/* Only 2F revision and it's successors support CPUFreq */ -if ((c->processor_id &PRID_REV_MASK ) >=PRID_REV_LOONGSON2F ) +if ((c->processor_id &PRID_REV_MASK ) ==PRID_REV_LOONGSON2F )return platform_device_register (&loongson2_cpufreq_device); +if ((c->processor_id &PRID_REV_MASK ) >=PRID_REV_LOONGSON3A_R1 ) +return platform_device_register (&loongson3_cpufreq_device);return -ENODEV ; } -arch_initcall (loongson2_cpufreq_init); +arch_initcall (loongson_cpufreq_init);
arch/mips/loongson64/loongson-3/Makefile +1 -1
@@ -1,7 +1,7 @@ # # Makefile for Loongson-3 family machines # -obj-y += irq.o cop2-ex.o platform.o acpi_init.o dma.o +obj-y += irq.o cop2-ex.o platform.o acpi_init.o dma.o clock.o obj-$(CONFIG_SMP) += smp.o
arch/mips/loongson64/loongson-3/clock.c new file +191 -0
191 lines not on this page · raw message
drivers/cpufreq/Kconfig +13 -0
@@ -276,6 +276,19 @@ config LOONGSON2_CPUFREQ If in doubt, say N. +config LOONGSON3_CPUFREQ + tristate "Loongson3 CPUFreq Driver" + depends on CPU_LOONGSON3 + help + This option adds a CPUFreq driver for loongson processors which + support software configurable cpu frequency. + + Loongson-3A and it's successors support this feature. + + For details, take a look at <file:Documentation/cpu-freq/>. + + If in doubt, say N. + config LOONGSON1_CPUFREQ tristate "Loongson1 CPUFreq Driver" depends on LOONGSON1_LS1B
drivers/cpufreq/Makefile +1 -0
@@ -102,6 +102,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_LOONGSON1_CPUFREQ) += loongson1-cpufreq.o obj-$(CONFIG_SH_CPU_FREQ) += sh-cpufreq.o obj-$(CONFIG_SPARC_US2E_CPUFREQ) += sparc-us2e-cpufreq.o
drivers/cpufreq/loongson3_cpufreq.c new file +190 -0
190 lines not on this page · raw message
Signature · 1 line
2.7.0