OMAP: PM: Added suspend target state control to debugfs for OMAP3
authorTero Kristo <tero.kristo@nokia.com>
Wed, 26 Nov 2008 10:26:24 +0000 (12:26 +0200)
committerKevin Hilman <khilman@deeprootsystems.com>
Wed, 2 Sep 2009 22:08:25 +0000 (15:08 -0700)
Target state can be read / programmed via files under:
  [debugfs]/pm_debug/[pwrdm]/suspend

Signed-off-by: Tero Kristo <tero.kristo@nokia.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
arch/arm/mach-omap2/pm-debug.c
arch/arm/mach-omap2/pm.h
arch/arm/mach-omap2/pm34xx.c

index 982aa67f2685cb6b4b0b16f94256c8a948f6bd64..1b4c1600f8d8c4c0f53ed5f70bd974d219777b83 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/module.h>
 
 #include <mach/clock.h>
 #include <mach/board.h>
@@ -484,10 +485,28 @@ int pm_dbg_regset_init(int reg_set)
        return 0;
 }
 
-static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
+static int pwrdm_suspend_get(void *data, u64 *val)
+{
+       *val = omap3_pm_get_suspend_state((struct powerdomain *)data);
+
+       if (*val >= 0)
+               return 0;
+       return *val;
+}
+
+static int pwrdm_suspend_set(void *data, u64 val)
+{
+       return omap3_pm_set_suspend_state((struct powerdomain *)data, (int)val);
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(pwrdm_suspend_fops, pwrdm_suspend_get,
+                       pwrdm_suspend_set, "%llu\n");
+
+static int __init pwrdms_setup(struct powerdomain *pwrdm, void *dir)
 {
        int i;
        s64 t;
+       struct dentry *d;
 
        t = sched_clock();
 
@@ -496,6 +515,14 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
 
        pwrdm->timer = t;
 
+       if (strncmp(pwrdm->name, "dpll", 4) == 0)
+               return 0;
+
+       d = debugfs_create_dir(pwrdm->name, (struct dentry *)dir);
+
+       (void) debugfs_create_file("suspend", S_IRUGO|S_IWUSR, d,
+                       (void *)pwrdm, &pwrdm_suspend_fops);
+
        return 0;
 }
 
@@ -524,7 +551,7 @@ static int __init pm_dbg_init(void)
        (void) debugfs_create_file("time", S_IRUGO,
                d, (void *)DEBUG_FILE_TIMERS, &debug_fops);
 
-       pwrdm_for_each(pwrdms_setup, NULL);
+       pwrdm_for_each(pwrdms_setup, (void *)d);
 
        pm_dbg_dir = debugfs_create_dir("registers", d);
        if (IS_ERR(pm_dbg_dir))
index 8fa856770188e20d6ea5eed2a84b9fa8b8fc2b94..8400f57689232ac0334d52c2340d1fa375c1e6d1 100644 (file)
@@ -13,6 +13,9 @@
 
 #include <mach/powerdomain.h>
 
+extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm);
+extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state);
+
 #ifdef CONFIG_PM_DEBUG
 extern void omap2_pm_dump(int mode, int resume, unsigned int us);
 extern int omap2_pm_debug;
index 331dfca93ed5a71d2bc56564bbbf1bb72182da5d..26f2aca9abe8ab45e7b0ffd36684159909a5109a 100644 (file)
@@ -664,6 +664,30 @@ static void __init prcm_setup_regs(void)
        omap3_d2d_idle();
 }
 
+int omap3_pm_get_suspend_state(struct powerdomain *pwrdm)
+{
+       struct power_state *pwrst;
+
+       list_for_each_entry(pwrst, &pwrst_list, node) {
+               if (pwrst->pwrdm == pwrdm)
+                       return pwrst->next_state;
+       }
+       return -EINVAL;
+}
+
+int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state)
+{
+       struct power_state *pwrst;
+
+       list_for_each_entry(pwrst, &pwrst_list, node) {
+               if (pwrst->pwrdm == pwrdm) {
+                       pwrst->next_state = state;
+                       return 0;
+               }
+       }
+       return -EINVAL;
+}
+
 static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
 {
        struct power_state *pwrst;