Re: [PATCHv9 1/8] ARM: OMAP: hwmod: Add support for per hwmod/module context lost count

2012-11-22 Thread Paul Walmsley
On Thu, 18 Oct 2012, Tero Kristo wrote:

 From: Rajendra Nayak rna...@ti.com
 
 OMAP4 has module specific context lost registers which makes it now
 possible to have module level context loss count, instead of relying
 on the powerdomain level context count.
 
 Add 2 private hwmod api's to update/clear the hwmod/module specific
 context lost counters/register.
 
 Update the module specific context_lost_counter and clear the hardware
 bits just after enabling the module.
 
 omap_hwmod_get_context_loss_count() now returns the hwmod context loss
 count them on platforms where they exist (OMAP4), else fall back on
 the pwrdm level counters for older platforms.
 
 Signed-off-by: Rajendra Nayak rna...@ti.com
 [p...@pwsan.com: added function kerneldoc, fixed structure kerneldoc,
  rearranged structure to avoid memory waste, marked fns as OMAP4-specific,
  prevent fn entry on non-OMAP4 chips, reduced indentation, merged update
  and clear, merged patches]
 [t-kri...@ti.com: added support for arch specific hwmod ops, and changed
  the no context offset indicator to USHRT_MAX]
 Signed-off-by: Tero Kristo t-kri...@ti.com
 [p...@pwsan.com: use NO_CONTEXT_LOSS_BIT flag rather than USHRT_MAX;
  convert unsigned context lost counter to int to match the return type;
  get rid of hwmod_ops in favor of the existing soc_ops mechanism]
 Signed-off-by: Paul Walmsley p...@pwsan.com

Here's an updated version of this one with the low-level PRM accesses 
moved out to the PRM code.


- Paul

From: Rajendra Nayak rna...@ti.com
Date: Wed, 21 Nov 2012 11:48:46 -0700
Subject: [PATCH] ARM: OMAP2+: hwmod: Add support for per hwmod/module context
 lost count

OMAP4 has module specific context lost registers which makes it now
possible to have module level context loss count, instead of relying
on the powerdomain level context count.

Add 2 private hwmod api's to update/clear the hwmod/module specific
context lost counters/register.

Update the module specific context_lost_counter and clear the hardware
bits just after enabling the module.

omap_hwmod_get_context_loss_count() now returns the hwmod context loss
count them on platforms where they exist (OMAP4), else fall back on
the pwrdm level counters for older platforms.

Signed-off-by: Rajendra Nayak rna...@ti.com
[p...@pwsan.com: added function kerneldoc, fixed structure kerneldoc,
 rearranged structure to avoid memory waste, marked fns as OMAP4-specific,
 prevent fn entry on non-OMAP4 chips, reduced indentation, merged update
 and clear, merged patches]
[t-kri...@ti.com: added support for arch specific hwmod ops, and changed
 the no context offset indicator to USHRT_MAX]
Signed-off-by: Tero Kristo t-kri...@ti.com
[p...@pwsan.com: use NO_CONTEXT_LOSS_BIT flag rather than USHRT_MAX;
 convert unsigned context lost counter to int to match the return type;
 get rid of hwmod_ops in favor of the existing soc_ops mechanism;
 move context loss low-level accesses to the PRM code]
Signed-off-by: Paul Walmsley p...@pwsan.com
---
 arch/arm/mach-omap2/omap_hwmod.c |   55 +++---
 arch/arm/mach-omap2/omap_hwmod.h |   10 ---
 arch/arm/mach-omap2/prm.h|   11 +++-
 arch/arm/mach-omap2/prm44xx.c|   33 +++
 arch/arm/mach-omap2/prm_common.c |   45 +++
 5 files changed, 146 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 68616b2..083adbe 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -187,6 +187,8 @@ struct omap_hwmod_soc_ops {
int (*is_hardreset_asserted)(struct omap_hwmod *oh,
 struct omap_hwmod_rst_info *ohri);
int (*init_clkdm)(struct omap_hwmod *oh);
+   void (*update_context_lost)(struct omap_hwmod *oh);
+   int (*get_context_lost)(struct omap_hwmod *oh);
 };
 
 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
