ARM: OMAP2+: hwmod: add parent_hwmod support
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Thu, 9 Oct 2014 14:03:14 +0000 (17:03 +0300)
committerPaul Walmsley <paul@pwsan.com>
Wed, 19 Nov 2014 21:48:12 +0000 (14:48 -0700)
Add parent_hwmod pointer to omap_hwmod. This can be set to point to a
"parent" hwmod that needs to be enabled for the "child" hwmod to work.

This is used at hwmod setup time: when doing the initial setup and
reset, first enable the parent hwmod, and after setup and reset is done,
restore the parent hwmod to postsetup_state.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Archit Taneja <archit.taneja@gmail.com>
[paul@pwsan.com: add kerneldoc documentation for parent_hwmod; note that it
 is a temporary workaround]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
arch/arm/mach-omap2/omap_hwmod.c
arch/arm/mach-omap2/omap_hwmod.h

index acae6d5..a2c7b30 100644 (file)
@@ -2719,11 +2719,33 @@ static int __init _setup(struct omap_hwmod *oh, void *data)
        if (oh->_state != _HWMOD_STATE_INITIALIZED)
                return 0;
 
+       if (oh->parent_hwmod) {
+               int r;
+
+               r = _enable(oh->parent_hwmod);
+               WARN(r, "hwmod: %s: setup: failed to enable parent hwmod %s\n",
+                    oh->name, oh->parent_hwmod->name);
+       }
+
        _setup_iclk_autoidle(oh);
 
        if (!_setup_reset(oh))
                _setup_postsetup(oh);
 
+       if (oh->parent_hwmod) {
+               u8 postsetup_state;
+
+               postsetup_state = oh->parent_hwmod->_postsetup_state;
+
+               if (postsetup_state == _HWMOD_STATE_IDLE)
+                       _idle(oh->parent_hwmod);
+               else if (postsetup_state == _HWMOD_STATE_DISABLED)
+                       _shutdown(oh->parent_hwmod);
+               else if (postsetup_state != _HWMOD_STATE_ENABLED)
+                       WARN(1, "hwmod: %s: unknown postsetup state %d! defaulting to enabled\n",
+                            oh->parent_hwmod->name, postsetup_state);
+       }
+
        return 0;
 }
 
index 512f809..35ca6ef 100644 (file)
@@ -633,6 +633,7 @@ struct omap_hwmod_link {
  * @flags: hwmod flags (documented below)
  * @_lock: spinlock serializing operations on this hwmod
  * @node: list node for hwmod list (internal use)
+ * @parent_hwmod: (temporary) a pointer to the hierarchical parent of this hwmod
  *
  * @main_clk refers to this module's "main clock," which for our
  * purposes is defined as "the functional clock needed for register
@@ -643,6 +644,12 @@ struct omap_hwmod_link {
  * the omap_hwmod code and should not be set during initialization.
  *
  * @masters and @slaves are now deprecated.
+ *
+ * @parent_hwmod is temporary; there should be no need for it, as this
+ * information should already be expressed in the OCP interface
+ * structures.  @parent_hwmod is present as a workaround until we improve
+ * handling for hwmods with multiple parents (e.g., OMAP4+ DSS with
+ * multiple register targets across different interconnects).
  */
 struct omap_hwmod {
        const char                      *name;
@@ -680,6 +687,7 @@ struct omap_hwmod {
        u8                              _int_flags;
        u8                              _state;
        u8                              _postsetup_state;
+       struct omap_hwmod               *parent_hwmod;
 };
 
 struct omap_hwmod *omap_hwmod_lookup(const char *name);