* [PATCH] PM: Added suspend target state control to debugfs for OMAP3
@ 2008-11-26 10:26 Tero Kristo
2008-11-26 18:54 ` Kevin Hilman
0 siblings, 1 reply; 2+ messages in thread
From: Tero Kristo @ 2008-11-26 10:26 UTC (permalink / raw)
To: linux-omap
Target state can be read / programmed via files under:
[debugfs]/pm_debug/[pwrdm]/suspend
Signed-off-by: Tero Kristo <tero.kristo@nokia.com>
---
arch/arm/mach-omap2/pm-debug.c | 30 ++++++++++++++++++++++++++++--
arch/arm/mach-omap2/pm.h | 4 ++++
arch/arm/mach-omap2/pm34xx.c | 24 ++++++++++++++++++++++++
3 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index 82219f4..ac61d15 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -26,6 +26,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>
@@ -511,11 +512,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 timespec now;
+ struct dentry *d;
getnstimeofday(&now);
t = timespec_to_ns(&now);
@@ -525,6 +543,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;
}
@@ -545,7 +571,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))
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 4b1ba7c..78fde57 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -34,8 +34,12 @@ extern void omap2_block_sleep(void);
extern void omap2_allow_sleep(void);
#ifdef CONFIG_ARCH_OMAP3
extern void omap3_pm_off_mode_enable(int);
+extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm);
+extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state);
#else
#define omap3_pm_off_mode_enable(int) do {} while (0);
+#define omap3_pm_get_suspend_state(pwrdm) do {} while (0);
+#define omap3_pm_set_suspend_state(pwrdm,state) do {} while (0);
#endif
extern int set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 191299c..73ac22c 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -780,6 +780,30 @@ void omap3_pm_off_mode_enable(int enable)
}
}
+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;
--
1.5.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PM: Added suspend target state control to debugfs for OMAP3
2008-11-26 10:26 [PATCH] PM: Added suspend target state control to debugfs for OMAP3 Tero Kristo
@ 2008-11-26 18:54 ` Kevin Hilman
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Hilman @ 2008-11-26 18:54 UTC (permalink / raw)
To: Tero Kristo; +Cc: linux-omap
Tero Kristo <tero.kristo@nokia.com> writes:
> Target state can be read / programmed via files under:
> [debugfs]/pm_debug/[pwrdm]/suspend
>
> Signed-off-by: Tero Kristo <tero.kristo@nokia.com>
Thanks, pulling into next PM branch.
Kevin
> ---
> arch/arm/mach-omap2/pm-debug.c | 30 ++++++++++++++++++++++++++++--
> arch/arm/mach-omap2/pm.h | 4 ++++
> arch/arm/mach-omap2/pm34xx.c | 24 ++++++++++++++++++++++++
> 3 files changed, 56 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
> index 82219f4..ac61d15 100644
> --- a/arch/arm/mach-omap2/pm-debug.c
> +++ b/arch/arm/mach-omap2/pm-debug.c
> @@ -26,6 +26,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>
> @@ -511,11 +512,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 timespec now;
> + struct dentry *d;
>
> getnstimeofday(&now);
> t = timespec_to_ns(&now);
> @@ -525,6 +543,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;
> }
>
> @@ -545,7 +571,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))
> diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
> index 4b1ba7c..78fde57 100644
> --- a/arch/arm/mach-omap2/pm.h
> +++ b/arch/arm/mach-omap2/pm.h
> @@ -34,8 +34,12 @@ extern void omap2_block_sleep(void);
> extern void omap2_allow_sleep(void);
> #ifdef CONFIG_ARCH_OMAP3
> extern void omap3_pm_off_mode_enable(int);
> +extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm);
> +extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state);
> #else
> #define omap3_pm_off_mode_enable(int) do {} while (0);
> +#define omap3_pm_get_suspend_state(pwrdm) do {} while (0);
> +#define omap3_pm_set_suspend_state(pwrdm,state) do {} while (0);
> #endif
> extern int set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
>
> diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
> index 191299c..73ac22c 100644
> --- a/arch/arm/mach-omap2/pm34xx.c
> +++ b/arch/arm/mach-omap2/pm34xx.c
> @@ -780,6 +780,30 @@ void omap3_pm_off_mode_enable(int enable)
> }
> }
>
> +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;
> --
> 1.5.4.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-11-26 18:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-26 10:26 [PATCH] PM: Added suspend target state control to debugfs for OMAP3 Tero Kristo
2008-11-26 18:54 ` Kevin Hilman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox