[PATCH 2/3] power off on state counter infrastructure

2008-07-24 Thread Peter 'p2' De Schrijver

Signed-off-by: Peter 'p2' De Schrijver [EMAIL PROTECTED]
---
 arch/arm/mach-omap2/powerdomain.c   |   48 +-
 include/asm-arm/arch-omap/powerdomain.h |9 +-
 2 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/powerdomain.c 
b/arch/arm/mach-omap2/powerdomain.c
index 7615f9d..721f73c 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -102,6 +102,27 @@ static struct powerdomain *_pwrdm_deps_lookup(struct 
powerdomain *pwrdm,
return pd-pwrdm;
 }
 
+static int pwr_domain_save_state_cb(struct powerdomain *pwrdm, void *user)
+{
+   pwrdm_save_state(pwrdm);
+
+   return 0;
+}
+
+static int pwr_domain_count_off_mode_cb(struct powerdomain *pwrdm, void *user)
+{
+   int prev;
+
+   prev = pwrdm_read_prev_pwrst(pwrdm);
+
+   if (prev != PWRDM_POWER_OFF  pwrdm-state != prev)
+pwrdm-offstate_count++;
+
+   pwrdm-state = pwrdm_read_pwrst(pwrdm);
+
+   return 0;
+}
+
 
 /* Public functions */
 
@@ -217,7 +238,7 @@ struct powerdomain *pwrdm_lookup(const char *name)
  * anything else to indicate failure; or -EINVAL if the function
  * pointer is null.
  */
-int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm))
+int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user), void 
*user)
 {
struct powerdomain *temp_pwrdm;
unsigned long flags;
@@ -228,7 +249,7 @@ int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm))
 
read_lock_irqsave(pwrdm_rwlock, flags);
list_for_each_entry(temp_pwrdm, pwrdm_list, node) {
-   ret = (*fn)(temp_pwrdm);
+   ret = (*fn)(temp_pwrdm, user);
if (ret)
break;
}
@@ -1110,4 +1131,27 @@ int pwrdm_wait_transition(struct powerdomain *pwrdm)
return 0;
 }
 
+void pwrdm_save_state(struct powerdomain *pwrdm)
+{
+   pwrdm-state = pwrdm_read_pwrst(pwrdm);
+}
+
+void pwrdm_check_off_mode(struct powerdomain *pwrdm)
+{
+   int state;
+
+   state = pwrdm_read_pwrst(pwrdm);
+   if (pwrdm-state == PWRDM_POWER_OFF  state == PWRDM_POWER_ON)
+   pwrdm-offstate_count++;
+}
+
+void pwrdm_save_state_all(void)
+{
+   pwrdm_for_each(pwr_domain_save_state_cb, NULL);
+}
+
+void pwrdm_count_off_mode(void)
+{
+   pwrdm_for_each(pwr_domain_count_off_mode_cb, NULL);
+}
 
diff --git a/include/asm-arm/arch-omap/powerdomain.h 
b/include/asm-arm/arch-omap/powerdomain.h
index 1cd8942..19ad6fd 100644
--- a/include/asm-arm/arch-omap/powerdomain.h
+++ b/include/asm-arm/arch-omap/powerdomain.h
@@ -117,6 +117,8 @@ struct powerdomain {
 
struct list_head node;
 
+   int state;
+   u32 offstate_count;
 };
 
 
@@ -126,7 +128,8 @@ int pwrdm_register(struct powerdomain *pwrdm);
 int pwrdm_unregister(struct powerdomain *pwrdm);
 struct powerdomain *pwrdm_lookup(const char *name);
 
-int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm));
+int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user),
+   void *user);
 
 int pwrdm_add_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm);
 int pwrdm_del_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm);
@@ -165,4 +168,8 @@ bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm);
 
 int pwrdm_wait_transition(struct powerdomain *pwrdm);
 
+void pwrdm_save_state(struct powerdomain *pwrdm);
+void pwrdm_check_off_mode(struct powerdomain *pwrdm);
+void pwrdm_save_state_all(void);
+void pwrdm_count_off_mode(void);
 #endif
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] Add hooks for counting off on power transitions

2008-07-24 Thread Peter 'p2' De Schrijver

Signed-off-by: Peter 'p2' De Schrijver [EMAIL PROTECTED]
---
 arch/arm/mach-omap2/clockdomain.c |   10 ++
 arch/arm/mach-omap2/pm34xx.c  |6 +-
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/clockdomain.c 
b/arch/arm/mach-omap2/clockdomain.c
index e975ca1..fac5778 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -571,6 +571,11 @@ int omap2_clkdm_clk_enable(struct clockdomain *clkdm, 
struct clk *clk)
/*Hook to inform the OMAP PM layer that the pwrdm has become active */
omap_pm_pwrdm_active(clkdm-pwrdm);
 
