]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - sitara-epos/sitara-epos-kernel.git/commitdiff
cpufreq: OMAP: AM33XX: Use PM notifiers to scale voltage in suspend
authorVaibhav Bedia <vaibhav.bedia@ti.com>
Wed, 14 Mar 2012 17:22:09 +0000 (22:52 +0530)
committerVaibhav Bedia <vaibhav.bedia@ti.com>
Wed, 14 Mar 2012 17:34:34 +0000 (23:04 +0530)
Use the PM notifiers to scale down the frequency and voltage in the
suspend path and then block any further transitions till the system
resumes.

NOTE: THIS PATCH HAS CHECKPATCH ERRORS WHICH VIM IS NOT WILLING
TO REMOVE RIGHT NOW :(

Signed-off-by: Vaibhav Bedia <vaibhav.bedia@ti.com>
drivers/cpufreq/omap-cpufreq.c

index 39d8d36ff958e9d2797de8c05ee32e2dc6c11c6f..0d1d0705507036eda9e20b25cbe8ff39a7fd0215 100644 (file)
 #define MPU_TOLERANCE  4
 #define PER_ROUND_VAL  100
 
+/* Use 275MHz when entering suspend */
+#define SLEEP_FREQ     (275 * 1000)
+
+
 #ifdef CONFIG_SMP
 struct lpj_info {
        unsigned long   ref;
@@ -237,14 +241,33 @@ static inline void freq_table_free(void)
 }
 
 static int omap_pm_notify(struct notifier_block *nb, unsigned long event,
-       void *dummy)
+                                void *dummy)
 {
+       struct cpufreq_policy *policy = cpufreq_cpu_get(0);
+       static unsigned int saved_frequency;
+
        mutex_lock(&omap_cpu_lock);
-       if (event == PM_SUSPEND_PREPARE) {
+       switch (event) {
+       case PM_SUSPEND_PREPARE:
+               if (is_suspended)
+                       goto out;
+
+                saved_frequency = omap_getspeed(0);
+
+                mutex_unlock(&omap_cpu_lock);
+               omap_target(policy, SLEEP_FREQ, CPUFREQ_RELATION_H);
+               mutex_lock(&omap_cpu_lock);
                is_suspended = true;
-       } else if (event == PM_POST_SUSPEND) {
-               is_suspended = false;
+                break;
+
+        case PM_POST_SUSPEND:
+                is_suspended = false;
+                mutex_unlock(&omap_cpu_lock);
+               omap_target(policy, saved_frequency, CPUFREQ_RELATION_H);
+               mutex_lock(&omap_cpu_lock);
+                break;
        }
+out:
        mutex_unlock(&omap_cpu_lock);
 
        return NOTIFY_OK;