aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/exynos-cpufreq.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2013-08-14 10:08:24 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-10-30 19:11:08 -0400
commitd4019f0a92ab802f385cc9c8ad3ab7b5449712cb (patch)
treeebd06695585e457ae1bf219653452b111e7508db /drivers/cpufreq/exynos-cpufreq.c
parent7dbf694db6ac7c759599316d50d7050efcbd512a (diff)
cpufreq: move freq change notifications to cpufreq core
Most of the drivers do following in their ->target_index() routines: struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead. There are few special cases though, like exynos5440, which doesn't do everything on the call to ->target_index() routine and call some kind of bottom halves for doing this work, work/tasklet/etc.. They may continue doing notification from their own code as flag: CPUFREQ_ASYNC_NOTIFICATION is already set for them. All drivers are also modified in this patch to avoid breaking 'git bisect', as double notification would happen otherwise. Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no> Acked-by: Jesper Nilsson <jesper.nilsson@axis.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Russell King <linux@arm.linux.org.uk> Acked-by: Stephen Warren <swarren@nvidia.com> Tested-by: Andrew Lunn <andrew@lunn.ch> Tested-by: Nicolas Pitre <nicolas.pitre@linaro.org> Reviewed-by: Lan Tianyu <tianyu.lan@intel.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/exynos-cpufreq.c')
-rw-r--r--drivers/cpufreq/exynos-cpufreq.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 9982fcb82257..7b6dc06b1bd4 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -25,7 +25,6 @@
25static struct exynos_dvfs_info *exynos_info; 25static struct exynos_dvfs_info *exynos_info;
26 26
27static struct regulator *arm_regulator; 27static struct regulator *arm_regulator;
28static struct cpufreq_freqs freqs;
29 28
30static unsigned int locking_frequency; 29static unsigned int locking_frequency;
31static bool frequency_locked; 30static bool frequency_locked;
@@ -59,18 +58,18 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
59 struct cpufreq_policy *policy = cpufreq_cpu_get(0); 58 struct cpufreq_policy *policy = cpufreq_cpu_get(0);
60 unsigned int arm_volt, safe_arm_volt = 0; 59 unsigned int arm_volt, safe_arm_volt = 0;
61 unsigned int mpll_freq_khz = exynos_info->mpll_freq_khz; 60 unsigned int mpll_freq_khz = exynos_info->mpll_freq_khz;
61 unsigned int old_freq;
62 int index, old_index; 62 int index, old_index;
63 int ret = 0; 63 int ret = 0;
64 64
65 freqs.old = policy->cur; 65 old_freq = policy->cur;
66 freqs.new = target_freq;
67 66
68 /* 67 /*
69 * The policy max have been changed so that we cannot get proper 68 * The policy max have been changed so that we cannot get proper
70 * old_index with cpufreq_frequency_table_target(). Thus, ignore 69 * old_index with cpufreq_frequency_table_target(). Thus, ignore
71 * policy and get the index from the raw freqeuncy table. 70 * policy and get the index from the raw freqeuncy table.
72 */ 71 */
73 old_index = exynos_cpufreq_get_index(freqs.old); 72 old_index = exynos_cpufreq_get_index(old_freq);
74 if (old_index < 0) { 73 if (old_index < 0) {
75 ret = old_index; 74 ret = old_index;
76 goto out; 75 goto out;
@@ -95,17 +94,14 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
95 } 94 }
96 arm_volt = volt_table[index]; 95 arm_volt = volt_table[index];
97 96
98 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
99
100 /* When the new frequency is higher than current frequency */ 97 /* When the new frequency is higher than current frequency */
101 if ((freqs.new > freqs.old) && !safe_arm_volt) { 98 if ((target_freq > old_freq) && !safe_arm_volt) {
102 /* Firstly, voltage up to increase frequency */ 99 /* Firstly, voltage up to increase frequency */
103 ret = regulator_set_voltage(arm_regulator, arm_volt, arm_volt); 100 ret = regulator_set_voltage(arm_regulator, arm_volt, arm_volt);
104 if (ret) { 101 if (ret) {
105 pr_err("%s: failed to set cpu voltage to %d\n", 102 pr_err("%s: failed to set cpu voltage to %d\n",
106 __func__, arm_volt); 103 __func__, arm_volt);
107 freqs.new = freqs.old; 104 return ret;
108 goto post_notify;
109 } 105 }
110 } 106 }
111 107
@@ -115,22 +111,15 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
115 if (ret) { 111 if (ret) {
116 pr_err("%s: failed to set cpu voltage to %d\n", 112 pr_err("%s: failed to set cpu voltage to %d\n",
117 __func__, safe_arm_volt); 113 __func__, safe_arm_volt);
118 freqs.new = freqs.old; 114 return ret;
119 goto post_notify;
120 } 115 }
121 } 116 }
122 117
123 exynos_info->set_freq(old_index, index); 118 exynos_info->set_freq(old_index, index);
124 119
125post_notify:
126 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
127
128 if (ret)
129 goto out;
130
131 /* When the new frequency is lower than current frequency */ 120 /* When the new frequency is lower than current frequency */
132 if ((freqs.new < freqs.old) || 121 if ((target_freq < old_freq) ||
133 ((freqs.new > freqs.old) && safe_arm_volt)) { 122 ((target_freq > old_freq) && safe_arm_volt)) {
134 /* down the voltage after frequency change */ 123 /* down the voltage after frequency change */
135 ret = regulator_set_voltage(arm_regulator, arm_volt, 124 ret = regulator_set_voltage(arm_regulator, arm_volt,
136 arm_volt); 125 arm_volt);
@@ -142,7 +131,6 @@ post_notify:
142 } 131 }
143 132
144out: 133out:
145
146 cpufreq_cpu_put(policy); 134 cpufreq_cpu_put(policy);
147 135
148 return ret; 136 return ret;