@@ -2220,3 +2220,21 @@ 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.
+ */
+int omap_hwmod_get_context_loss_count(struct omap_hwmod *oh)
+{
+ struct powerdomain *pwrdm;
+
+ pwrdm = omap_hwmod_get_pwrdm(oh);
+ if (!pwrdm)
+ return -ENODEV;
+
+ return pwrdm_get_context_loss_count(pwrdm);
+}
@@ -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);
+int omap_device_get_context_loss_count(struct platform_device *pdev);
/* Other */
@@ -568,6 +568,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);
+int omap_hwmod_get_context_loss_count(struct omap_hwmod *oh);
/*
* Chip variant-specific hwmod init routines - XXX should be converted
@@ -20,9 +20,11 @@
#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>
struct omap_opp *dsp_opps;
struct omap_opp *mpu_opps;
@@ -288,20 +290,19 @@ unsigned long omap_pm_cpu_get_freq(void)
int omap_pm_get_dev_context_loss_count(struct device *dev)
{
+ struct platform_device *pdev = to_platform_device(dev);
+ int count;
+
if (!dev) {
WARN_ON(1);
return -EINVAL;
};
- pr_debug("OMAP PM: returning context loss count for dev %s\n",
- dev_name(dev));
+ count = omap_device_get_context_loss_count(pdev);
+ pr_debug("OMAP PM: context loss count for dev %s = %d\n",
+ dev_name(dev), count);
- /*
- * Map the device to the powerdomain. Return the powerdomain
- * off counter.
- */
-
- return 0;
+ return count;
}
@@ -280,6 +280,26 @@ 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 for this device, query the context loss
+ * count for this device.
+ */
+int omap_device_get_context_loss_count(struct platform_device *pdev)
+{
+ struct omap_device *od;
+ int ret = -ENODEV;
+
+ od = _find_by_pdev(pdev);
+
+ if (od->hwmods_cnt)
+ 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 *
*