+   if (clkdm != NULL  clkdm-pwrdm != NULL) {
+   pwrdm_wait_transition(clkdm-pwrdm);
+   pwrdm_check_off_mode(clkdm-pwrdm);
+   }
+
return 0;
 }
 
@@ -625,6 +630,11 @@ int omap2_clkdm_clk_disable(struct clockdomain *clkdm, 
struct clk *clk)
/*Hook to inform the OMAP PM layer that the pwrdm has become inactive */
omap_pm_pwrdm_inactive(clkdm-pwrdm);
 
+   if (clkdm != NULL  clkdm-pwrdm != NULL) {
+   pwrdm_wait_transition(clkdm-pwrdm);
+   pwrdm_save_state(clkdm-pwrdm);
+   }
+
return 0;
 }
 
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 8b6b09e..f70035a 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -269,6 +269,8 @@ void omap_sram_idle(void)
return;
}
 
+   pwrdm_save_state_all();
+
/* NEON control */
if (pwrdm_read_pwrst(neon_pwrdm) == PWRDM_POWER_ON)
set_pwrdm_state(neon_pwrdm, mpu_next_state);
@@ -346,6 +348,8 @@ void omap_sram_idle(void)
}
omap2_gpio_resume_after_retention();
}
+
+   pwrdm_count_off_mode();
 }
 
 static int omap3_fclks_active(void)
@@ -848,7 +852,7 @@ int __init omap3_pm_init(void)
goto err2;
}
 
-   ret = pwrdm_for_each(pwrdms_setup);
+   ret = pwrdm_for_each(pwrdms_setup, NULL);
if (ret) {
printk(KERN_ERR Failed to setup powerdomains\n);
goto err2;
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] Power off on state counter debugging

2008-07-24 Thread Peter 'p2' De Schrijver

Signed-off-by: Peter 'p2' De Schrijver [EMAIL PROTECTED]
---
 arch/arm/mach-omap2/Makefile  |2 +-
 arch/arm/mach-omap2/off-state-counter-debug.c |   50 +
 2 files changed, 51 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/off-state-counter-debug.c

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 0d8507c..a48f832 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -5,7 +5,7 @@
 # Common support
 obj-y := irq.o id.o io.o memory.o control.o prcm.o clock.o mux.o \
devices.o serial.o gpmc.o timer-gp.o powerdomain.o \
-   clockdomain.o
+   clockdomain.o off-state-counter-debug.o
 
 obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
 
diff --git a/arch/arm/mach-omap2/off-state-counter-debug.c 
b/arch/arm/mach-omap2/off-state-counter-debug.c
new file mode 100644
index 000..7db54b6
--- /dev/null
+++ b/arch/arm/mach-omap2/off-state-counter-debug.c
@@ -0,0 +1,50 @@
+#include linux/debugfs.h
+#include linux/seq_file.h
+#include asm/arch/powerdomain.h
+
+
+int show_off_mode_count(struct powerdomain *pwrdm, void *user)
+{
+   struct seq_file *s = (struct seq_file *)user;
+
+   if (strcmp(pwrdm-name, emu_pwrdm) 
+   strcmp(pwrdm-name, wkup_pwrdm))
+   seq_printf(s, %s : %d\n, pwrdm-name, pwrdm-offstate_count);
+
+   return 0;
+}
+
+int show_off_mode_counters(struct seq_file *s, void *unused)
+{
+   pwrdm_for_each(show_off_mode_count, s);
+
+   return 0;
+}
+
+static int off_mode_counter_open(struct inode *inode, struct file *file)
+{
+   return single_open(file, show_off_mode_counters, inode-i_private);
+}
+
+static const struct file_operations debug_fops = {
+   .open   = off_mode_counter_open,
+   .read   = seq_read,
+   .llseek = seq_lseek,
+   .release = single_release,
+};
+
+static int __init off_mode_counter_debug(void)
+{
+   struct dentry *d;
+
+   d = debugfs_create_dir(off_mode_counters, NULL);
+   if (IS_ERR(d))
+   return PTR_ERR(d);
+
+   debugfs_create_file(count, S_IRUGO,
+   d, NULL, debug_fops);
+
+   return 0;
+}
+
+late_initcall(off_mode_counter_debug);
-- 
1.5.6.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] Implement powerdomain off on state counters

2008-07-24 Thread Peter 'p2' De Schrijver
On Thu, Jul 24, 2008 at 04:00:31PM +0300, Peter 'p2' De Schrijver wrote:
 This patchset implement counters to count the number of off to on state 
 transitions in a powerdomain. These counters will be made available to
 drivers in a later patchset to allow them to make a better informed decision 
 wether to restore the hardware registers or not.

Thanks to Tero Kristo for providing the basis of this patch in the form
of the PM Debug counters.

