ARM: tegra: clock: Set clock to fixed rate if set
Ashwin Joshi [Mon, 26 May 2014 09:15:14 +0000 (14:15 +0530)]
If for a particular clock, fixed rate is specified, then always set that
clock at that rate, irrespective of rate requested by driver

Bug 1410210
Bug 1468321
Bug 200017463

Signed-off-by: Ashwin Joshi <asjoshi@nvidia.com>
Reviewed-on: http://git-master/r/414920
(cherry picked from commit ba6743dd0aa8f5669fcabdfba08690df0c4ef2ad)

Change-Id: Icdac8ca0ce4238dcb79dbdcaaec1250d4829a4eb
Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/434033
Reviewed-by: Joshua Cha <joshuac@nvidia.com>
Reviewed-by: Aleksandr Frid <afrid@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

arch/arm/mach-tegra/clock.c

index 62de688..76b6594 100644 (file)
@@ -528,6 +528,19 @@ int clk_set_rate_locked(struct clk *c, unsigned long rate)
        if (rate > max_rate)
                rate = max_rate;
 
+       /* Check if rate is supposed to be fixed */
+       if (c->fixed_target_rate) {
+               /* If it is already set at target rate, do nothing */
+               if (old_rate == c->fixed_target_rate)
+                       return 0;
+
+               pr_warn("clock %s was not running at expected target rate %lu"
+                               " (old rate = %lu, requested rate = %lu), "
+                               "fixing the same",
+                               c->name, c->fixed_target_rate, old_rate, rate);
+               rate = c->fixed_target_rate;
+       }
+
        if (c->ops && c->ops->round_rate) {
                new_rate = c->ops->round_rate(c, rate);
 
@@ -575,15 +588,6 @@ out:
        if (disable)
                clk_disable_locked(c);
 
-       if (c->fixed_target_rate &&
-                       (clk_get_rate_locked(c) != c->fixed_target_rate)) {
-
-               pr_err("Violating expected target rate for clock:%s "
-                               "expected rate:%lu, new rate set:%lu\n",
-                               c->name, c->fixed_target_rate, clk_get_rate_locked(c));
-               WARN_ON(1);
-       }
-
        return ret;
 }