aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/blackfin-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/blackfin-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/blackfin-cpufreq.c')
-rw-r--r--drivers/cpufreq/blackfin-cpufreq.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c
index 12528b28d45d..e9e63fc9c2c9 100644
--- a/drivers/cpufreq/blackfin-cpufreq.c
+++ b/drivers/cpufreq/blackfin-cpufreq.c
@@ -132,27 +132,23 @@ static int bfin_target(struct cpufreq_policy *policy, unsigned int index)
132#ifndef CONFIG_BF60x 132#ifndef CONFIG_BF60x
133 unsigned int plldiv; 133 unsigned int plldiv;
134#endif 134#endif
135 struct cpufreq_freqs freqs;
136 static unsigned long lpj_ref; 135 static unsigned long lpj_ref;
137 static unsigned int lpj_ref_freq; 136 static unsigned int lpj_ref_freq;
137 unsigned int old_freq, new_freq;
138 int ret = 0; 138 int ret = 0;
139 139
140#if defined(CONFIG_CYCLES_CLOCKSOURCE) 140#if defined(CONFIG_CYCLES_CLOCKSOURCE)
141 cycles_t cycles; 141 cycles_t cycles;
142#endif 142#endif
143 143
144 freqs.old = bfin_getfreq_khz(0); 144 old_freq = bfin_getfreq_khz(0);
145 freqs.new = bfin_freq_table[index].frequency; 145 new_freq = bfin_freq_table[index].frequency;
146 146
147 pr_debug("cpufreq: changing cclk to %lu; target = %u, oldfreq = %u\n",
148 freqs.new, freqs.new, freqs.old);
149
150 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
151#ifndef CONFIG_BF60x 147#ifndef CONFIG_BF60x
152 plldiv = (bfin_read_PLL_DIV() & SSEL) | dpm_state_table[index].csel; 148 plldiv = (bfin_read_PLL_DIV() & SSEL) | dpm_state_table[index].csel;
153 bfin_write_PLL_DIV(plldiv); 149 bfin_write_PLL_DIV(plldiv);
154#else 150#else
155 ret = cpu_set_cclk(policy->cpu, freqs.new * 1000); 151 ret = cpu_set_cclk(policy->cpu, new_freq * 1000);
156 if (ret != 0) { 152 if (ret != 0) {
157 WARN_ONCE(ret, "cpufreq set freq failed %d\n", ret); 153 WARN_ONCE(ret, "cpufreq set freq failed %d\n", ret);
158 return ret; 154 return ret;
@@ -168,17 +164,13 @@ static int bfin_target(struct cpufreq_policy *policy, unsigned int index)
168#endif 164#endif
169 if (!lpj_ref_freq) { 165 if (!lpj_ref_freq) {
170 lpj_ref = loops_per_jiffy; 166 lpj_ref = loops_per_jiffy;
171 lpj_ref_freq = freqs.old; 167 lpj_ref_freq = old_freq;
172 } 168 }
173 if (freqs.new != freqs.old) { 169 if (new_freq != old_freq) {
174 loops_per_jiffy = cpufreq_scale(lpj_ref, 170 loops_per_jiffy = cpufreq_scale(lpj_ref,
175 lpj_ref_freq, freqs.new); 171 lpj_ref_freq, new_freq);
176 } 172 }
177 173
178 /* TODO: just test case for cycles clock source, remove later */
179 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
180
181 pr_debug("cpufreq: done\n");
182 return ret; 174 return ret;
183} 175}
184 176