OMAP: PM noop: implement context loss count for non-omap_devices
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)
For devices which have not (yet) been converted to use omap_device,
implement the context loss counter using the "brutal method" as
originally proposed by Paul Walmsley[1].

The dummy context loss counter is incremented every time it is
checked, but only when off-mode is enabled.  When off-mode is
disabled, the dummy counter stops incrementing.

Tested on 36xx/Zoom3 using MMC driver, which is currently the
only in-tree user of this API.

This patch should be reverted after all devices are converted to using
omap_device.

[1] http://marc.info/?l=linux-omap&m=129176260000626&w=2

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
[paul@pwsan.com: fixed compile warning; fixed to compile on OMAP1]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
arch/arm/mach-omap2/pm-debug.c
arch/arm/plat-omap/include/plat/omap-pm.h
arch/arm/plat-omap/omap-pm-noop.c

index e535082b0c2e443fa6c9a056c01d2859aebcedf2..125f56591fb56bb135442f7dcf0eeb8c855e894b 100644 (file)
@@ -32,6 +32,7 @@
 #include "powerdomain.h"
 #include "clockdomain.h"
 #include <plat/dmtimer.h>
+#include <plat/omap-pm.h>
 
 #include "cm2xxx_3xxx.h"
 #include "prm2xxx_3xxx.h"
@@ -581,6 +582,10 @@ static int option_set(void *data, u64 val)
        *option = val;
 
        if (option == &enable_off_mode) {
+               if (val)
+                       omap_pm_enable_off_mode();
+               else
+                       omap_pm_disable_off_mode();
                if (cpu_is_omap34xx())
                        omap3_pm_off_mode_enable(val);
        }
index c07bb44e9e5a53813a6dbc0a862621d6888b5e9e..c0a752053039a5387b34807954b924fe330b64f7 100644 (file)
@@ -354,5 +354,7 @@ unsigned long omap_pm_cpu_get_freq(void);
  */
 u32 omap_pm_get_dev_context_loss_count(struct device *dev);
 
+void omap_pm_enable_off_mode(void);
+void omap_pm_disable_off_mode(void);
 
 #endif
index af58daddcf500595857ca01f08e2b4ae3561655b..b0471bb2d47dda81c45447e381ada7ff294b502f 100644 (file)
@@ -26,6 +26,9 @@
 #include <plat/omap-pm.h>
 #include <plat/omap_device.h>
 
+static bool off_mode_enabled;
+static u32 dummy_context_loss_counter;
+
 /*
  * Device-driver-originated constraints (via board-*.c files)
  */
@@ -280,10 +283,34 @@ unsigned long omap_pm_cpu_get_freq(void)
        return 0;
 }
 
+/**
+ * omap_pm_enable_off_mode - notify OMAP PM that off-mode is enabled
+ *
+ * Intended for use only by OMAP PM core code to notify this layer
+ * that off mode has been enabled.
+ */
+void omap_pm_enable_off_mode(void)
+{
+       off_mode_enabled = true;
+}
+
+/**
+ * omap_pm_disable_off_mode - notify OMAP PM that off-mode is disabled
+ *
+ * Intended for use only by OMAP PM core code to notify this layer
+ * that off mode has been disabled.
+ */
+void omap_pm_disable_off_mode(void)
+{
+       off_mode_enabled = false;
+}
+
 /*
  * Device context loss tracking
  */
 
+#ifdef CONFIG_ARCH_OMAP2PLUS
+
 u32 omap_pm_get_dev_context_loss_count(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
@@ -292,13 +319,30 @@ u32 omap_pm_get_dev_context_loss_count(struct device *dev)
        if (WARN_ON(!dev))
                return 0;
 
-       count = omap_device_get_context_loss_count(pdev);
+       if (dev->parent == &omap_device_parent) {
+               count = omap_device_get_context_loss_count(pdev);
+       } else {
+               WARN_ONCE(off_mode_enabled, "omap_pm: using dummy context loss counter; device %s should be converted to omap_device",
+                         dev_name(dev));
+               if (off_mode_enabled)
+                       dummy_context_loss_counter++;
+               count = dummy_context_loss_counter;
+       }
+
        pr_debug("OMAP PM: context loss count for dev %s = %d\n",
                 dev_name(dev), count);
 
        return count;
 }
 
+#else
+
+u32 omap_pm_get_dev_context_loss_count(struct device *dev)
+{
+       return dummy_context_loss_counter;
+}
+
+#endif
 
 /* Should be called before clk framework init */
 int __init omap_pm_if_early_init(void)