@@ -1983,6 +1985,42 @@ static void _reconfigure_io_chain(void)
 }
 
 /**
+ * _omap4_update_context_lost - increment hwmod context loss counter if
+ * hwmod context was lost, and clear hardware context loss reg
+ * @oh: hwmod to check for context loss
+ *
+ * If the PRCM indicates that the hwmod @oh lost context, increment
+ * our in-memory context loss counter, and clear the RM_*_CONTEXT
+ * bits. No return value.
+ */
+static void _omap4_update_context_lost(struct omap_hwmod *oh)
+{
+   if (oh-prcm.omap4.flags  HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT)
+   return;
+
+   if (!prm_was_any_context_lost_old(oh-clkdm-pwrdm.ptr-prcm_partition,
+ oh-clkdm-pwrdm.ptr-prcm_offs,
+ oh-prcm.omap4.context_offs))
+   return;
+
+   oh-prcm.omap4.context_lost_counter++;
+   prm_clear_context_loss_flags_old(oh-clkdm-pwrdm.ptr-prcm_partition,
+oh-clkdm-pwrdm.ptr-prcm_offs,
+   

Re: [PATCHv9 1/8] ARM: OMAP: hwmod: Add support for per hwmod/module context lost count

2012-10-26 Thread Paul Walmsley
Hi,

On Thu, 18 Oct 2012, Tero Kristo wrote:

 From: Rajendra Nayak rna...@ti.com
 
 OMAP4 has module specific context lost registers which makes it now
 possible to have module level context loss count, instead of relying
 on the powerdomain level context count.
 
 Add 2 private hwmod api's to update/clear the hwmod/module specific
 context lost counters/register.
 
 Update the module specific context_lost_counter and clear the hardware
 bits just after enabling the module.
 
 omap_hwmod_get_context_loss_count() now returns the hwmod context loss
 count them on platforms where they exist (OMAP4), else fall back on
 the pwrdm level counters for older platforms.
 
 Signed-off-by: Rajendra Nayak rna...@ti.com
 [p...@pwsan.com: added function kerneldoc, fixed structure kerneldoc,
  rearranged structure to avoid memory waste, marked fns as OMAP4-specific,
  prevent fn entry on non-OMAP4 chips, reduced indentation, merged update
  and clear, merged patches]
 [t-kri...@ti.com: added support for arch specific hwmod ops, and changed
  the no context offset indicator to USHRT_MAX]
 Signed-off-by: Tero Kristo t-kri...@ti.com
 [p...@pwsan.com: use NO_CONTEXT_LOSS_BIT flag rather than USHRT_MAX;
  convert unsigned context lost counter to int to match the return type;
  get rid of hwmod_ops in favor of the existing soc_ops mechanism]
 Signed-off-by: Paul Walmsley p...@pwsan.com

Thanks, re-queued for 3.8.

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


[PATCHv9 1/8] ARM: OMAP: hwmod: Add support for per hwmod/module context lost count

2012-10-18 Thread Tero Kristo
From: Rajendra Nayak rna...@ti.com

OMAP4 has module specific context lost registers which makes it now
possible to have module level context loss count, instead of relying
on the powerdomain level context count.

Add 2 private hwmod api's to update/clear the hwmod/module specific
context lost counters/register.

Update the module specific context_lost_counter and clear the hardware
bits just after enabling the module.

omap_hwmod_get_context_loss_count() now returns the hwmod context loss
count them on platforms where they exist (OMAP4), else fall back on
the pwrdm level counters for older platforms.

Signed-off-by: Rajendra Nayak rna...@ti.com
[p...@pwsan.com: added function kerneldoc, fixed structure kerneldoc,
 rearranged structure to avoid memory waste, marked fns as OMAP4-specific,
 prevent fn entry on non-OMAP4 chips, reduced indentation, merged update
 and clear, merged patches]
[t-kri...@ti.com: added support for arch specific hwmod ops, and changed
 the no context offset indicator to USHRT_MAX]
Signed-off-by: Tero Kristo t-kri...@ti.com
[p...@pwsan.com: use NO_CONTEXT_LOSS_BIT flag rather than USHRT_MAX;
 convert unsigned context lost counter to int to match the return type;
 get rid of hwmod_ops in favor of the existing soc_ops mechanism]
Signed-off-by: Paul Walmsley p...@pwsan.com
---
 arch/arm/mach-omap2/omap_hwmod.c |   60 --
 arch/arm/plat-omap/include/plat/omap_hwmod.h |   10 +++-
 2 files changed, 63 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index b969ab1..d810f85 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -189,6 +189,8 @@ struct omap_hwmod_soc_ops {
int (*is_hardreset_asserted)(struct omap_hwmod *oh,
 struct omap_hwmod_rst_info *ohri);
int (*init_clkdm)(struct omap_hwmod *oh);
+   void (*update_context_lost)(struct omap_hwmod *oh);
+   int (*get_context_lost)(struct omap_hwmod *oh);
 };
 
 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
@@ -1962,6 +1964,47 @@ static void _reconfigure_io_chain(void)
 }
 
 /**
+ * _omap4_update_context_lost - increment hwmod context loss counter if
+ * hwmod context was lost, and clear hardware context loss reg
+ * @oh: hwmod to check for context loss
+ *
+ * If the PRCM indicates that the hwmod @oh lost context, increment
+ * our in-memory context loss counter, and clear the RM_*_CONTEXT
+ * bits. No return value.
+ */
+static void _omap4_update_context_lost(struct omap_hwmod *oh)
+{
+   u32 r;
+
+   if (oh-prcm.omap4.flags  HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT)
+   return;
+
+   r = omap4_prminst_read_inst_reg(oh-clkdm-pwrdm.ptr-prcm_partition,
+   oh-clkdm-pwrdm.ptr-prcm_offs,
+   oh-prcm.omap4.context_offs);
+
+   if (!r)
+   return;
+
+   oh-prcm.omap4.context_lost_counter++;
+
+   omap4_prminst_write_inst_reg(r, oh-clkdm-pwrdm.ptr-prcm_partition,
+oh-clkdm-pwrdm.ptr-prcm_offs,
+oh-prcm.omap4.context_offs);
+}
+
+/**
+ * _omap4_get_context_lost - get context loss counter for a hwmod
+ * @oh: hwmod to get context loss counter for
+ *
+ * Returns the in-memory context loss counter for a hwmod.
+ */
+static int _omap4_get_context_lost(struct omap_hwmod *oh)
+{
+   return oh-prcm.omap4.context_lost_counter;
+}
+
+/**
  * _enable - enable an omap_hwmod
  * @oh: struct omap_hwmod *
  *
@@ -2044,6 +2087,9 @@ static int _enable(struct omap_hwmod *oh)
if (soc_ops.enable_module)
soc_ops.enable_module(oh);
 
+   if (soc_ops.update_context_lost)
+   soc_ops.update_context_lost(oh);
+
r = (soc_ops.wait_target_ready) ? soc_ops.wait_target_ready(oh) :
-EINVAL;
if (!r) {
@@ -3852,17 +3898,21 @@ ohsps_unlock:
  * 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 associated @oh
+ * upon success, or zero if no context loss data is available.
  *
- * Returns the context loss count of the powerdomain assocated with @oh
- * upon success, or zero if no powerdomain exists for @oh.
+ * On OMAP4, this queries the per-hwmod context loss register,
+ * assuming one exists.  If not, or on OMAP2/3, this queries the
+ * enclosing powerdomain context loss count.
  */
 int omap_hwmod_get_context_loss_count(struct omap_hwmod *oh)
 {
struct powerdomain *pwrdm;
int ret = 0;
 
+   if (soc_ops.get_context_lost)
+   return soc_ops.get_context_lost(oh);
+
pwrdm = omap_hwmod_get_pwrdm(oh);
if (pwrdm)
ret = pwrdm_get_context_loss_count(pwrdm);
@@ -3980,6 +4030,8 @@ void __init