-- 
goa is a state of mind
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/0] Power domain and clock domain patches for omap

2008-07-24 Thread David Brownell
On Monday 21 July 2008, Russell King - ARM Linux wrote:
 On Wed, Jul 16, 2008 at 06:19:05PM +0300, Tony Lindgren wrote:
  I'm reposting the series to a wider audience as Russell King suspected that
  other archs may be interested in reviewing these too, or at least some
  parts of the code.
 
 It would be nice to have some comment on these patches from other
 people.  My suspicions is that this infrastructure is solving a
 problem found on other SoCs in addition to OMAP,

ISTR that DaVinci is similar ... but much simpler, with fewer
power domains and more are always on.  Not much of the DaVinci
support is upstream yet though.

I'm not sure how many non-TI parts will need similar software
support.  It's my understanding that not many vendors put
that much energy into support for leakage current management.

(Here, a key observation is that when a section of a chip has
gated all its clocks off, that leaves leakage current as the
top source of power wastage.  Cooperative drivers could then
let that section be powered down to eliminate leakage.  So the
first level of power management is clock gating, at least in
part with software support.  The power domain gating is a
second level.)


The regulator stuff is not unrelated ... except that this
power domain stuff *only* needs on/off switches (like almost all
power domains I've ever used), is tightly coupled to clocks,
and unlike regulators is more oriented towards SOC-internal
concerns than board-level ones.


 and, if this is 
 useful to other people, it should become cross-SoC infrastructure.

My two cents:  merge the OMAP stuff first, then see what kinds
of generalization would be needed before other chips could use it.

Nobody wins by holding this back ... but everyone on OMAP2/OMAP3
loses.

- Dave



 Since I don't know the answer to whether it would be useful, I'm
 trying to ensure that these patches have sufficient exposure to
 people who _may_ know the answer.
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


git-clone from omapzoom.org failed.

2008-07-24 Thread stanley.miao
[EMAIL PROTECTED] ~]$ git clone http://git.omapzoom.org/repo/omapkernel
Initialized empty Git repository in /folk/smiao/omapkernel/.git/
got dd06a28f41991f2f004f388fde3f7edea01c1c5b
walk dd06a28f41991f2f004f388fde3f7edea01c1c5b
got 6480cf6936cf32308a113adb9af0f8602b6223f0
walk 6480cf6936cf32308a113adb9af0f8602b6223f0
Getting alternates list for http://git.omapzoom.org/repo/omapkernel
Getting pack list for http://git.omapzoom.org/repo/omapkernel
Getting index for pack 6766f8f96d6592cbccc117fdd5d91ea07ec09a60
Getting index for pack 93a2e6816791fe92516ccae4319a9037e7f1d073
[...]
Getting index for pack cdf798f41c0ed5673d2c4a81cc1ef8dffa410c6f
Getting index for pack 3651d2351b3e129d6205a06e127e6fd92899af0a
Getting pack b80f02e70fab8ef2602f6a1f2b3caab5d6156e2b
 which contains 273d545654e472dc60b2f5fee3f1bdac921a615e
walk 273d545654e472dc60b2f5fee3f1bdac921a615e
Getting pack ed451160b26a54bf420075568d28f11136b6121e
 which contains 050684c18f2ea0b08fdd5233a0cd3c7f96e00a0e
walk 050684c18f2ea0b08fdd5233a0cd3c7f96e00a0e
Getting pack c7c0ee3fb425edb3e01abdd63fccf219d913cc1d
 which contains 3ce7ba0c3c9566f50725b0108916180db86e1641
walk 3ce7ba0c3c9566f50725b0108916180db86e1641
Getting pack 407c38017452a9a8c0d8b5f9765bad837d4905eb
 which contains b4525f04fdc8a321cc78c5af6c9a899989aa7f4c
walk b4525f04fdc8a321cc78c5af6c9a899989aa7f4c
Getting pack 74316fb8187ba65d2da192a939f0c4b55a2e1ae6
 which contains 120dd64cacd4fb796bca0acba3665553f1d9ecaa
walk 120dd64cacd4fb796bca0acba3665553f1d9ecaa
Getting pack a88495de3ab49c0e59d33e2d8e9e97d6241377ed
 which contains 324384fe715944f44406012ea4285738c17ef833
error:
packfile 
/folk/smiao/omapkernel/.git/objects/pack/pack-a88495de3ab49c0e59d33e2d8e9e97d6241377ed.pack
 size changed
fatal:
packfile 
/folk/smiao/omapkernel/.git/objects/pack/pack-a88495de3ab49c0e59d33e2d8e9e97d6241377ed.pack
 cannot be accessed


Does anybody encounter the same problem with me ? I have tried several
times, sometimes it hang here, sometimes it got a error here.

Thanks
Stanley.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html