OMAP2+: powerdomain: add API to get context loss count
authorKevin Hilman <khilman@deeprootsystems.com>
Wed, 22 Dec 2010 04:31:55 +0000 (21:31 -0700)
committerPaul Walmsley <paul@pwsan.com>
Wed, 22 Dec 2010 04:31:55 +0000 (21:31 -0700)
Add new powerdomain API

    u32 pwrdm_get_context_loss_count(struct powerdomain *pwrdm)

for checking how many times the powerdomain has lost context.  The
loss count is the sum of the powerdomain off-mode counter, the
logic off counter and the per-bank memory off counter.

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
[paul@pwsan.com: removed bogus return value on error; improved kerneldoc;
 tweaked commit message]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
arch/arm/mach-omap2/powerdomain.c
arch/arm/mach-omap2/powerdomain.h

index 06ef60eebebde358899e9b49f564cfb7ee37d2a2..eaed0df166999ed2a9ea4f60e259cbca6ccc7b89 100644 (file)
@@ -909,3 +909,32 @@ int pwrdm_post_transition(void)
        pwrdm_for_each(_pwrdm_post_transition_cb, NULL);
        return 0;
 }
+
+/**
+ * pwrdm_get_context_loss_count - get powerdomain's context loss count
+ * @pwrdm: struct powerdomain * to wait for
+ *
+ * Context loss count is the sum of powerdomain off-mode counter, the
+ * logic off counter and the per-bank memory off counter.  Returns 0
+ * (and WARNs) upon error, otherwise, returns the context loss count.
+ */
+u32 pwrdm_get_context_loss_count(struct powerdomain *pwrdm)
+{
+       int i, count;
+
+       if (!pwrdm) {
+               WARN(1, "powerdomain: %s: pwrdm is null\n", __func__);
+               return 0;
+       }
+
+       count = pwrdm->state_counter[PWRDM_POWER_OFF];
+       count += pwrdm->ret_logic_off_counter;
+
+       for (i = 0; i < pwrdm->banks; i++)
+               count += pwrdm->ret_mem_off_counter[i];
+
+       pr_debug("powerdomain: %s: context loss count = %u\n",
+                pwrdm->name, count);
+
+       return count;
+}
index 35b5b4800a43fa95c0f2969111099f2fbc006443..c66431edfeb7e209de649bd12f6ef52419da3f50 100644 (file)
@@ -211,6 +211,7 @@ int pwrdm_clkdm_state_switch(struct clockdomain *clkdm);
 int pwrdm_pre_transition(void);
 int pwrdm_post_transition(void);
 int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm);
+u32 pwrdm_get_context_loss_count(struct powerdomain *pwrdm);
 
 extern void omap2xxx_powerdomains_init(void);
 extern void omap3xxx_powerdomains_init(void);