]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
OMAP: PM: implement context loss count APIs
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)
Implement OMAP PM layer omap_pm_get_dev_context_loss_count() API by
creating similar APIs at the omap_device and omap_hwmod levels.  The
omap_hwmod level call is the layer with access to the powerdomain
core, so it is the place where the powerdomain is queried to get the
context loss count.

The new APIs return an unsigned value that can wrap as the
context-loss count grows.  However, the wrapping is not important as
the role of this function is to determine context loss by checking for
any difference in subsequent calls to this function.

Note that these APIs at each level can return zero when no context
loss is detected, or on errors.  This is to avoid returning error
codes which could potentially be mistaken for large context loss
counters.

NOTE: only works for devices which have been converted to use
      omap_device/omap_hwmod.

Longer term, we could possibly remove this API from the OMAP PM layer,
and instead directly use the omap_device level API.

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Signed-off-by: Paul Walmsley <paul@pwsan.com>
arch/arm/mach-omap2/omap_hwmod.c
arch/arm/plat-omap/include/plat/omap-pm.h
arch/arm/plat-omap/include/plat/omap_device.h
arch/arm/plat-omap/include/plat/omap_hwmod.h
arch/arm/plat-omap/omap-pm-noop.c
arch/arm/plat-omap/omap_device.c

index 03ffa3b282b1f574f46cd4d4453e2c82731cc34e..77a8be64cfaedb393cf6d177ef27e0ee186de7c4 100644 (file)
@@ -2188,3 +2188,25 @@ ohsps_unlock:
 
        return ret;
 }
+
+/**
+ * omap_hwmod_get_context_loss_count - get lost context count
+ * @oh: struct omap_hwmod *
+ *
+ * Query the powerdomain of of @oh to get the context loss
+ * count for this device.
+ *
+ * Returns the context loss count of the powerdomain assocated with @oh
+ * upon success, or zero if no powerdomain exists for @oh.
+ */
+u32 omap_hwmod_get_context_loss_count(struct omap_hwmod *oh)
+{
+       struct powerdomain *pwrdm;
+       int ret = 0;
+
+       pwrdm = omap_hwmod_get_pwrdm(oh);
+       if (pwrdm)
+               ret = pwrdm_get_context_loss_count(pwrdm);
+
+       return ret;
+}
index 47d61107ccdab607878aef1b087d30e3202bea03..c07bb44e9e5a53813a6dbc0a862621d6888b5e9e 100644 (file)
@@ -350,9 +350,9 @@ unsigned long omap_pm_cpu_get_freq(void);
  * driver must restore device context.   If the number of context losses
  * exceeds the maximum positive integer, the function will wrap to 0 and
  * continue counting.  Returns the number of context losses for this device,
- * or -EINVAL upon error.
+ * or zero upon error.
  */
-int omap_pm_get_dev_context_loss_count(struct device *dev);
+u32 omap_pm_get_dev_context_loss_count(struct device *dev);
 
 
 #endif
index 28e2d1a78433b6d57c94e40b4050bb8ab521717c..e4c349ff9fd8ef1a77e071db608a2c75610ecc38 100644 (file)
@@ -107,6 +107,7 @@ void __iomem *omap_device_get_rt_va(struct omap_device *od);
 int omap_device_align_pm_lat(struct platform_device *pdev,
                             u32 new_wakeup_lat_limit);
 struct powerdomain *omap_device_get_pwrdm(struct omap_device *od);
+u32 omap_device_get_context_loss_count(struct platform_device *pdev);
 
 /* Other */
 
index 619877c6b3abe0698f34d55d0e14dedeeceaccfb..2825b456da0e4df7d64a2698a5ce7588dd4d8f6d 100644 (file)
@@ -569,6 +569,7 @@ int omap_hwmod_for_each_by_class(const char *classname,
                                 void *user);
 
 int omap_hwmod_set_postsetup_state(struct omap_hwmod *oh, u8 state);
+u32 omap_hwmod_get_context_loss_count(struct omap_hwmod *oh);
 
 /*
  * Chip variant-specific hwmod init routines - XXX should be converted
index 19cb9f5a9f04e541b9abceb9ee18394b9a7f3a19..af58daddcf500595857ca01f08e2b4ae3561655b 100644 (file)
 #include <linux/init.h>
 #include <linux/cpufreq.h>
 #include <linux/device.h>
+#include <linux/platform_device.h>
 
 /* Interface documentation is in mach/omap-pm.h */
 #include <plat/omap-pm.h>
+#include <plat/omap_device.h>
 
 /*
  * Device-driver-originated constraints (via board-*.c files)
@@ -282,22 +284,19 @@ unsigned long omap_pm_cpu_get_freq(void)
  * Device context loss tracking
  */
 
-int omap_pm_get_dev_context_loss_count(struct device *dev)
+u32 omap_pm_get_dev_context_loss_count(struct device *dev)
 {
-       if (!dev) {
-               WARN_ON(1);
-               return -EINVAL;
-       };
+       struct platform_device *pdev = to_platform_device(dev);
+       u32 count;
 
-       pr_debug("OMAP PM: returning context loss count for dev %s\n",
-                dev_name(dev));
+       if (WARN_ON(!dev))
+               return 0;
 
-       /*
-        * Map the device to the powerdomain.  Return the powerdomain
-        * off counter.
-        */
+       count = omap_device_get_context_loss_count(pdev);
+       pr_debug("OMAP PM: context loss count for dev %s = %d\n",
+                dev_name(dev), count);
 
-       return 0;
+       return count;
 }
 
 
index abe933cd8f0926c99b059d2a214bda900e5326eb..57adb270767b8bb2ebc409cdd2a50e6d6e83b0d0 100644 (file)
@@ -279,6 +279,34 @@ static void _add_optional_clock_alias(struct omap_device *od,
 
 /* Public functions for use by core code */
 
+/**
+ * omap_device_get_context_loss_count - get lost context count
+ * @od: struct omap_device *
+ *
+ * Using the primary hwmod, query the context loss count for this
+ * device.
+ *
+ * Callers should consider context for this device lost any time this
+ * function returns a value different than the value the caller got
+ * the last time it called this function.
+ *
+ * If any hwmods exist for the omap_device assoiated with @pdev,
+ * return the context loss counter for that hwmod, otherwise return
+ * zero.
+ */
+u32 omap_device_get_context_loss_count(struct platform_device *pdev)
+{
+       struct omap_device *od;
+       u32 ret = 0;
+
+       od = _find_by_pdev(pdev);
+
+       if (od->hwmods_cnt)
+               ret = omap_hwmod_get_context_loss_count(od->hwmods[0]);
+
+       return ret;
+}
+
 /**
  * omap_device_count_resources - count number of struct resource entries needed
  * @od: struct omap_device *