aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/clkt_dpll.c
diff options
context:
space:
mode:
authorRajendra Nayak <rnayak@ti.com>2012-09-22 04:24:17 -0400
committerPaul Walmsley <paul@pwsan.com>2012-09-22 12:52:56 -0400
commit5dcc3b975e972989574c009457f0e333c342910d (patch)
tree1e8c96d112b329fd5fface92d6a1a74d79f2a6ef /arch/arm/mach-omap2/clkt_dpll.c
parent6ea74cb9853e923f8945586cd9ccdd42e6f00ba9 (diff)
ARM: OMAP2+: clock: Remove all direct dereferencing of struct clk
While we move to Common Clk Framework (CCF), direct deferencing of struct clk wouldn't be possible anymore. Hence get rid of all such instances in the current clock code and use macros/helpers similar to the ones that are provided by CCF. While here also concatenate some strings split across multiple lines which seem to be needed anyway. Signed-off-by: Rajendra Nayak <rnayak@ti.com> [paul@pwsan.com: simplified some compound expressions; reformatted some messages] Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'arch/arm/mach-omap2/clkt_dpll.c')
-rw-r--r--arch/arm/mach-omap2/clkt_dpll.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/arch/arm/mach-omap2/clkt_dpll.c b/arch/arm/mach-omap2/clkt_dpll.c
index 0bf0ec3e352c..470828e6f293 100644
--- a/arch/arm/mach-omap2/clkt_dpll.c
+++ b/arch/arm/mach-omap2/clkt_dpll.c
@@ -87,7 +87,7 @@ static int _dpll_test_fint(struct clk *clk, u8 n)
87 dd = clk->dpll_data; 87 dd = clk->dpll_data;
88 88
89 /* DPLL divider must result in a valid jitter correction val */ 89 /* DPLL divider must result in a valid jitter correction val */
90 fint = clk->parent->rate / n; 90 fint = __clk_get_rate(__clk_get_parent(clk)) / n;
91 91
92 if (cpu_is_omap24xx()) { 92 if (cpu_is_omap24xx()) {
93 /* Should not be called for OMAP2, so warn if it is called */ 93 /* Should not be called for OMAP2, so warn if it is called */
@@ -252,16 +252,16 @@ u32 omap2_get_dpll_rate(struct clk *clk)
252 if (cpu_is_omap24xx()) { 252 if (cpu_is_omap24xx()) {
253 if (v == OMAP2XXX_EN_DPLL_LPBYPASS || 253 if (v == OMAP2XXX_EN_DPLL_LPBYPASS ||
254 v == OMAP2XXX_EN_DPLL_FRBYPASS) 254 v == OMAP2XXX_EN_DPLL_FRBYPASS)
255 return dd->clk_bypass->rate; 255 return __clk_get_rate(dd->clk_bypass);
256 } else if (cpu_is_omap34xx()) { 256 } else if (cpu_is_omap34xx()) {
257 if (v == OMAP3XXX_EN_DPLL_LPBYPASS || 257 if (v == OMAP3XXX_EN_DPLL_LPBYPASS ||
258 v == OMAP3XXX_EN_DPLL_FRBYPASS) 258 v == OMAP3XXX_EN_DPLL_FRBYPASS)
259 return dd->clk_bypass->rate; 259 return __clk_get_rate(dd->clk_bypass);
260 } else if (soc_is_am33xx() || cpu_is_omap44xx()) { 260 } else if (soc_is_am33xx() || cpu_is_omap44xx()) {
261 if (v == OMAP4XXX_EN_DPLL_LPBYPASS || 261 if (v == OMAP4XXX_EN_DPLL_LPBYPASS ||
262 v == OMAP4XXX_EN_DPLL_FRBYPASS || 262 v == OMAP4XXX_EN_DPLL_FRBYPASS ||
263 v == OMAP4XXX_EN_DPLL_MNBYPASS) 263 v == OMAP4XXX_EN_DPLL_MNBYPASS)
264 return dd->clk_bypass->rate; 264 return __clk_get_rate(dd->clk_bypass);
265 } 265 }
266 266
267 v = __raw_readl(dd->mult_div1_reg); 267 v = __raw_readl(dd->mult_div1_reg);
@@ -270,7 +270,7 @@ u32 omap2_get_dpll_rate(struct clk *clk)
270 dpll_div = v & dd->div1_mask; 270 dpll_div = v & dd->div1_mask;
271 dpll_div >>= __ffs(dd->div1_mask); 271 dpll_div >>= __ffs(dd->div1_mask);
272 272
273 dpll_clk = (long long)dd->clk_ref->rate * dpll_mult; 273 dpll_clk = (long long) __clk_get_rate(dd->clk_ref) * dpll_mult;
274 do_div(dpll_clk, dpll_div + 1); 274 do_div(dpll_clk, dpll_div + 1);
275 275
276 return dpll_clk; 276 return dpll_clk;
@@ -296,16 +296,20 @@ long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate)
296 unsigned long scaled_rt_rp; 296 unsigned long scaled_rt_rp;
297 unsigned long new_rate = 0; 297 unsigned long new_rate = 0;
298 struct dpll_data *dd; 298 struct dpll_data *dd;
299 unsigned long ref_rate;
300 const char *clk_name;
299 301
300 if (!clk || !clk->dpll_data) 302 if (!clk || !clk->dpll_data)
301 return ~0; 303 return ~0;
302 304
303 dd = clk->dpll_data; 305 dd = clk->dpll_data;
304 306
307 ref_rate = __clk_get_rate(dd->clk_ref);
308 clk_name = __clk_get_name(clk);
305 pr_debug("clock: %s: starting DPLL round_rate, target rate %ld\n", 309 pr_debug("clock: %s: starting DPLL round_rate, target rate %ld\n",
306 clk->name, target_rate); 310 clk_name, target_rate);
307 311
308 scaled_rt_rp = target_rate / (dd->clk_ref->rate / DPLL_SCALE_FACTOR); 312 scaled_rt_rp = target_rate / (ref_rate / DPLL_SCALE_FACTOR);
309 scaled_max_m = dd->max_multiplier * DPLL_SCALE_FACTOR; 313 scaled_max_m = dd->max_multiplier * DPLL_SCALE_FACTOR;
310 314
311 dd->last_rounded_rate = 0; 315 dd->last_rounded_rate = 0;
@@ -332,14 +336,14 @@ long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate)
332 break; 336 break;
333 337
334 r = _dpll_test_mult(&m, n, &new_rate, target_rate, 338 r = _dpll_test_mult(&m, n, &new_rate, target_rate,
335 dd->clk_ref->rate); 339 ref_rate);
336 340
337 /* m can't be set low enough for this n - try with a larger n */ 341 /* m can't be set low enough for this n - try with a larger n */
338 if (r == DPLL_MULT_UNDERFLOW) 342 if (r == DPLL_MULT_UNDERFLOW)
339 continue; 343 continue;
340 344
341 pr_debug("clock: %s: m = %d: n = %d: new_rate = %ld\n", 345 pr_debug("clock: %s: m = %d: n = %d: new_rate = %ld\n",
342 clk->name, m, n, new_rate); 346 clk_name, m, n, new_rate);
343 347
344 if (target_rate == new_rate) { 348 if (target_rate == new_rate) {
345 dd->last_rounded_m = m; 349 dd->last_rounded_m = m;
@@ -350,8 +354,8 @@ long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate)
350 } 354 }
351 355
352 if (target_rate != new_rate) { 356 if (target_rate != new_rate) {
353 pr_debug("clock: %s: cannot round to rate %ld\n", clk->name, 357 pr_debug("clock: %s: cannot round to rate %ld\n",
354 target_rate); 358 clk_name, target_rate);
355 return ~0; 359 return ~0;
356 } 360 }
357 361