ARM: S5PV210: Add support CPUFREQ
PATCH 4/5 ARM: S5PV210: Add support CPUFREQ
Quoted 3 lines · MyungJoo Ham
Hello,
Hi,
Quoted 42 lines · Jaecheol Lee
Quoted 1 line
This patch adds CPUFREQ driver for supporting DFS(Dynamic Frequency
Scaling).
Quoted 4 lines
Signed-off-by Jaecheol Lee <[email protected]>---
?arch/arm/mach-s5pv210/cpufreq.c | ?415+++++++++++++++++++++++++++++++++++++++
arch/arm/mach-
Quoted 4 lines
?1 files changed, 415 insertions(+), 0 deletions(-) ?create mode 100644
arch/arm/mach-s5pv210/cpufreq.carch/arm/mach- renamed from arch/arm/mach-s5pv210/cpufreq.c +0
-0
s5pv210/cpufreq.cQuoted 2 lines
new file mode 100644
index 0000000..aa39c2e(snip)
Quoted 24 lines
arch/arm/mach- renamed from arch/arm/mach-s5pv210/cpufreq.c +24
-0+static int s5pv210_target(struct cpufreq_policy *policy, + ? ? ? ? ? ? ? ? ? ? ? ? unsigned int target_freq, + ? ? ? ? ? ? ? ? ? ? ? ? unsigned int relation) +{ + ? ? ? unsigned long reg; + ? ? ? unsigned int index, priv_index; + ? ? ? unsigned int pll_changing = 0; + ? ? ? unsigned int bus_speed_changing = 0; + + ? ? ? freqs.old = s5pv210_getspeed ; + + ? ? ? if (cpufreq_frequency_table_target(policy, s5pv210_freq_table, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?target_freq, relation, &index)) + ? ? ? ? ? ? ? return -EINVAL; + + ? ? ? freqs.new = s5pv210_freq_table[index].frequency; + ? ? ? freqs.cpu = 0; + + ? ? ? if (freqs.new == freqs.old) + ? ? ? ? ? ? ? return 0; + + ? ? ? /* Finding current running level index */ + ? ? ? if (cpufreq_frequency_table_target(policy, s5pv210_freq_table, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?freqs.old, relation, &priv_index))
Quoted 9 lines
arch/arm/mach-
Quoted 6 lines
+ ? ? ? ? ? ? ? return
-EINVAL;arch/arm/mach- renamed from arch/arm/mach-s5pv210/cpufreq.c +5
-0+ + ? ? ? cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); + + ? ? ? if (freqs.new > freqs.old) { + ? ? ? ? ? ? ? /* Voltage up: will be implemented */This could be crucial to the system stability. It is usually not optional.
I think it does not occur any stability problem because current default voltage is maximum value.
Actually, tested its functionality on the SMDK with max8698 PMIC driver internally. ..but there is no max8698 device driver in the current mainline...
So this feature has been removed in this patch... Anyway, will be implemented after submitting max8698 later.
Quoted 17 lines
Quoted 17 lines
+ ? ? ? }
arch/arm/mach- renamed from arch/arm/mach-s5pv210/cpufreq.c +16
-0+ + ? ? ? /* Check if there need to change PLL */ + ? ? ? if ((index == L0) || (priv_index == L0)) + ? ? ? ? ? ? ? pll_changing = 1; + + ? ? ? /* Check if there need to change System bus clock */ + ? ? ? if ((index == L4) || (priv_index == L4)) + ? ? ? ? ? ? ? bus_speed_changing = 1; + + ? ? ? if (bus_speed_changing) { + ? ? ? ? ? ? ? /* + ? ? ? ? ? ? ? ?* Reconfigure DRAM refresh counter value for minimum + ? ? ? ? ? ? ? ?* temporary clock while changing divider. + ? ? ? ? ? ? ? ?* expected clock is 83Mhz : 7.8usec/(1/83Mhz) = 0x287 + ? ? ? ? ? ? ? ?*/ + ? ? ? ? ? ? ? if (pll_changing)
Quoted 9 lines
Quoted 5 lines
+ ? ? ? ? ? ? ? ? ? ? ?
__raw_writel(0x287, S5P_VA_DMC1 + 0x30);
+ ? ? ? ? ? ? ? else
+ ? ? ? ? ? ? ? ? ? ? ?__raw_writel(0x30c, S5P_VA_DMC1 + 0x30); +
+ ? ? ? ? ? ? ?__raw_writel(0x287, S5P_VA_DMC0 + 0x30);It'd be better to set values based on the real MPLL, APLL clock speeds, not hard-coding them.
Will modify.
(snip)
Quoted 18 lines
Quoted 9 lines
+
+ ? ? ? ? ? ? ? /* Reconfigure DRAM refresh counter value */
+ ? ? ? ? ? ? ? if (index != L4) {
+ ? ? ? ? ? ? ? ? ? ? ? /*
+ ? ? ? ? ? ? ? ? ? ? ? ?* DMC0 : 166Mhz
+ ? ? ? ? ? ? ? ? ? ? ? ?* DMC1 : 200Mhz
+ ? ? ? ? ? ? ? ? ? ? ? ?*/
+ ? ? ? ? ? ? ? ? ? ? ?__raw_writel(0x618, S5P_VA_DMC1 + 0x30);
+ ? ? ? ? ? ? ? ? ? ? ?__raw_writel(0x50e, S5P_VA_DMC0 + 0x30);Quoted 8 lines
+ ? ? ? ? ? ? ? } else {
+ ? ? ? ? ? ? ? ? ? ? ? /*
+ ? ? ? ? ? ? ? ? ? ? ? ?* DMC0 : 83Mhz
+ ? ? ? ? ? ? ? ? ? ? ? ?* DMC1 : 100Mhz
+ ? ? ? ? ? ? ? ? ? ? ? ?*/
+ ? ? ? ? ? ? ? ? ? ? ?__raw_writel(0x30c, S5P_VA_DMC1 + 0x30);
+ ? ? ? ? ? ? ? ? ? ? ?__raw_writel(0x287, S5P_VA_DMC0 + 0x30);
+ ? ? ? ? ? ? ? }
Quoted 3 lines
Same here. It'd better not be hard coded. We can't sure about the clock speeds for different boards.
Will modify.
Quoted 12 lines
arch/arm/mach-
Quoted 9 lines
+ ? ? ? }
arch/arm/mach- renamed from arch/arm/mach-s5pv210/cpufreq.c +8
-0+ + ? ? ? if (freqs.new < freqs.old) { + ? ? ? ? ? ? ? /* Voltage down: will be implemented */ + ? ? ? } + + ? ? ? cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); + + ? ? ? printk(KERN_INFO "Perf changed[L%d]\n", index);This may incur too many clutters.
Yeah, you're right...should be other print level such as KERN_DEBUG.
(snip)
Thanks.