]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00234685-1 cpufreq:fix one bug in cpufreq driver if I2C transfer error
authorRobin Gong <b38343@freescale.com>
Mon, 26 Nov 2012 03:23:28 +0000 (11:23 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:35:45 +0000 (08:35 +0200)
Currently, if we used LDO bypass, will set pfuze register by I2C bus to modify
voltage according to different cpu frequency, if I2C transfer error, we should
restore to old cpu frequency, not only in cpufreq driver but also cpufreq core.

Signed-off-by: Robin Gong <b38343@freescale.com>
arch/arm/plat-mxc/cpufreq.c

index 3d450e07d6a836d7aea2cee52a7fa4fa6a420dbb..4cdc8377e972ab7f0eb2d3c2a9bde89be69755f1 100755 (executable)
@@ -264,8 +264,18 @@ static int mxc_set_target(struct cpufreq_policy *policy,
                cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
        }
        ret = set_cpu_freq(freq_Hz);
-       if (ret)
+       if (ret) {
+               /*restore cpufreq and tell cpufreq core if set fail*/
+               freqs.old = clk_get_rate(cpu_clk) / 1000;
+               freqs.new = freqs.old;
+               freqs.cpu = policy->cpu;
+               freqs.flags = 0;
+               for (i = 0; i < num_cpus; i++) {
+                       freqs.cpu = i;
+                       cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
+               }
                goto  Set_finish;
+       }
 #ifdef CONFIG_SMP
        /* Loops per jiffy is not updated by the CPUFREQ driver for SMP systems.
          * So update it for all CPUs.
@@ -417,8 +427,17 @@ static int cpufreq_pm_notify(struct notifier_block *nb, unsigned long event,
                                cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
                        }
                        ret = set_cpu_freq(imx_freq_table[0].frequency * 1000);
-                       if (ret)
+                       /*restore cpufreq and tell cpufreq core if set fail*/
+                       if (ret) {
+                               freqs.old =  clk_get_rate(cpu_clk)/1000;
+                               freqs.new = freqs.old;
+                               freqs.flags = 0;
+                               for (i = 0; i < num_cpus; i++) {
+                                       freqs.cpu = i;
+                                       cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
+                               }
                                goto Notify_finish;/*if update freq error,return*/
+                       }
 #ifdef CONFIG_SMP
                        for_each_possible_cpu(i)
                                per_cpu(cpu_data, i).loops_per_jiffy =
@@ -446,8 +465,17 @@ static int cpufreq_pm_notify(struct notifier_block *nb, unsigned long event,
                                cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
                        }
                        ret = set_cpu_freq(pre_suspend_rate);
-                       if (ret)
+                       /*restore cpufreq and tell cpufreq core if set fail*/
+                       if (ret) {
+                               freqs.old =  clk_get_rate(cpu_clk)/1000;
+                               freqs.new = freqs.old;
+                               freqs.flags = 0;
+                               for (i = 0; i < num_cpus; i++) {
+                                       freqs.cpu = i;
+                                       cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
+                               }
                                goto Notify_finish;/*if update freq error,return*/
+                       }
 #ifdef CONFIG_SMP
                        for_each_possible_cpu(i)
                                per_cpu(cpu_data, i).loops_per_jiffy =