Commit fe66c6993c174934d26043286370254e43c09e7f

Authored by Dave Gerlach
Committed by Rajendra Nayak
1 parent 683e030348

ARM: OMAP2+: omap_hwmod: Add context ops to am43xx soc_ops

AM43XX contains PRM_*_CONTEXT registers like OMAP4 did to track loss
of context in modules so utilize the same get_context_loss_count soc_op
present for OMAP4 but define a custom update context loss function for
am43xx. Because we do not define context_offs for each hwmod, introduce
a new flag to indicate when we have so we only bother to update when
we know that it is valid.

Certain drivers use the context loss count to determine if context was
truly lost during a suspend operation to decide whether or not a
context restore is truly necessary. Without this, some drivers may
choose not to restore context when they have actually lost it and fail
to properly resume.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>

Showing 2 changed files with 28 additions and 0 deletions Side-by-side Diff

arch/arm/mach-omap2/omap_hwmod.c
... ... @@ -2124,6 +2124,31 @@
2124 2124 }
2125 2125  
2126 2126 /**
  2127 + * _am437x_update_context_lost - increment hwmod context loss counter if
  2128 + * hwmod context was lost, and clear hardware context loss reg
  2129 + * @oh: hwmod to check for context loss
  2130 + *
  2131 + * If the PRCM indicates that the hwmod @oh lost context, increment
  2132 + * our in-memory context loss counter, and clear the RM_*_CONTEXT
  2133 + * bits. No return value.
  2134 + */
  2135 +static void _am437x_update_context_lost(struct omap_hwmod *oh)
  2136 +{
  2137 + if (!(oh->prcm.omap4.flags & HWMOD_AM437X_HAS_CONTEXT_LOSS_BIT))
  2138 + return;
  2139 +
  2140 + if (!prm_was_any_context_lost_old(oh->clkdm->pwrdm.ptr->prcm_partition,
  2141 + oh->clkdm->pwrdm.ptr->prcm_offs,
  2142 + oh->prcm.omap4.context_offs))
  2143 + return;
  2144 +
  2145 + oh->prcm.omap4.context_lost_counter++;
  2146 + prm_clear_context_loss_flags_old(oh->clkdm->pwrdm.ptr->prcm_partition,
  2147 + oh->clkdm->pwrdm.ptr->prcm_offs,
  2148 + oh->prcm.omap4.context_offs);
  2149 +}
  2150 +
  2151 +/**
2127 2152 * _omap4_get_context_lost - get context loss counter for a hwmod
2128 2153 * @oh: hwmod to get context loss counter for
2129 2154 *
... ... @@ -4220,6 +4245,8 @@
4220 4245 soc_ops.deassert_hardreset = _omap4_deassert_hardreset;
4221 4246 soc_ops.is_hardreset_asserted = _omap4_is_hardreset_asserted;
4222 4247 soc_ops.init_clkdm = _init_clkdm;
  4248 + soc_ops.update_context_lost = _am437x_update_context_lost;
  4249 + soc_ops.get_context_lost = _omap4_get_context_lost;
4223 4250 } else if (soc_is_am33xx()) {
4224 4251 soc_ops.enable_module = _am33xx_enable_module;
4225 4252 soc_ops.disable_module = _am33xx_disable_module;
arch/arm/mach-omap2/omap_hwmod.h
... ... @@ -450,6 +450,7 @@
450 450 * flag bit should be set in those cases
451 451 */
452 452 #define HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT (1 << 0)
  453 +#define HWMOD_AM437X_HAS_CONTEXT_LOSS_BIT (1 << 1)
453 454  
454 455 /**
455 456 * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data