diff options
Diffstat (limited to 'arch/arm/mach-omap2/clock.c')
-rw-r--r-- | arch/arm/mach-omap2/clock.c | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c index 53fda9977d55..886f73f3933a 100644 --- a/arch/arm/mach-omap2/clock.c +++ b/arch/arm/mach-omap2/clock.c | |||
@@ -26,7 +26,6 @@ | |||
26 | 26 | ||
27 | #include <mach/clock.h> | 27 | #include <mach/clock.h> |
28 | #include <mach/clockdomain.h> | 28 | #include <mach/clockdomain.h> |
29 | #include <mach/sram.h> | ||
30 | #include <mach/cpu.h> | 29 | #include <mach/cpu.h> |
31 | #include <asm/div64.h> | 30 | #include <asm/div64.h> |
32 | 31 | ||
@@ -187,11 +186,10 @@ int omap2_wait_clock_ready(void __iomem *reg, u32 mask, const char *name) | |||
187 | * 24xx uses 0 to indicate not ready, and 1 to indicate ready. | 186 | * 24xx uses 0 to indicate not ready, and 1 to indicate ready. |
188 | * 34xx reverses this, just to keep us on our toes | 187 | * 34xx reverses this, just to keep us on our toes |
189 | */ | 188 | */ |
190 | if (cpu_mask & (RATE_IN_242X | RATE_IN_243X)) { | 189 | if (cpu_mask & (RATE_IN_242X | RATE_IN_243X)) |
191 | ena = mask; | 190 | ena = mask; |
192 | } else if (cpu_mask & RATE_IN_343X) { | 191 | else if (cpu_mask & RATE_IN_343X) |
193 | ena = 0; | 192 | ena = 0; |
194 | } | ||
195 | 193 | ||
196 | /* Wait for lock */ | 194 | /* Wait for lock */ |
197 | while (((__raw_readl(reg) & mask) != ena) && | 195 | while (((__raw_readl(reg) & mask) != ena) && |
@@ -267,7 +265,7 @@ static int omap2_dflt_clk_enable_wait(struct clk *clk) | |||
267 | { | 265 | { |
268 | int ret; | 266 | int ret; |
269 | 267 | ||
270 | if (unlikely(clk->enable_reg == NULL)) { | 268 | if (!clk->enable_reg) { |
271 | printk(KERN_ERR "clock.c: Enable for %s without enable code\n", | 269 | printk(KERN_ERR "clock.c: Enable for %s without enable code\n", |
272 | clk->name); | 270 | clk->name); |
273 | return 0; /* REVISIT: -EINVAL */ | 271 | return 0; /* REVISIT: -EINVAL */ |
@@ -283,7 +281,7 @@ static void omap2_dflt_clk_disable(struct clk *clk) | |||
283 | { | 281 | { |
284 | u32 regval32; | 282 | u32 regval32; |
285 | 283 | ||
286 | if (clk->enable_reg == NULL) { | 284 | if (!clk->enable_reg) { |
287 | /* | 285 | /* |
288 | * 'Independent' here refers to a clock which is not | 286 | * 'Independent' here refers to a clock which is not |
289 | * controlled by its parent. | 287 | * controlled by its parent. |
@@ -330,7 +328,7 @@ void omap2_clk_disable(struct clk *clk) | |||
330 | { | 328 | { |
331 | if (clk->usecount > 0 && !(--clk->usecount)) { | 329 | if (clk->usecount > 0 && !(--clk->usecount)) { |
332 | _omap2_clk_disable(clk); | 330 | _omap2_clk_disable(clk); |
333 | if (likely((u32)clk->parent)) | 331 | if (clk->parent) |
334 | omap2_clk_disable(clk->parent); | 332 | omap2_clk_disable(clk->parent); |
335 | if (clk->clkdm) | 333 | if (clk->clkdm) |
336 | omap2_clkdm_clk_disable(clk->clkdm, clk); | 334 | omap2_clkdm_clk_disable(clk->clkdm, clk); |
@@ -343,10 +341,10 @@ int omap2_clk_enable(struct clk *clk) | |||
343 | int ret = 0; | 341 | int ret = 0; |
344 | 342 | ||
345 | if (clk->usecount++ == 0) { | 343 | if (clk->usecount++ == 0) { |
346 | if (likely((u32)clk->parent)) | 344 | if (clk->parent) |
347 | ret = omap2_clk_enable(clk->parent); | 345 | ret = omap2_clk_enable(clk->parent); |
348 | 346 | ||
349 | if (unlikely(ret != 0)) { | 347 | if (ret != 0) { |
350 | clk->usecount--; | 348 | clk->usecount--; |
351 | return ret; | 349 | return ret; |
352 | } | 350 | } |
@@ -356,7 +354,7 @@ int omap2_clk_enable(struct clk *clk) | |||
356 | 354 | ||
357 | ret = _omap2_clk_enable(clk); | 355 | ret = _omap2_clk_enable(clk); |
358 | 356 | ||
359 | if (unlikely(ret != 0)) { | 357 | if (ret != 0) { |
360 | if (clk->clkdm) | 358 | if (clk->clkdm) |
361 | omap2_clkdm_clk_disable(clk->clkdm, clk); | 359 | omap2_clkdm_clk_disable(clk->clkdm, clk); |
362 | 360 | ||
@@ -384,7 +382,7 @@ void omap2_clksel_recalc(struct clk *clk) | |||
384 | if (div == 0) | 382 | if (div == 0) |
385 | return; | 383 | return; |
386 | 384 | ||
387 | if (unlikely(clk->rate == clk->parent->rate / div)) | 385 | if (clk->rate == (clk->parent->rate / div)) |
388 | return; | 386 | return; |
389 | clk->rate = clk->parent->rate / div; | 387 | clk->rate = clk->parent->rate / div; |
390 | 388 | ||
@@ -400,8 +398,8 @@ void omap2_clksel_recalc(struct clk *clk) | |||
400 | * the element associated with the supplied parent clock address. | 398 | * the element associated with the supplied parent clock address. |
401 | * Returns a pointer to the struct clksel on success or NULL on error. | 399 | * Returns a pointer to the struct clksel on success or NULL on error. |
402 | */ | 400 | */ |
403 | const struct clksel *omap2_get_clksel_by_parent(struct clk *clk, | 401 | static const struct clksel *omap2_get_clksel_by_parent(struct clk *clk, |
404 | struct clk *src_clk) | 402 | struct clk *src_clk) |
405 | { | 403 | { |
406 | const struct clksel *clks; | 404 | const struct clksel *clks; |
407 | 405 | ||
@@ -450,7 +448,7 @@ u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate, | |||
450 | *new_div = 1; | 448 | *new_div = 1; |
451 | 449 | ||
452 | clks = omap2_get_clksel_by_parent(clk, clk->parent); | 450 | clks = omap2_get_clksel_by_parent(clk, clk->parent); |
453 | if (clks == NULL) | 451 | if (!clks) |
454 | return ~0; | 452 | return ~0; |
455 | 453 | ||
456 | for (clkr = clks->rates; clkr->div; clkr++) { | 454 | for (clkr = clks->rates; clkr->div; clkr++) { |
@@ -509,7 +507,7 @@ long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate) | |||
509 | /* Given a clock and a rate apply a clock specific rounding function */ | 507 | /* Given a clock and a rate apply a clock specific rounding function */ |
510 | long omap2_clk_round_rate(struct clk *clk, unsigned long rate) | 508 | long omap2_clk_round_rate(struct clk *clk, unsigned long rate) |
511 | { | 509 | { |
512 | if (clk->round_rate != NULL) | 510 | if (clk->round_rate) |
513 | return clk->round_rate(clk, rate); | 511 | return clk->round_rate(clk, rate); |
514 | 512 | ||
515 | if (clk->flags & RATE_FIXED) | 513 | if (clk->flags & RATE_FIXED) |
@@ -535,7 +533,7 @@ u32 omap2_clksel_to_divisor(struct clk *clk, u32 field_val) | |||
535 | const struct clksel_rate *clkr; | 533 | const struct clksel_rate *clkr; |
536 | 534 | ||
537 | clks = omap2_get_clksel_by_parent(clk, clk->parent); | 535 | clks = omap2_get_clksel_by_parent(clk, clk->parent); |
538 | if (clks == NULL) | 536 | if (!clks) |
539 | return 0; | 537 | return 0; |
540 | 538 | ||
541 | for (clkr = clks->rates; clkr->div; clkr++) { | 539 | for (clkr = clks->rates; clkr->div; clkr++) { |
@@ -571,7 +569,7 @@ u32 omap2_divisor_to_clksel(struct clk *clk, u32 div) | |||
571 | WARN_ON(div == 0); | 569 | WARN_ON(div == 0); |
572 | 570 | ||
573 | clks = omap2_get_clksel_by_parent(clk, clk->parent); | 571 | clks = omap2_get_clksel_by_parent(clk, clk->parent); |
574 | if (clks == NULL) | 572 | if (!clks) |
575 | return 0; | 573 | return 0; |
576 | 574 | ||
577 | for (clkr = clks->rates; clkr->div; clkr++) { | 575 | for (clkr = clks->rates; clkr->div; clkr++) { |
@@ -596,9 +594,9 @@ u32 omap2_divisor_to_clksel(struct clk *clk, u32 div) | |||
596 | * | 594 | * |
597 | * Returns the address of the clksel register upon success or NULL on error. | 595 | * Returns the address of the clksel register upon success or NULL on error. |
598 | */ | 596 | */ |
599 | void __iomem *omap2_get_clksel(struct clk *clk, u32 *field_mask) | 597 | static void __iomem *omap2_get_clksel(struct clk *clk, u32 *field_mask) |
600 | { | 598 | { |
601 | if (unlikely((clk->clksel_reg == NULL) || (clk->clksel_mask == NULL))) | 599 | if (!clk->clksel_reg || (clk->clksel_mask == 0)) |
602 | return NULL; | 600 | return NULL; |
603 | 601 | ||
604 | *field_mask = clk->clksel_mask; | 602 | *field_mask = clk->clksel_mask; |
@@ -618,7 +616,7 @@ u32 omap2_clksel_get_divisor(struct clk *clk) | |||
618 | void __iomem *div_addr; | 616 | void __iomem *div_addr; |
619 | 617 | ||
620 | div_addr = omap2_get_clksel(clk, &field_mask); | 618 | div_addr = omap2_get_clksel(clk, &field_mask); |
621 | if (div_addr == NULL) | 619 | if (!div_addr) |
622 | return 0; | 620 | return 0; |
623 | 621 | ||
624 | field_val = __raw_readl(div_addr) & field_mask; | 622 | field_val = __raw_readl(div_addr) & field_mask; |
@@ -637,7 +635,7 @@ int omap2_clksel_set_rate(struct clk *clk, unsigned long rate) | |||
637 | return -EINVAL; | 635 | return -EINVAL; |
638 | 636 | ||
639 | div_addr = omap2_get_clksel(clk, &field_mask); | 637 | div_addr = omap2_get_clksel(clk, &field_mask); |
640 | if (div_addr == NULL) | 638 | if (!div_addr) |
641 | return -EINVAL; | 639 | return -EINVAL; |
642 | 640 | ||
643 | field_val = omap2_divisor_to_clksel(clk, new_div); | 641 | field_val = omap2_divisor_to_clksel(clk, new_div); |
@@ -675,7 +673,7 @@ int omap2_clk_set_rate(struct clk *clk, unsigned long rate) | |||
675 | return -EINVAL; | 673 | return -EINVAL; |
676 | 674 | ||
677 | /* dpll_ck, core_ck, virt_prcm_set; plus all clksel clocks */ | 675 | /* dpll_ck, core_ck, virt_prcm_set; plus all clksel clocks */ |
678 | if (clk->set_rate != NULL) | 676 | if (clk->set_rate) |
679 | ret = clk->set_rate(clk, rate); | 677 | ret = clk->set_rate(clk, rate); |
680 | 678 | ||
681 | return ret; | 679 | return ret; |
@@ -696,7 +694,7 @@ static u32 omap2_clksel_get_src_field(void __iomem **src_addr, | |||
696 | *src_addr = NULL; | 694 | *src_addr = NULL; |
697 | 695 | ||
698 | clks = omap2_get_clksel_by_parent(clk, src_clk); | 696 | clks = omap2_get_clksel_by_parent(clk, src_clk); |
699 | if (clks == NULL) | 697 | if (!clks) |
700 | return 0; | 698 | return 0; |
701 | 699 | ||
702 | for (clkr = clks->rates; clkr->div; clkr++) { | 700 | for (clkr = clks->rates; clkr->div; clkr++) { |
@@ -726,7 +724,7 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent) | |||
726 | void __iomem *src_addr; | 724 | void __iomem *src_addr; |
727 | u32 field_val, field_mask, reg_val, parent_div; | 725 | u32 field_val, field_mask, reg_val, parent_div; |
728 | 726 | ||
729 | if (unlikely(clk->flags & CONFIG_PARTICIPANT)) | 727 | if (clk->flags & CONFIG_PARTICIPANT) |
730 | return -EINVAL; | 728 | return -EINVAL; |
731 | 729 | ||
732 | if (!clk->clksel) | 730 | if (!clk->clksel) |
@@ -734,7 +732,7 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent) | |||
734 | 732 | ||
735 | field_val = omap2_clksel_get_src_field(&src_addr, new_parent, | 733 | field_val = omap2_clksel_get_src_field(&src_addr, new_parent, |
736 | &field_mask, clk, &parent_div); | 734 | &field_mask, clk, &parent_div); |
737 | if (src_addr == NULL) | 735 | if (!src_addr) |
738 | return -EINVAL; | 736 | return -EINVAL; |
739 | 737 | ||
740 | if (clk->usecount > 0) | 738 | if (clk->usecount > 0) |
@@ -794,7 +792,8 @@ int omap2_dpll_set_rate_tolerance(struct clk *clk, unsigned int tolerance) | |||
794 | return 0; | 792 | return 0; |
795 | } | 793 | } |
796 | 794 | ||
797 | static unsigned long _dpll_compute_new_rate(unsigned long parent_rate, unsigned int m, unsigned int n) | 795 | static unsigned long _dpll_compute_new_rate(unsigned long parent_rate, |
796 | unsigned int m, unsigned int n) | ||
798 | { | 797 | { |
799 | unsigned long long num; | 798 | unsigned long long num; |
800 | 799 | ||