All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking
@ 2012-04-27 20:05 ` Kevin Hilman
  0 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: Paul Walmsley, linux-omap; +Cc: linux-arm-kernel

This series attempts to remove all the runtime cpu_is* checking in
omap_hwmod.c in favor of using function pointers initialized at init
time.

This series was motivated by the addition of support for the AM335x
series which was done by adding several more cpu_is* checks, and
provided the proverbial straw that broke the camel's back.  

In addition to the cleanup, this provides a much cleaner way of adding
additional SoC support since it no longer requires adding additional
runtime cpu_is* checks.

Boot tested on OMAP3530/Overo and OMAP4430/Panda.

Kevin Hilman (6):
  ARM: OMAP4: hwmod: rename _enable_module to _omap4_enable_module()
  ARM: OMAP2+: hwmod: use init-time function ptrs for enable/disable
    module
  ARM: OMAP4: hwmod: drop extra cpu_is check from
    _wait_target_disable()
  ARM: OMAP2+: hwmod: use init-time function pointer for
    wait_target_ready
  ARM: OMAP2+: hwmod: use init-time function pointer for hardreset
  ARM: OMAP2+: hwmod: use init-time function pointer for _init_clkdm

 arch/arm/mach-omap2/omap_hwmod.c             |  192 +++++++++++++++-----------
 arch/arm/plat-omap/include/plat/omap_hwmod.h |   11 ++
 2 files changed, 126 insertions(+), 77 deletions(-)

-- 
1.7.9.2

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking
@ 2012-04-27 20:05 ` Kevin Hilman
  0 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: linux-arm-kernel

This series attempts to remove all the runtime cpu_is* checking in
omap_hwmod.c in favor of using function pointers initialized at init
time.

This series was motivated by the addition of support for the AM335x
series which was done by adding several more cpu_is* checks, and
provided the proverbial straw that broke the camel's back.  

In addition to the cleanup, this provides a much cleaner way of adding
additional SoC support since it no longer requires adding additional
runtime cpu_is* checks.

Boot tested on OMAP3530/Overo and OMAP4430/Panda.

Kevin Hilman (6):
  ARM: OMAP4: hwmod: rename _enable_module to _omap4_enable_module()
  ARM: OMAP2+: hwmod: use init-time function ptrs for enable/disable
    module
  ARM: OMAP4: hwmod: drop extra cpu_is check from
    _wait_target_disable()
  ARM: OMAP2+: hwmod: use init-time function pointer for
    wait_target_ready
  ARM: OMAP2+: hwmod: use init-time function pointer for hardreset
  ARM: OMAP2+: hwmod: use init-time function pointer for _init_clkdm

 arch/arm/mach-omap2/omap_hwmod.c             |  192 +++++++++++++++-----------
 arch/arm/plat-omap/include/plat/omap_hwmod.h |   11 ++
 2 files changed, 126 insertions(+), 77 deletions(-)

-- 
1.7.9.2

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 1/6] ARM: OMAP4: hwmod: rename _enable_module to _omap4_enable_module()
  2012-04-27 20:05 ` Kevin Hilman
@ 2012-04-27 20:05   ` Kevin Hilman
  -1 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: Paul Walmsley, linux-omap; +Cc: linux-arm-kernel

_enable_module is specific to OMAP4-class SoCs, so rename it to
be consistend with the corresponding _omap4_disable_module.

Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index bf86f7e..939032a 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -771,13 +771,13 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
 }
 
 /**
- * _enable_module - enable CLKCTRL modulemode on OMAP4
+ * _omap4_enable_module - enable CLKCTRL modulemode on OMAP4
  * @oh: struct omap_hwmod *
  *
  * Enables the PRCM module mode related to the hwmod @oh.
  * No return value.
  */
-static void _enable_module(struct omap_hwmod *oh)
+static void _omap4_enable_module(struct omap_hwmod *oh)
 {
 	/* The module mode does not exist prior OMAP4 */
 	if (cpu_is_omap24xx() || cpu_is_omap34xx())
@@ -786,8 +786,8 @@ static void _enable_module(struct omap_hwmod *oh)
 	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
 		return;
 
-	pr_debug("omap_hwmod: %s: _enable_module: %d\n",
-		 oh->name, oh->prcm.omap4.modulemode);
+	pr_debug("omap_hwmod: %s: %s: %d\n",
+		 oh->name, __func__, oh->prcm.omap4.modulemode);
 
 	omap4_cminst_module_enable(oh->prcm.omap4.modulemode,
 				   oh->clkdm->prcm_partition,
@@ -1814,7 +1814,7 @@ static int _enable(struct omap_hwmod *oh)
 	}
 
 	_enable_clocks(oh);
-	_enable_module(oh);
+	_omap4_enable_module(oh);
 
 	r = _wait_target_ready(oh);
 	if (!r) {
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 1/6] ARM: OMAP4: hwmod: rename _enable_module to _omap4_enable_module()
@ 2012-04-27 20:05   ` Kevin Hilman
  0 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: linux-arm-kernel

_enable_module is specific to OMAP4-class SoCs, so rename it to
be consistend with the corresponding _omap4_disable_module.

Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index bf86f7e..939032a 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -771,13 +771,13 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
 }
 
 /**
- * _enable_module - enable CLKCTRL modulemode on OMAP4
+ * _omap4_enable_module - enable CLKCTRL modulemode on OMAP4
  * @oh: struct omap_hwmod *
  *
  * Enables the PRCM module mode related to the hwmod @oh.
  * No return value.
  */
-static void _enable_module(struct omap_hwmod *oh)
+static void _omap4_enable_module(struct omap_hwmod *oh)
 {
 	/* The module mode does not exist prior OMAP4 */
 	if (cpu_is_omap24xx() || cpu_is_omap34xx())
@@ -786,8 +786,8 @@ static void _enable_module(struct omap_hwmod *oh)
 	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
 		return;
 
-	pr_debug("omap_hwmod: %s: _enable_module: %d\n",
-		 oh->name, oh->prcm.omap4.modulemode);
+	pr_debug("omap_hwmod: %s: %s: %d\n",
+		 oh->name, __func__, oh->prcm.omap4.modulemode);
 
 	omap4_cminst_module_enable(oh->prcm.omap4.modulemode,
 				   oh->clkdm->prcm_partition,
@@ -1814,7 +1814,7 @@ static int _enable(struct omap_hwmod *oh)
 	}
 
 	_enable_clocks(oh);
-	_enable_module(oh);
+	_omap4_enable_module(oh);
 
 	r = _wait_target_ready(oh);
 	if (!r) {
-- 
1.7.9.2

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 2/6] ARM: OMAP2+: hwmod: use init-time function ptrs for enable/disable module
  2012-04-27 20:05 ` Kevin Hilman
@ 2012-04-27 20:05   ` Kevin Hilman
  -1 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: Paul Walmsley, linux-omap; +Cc: linux-arm-kernel

The enable/disable module functions are specific to SoCs with
OMAP4-class PRCM.  Rather than use cpu_is* checks at runtime inside
the enable/disable module functions, use cpu_is at init time to
initialize function pointers only for SoCs that need them.

NOTE: the cpu_is* check for _enable_module was different than
      the one for _disable_module, and this patch uses
      cpu_is_omap44xx() for both.

Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |   22 +++++++++++-----------
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    3 +++
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 939032a..a978350 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -779,10 +779,6 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
  */
 static void _omap4_enable_module(struct omap_hwmod *oh)
 {
-	/* The module mode does not exist prior OMAP4 */
-	if (cpu_is_omap24xx() || cpu_is_omap34xx())
-		return;
-
 	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
 		return;
 
@@ -1571,10 +1567,6 @@ static int _omap4_disable_module(struct omap_hwmod *oh)
 {
 	int v;
 
-	/* The module mode does not exist prior OMAP4 */
-	if (!cpu_is_omap44xx())
-		return -EINVAL;
-
 	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
 		return -EINVAL;
 
@@ -1814,7 +1806,8 @@ static int _enable(struct omap_hwmod *oh)
 	}
 
 	_enable_clocks(oh);
-	_omap4_enable_module(oh);
+	if (oh->enable_module)
+		oh->enable_module(oh);
 
 	r = _wait_target_ready(oh);
 	if (!r) {
@@ -1870,7 +1863,8 @@ static int _idle(struct omap_hwmod *oh)
 		_idle_sysc(oh);
 	_del_initiator_dep(oh, mpu_oh);
 
-	_omap4_disable_module(oh);
+	if (oh->disable_module)
+		oh->disable_module(oh);
 
 	/*
 	 * The module must be in idle mode before disabling any parents
@@ -1975,7 +1969,8 @@ static int _shutdown(struct omap_hwmod *oh)
 	if (oh->_state == _HWMOD_STATE_ENABLED) {
 		_del_initiator_dep(oh, mpu_oh);
 		/* XXX what about the other system initiators here? dma, dsp */
-		_omap4_disable_module(oh);
+		if (oh->disable_module)
+			oh->disable_module(oh);
 		_disable_clocks(oh);
 		if (oh->clkdm)
 			clkdm_hwmod_disable(oh->clkdm, oh);
@@ -2063,6 +2058,11 @@ static int __init _init(struct omap_hwmod *oh, void *data)
 		return -EINVAL;
 	}
 
+	if (cpu_is_omap44xx()) {
+		oh->enable_module = _omap4_enable_module;
+		oh->disable_module = _omap4_disable_module;
+	}
+
 	oh->_state = _HWMOD_STATE_INITIALIZED;
 
 	return 0;
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 14dde32..0dbe8cf 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -564,6 +564,9 @@ struct omap_hwmod {
 	u8				_int_flags;
 	u8				_state;
 	u8				_postsetup_state;
+
+	void (*enable_module)(struct omap_hwmod *oh);
+	int (*disable_module)(struct omap_hwmod *oh);
 };
 
 struct omap_hwmod *omap_hwmod_lookup(const char *name);
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 2/6] ARM: OMAP2+: hwmod: use init-time function ptrs for enable/disable module
@ 2012-04-27 20:05   ` Kevin Hilman
  0 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: linux-arm-kernel

The enable/disable module functions are specific to SoCs with
OMAP4-class PRCM.  Rather than use cpu_is* checks at runtime inside
the enable/disable module functions, use cpu_is at init time to
initialize function pointers only for SoCs that need them.

NOTE: the cpu_is* check for _enable_module was different than
      the one for _disable_module, and this patch uses
      cpu_is_omap44xx() for both.

Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |   22 +++++++++++-----------
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    3 +++
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 939032a..a978350 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -779,10 +779,6 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
  */
 static void _omap4_enable_module(struct omap_hwmod *oh)
 {
-	/* The module mode does not exist prior OMAP4 */
-	if (cpu_is_omap24xx() || cpu_is_omap34xx())
-		return;
-
 	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
 		return;
 
@@ -1571,10 +1567,6 @@ static int _omap4_disable_module(struct omap_hwmod *oh)
 {
 	int v;
 
-	/* The module mode does not exist prior OMAP4 */
-	if (!cpu_is_omap44xx())
-		return -EINVAL;
-
 	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
 		return -EINVAL;
 
@@ -1814,7 +1806,8 @@ static int _enable(struct omap_hwmod *oh)
 	}
 
 	_enable_clocks(oh);
-	_omap4_enable_module(oh);
+	if (oh->enable_module)
+		oh->enable_module(oh);
 
 	r = _wait_target_ready(oh);
 	if (!r) {
@@ -1870,7 +1863,8 @@ static int _idle(struct omap_hwmod *oh)
 		_idle_sysc(oh);
 	_del_initiator_dep(oh, mpu_oh);
 
-	_omap4_disable_module(oh);
+	if (oh->disable_module)
+		oh->disable_module(oh);
 
 	/*
 	 * The module must be in idle mode before disabling any parents
@@ -1975,7 +1969,8 @@ static int _shutdown(struct omap_hwmod *oh)
 	if (oh->_state == _HWMOD_STATE_ENABLED) {
 		_del_initiator_dep(oh, mpu_oh);
 		/* XXX what about the other system initiators here? dma, dsp */
-		_omap4_disable_module(oh);
+		if (oh->disable_module)
+			oh->disable_module(oh);
 		_disable_clocks(oh);
 		if (oh->clkdm)
 			clkdm_hwmod_disable(oh->clkdm, oh);
@@ -2063,6 +2058,11 @@ static int __init _init(struct omap_hwmod *oh, void *data)
 		return -EINVAL;
 	}
 
+	if (cpu_is_omap44xx()) {
+		oh->enable_module = _omap4_enable_module;
+		oh->disable_module = _omap4_disable_module;
+	}
+
 	oh->_state = _HWMOD_STATE_INITIALIZED;
 
 	return 0;
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 14dde32..0dbe8cf 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -564,6 +564,9 @@ struct omap_hwmod {
 	u8				_int_flags;
 	u8				_state;
 	u8				_postsetup_state;
+
+	void (*enable_module)(struct omap_hwmod *oh);
+	int (*disable_module)(struct omap_hwmod *oh);
 };
 
 struct omap_hwmod *omap_hwmod_lookup(const char *name);
-- 
1.7.9.2

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 3/6] ARM: OMAP4: hwmod: drop extra cpu_is check from _wait_target_disable()
  2012-04-27 20:05 ` Kevin Hilman
@ 2012-04-27 20:05   ` Kevin Hilman
  -1 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: Paul Walmsley, linux-omap; +Cc: linux-arm-kernel

_omap4_wait_target_disable() is called only from inside _omap4_disable_module()
which is already protected by SoC specific checks.  Remove the cpu_is check
here.

Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index a978350..3641b0a 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -803,9 +803,6 @@ static void _omap4_enable_module(struct omap_hwmod *oh)
  */
 static int _omap4_wait_target_disable(struct omap_hwmod *oh)
 {
-	if (!cpu_is_omap44xx())
-		return 0;
-
 	if (!oh)
 		return -EINVAL;
 
-- 
1.7.9.2

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 3/6] ARM: OMAP4: hwmod: drop extra cpu_is check from _wait_target_disable()
@ 2012-04-27 20:05   ` Kevin Hilman
  0 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: linux-arm-kernel

_omap4_wait_target_disable() is called only from inside _omap4_disable_module()
which is already protected by SoC specific checks.  Remove the cpu_is check
here.

Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index a978350..3641b0a 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -803,9 +803,6 @@ static void _omap4_enable_module(struct omap_hwmod *oh)
  */
 static int _omap4_wait_target_disable(struct omap_hwmod *oh)
 {
-	if (!cpu_is_omap44xx())
-		return 0;
-
 	if (!oh)
 		return -EINVAL;
 
-- 
1.7.9.2

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 4/6] ARM: OMAP2+: hwmod: use init-time function pointer for wait_target_ready
  2012-04-27 20:05 ` Kevin Hilman
@ 2012-04-27 20:05   ` Kevin Hilman
  -1 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: Paul Walmsley, linux-omap; +Cc: linux-arm-kernel

Rather than using cpu_is* checking at runtime, initialize an SoC specific
function pointer for wait_target_ready().

While here, downgrade the BUG() to a WARN_ON() so it gives a noisy
warning instead of causing a kernel panic.

Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |   43 ++++++++++++++++----------
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    1 +
 2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 3641b0a..6dd454d 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1341,6 +1341,24 @@ static int _init_clocks(struct omap_hwmod *oh, void *data)
 	return ret;
 }
 
+static int omap2_wait_module_ready(struct omap_hwmod *oh)
+{
+	return omap2_cm_wait_module_ready(oh->prcm.omap2.module_offs,
+					  oh->prcm.omap2.idlest_reg_id,
+					  oh->prcm.omap2.idlest_idle_bit);
+}
+
+static int omap4_wait_module_ready(struct omap_hwmod *oh)
+{
+	if (!oh->clkdm)
+		return -EINVAL;
+
+	return omap4_cminst_wait_module_ready(oh->clkdm->prcm_partition,
+					      oh->clkdm->cm_inst,
+					      oh->clkdm->clkdm_offs,
+					      oh->prcm.omap4.clkctrl_offs);
+}
+
 /**
  * _wait_target_ready - wait for a module to leave slave idle
  * @oh: struct omap_hwmod *
@@ -1353,7 +1371,7 @@ static int _init_clocks(struct omap_hwmod *oh, void *data)
 static int _wait_target_ready(struct omap_hwmod *oh)
 {
 	struct omap_hwmod_ocp_if *os;
-	int ret;
+	int ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
@@ -1369,21 +1387,9 @@ static int _wait_target_ready(struct omap_hwmod *oh)
 
 	/* XXX check clock enable states */
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-		ret = omap2_cm_wait_module_ready(oh->prcm.omap2.module_offs,
-						 oh->prcm.omap2.idlest_reg_id,
-						 oh->prcm.omap2.idlest_idle_bit);
-	} else if (cpu_is_omap44xx()) {
-		if (!oh->clkdm)
-			return -EINVAL;
-
-		ret = omap4_cminst_wait_module_ready(oh->clkdm->prcm_partition,
-						     oh->clkdm->cm_inst,
-						     oh->clkdm->clkdm_offs,
-						     oh->prcm.omap4.clkctrl_offs);
-	} else {
-		BUG();
-	};
+	WARN_ON(!oh->wait_module_ready);
+	if (oh->wait_module_ready)
+		ret = oh->wait_module_ready(oh);
 
 	return ret;
 }
@@ -2055,9 +2061,12 @@ static int __init _init(struct omap_hwmod *oh, void *data)
 		return -EINVAL;
 	}
 
-	if (cpu_is_omap44xx()) {
+	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
+		oh->wait_module_ready = omap2_wait_module_ready;
+	} else if (cpu_is_omap44xx()) {
 		oh->enable_module = _omap4_enable_module;
 		oh->disable_module = _omap4_disable_module;
+		oh->wait_module_ready = omap4_wait_module_ready;
 	}
 
 	oh->_state = _HWMOD_STATE_INITIALIZED;
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 0dbe8cf..329ede5 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -567,6 +567,7 @@ struct omap_hwmod {
 
 	void (*enable_module)(struct omap_hwmod *oh);
 	int (*disable_module)(struct omap_hwmod *oh);
+	int (*wait_module_ready)(struct omap_hwmod *oh);
 };
 
 struct omap_hwmod *omap_hwmod_lookup(const char *name);
-- 
1.7.9.2

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 4/6] ARM: OMAP2+: hwmod: use init-time function pointer for wait_target_ready
@ 2012-04-27 20:05   ` Kevin Hilman
  0 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: linux-arm-kernel

Rather than using cpu_is* checking at runtime, initialize an SoC specific
function pointer for wait_target_ready().

While here, downgrade the BUG() to a WARN_ON() so it gives a noisy
warning instead of causing a kernel panic.

Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |   43 ++++++++++++++++----------
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    1 +
 2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 3641b0a..6dd454d 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1341,6 +1341,24 @@ static int _init_clocks(struct omap_hwmod *oh, void *data)
 	return ret;
 }
 
+static int omap2_wait_module_ready(struct omap_hwmod *oh)
+{
+	return omap2_cm_wait_module_ready(oh->prcm.omap2.module_offs,
+					  oh->prcm.omap2.idlest_reg_id,
+					  oh->prcm.omap2.idlest_idle_bit);
+}
+
+static int omap4_wait_module_ready(struct omap_hwmod *oh)
+{
+	if (!oh->clkdm)
+		return -EINVAL;
+
+	return omap4_cminst_wait_module_ready(oh->clkdm->prcm_partition,
+					      oh->clkdm->cm_inst,
+					      oh->clkdm->clkdm_offs,
+					      oh->prcm.omap4.clkctrl_offs);
+}
+
 /**
  * _wait_target_ready - wait for a module to leave slave idle
  * @oh: struct omap_hwmod *
@@ -1353,7 +1371,7 @@ static int _init_clocks(struct omap_hwmod *oh, void *data)
 static int _wait_target_ready(struct omap_hwmod *oh)
 {
 	struct omap_hwmod_ocp_if *os;
-	int ret;
+	int ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
@@ -1369,21 +1387,9 @@ static int _wait_target_ready(struct omap_hwmod *oh)
 
 	/* XXX check clock enable states */
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-		ret = omap2_cm_wait_module_ready(oh->prcm.omap2.module_offs,
-						 oh->prcm.omap2.idlest_reg_id,
-						 oh->prcm.omap2.idlest_idle_bit);
-	} else if (cpu_is_omap44xx()) {
-		if (!oh->clkdm)
-			return -EINVAL;
-
-		ret = omap4_cminst_wait_module_ready(oh->clkdm->prcm_partition,
-						     oh->clkdm->cm_inst,
-						     oh->clkdm->clkdm_offs,
-						     oh->prcm.omap4.clkctrl_offs);
-	} else {
-		BUG();
-	};
+	WARN_ON(!oh->wait_module_ready);
+	if (oh->wait_module_ready)
+		ret = oh->wait_module_ready(oh);
 
 	return ret;
 }
@@ -2055,9 +2061,12 @@ static int __init _init(struct omap_hwmod *oh, void *data)
 		return -EINVAL;
 	}
 
-	if (cpu_is_omap44xx()) {
+	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
+		oh->wait_module_ready = omap2_wait_module_ready;
+	} else if (cpu_is_omap44xx()) {
 		oh->enable_module = _omap4_enable_module;
 		oh->disable_module = _omap4_disable_module;
+		oh->wait_module_ready = omap4_wait_module_ready;
 	}
 
 	oh->_state = _HWMOD_STATE_INITIALIZED;
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 0dbe8cf..329ede5 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -567,6 +567,7 @@ struct omap_hwmod {
 
 	void (*enable_module)(struct omap_hwmod *oh);
 	int (*disable_module)(struct omap_hwmod *oh);
+	int (*wait_module_ready)(struct omap_hwmod *oh);
 };
 
 struct omap_hwmod *omap_hwmod_lookup(const char *name);
-- 
1.7.9.2

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 5/6] ARM: OMAP2+: hwmod: use init-time function pointer for hardreset
  2012-04-27 20:05 ` Kevin Hilman
@ 2012-04-27 20:05   ` Kevin Hilman
  -1 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: Paul Walmsley, linux-omap; +Cc: linux-arm-kernel

Rather than using cpu_is* checking at runtime, initialize SoC specific
function pointers for the various hard reset functions at init time.

Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |  111 +++++++++++++++++---------
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    6 ++
 2 files changed, 78 insertions(+), 39 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 6dd454d..6b08f19 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1424,6 +1424,59 @@ static u8 _lookup_hardreset(struct omap_hwmod *oh, const char *name,
 	return -ENOENT;
 }
 
+static int omap2_assert_hardreset(struct omap_hwmod *oh,
+				  struct omap_hwmod_rst_info *ohri)
+{
+	return omap2_prm_assert_hardreset(oh->prcm.omap2.module_offs,
+					  ohri->rst_shift);
+}
+
+static int omap2_deassert_hardreset(struct omap_hwmod *oh,
+				    struct omap_hwmod_rst_info *ohri)
+{
+	return omap2_prm_deassert_hardreset(oh->prcm.omap2.module_offs,
+					    ohri->rst_shift,
+					    ohri->st_shift);
+}
+
+static int omap2_is_hardreset_asserted(struct omap_hwmod *oh,
+				       struct omap_hwmod_rst_info *ohri)
+{
+	return omap2_prm_is_hardreset_asserted(oh->prcm.omap2.module_offs,
+					       ohri->st_shift);
+}
+
+static int omap4_assert_hardreset(struct omap_hwmod *oh,
+				  struct omap_hwmod_rst_info *ohri)
+
+{
+	return omap4_prminst_assert_hardreset(ohri->rst_shift,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.rstctrl_offs);
+}
+
+static int omap4_deassert_hardreset(struct omap_hwmod *oh,
+				    struct omap_hwmod_rst_info *ohri)
+{
+	if (ohri->st_shift)
+		pr_err("omap_hwmod: %s: %s: hwmod data error: OMAP4 does not support st_shift\n",
+		       oh->name, ohri->name);
+	return omap4_prminst_deassert_hardreset(ohri->rst_shift,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.rstctrl_offs);
+}
+
+static int omap4_is_hardreset_asserted(struct omap_hwmod *oh,
+				       struct omap_hwmod_rst_info *ohri)
+{
+	return omap4_prminst_is_hardreset_asserted(ohri->rst_shift,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.rstctrl_offs);
+}
+
 /**
  * _assert_hardreset - assert the HW reset line of submodules
  * contained in the hwmod module.
@@ -1437,7 +1490,7 @@ static u8 _lookup_hardreset(struct omap_hwmod *oh, const char *name,
 static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
 {
 	struct omap_hwmod_rst_info ohri;
-	u8 ret;
+	u8 ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
@@ -1446,16 +1499,10 @@ static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
 	if (IS_ERR_VALUE(ret))
 		return ret;
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx())
-		return omap2_prm_assert_hardreset(oh->prcm.omap2.module_offs,
-						  ohri.rst_shift);
-	else if (cpu_is_omap44xx())
-		return omap4_prminst_assert_hardreset(ohri.rst_shift,
-				  oh->clkdm->pwrdm.ptr->prcm_partition,
-				  oh->clkdm->pwrdm.ptr->prcm_offs,
-				  oh->prcm.omap4.rstctrl_offs);
-	else
-		return -EINVAL;
+	if (oh->assert_hardreset)
+		ret = oh->assert_hardreset(oh, &ohri);
+
+	return ret;
 }
 
 /**
@@ -1471,7 +1518,7 @@ static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
 static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
 {
 	struct omap_hwmod_rst_info ohri;
-	int ret;
+	int ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
@@ -1480,21 +1527,8 @@ static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
 	if (IS_ERR_VALUE(ret))
 		return ret;
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-		ret = omap2_prm_deassert_hardreset(oh->prcm.omap2.module_offs,
-						   ohri.rst_shift,
-						   ohri.st_shift);
-	} else if (cpu_is_omap44xx()) {
-		if (ohri.st_shift)
-			pr_err("omap_hwmod: %s: %s: hwmod data error: OMAP4 does not support st_shift\n",
-			       oh->name, name);
-		ret = omap4_prminst_deassert_hardreset(ohri.rst_shift,
-				  oh->clkdm->pwrdm.ptr->prcm_partition,
-				  oh->clkdm->pwrdm.ptr->prcm_offs,
-				  oh->prcm.omap4.rstctrl_offs);
-	} else {
-		return -EINVAL;
-	}
+	if (oh->deassert_hardreset)
+		ret = oh->deassert_hardreset(oh, &ohri);
 
 	if (ret == -EBUSY)
 		pr_warning("omap_hwmod: %s: failed to hardreset\n", oh->name);
@@ -1513,7 +1547,7 @@ static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
 static int _read_hardreset(struct omap_hwmod *oh, const char *name)
 {
 	struct omap_hwmod_rst_info ohri;
-	u8 ret;
+	u8 ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
@@ -1522,17 +1556,10 @@ static int _read_hardreset(struct omap_hwmod *oh, const char *name)
 	if (IS_ERR_VALUE(ret))
 		return ret;
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-		return omap2_prm_is_hardreset_asserted(oh->prcm.omap2.module_offs,
-						       ohri.st_shift);
-	} else if (cpu_is_omap44xx()) {
-		return omap4_prminst_is_hardreset_asserted(ohri.rst_shift,
-				  oh->clkdm->pwrdm.ptr->prcm_partition,
-				  oh->clkdm->pwrdm.ptr->prcm_offs,
-				  oh->prcm.omap4.rstctrl_offs);
-	} else {
-		return -EINVAL;
-	}
+	if (oh->is_hardreset_asserted)
+		ret = oh->is_hardreset_asserted(oh, &ohri);
+
+	return ret;
 }
 
 /**
@@ -2063,10 +2090,16 @@ static int __init _init(struct omap_hwmod *oh, void *data)
 
 	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
 		oh->wait_module_ready = omap2_wait_module_ready;
+		oh->assert_hardreset = omap2_assert_hardreset;
+		oh->deassert_hardreset = omap2_deassert_hardreset;
+		oh->is_hardreset_asserted = omap2_is_hardreset_asserted;
 	} else if (cpu_is_omap44xx()) {
 		oh->enable_module = _omap4_enable_module;
 		oh->disable_module = _omap4_disable_module;
 		oh->wait_module_ready = omap4_wait_module_ready;
+		oh->assert_hardreset = omap4_assert_hardreset;
+		oh->deassert_hardreset = omap4_deassert_hardreset;
+		oh->is_hardreset_asserted = omap4_is_hardreset_asserted;
 	}
 
 	oh->_state = _HWMOD_STATE_INITIALIZED;
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 329ede5..4f512b6 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -568,6 +568,12 @@ struct omap_hwmod {
 	void (*enable_module)(struct omap_hwmod *oh);
 	int (*disable_module)(struct omap_hwmod *oh);
 	int (*wait_module_ready)(struct omap_hwmod *oh);
+	int (*assert_hardreset)(struct omap_hwmod *oh,
+				struct omap_hwmod_rst_info *ohri);
+	int (*deassert_hardreset)(struct omap_hwmod *oh,
+				  struct omap_hwmod_rst_info *ohri);
+	int (*is_hardreset_asserted)(struct omap_hwmod *oh,
+				     struct omap_hwmod_rst_info *ohri);
 };
 
 struct omap_hwmod *omap_hwmod_lookup(const char *name);
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 5/6] ARM: OMAP2+: hwmod: use init-time function pointer for hardreset
@ 2012-04-27 20:05   ` Kevin Hilman
  0 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: linux-arm-kernel

Rather than using cpu_is* checking at runtime, initialize SoC specific
function pointers for the various hard reset functions at init time.

Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |  111 +++++++++++++++++---------
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    6 ++
 2 files changed, 78 insertions(+), 39 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 6dd454d..6b08f19 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1424,6 +1424,59 @@ static u8 _lookup_hardreset(struct omap_hwmod *oh, const char *name,
 	return -ENOENT;
 }
 
+static int omap2_assert_hardreset(struct omap_hwmod *oh,
+				  struct omap_hwmod_rst_info *ohri)
+{
+	return omap2_prm_assert_hardreset(oh->prcm.omap2.module_offs,
+					  ohri->rst_shift);
+}
+
+static int omap2_deassert_hardreset(struct omap_hwmod *oh,
+				    struct omap_hwmod_rst_info *ohri)
+{
+	return omap2_prm_deassert_hardreset(oh->prcm.omap2.module_offs,
+					    ohri->rst_shift,
+					    ohri->st_shift);
+}
+
+static int omap2_is_hardreset_asserted(struct omap_hwmod *oh,
+				       struct omap_hwmod_rst_info *ohri)
+{
+	return omap2_prm_is_hardreset_asserted(oh->prcm.omap2.module_offs,
+					       ohri->st_shift);
+}
+
+static int omap4_assert_hardreset(struct omap_hwmod *oh,
+				  struct omap_hwmod_rst_info *ohri)
+
+{
+	return omap4_prminst_assert_hardreset(ohri->rst_shift,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.rstctrl_offs);
+}
+
+static int omap4_deassert_hardreset(struct omap_hwmod *oh,
+				    struct omap_hwmod_rst_info *ohri)
+{
+	if (ohri->st_shift)
+		pr_err("omap_hwmod: %s: %s: hwmod data error: OMAP4 does not support st_shift\n",
+		       oh->name, ohri->name);
+	return omap4_prminst_deassert_hardreset(ohri->rst_shift,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.rstctrl_offs);
+}
+
+static int omap4_is_hardreset_asserted(struct omap_hwmod *oh,
+				       struct omap_hwmod_rst_info *ohri)
+{
+	return omap4_prminst_is_hardreset_asserted(ohri->rst_shift,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.rstctrl_offs);
+}
+
 /**
  * _assert_hardreset - assert the HW reset line of submodules
  * contained in the hwmod module.
@@ -1437,7 +1490,7 @@ static u8 _lookup_hardreset(struct omap_hwmod *oh, const char *name,
 static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
 {
 	struct omap_hwmod_rst_info ohri;
-	u8 ret;
+	u8 ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
@@ -1446,16 +1499,10 @@ static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
 	if (IS_ERR_VALUE(ret))
 		return ret;
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx())
-		return omap2_prm_assert_hardreset(oh->prcm.omap2.module_offs,
-						  ohri.rst_shift);
-	else if (cpu_is_omap44xx())
-		return omap4_prminst_assert_hardreset(ohri.rst_shift,
-				  oh->clkdm->pwrdm.ptr->prcm_partition,
-				  oh->clkdm->pwrdm.ptr->prcm_offs,
-				  oh->prcm.omap4.rstctrl_offs);
-	else
-		return -EINVAL;
+	if (oh->assert_hardreset)
+		ret = oh->assert_hardreset(oh, &ohri);
+
+	return ret;
 }
 
 /**
@@ -1471,7 +1518,7 @@ static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
 static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
 {
 	struct omap_hwmod_rst_info ohri;
-	int ret;
+	int ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
@@ -1480,21 +1527,8 @@ static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
 	if (IS_ERR_VALUE(ret))
 		return ret;
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-		ret = omap2_prm_deassert_hardreset(oh->prcm.omap2.module_offs,
-						   ohri.rst_shift,
-						   ohri.st_shift);
-	} else if (cpu_is_omap44xx()) {
-		if (ohri.st_shift)
-			pr_err("omap_hwmod: %s: %s: hwmod data error: OMAP4 does not support st_shift\n",
-			       oh->name, name);
-		ret = omap4_prminst_deassert_hardreset(ohri.rst_shift,
-				  oh->clkdm->pwrdm.ptr->prcm_partition,
-				  oh->clkdm->pwrdm.ptr->prcm_offs,
-				  oh->prcm.omap4.rstctrl_offs);
-	} else {
-		return -EINVAL;
-	}
+	if (oh->deassert_hardreset)
+		ret = oh->deassert_hardreset(oh, &ohri);
 
 	if (ret == -EBUSY)
 		pr_warning("omap_hwmod: %s: failed to hardreset\n", oh->name);
@@ -1513,7 +1547,7 @@ static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
 static int _read_hardreset(struct omap_hwmod *oh, const char *name)
 {
 	struct omap_hwmod_rst_info ohri;
-	u8 ret;
+	u8 ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
@@ -1522,17 +1556,10 @@ static int _read_hardreset(struct omap_hwmod *oh, const char *name)
 	if (IS_ERR_VALUE(ret))
 		return ret;
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-		return omap2_prm_is_hardreset_asserted(oh->prcm.omap2.module_offs,
-						       ohri.st_shift);
-	} else if (cpu_is_omap44xx()) {
-		return omap4_prminst_is_hardreset_asserted(ohri.rst_shift,
-				  oh->clkdm->pwrdm.ptr->prcm_partition,
-				  oh->clkdm->pwrdm.ptr->prcm_offs,
-				  oh->prcm.omap4.rstctrl_offs);
-	} else {
-		return -EINVAL;
-	}
+	if (oh->is_hardreset_asserted)
+		ret = oh->is_hardreset_asserted(oh, &ohri);
+
+	return ret;
 }
 
 /**
@@ -2063,10 +2090,16 @@ static int __init _init(struct omap_hwmod *oh, void *data)
 
 	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
 		oh->wait_module_ready = omap2_wait_module_ready;
+		oh->assert_hardreset = omap2_assert_hardreset;
+		oh->deassert_hardreset = omap2_deassert_hardreset;
+		oh->is_hardreset_asserted = omap2_is_hardreset_asserted;
 	} else if (cpu_is_omap44xx()) {
 		oh->enable_module = _omap4_enable_module;
 		oh->disable_module = _omap4_disable_module;
 		oh->wait_module_ready = omap4_wait_module_ready;
+		oh->assert_hardreset = omap4_assert_hardreset;
+		oh->deassert_hardreset = omap4_deassert_hardreset;
+		oh->is_hardreset_asserted = omap4_is_hardreset_asserted;
 	}
 
 	oh->_state = _HWMOD_STATE_INITIALIZED;
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 329ede5..4f512b6 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -568,6 +568,12 @@ struct omap_hwmod {
 	void (*enable_module)(struct omap_hwmod *oh);
 	int (*disable_module)(struct omap_hwmod *oh);
 	int (*wait_module_ready)(struct omap_hwmod *oh);
+	int (*assert_hardreset)(struct omap_hwmod *oh,
+				struct omap_hwmod_rst_info *ohri);
+	int (*deassert_hardreset)(struct omap_hwmod *oh,
+				  struct omap_hwmod_rst_info *ohri);
+	int (*is_hardreset_asserted)(struct omap_hwmod *oh,
+				     struct omap_hwmod_rst_info *ohri);
 };
 
 struct omap_hwmod *omap_hwmod_lookup(const char *name);
-- 
1.7.9.2

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 6/6] ARM: OMAP2+: hwmod: use init-time function pointer for _init_clkdm
  2012-04-27 20:05 ` Kevin Hilman
@ 2012-04-27 20:05   ` Kevin Hilman
  -1 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: Paul Walmsley, linux-omap; +Cc: linux-arm-kernel

Rather than use runtime cpu_is* checking inside _init_clkdm, initialize
SoC specific function pointer at init time.

Note that initializing the function pointer oh->init_clkdm pointer
must be done before _init_clocks() is called because it is used there.

Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |   19 +++++++++----------
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    1 +
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 6b08f19..e7d95e6 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1288,9 +1288,6 @@ static struct omap_hwmod *_lookup(const char *name)
  */
 static int _init_clkdm(struct omap_hwmod *oh)
 {
-	if (cpu_is_omap24xx() || cpu_is_omap34xx())
-		return 0;
-
 	if (!oh->clkdm_name) {
 		pr_warning("omap_hwmod: %s: no clkdm_name\n", oh->name);
 		return -EINVAL;
@@ -1331,7 +1328,8 @@ static int _init_clocks(struct omap_hwmod *oh, void *data)
 	ret |= _init_main_clk(oh);
 	ret |= _init_interface_clks(oh);
 	ret |= _init_opt_clks(oh);
-	ret |= _init_clkdm(oh);
+	if (oh->init_clkdm)
+		ret |= oh->init_clkdm(oh);
 
 	if (!ret)
 		oh->_state = _HWMOD_STATE_CLKS_INITED;
@@ -2082,12 +2080,6 @@ static int __init _init(struct omap_hwmod *oh, void *data)
 
 	_init_mpu_rt_base(oh, NULL);
 
-	r = _init_clocks(oh, NULL);
-	if (IS_ERR_VALUE(r)) {
-		WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name);
-		return -EINVAL;
-	}
-
 	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
 		oh->wait_module_ready = omap2_wait_module_ready;
 		oh->assert_hardreset = omap2_assert_hardreset;
@@ -2100,6 +2092,13 @@ static int __init _init(struct omap_hwmod *oh, void *data)
 		oh->assert_hardreset = omap4_assert_hardreset;
 		oh->deassert_hardreset = omap4_deassert_hardreset;
 		oh->is_hardreset_asserted = omap4_is_hardreset_asserted;
+		oh->init_clkdm = _init_clkdm;
+	}
+
+	r = _init_clocks(oh, NULL);
+	if (IS_ERR_VALUE(r)) {
+		WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name);
+		return -EINVAL;
 	}
 
 	oh->_state = _HWMOD_STATE_INITIALIZED;
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 4f512b6..6c10e08 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -574,6 +574,7 @@ struct omap_hwmod {
 				  struct omap_hwmod_rst_info *ohri);
 	int (*is_hardreset_asserted)(struct omap_hwmod *oh,
 				     struct omap_hwmod_rst_info *ohri);
+	int (*init_clkdm)(struct omap_hwmod *oh);
 };
 
 struct omap_hwmod *omap_hwmod_lookup(const char *name);
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 6/6] ARM: OMAP2+: hwmod: use init-time function pointer for _init_clkdm
@ 2012-04-27 20:05   ` Kevin Hilman
  0 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-27 20:05 UTC (permalink / raw)
  To: linux-arm-kernel

Rather than use runtime cpu_is* checking inside _init_clkdm, initialize
SoC specific function pointer at init time.

Note that initializing the function pointer oh->init_clkdm pointer
must be done before _init_clocks() is called because it is used there.

Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |   19 +++++++++----------
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    1 +
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 6b08f19..e7d95e6 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1288,9 +1288,6 @@ static struct omap_hwmod *_lookup(const char *name)
  */
 static int _init_clkdm(struct omap_hwmod *oh)
 {
-	if (cpu_is_omap24xx() || cpu_is_omap34xx())
-		return 0;
-
 	if (!oh->clkdm_name) {
 		pr_warning("omap_hwmod: %s: no clkdm_name\n", oh->name);
 		return -EINVAL;
@@ -1331,7 +1328,8 @@ static int _init_clocks(struct omap_hwmod *oh, void *data)
 	ret |= _init_main_clk(oh);
 	ret |= _init_interface_clks(oh);
 	ret |= _init_opt_clks(oh);
-	ret |= _init_clkdm(oh);
+	if (oh->init_clkdm)
+		ret |= oh->init_clkdm(oh);
 
 	if (!ret)
 		oh->_state = _HWMOD_STATE_CLKS_INITED;
@@ -2082,12 +2080,6 @@ static int __init _init(struct omap_hwmod *oh, void *data)
 
 	_init_mpu_rt_base(oh, NULL);
 
-	r = _init_clocks(oh, NULL);
-	if (IS_ERR_VALUE(r)) {
-		WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name);
-		return -EINVAL;
-	}
-
 	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
 		oh->wait_module_ready = omap2_wait_module_ready;
 		oh->assert_hardreset = omap2_assert_hardreset;
@@ -2100,6 +2092,13 @@ static int __init _init(struct omap_hwmod *oh, void *data)
 		oh->assert_hardreset = omap4_assert_hardreset;
 		oh->deassert_hardreset = omap4_deassert_hardreset;
 		oh->is_hardreset_asserted = omap4_is_hardreset_asserted;
+		oh->init_clkdm = _init_clkdm;
+	}
+
+	r = _init_clocks(oh, NULL);
+	if (IS_ERR_VALUE(r)) {
+		WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name);
+		return -EINVAL;
 	}
 
 	oh->_state = _HWMOD_STATE_INITIALIZED;
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 4f512b6..6c10e08 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -574,6 +574,7 @@ struct omap_hwmod {
 				  struct omap_hwmod_rst_info *ohri);
 	int (*is_hardreset_asserted)(struct omap_hwmod *oh,
 				     struct omap_hwmod_rst_info *ohri);
+	int (*init_clkdm)(struct omap_hwmod *oh);
 };
 
 struct omap_hwmod *omap_hwmod_lookup(const char *name);
-- 
1.7.9.2

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* RE: [PATCH 1/6] ARM: OMAP4: hwmod: rename _enable_module to _omap4_enable_module()
  2012-04-27 20:05   ` Kevin Hilman
@ 2012-04-29 10:11     ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 40+ messages in thread
From: Hiremath, Vaibhav @ 2012-04-29 10:11 UTC (permalink / raw)
  To: Hilman, Kevin, Paul Walmsley, linux-omap; +Cc: linux-arm-kernel

On Sat, Apr 28, 2012 at 01:35:35, Hilman, Kevin wrote:
> _enable_module is specific to OMAP4-class SoCs, so rename it to
> be consistend with the corresponding _omap4_disable_module.
> 

If we assume AM33xx device under omap4 class, then above statement makes 
sense, else its not really true.

Just wanted to remind on the fact that, we still have not concluded on 
am33xx device, whether to have separate class or OMAP3 class or OAMP4 class?

Also, I and sure that, most of the new family of devices coming 
in will use OMAP4 look-a-like PRCM block.

Also, minor spelling mistake above,
s/consistend/consistent


> Signed-off-by: Kevin Hilman <khilman@ti.com>
> ---
>  arch/arm/mach-omap2/omap_hwmod.c |   10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index bf86f7e..939032a 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -771,13 +771,13 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
>  }
>  
>  /**
> - * _enable_module - enable CLKCTRL modulemode on OMAP4
> + * _omap4_enable_module - enable CLKCTRL modulemode on OMAP4
>   * @oh: struct omap_hwmod *
>   *
>   * Enables the PRCM module mode related to the hwmod @oh.
>   * No return value.
>   */
> -static void _enable_module(struct omap_hwmod *oh)
> +static void _omap4_enable_module(struct omap_hwmod *oh)

In that case, does it make sense to move this function to cminst44xx.c file. 
And same applies to _disable_module() as well. 

Thanks,
Vaibhav
>  {
>  	/* The module mode does not exist prior OMAP4 */
>  	if (cpu_is_omap24xx() || cpu_is_omap34xx())
> @@ -786,8 +786,8 @@ static void _enable_module(struct omap_hwmod *oh)
>  	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
>  		return;
>  
> -	pr_debug("omap_hwmod: %s: _enable_module: %d\n",
> -		 oh->name, oh->prcm.omap4.modulemode);
> +	pr_debug("omap_hwmod: %s: %s: %d\n",
> +		 oh->name, __func__, oh->prcm.omap4.modulemode);
>  
>  	omap4_cminst_module_enable(oh->prcm.omap4.modulemode,
>  				   oh->clkdm->prcm_partition,
> @@ -1814,7 +1814,7 @@ static int _enable(struct omap_hwmod *oh)
>  	}
>  
>  	_enable_clocks(oh);
> -	_enable_module(oh);
> +	_omap4_enable_module(oh);
>  
>  	r = _wait_target_ready(oh);
>  	if (!r) {
> -- 
> 1.7.9.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 1/6] ARM: OMAP4: hwmod: rename _enable_module to _omap4_enable_module()
@ 2012-04-29 10:11     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 40+ messages in thread
From: Hiremath, Vaibhav @ 2012-04-29 10:11 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Apr 28, 2012 at 01:35:35, Hilman, Kevin wrote:
> _enable_module is specific to OMAP4-class SoCs, so rename it to
> be consistend with the corresponding _omap4_disable_module.
> 

If we assume AM33xx device under omap4 class, then above statement makes 
sense, else its not really true.

Just wanted to remind on the fact that, we still have not concluded on 
am33xx device, whether to have separate class or OMAP3 class or OAMP4 class?

Also, I and sure that, most of the new family of devices coming 
in will use OMAP4 look-a-like PRCM block.

Also, minor spelling mistake above,
s/consistend/consistent


> Signed-off-by: Kevin Hilman <khilman@ti.com>
> ---
>  arch/arm/mach-omap2/omap_hwmod.c |   10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index bf86f7e..939032a 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -771,13 +771,13 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
>  }
>  
>  /**
> - * _enable_module - enable CLKCTRL modulemode on OMAP4
> + * _omap4_enable_module - enable CLKCTRL modulemode on OMAP4
>   * @oh: struct omap_hwmod *
>   *
>   * Enables the PRCM module mode related to the hwmod @oh.
>   * No return value.
>   */
> -static void _enable_module(struct omap_hwmod *oh)
> +static void _omap4_enable_module(struct omap_hwmod *oh)

In that case, does it make sense to move this function to cminst44xx.c file. 
And same applies to _disable_module() as well. 

Thanks,
Vaibhav
>  {
>  	/* The module mode does not exist prior OMAP4 */
>  	if (cpu_is_omap24xx() || cpu_is_omap34xx())
> @@ -786,8 +786,8 @@ static void _enable_module(struct omap_hwmod *oh)
>  	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
>  		return;
>  
> -	pr_debug("omap_hwmod: %s: _enable_module: %d\n",
> -		 oh->name, oh->prcm.omap4.modulemode);
> +	pr_debug("omap_hwmod: %s: %s: %d\n",
> +		 oh->name, __func__, oh->prcm.omap4.modulemode);
>  
>  	omap4_cminst_module_enable(oh->prcm.omap4.modulemode,
>  				   oh->clkdm->prcm_partition,
> @@ -1814,7 +1814,7 @@ static int _enable(struct omap_hwmod *oh)
>  	}
>  
>  	_enable_clocks(oh);
> -	_enable_module(oh);
> +	_omap4_enable_module(oh);
>  
>  	r = _wait_target_ready(oh);
>  	if (!r) {
> -- 
> 1.7.9.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 40+ messages in thread

* RE: [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking
  2012-04-27 20:05 ` Kevin Hilman
@ 2012-04-29 10:29   ` Hiremath, Vaibhav
  -1 siblings, 0 replies; 40+ messages in thread
From: Hiremath, Vaibhav @ 2012-04-29 10:29 UTC (permalink / raw)
  To: Hilman, Kevin, Paul Walmsley, linux-omap; +Cc: linux-arm-kernel

On Sat, Apr 28, 2012 at 01:35:34, Hilman, Kevin wrote:
> This series attempts to remove all the runtime cpu_is* checking in
> omap_hwmod.c in favor of using function pointers initialized at init
> time.
> 
> This series was motivated by the addition of support for the AM335x
> series which was done by adding several more cpu_is* checks, and
> provided the proverbial straw that broke the camel's back.  
> 
> In addition to the cleanup, this provides a much cleaner way of adding
> additional SoC support since it no longer requires adding additional
> runtime cpu_is* checks.
> 
> Boot tested on OMAP3530/Overo and OMAP4430/Panda.
> 

Also, tested on AM37xEVM. And also, will integrated for AM33xx development, so that I won't get into cpu_is_xxx check at all.


Thanks,
Vaibhav

> Kevin Hilman (6):
>   ARM: OMAP4: hwmod: rename _enable_module to _omap4_enable_module()
>   ARM: OMAP2+: hwmod: use init-time function ptrs for enable/disable
>     module
>   ARM: OMAP4: hwmod: drop extra cpu_is check from
>     _wait_target_disable()
>   ARM: OMAP2+: hwmod: use init-time function pointer for
>     wait_target_ready
>   ARM: OMAP2+: hwmod: use init-time function pointer for hardreset
>   ARM: OMAP2+: hwmod: use init-time function pointer for _init_clkdm
> 
>  arch/arm/mach-omap2/omap_hwmod.c             |  192 +++++++++++++++-----------
>  arch/arm/plat-omap/include/plat/omap_hwmod.h |   11 ++
>  2 files changed, 126 insertions(+), 77 deletions(-)
> 
> -- 
> 1.7.9.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking
@ 2012-04-29 10:29   ` Hiremath, Vaibhav
  0 siblings, 0 replies; 40+ messages in thread
From: Hiremath, Vaibhav @ 2012-04-29 10:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Apr 28, 2012 at 01:35:34, Hilman, Kevin wrote:
> This series attempts to remove all the runtime cpu_is* checking in
> omap_hwmod.c in favor of using function pointers initialized at init
> time.
> 
> This series was motivated by the addition of support for the AM335x
> series which was done by adding several more cpu_is* checks, and
> provided the proverbial straw that broke the camel's back.  
> 
> In addition to the cleanup, this provides a much cleaner way of adding
> additional SoC support since it no longer requires adding additional
> runtime cpu_is* checks.
> 
> Boot tested on OMAP3530/Overo and OMAP4430/Panda.
> 

Also, tested on AM37xEVM. And also, will integrated for AM33xx development, so that I won't get into cpu_is_xxx check at all.


Thanks,
Vaibhav

> Kevin Hilman (6):
>   ARM: OMAP4: hwmod: rename _enable_module to _omap4_enable_module()
>   ARM: OMAP2+: hwmod: use init-time function ptrs for enable/disable
>     module
>   ARM: OMAP4: hwmod: drop extra cpu_is check from
>     _wait_target_disable()
>   ARM: OMAP2+: hwmod: use init-time function pointer for
>     wait_target_ready
>   ARM: OMAP2+: hwmod: use init-time function pointer for hardreset
>   ARM: OMAP2+: hwmod: use init-time function pointer for _init_clkdm
> 
>  arch/arm/mach-omap2/omap_hwmod.c             |  192 +++++++++++++++-----------
>  arch/arm/plat-omap/include/plat/omap_hwmod.h |   11 ++
>  2 files changed, 126 insertions(+), 77 deletions(-)
> 
> -- 
> 1.7.9.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking
  2012-04-27 20:05 ` Kevin Hilman
@ 2012-04-30 12:59   ` Santosh Shilimkar
  -1 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2012-04-30 12:59 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: Paul Walmsley, linux-omap, linux-arm-kernel

On Saturday 28 April 2012 01:35 AM, Kevin Hilman wrote:
> This series attempts to remove all the runtime cpu_is* checking in
> omap_hwmod.c in favor of using function pointers initialized at init
> time.
> 
> This series was motivated by the addition of support for the AM335x
> series which was done by adding several more cpu_is* checks, and
> provided the proverbial straw that broke the camel's back.  
> 
> In addition to the cleanup, this provides a much cleaner way of adding
> additional SoC support since it no longer requires adding additional
> runtime cpu_is* checks.
> 
> Boot tested on OMAP3530/Overo and OMAP4430/Panda.
> 
I was looking at some of these while trying to OMAP5
support. Indeed the cpu_is_* is becoming increasingly
no maintanable and ugly. Thanks for the series.

Have reviewed the series & tested it on OMAP4430 SDP.
Firstly I tried applying the branch against mainline
only to realise that it does depend on Paul's
earlier series. So used directly your branch
"for_3.5/cleanup/hwmod-cpu-is" to test it out.

Only one comment on function names considering
OMAP4/5 compatibility.
Should omap4_*() defined in this series should be
called omap4plus_*() or similar considering they can
be directly used on OMAP5 devices too.

Otherwise FWIW,
Reviewed-tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

Regards
santosh




^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking
@ 2012-04-30 12:59   ` Santosh Shilimkar
  0 siblings, 0 replies; 40+ messages in thread
From: Santosh Shilimkar @ 2012-04-30 12:59 UTC (permalink / raw)
  To: linux-arm-kernel

On Saturday 28 April 2012 01:35 AM, Kevin Hilman wrote:
> This series attempts to remove all the runtime cpu_is* checking in
> omap_hwmod.c in favor of using function pointers initialized at init
> time.
> 
> This series was motivated by the addition of support for the AM335x
> series which was done by adding several more cpu_is* checks, and
> provided the proverbial straw that broke the camel's back.  
> 
> In addition to the cleanup, this provides a much cleaner way of adding
> additional SoC support since it no longer requires adding additional
> runtime cpu_is* checks.
> 
> Boot tested on OMAP3530/Overo and OMAP4430/Panda.
> 
I was looking at some of these while trying to OMAP5
support. Indeed the cpu_is_* is becoming increasingly
no maintanable and ugly. Thanks for the series.

Have reviewed the series & tested it on OMAP4430 SDP.
Firstly I tried applying the branch against mainline
only to realise that it does depend on Paul's
earlier series. So used directly your branch
"for_3.5/cleanup/hwmod-cpu-is" to test it out.

Only one comment on function names considering
OMAP4/5 compatibility.
Should omap4_*() defined in this series should be
called omap4plus_*() or similar considering they can
be directly used on OMAP5 devices too.

Otherwise FWIW,
Reviewed-tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

Regards
santosh

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 1/6] ARM: OMAP4: hwmod: rename _enable_module to _omap4_enable_module()
  2012-04-27 20:05   ` Kevin Hilman
@ 2012-04-30 14:22     ` Paul Walmsley
  -1 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:22 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, linux-arm-kernel

Hi Kevin,

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> _enable_module is specific to OMAP4-class SoCs, so rename it to
> be consistend with the corresponding _omap4_disable_module.
> 
> Signed-off-by: Kevin Hilman <khilman@ti.com>

I tweaked the commit message here a little bit - please let me know if you 
have any comments.


- Paul

From: Kevin Hilman <khilman@ti.com>
Date: Fri, 27 Apr 2012 22:25:59 -0600
Subject: [PATCH 1/6] ARM: OMAP4: hwmod: rename _enable_module to
 _omap4_enable_module()

_enable_module is specific to SoCs with PRCM interfaces similar to
that of the OMAP4, so rename it to be consistent with the
corresponding _omap4_disable_module.

Signed-off-by: Kevin Hilman <khilman@ti.com>
[paul@pwsan.com: tweaked commit message]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index bf86f7e..939032a 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -771,13 +771,13 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
 }
 
 /**
- * _enable_module - enable CLKCTRL modulemode on OMAP4
+ * _omap4_enable_module - enable CLKCTRL modulemode on OMAP4
  * @oh: struct omap_hwmod *
  *
  * Enables the PRCM module mode related to the hwmod @oh.
  * No return value.
  */
-static void _enable_module(struct omap_hwmod *oh)
+static void _omap4_enable_module(struct omap_hwmod *oh)
 {
 	/* The module mode does not exist prior OMAP4 */
 	if (cpu_is_omap24xx() || cpu_is_omap34xx())
@@ -786,8 +786,8 @@ static void _enable_module(struct omap_hwmod *oh)
 	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
 		return;
 
-	pr_debug("omap_hwmod: %s: _enable_module: %d\n",
-		 oh->name, oh->prcm.omap4.modulemode);
+	pr_debug("omap_hwmod: %s: %s: %d\n",
+		 oh->name, __func__, oh->prcm.omap4.modulemode);
 
 	omap4_cminst_module_enable(oh->prcm.omap4.modulemode,
 				   oh->clkdm->prcm_partition,
@@ -1814,7 +1814,7 @@ static int _enable(struct omap_hwmod *oh)
 	}
 
 	_enable_clocks(oh);
-	_enable_module(oh);
+	_omap4_enable_module(oh);
 
 	r = _wait_target_ready(oh);
 	if (!r) {
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 1/6] ARM: OMAP4: hwmod: rename _enable_module to _omap4_enable_module()
@ 2012-04-30 14:22     ` Paul Walmsley
  0 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:22 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Kevin,

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> _enable_module is specific to OMAP4-class SoCs, so rename it to
> be consistend with the corresponding _omap4_disable_module.
> 
> Signed-off-by: Kevin Hilman <khilman@ti.com>

I tweaked the commit message here a little bit - please let me know if you 
have any comments.


- Paul

From: Kevin Hilman <khilman@ti.com>
Date: Fri, 27 Apr 2012 22:25:59 -0600
Subject: [PATCH 1/6] ARM: OMAP4: hwmod: rename _enable_module to
 _omap4_enable_module()

_enable_module is specific to SoCs with PRCM interfaces similar to
that of the OMAP4, so rename it to be consistent with the
corresponding _omap4_disable_module.

Signed-off-by: Kevin Hilman <khilman@ti.com>
[paul at pwsan.com: tweaked commit message]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index bf86f7e..939032a 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -771,13 +771,13 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
 }
 
 /**
- * _enable_module - enable CLKCTRL modulemode on OMAP4
+ * _omap4_enable_module - enable CLKCTRL modulemode on OMAP4
  * @oh: struct omap_hwmod *
  *
  * Enables the PRCM module mode related to the hwmod @oh.
  * No return value.
  */
-static void _enable_module(struct omap_hwmod *oh)
+static void _omap4_enable_module(struct omap_hwmod *oh)
 {
 	/* The module mode does not exist prior OMAP4 */
 	if (cpu_is_omap24xx() || cpu_is_omap34xx())
@@ -786,8 +786,8 @@ static void _enable_module(struct omap_hwmod *oh)
 	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
 		return;
 
-	pr_debug("omap_hwmod: %s: _enable_module: %d\n",
-		 oh->name, oh->prcm.omap4.modulemode);
+	pr_debug("omap_hwmod: %s: %s: %d\n",
+		 oh->name, __func__, oh->prcm.omap4.modulemode);
 
 	omap4_cminst_module_enable(oh->prcm.omap4.modulemode,
 				   oh->clkdm->prcm_partition,
@@ -1814,7 +1814,7 @@ static int _enable(struct omap_hwmod *oh)
 	}
 
 	_enable_clocks(oh);
-	_enable_module(oh);
+	_omap4_enable_module(oh);
 
 	r = _wait_target_ready(oh);
 	if (!r) {
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH 2/6] ARM: OMAP2+: hwmod: use init-time function ptrs for enable/disable module
  2012-04-27 20:05   ` Kevin Hilman
@ 2012-04-30 14:28     ` Paul Walmsley
  -1 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:28 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, linux-arm-kernel

Hi Kevin,

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> The enable/disable module functions are specific to SoCs with
> OMAP4-class PRCM.  Rather than use cpu_is* checks at runtime inside
> the enable/disable module functions, use cpu_is at init time to
> initialize function pointers only for SoCs that need them.
> 
> NOTE: the cpu_is* check for _enable_module was different than
>       the one for _disable_module, and this patch uses
>       cpu_is_omap44xx() for both.
> 
> Signed-off-by: Kevin Hilman <khilman@ti.com>

Since these function pointers are common to all of the hwmods on the 
currently-booted SoC, they've been moved off into a separate structure, 
used by a file static variable (for omap_hwmod.c).  This should conserve 
some memory and cache.  Also moved the initialization of these pointers 
off to an init function that is called once during kernel init, before any 
hwmods are registered.  Please let me know if you have any comments.


- Paul

From: Kevin Hilman <khilman@ti.com>
Date: Fri, 27 Apr 2012 13:05:36 -0700
Subject: [PATCH 2/6] ARM: OMAP2+: hwmod: use init-time function ptrs for
 enable/disable module

The enable/disable module functions are specific to SoCs with
OMAP4-class PRCM.  Rather than use cpu_is* checks at runtime inside
the enable/disable module functions, use cpu_is at init time to
initialize function pointers only for SoCs that need them.

NOTE: the cpu_is* check for _enable_module was different than
      the one for _disable_module, and this patch uses
      cpu_is_omap44xx() for both.

Signed-off-by: Kevin Hilman <khilman@ti.com>
[paul@pwsan.com: moved soc_ops function pointers to be per-kernel rather than
 per-hwmod since they do not vary by hwmod; added kerneldoc]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |   62 +++++++++++++++++++++-----
 arch/arm/mach-omap2/omap_hwmod_2420_data.c   |    1 +
 arch/arm/mach-omap2/omap_hwmod_2430_data.c   |    1 +
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c   |    2 +
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c   |    1 +
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    2 +
 6 files changed, 57 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 939032a..634a798 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -166,6 +166,23 @@
  */
 #define LINKS_PER_OCP_IF		2
 
+/**
+ * struct omap_hwmod_soc_ops - fn ptrs for some SoC-specific operations
+ * @enable_module: function to enable a module (via MODULEMODE)
+ * @disable_module: function to disable a module (via MODULEMODE)
+ *
+ * XXX Eventually this functionality will be hidden inside the PRM/CM
+ * device drivers.  Until then, this should avoid huge blocks of cpu_is_*()
+ * conditionals in this code.
+ */
+struct omap_hwmod_soc_ops {
+	void (*enable_module)(struct omap_hwmod *oh);
+	int (*disable_module)(struct omap_hwmod *oh);
+};
+
+/* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
+static struct omap_hwmod_soc_ops soc_ops;
+
 /* omap_hwmod_list contains all registered struct omap_hwmods */
 static LIST_HEAD(omap_hwmod_list);
 
@@ -186,6 +203,9 @@ static struct omap_hwmod_link *linkspace;
  */
 static unsigned short free_ls, max_ls, ls_supp;
 
+/* inited: set to true once the hwmod code is initialized */
+static bool inited;
+
 /* Private functions */
 
 /**
@@ -779,10 +799,6 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
  */
 static void _omap4_enable_module(struct omap_hwmod *oh)
 {
-	/* The module mode does not exist prior OMAP4 */
-	if (cpu_is_omap24xx() || cpu_is_omap34xx())
-		return;
-
 	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
 		return;
 
@@ -1571,10 +1587,6 @@ static int _omap4_disable_module(struct omap_hwmod *oh)
 {
 	int v;
 
-	/* The module mode does not exist prior OMAP4 */
-	if (!cpu_is_omap44xx())
-		return -EINVAL;
-
 	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
 		return -EINVAL;
 
@@ -1814,7 +1826,8 @@ static int _enable(struct omap_hwmod *oh)
 	}
 
 	_enable_clocks(oh);
-	_omap4_enable_module(oh);
+	if (soc_ops.enable_module)
+		soc_ops.enable_module(oh);
 
 	r = _wait_target_ready(oh);
 	if (!r) {
@@ -1870,7 +1883,8 @@ static int _idle(struct omap_hwmod *oh)
 		_idle_sysc(oh);
 	_del_initiator_dep(oh, mpu_oh);
 
-	_omap4_disable_module(oh);
+	if (soc_ops.disable_module)
+		soc_ops.disable_module(oh);
 
 	/*
 	 * The module must be in idle mode before disabling any parents
@@ -1975,7 +1989,8 @@ static int _shutdown(struct omap_hwmod *oh)
 	if (oh->_state == _HWMOD_STATE_ENABLED) {
 		_del_initiator_dep(oh, mpu_oh);
 		/* XXX what about the other system initiators here? dma, dsp */
-		_omap4_disable_module(oh);
+		if (soc_ops.disable_module)
+			soc_ops.disable_module(oh);
 		_disable_clocks(oh);
 		if (oh->clkdm)
 			clkdm_hwmod_disable(oh->clkdm, oh);
@@ -2563,12 +2578,18 @@ int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data),
  *
  * Intended to be called early in boot before the clock framework is
  * initialized.  If @ois is not null, will register all omap_hwmods
- * listed in @ois that are valid for this chip.  Returns 0.
+ * listed in @ois that are valid for this chip.  Returns -EINVAL if
+ * omap_hwmod_init() hasn't been called before calling this function,
+ * -ENOMEM if the link memory area can't be allocated, or 0 upon
+ * success.
  */
 int __init omap_hwmod_register_links(struct omap_hwmod_ocp_if **ois)
 {
 	int r, i;
 
+	if (!inited)
+		return -EINVAL;
+
 	if (!ois)
 		return 0;
 
@@ -3401,3 +3422,20 @@ int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int pad_idx, int irq_idx)
 
 	return 0;
 }
+
+/**
+ * omap_hwmod_init - initialize the hwmod code
+ *
+ * Sets up some function pointers needed by the hwmod code to operate on the
+ * currently-booted SoC.  Intended to be called once during kernel init
+ * before any hwmods are registered.  No return value.
+ */
+void __init omap_hwmod_init(void)
+{
+	if (cpu_is_omap44xx()) {
+		soc_ops.enable_module = _omap4_enable_module;
+		soc_ops.disable_module = _omap4_disable_module;
+	}
+
+	inited = true;
+}
diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
index 2c087ff..f30a219 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
@@ -473,5 +473,6 @@ static struct omap_hwmod_ocp_if *omap2420_hwmod_ocp_ifs[] __initdata = {
 
 int __init omap2420_hwmod_init(void)
 {
+	omap_hwmod_init();
 	return omap_hwmod_register_links(omap2420_hwmod_ocp_ifs);
 }
diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
index 71d9f88..2e561ff 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
@@ -891,5 +891,6 @@ static struct omap_hwmod_ocp_if *omap2430_hwmod_ocp_ifs[] __initdata = {
 
 int __init omap2430_hwmod_init(void)
 {
+	omap_hwmod_init();
 	return omap_hwmod_register_links(omap2430_hwmod_ocp_ifs);
 }
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 0c65079..34fc5bd 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -3201,6 +3201,8 @@ int __init omap3xxx_hwmod_init(void)
 	struct omap_hwmod_ocp_if **h = NULL;
 	unsigned int rev;
 
+	omap_hwmod_init();
+
 	/* Register hwmod links common to all OMAP3 */
 	r = omap_hwmod_register_links(omap3xxx_hwmod_ocp_ifs);
 	if (r < 0)
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index 0d91dec..4b436b7 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -4796,6 +4796,7 @@ static struct omap_hwmod_ocp_if *omap44xx_hwmod_ocp_ifs[] __initdata = {
 
 int __init omap44xx_hwmod_init(void)
 {
+	omap_hwmod_init();
 	return omap_hwmod_register_links(omap44xx_hwmod_ocp_ifs);
 }
 
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 14dde32..d2f3ee4 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -628,6 +628,8 @@ int omap_hwmod_no_setup_reset(struct omap_hwmod *oh);
 
 int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int pad_idx, int irq_idx);
 
+extern void __init omap_hwmod_init(void);
+
 /*
  * Chip variant-specific hwmod init routines - XXX should be converted
  * to use initcalls once the initial boot ordering is straightened out
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 2/6] ARM: OMAP2+: hwmod: use init-time function ptrs for enable/disable module
@ 2012-04-30 14:28     ` Paul Walmsley
  0 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:28 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Kevin,

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> The enable/disable module functions are specific to SoCs with
> OMAP4-class PRCM.  Rather than use cpu_is* checks at runtime inside
> the enable/disable module functions, use cpu_is at init time to
> initialize function pointers only for SoCs that need them.
> 
> NOTE: the cpu_is* check for _enable_module was different than
>       the one for _disable_module, and this patch uses
>       cpu_is_omap44xx() for both.
> 
> Signed-off-by: Kevin Hilman <khilman@ti.com>

Since these function pointers are common to all of the hwmods on the 
currently-booted SoC, they've been moved off into a separate structure, 
used by a file static variable (for omap_hwmod.c).  This should conserve 
some memory and cache.  Also moved the initialization of these pointers 
off to an init function that is called once during kernel init, before any 
hwmods are registered.  Please let me know if you have any comments.


- Paul

From: Kevin Hilman <khilman@ti.com>
Date: Fri, 27 Apr 2012 13:05:36 -0700
Subject: [PATCH 2/6] ARM: OMAP2+: hwmod: use init-time function ptrs for
 enable/disable module

The enable/disable module functions are specific to SoCs with
OMAP4-class PRCM.  Rather than use cpu_is* checks at runtime inside
the enable/disable module functions, use cpu_is at init time to
initialize function pointers only for SoCs that need them.

NOTE: the cpu_is* check for _enable_module was different than
      the one for _disable_module, and this patch uses
      cpu_is_omap44xx() for both.

Signed-off-by: Kevin Hilman <khilman@ti.com>
[paul at pwsan.com: moved soc_ops function pointers to be per-kernel rather than
 per-hwmod since they do not vary by hwmod; added kerneldoc]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |   62 +++++++++++++++++++++-----
 arch/arm/mach-omap2/omap_hwmod_2420_data.c   |    1 +
 arch/arm/mach-omap2/omap_hwmod_2430_data.c   |    1 +
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c   |    2 +
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c   |    1 +
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    2 +
 6 files changed, 57 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 939032a..634a798 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -166,6 +166,23 @@
  */
 #define LINKS_PER_OCP_IF		2
 
+/**
+ * struct omap_hwmod_soc_ops - fn ptrs for some SoC-specific operations
+ * @enable_module: function to enable a module (via MODULEMODE)
+ * @disable_module: function to disable a module (via MODULEMODE)
+ *
+ * XXX Eventually this functionality will be hidden inside the PRM/CM
+ * device drivers.  Until then, this should avoid huge blocks of cpu_is_*()
+ * conditionals in this code.
+ */
+struct omap_hwmod_soc_ops {
+	void (*enable_module)(struct omap_hwmod *oh);
+	int (*disable_module)(struct omap_hwmod *oh);
+};
+
+/* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
+static struct omap_hwmod_soc_ops soc_ops;
+
 /* omap_hwmod_list contains all registered struct omap_hwmods */
 static LIST_HEAD(omap_hwmod_list);
 
@@ -186,6 +203,9 @@ static struct omap_hwmod_link *linkspace;
  */
 static unsigned short free_ls, max_ls, ls_supp;
 
+/* inited: set to true once the hwmod code is initialized */
+static bool inited;
+
 /* Private functions */
 
 /**
@@ -779,10 +799,6 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
  */
 static void _omap4_enable_module(struct omap_hwmod *oh)
 {
-	/* The module mode does not exist prior OMAP4 */
-	if (cpu_is_omap24xx() || cpu_is_omap34xx())
-		return;
-
 	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
 		return;
 
@@ -1571,10 +1587,6 @@ static int _omap4_disable_module(struct omap_hwmod *oh)
 {
 	int v;
 
-	/* The module mode does not exist prior OMAP4 */
-	if (!cpu_is_omap44xx())
-		return -EINVAL;
-
 	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
 		return -EINVAL;
 
@@ -1814,7 +1826,8 @@ static int _enable(struct omap_hwmod *oh)
 	}
 
 	_enable_clocks(oh);
-	_omap4_enable_module(oh);
+	if (soc_ops.enable_module)
+		soc_ops.enable_module(oh);
 
 	r = _wait_target_ready(oh);
 	if (!r) {
@@ -1870,7 +1883,8 @@ static int _idle(struct omap_hwmod *oh)
 		_idle_sysc(oh);
 	_del_initiator_dep(oh, mpu_oh);
 
-	_omap4_disable_module(oh);
+	if (soc_ops.disable_module)
+		soc_ops.disable_module(oh);
 
 	/*
 	 * The module must be in idle mode before disabling any parents
@@ -1975,7 +1989,8 @@ static int _shutdown(struct omap_hwmod *oh)
 	if (oh->_state == _HWMOD_STATE_ENABLED) {
 		_del_initiator_dep(oh, mpu_oh);
 		/* XXX what about the other system initiators here? dma, dsp */
-		_omap4_disable_module(oh);
+		if (soc_ops.disable_module)
+			soc_ops.disable_module(oh);
 		_disable_clocks(oh);
 		if (oh->clkdm)
 			clkdm_hwmod_disable(oh->clkdm, oh);
@@ -2563,12 +2578,18 @@ int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data),
  *
  * Intended to be called early in boot before the clock framework is
  * initialized.  If @ois is not null, will register all omap_hwmods
- * listed in @ois that are valid for this chip.  Returns 0.
+ * listed in @ois that are valid for this chip.  Returns -EINVAL if
+ * omap_hwmod_init() hasn't been called before calling this function,
+ * -ENOMEM if the link memory area can't be allocated, or 0 upon
+ * success.
  */
 int __init omap_hwmod_register_links(struct omap_hwmod_ocp_if **ois)
 {
 	int r, i;
 
+	if (!inited)
+		return -EINVAL;
+
 	if (!ois)
 		return 0;
 
@@ -3401,3 +3422,20 @@ int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int pad_idx, int irq_idx)
 
 	return 0;
 }
+
+/**
+ * omap_hwmod_init - initialize the hwmod code
+ *
+ * Sets up some function pointers needed by the hwmod code to operate on the
+ * currently-booted SoC.  Intended to be called once during kernel init
+ * before any hwmods are registered.  No return value.
+ */
+void __init omap_hwmod_init(void)
+{
+	if (cpu_is_omap44xx()) {
+		soc_ops.enable_module = _omap4_enable_module;
+		soc_ops.disable_module = _omap4_disable_module;
+	}
+
+	inited = true;
+}
diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
index 2c087ff..f30a219 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
@@ -473,5 +473,6 @@ static struct omap_hwmod_ocp_if *omap2420_hwmod_ocp_ifs[] __initdata = {
 
 int __init omap2420_hwmod_init(void)
 {
+	omap_hwmod_init();
 	return omap_hwmod_register_links(omap2420_hwmod_ocp_ifs);
 }
diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
index 71d9f88..2e561ff 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
@@ -891,5 +891,6 @@ static struct omap_hwmod_ocp_if *omap2430_hwmod_ocp_ifs[] __initdata = {
 
 int __init omap2430_hwmod_init(void)
 {
+	omap_hwmod_init();
 	return omap_hwmod_register_links(omap2430_hwmod_ocp_ifs);
 }
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 0c65079..34fc5bd 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -3201,6 +3201,8 @@ int __init omap3xxx_hwmod_init(void)
 	struct omap_hwmod_ocp_if **h = NULL;
 	unsigned int rev;
 
+	omap_hwmod_init();
+
 	/* Register hwmod links common to all OMAP3 */
 	r = omap_hwmod_register_links(omap3xxx_hwmod_ocp_ifs);
 	if (r < 0)
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index 0d91dec..4b436b7 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -4796,6 +4796,7 @@ static struct omap_hwmod_ocp_if *omap44xx_hwmod_ocp_ifs[] __initdata = {
 
 int __init omap44xx_hwmod_init(void)
 {
+	omap_hwmod_init();
 	return omap_hwmod_register_links(omap44xx_hwmod_ocp_ifs);
 }
 
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 14dde32..d2f3ee4 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -628,6 +628,8 @@ int omap_hwmod_no_setup_reset(struct omap_hwmod *oh);
 
 int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int pad_idx, int irq_idx);
 
+extern void __init omap_hwmod_init(void);
+
 /*
  * Chip variant-specific hwmod init routines - XXX should be converted
  * to use initcalls once the initial boot ordering is straightened out
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/6] ARM: OMAP4: hwmod: drop extra cpu_is check from _wait_target_disable()
  2012-04-27 20:05   ` Kevin Hilman
@ 2012-04-30 14:29     ` Paul Walmsley
  -1 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:29 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, linux-arm-kernel

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> _omap4_wait_target_disable() is called only from inside _omap4_disable_module()
> which is already protected by SoC specific checks.  Remove the cpu_is check
> here.
> 
> Signed-off-by: Kevin Hilman <khilman@ti.com>

Looks good to me.


- Paul

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 3/6] ARM: OMAP4: hwmod: drop extra cpu_is check from _wait_target_disable()
@ 2012-04-30 14:29     ` Paul Walmsley
  0 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> _omap4_wait_target_disable() is called only from inside _omap4_disable_module()
> which is already protected by SoC specific checks.  Remove the cpu_is check
> here.
> 
> Signed-off-by: Kevin Hilman <khilman@ti.com>

Looks good to me.


- Paul

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 4/6] ARM: OMAP2+: hwmod: use init-time function pointer for wait_target_ready
  2012-04-27 20:05   ` Kevin Hilman
@ 2012-04-30 14:33     ` Paul Walmsley
  -1 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:33 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, linux-arm-kernel

Hi Kevin,

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> Rather than using cpu_is* checking at runtime, initialize an SoC specific
> function pointer for wait_target_ready().
> 
> While here, downgrade the BUG() to a WARN_ON() so it gives a noisy
> warning instead of causing a kernel panic.
> 
> Signed-off-by: Kevin Hilman <khilman@ti.com>

I've added some kerneldoc for each of these functions.  I'm trying to 
ensure that kerneldoc is present for all of the functions and structures 
that are added to code that I have to deal with, so it would be really 
great to have kerneldoc added on future patches :-)

Also the function pointers added here have been moved to the soc_ops 
structure created by earlier patches, and the wait_module_disable code has 
been integrated with the calling function and renamed to 
*_wait_target_disable(), which is slightly more descriptive in this case.
Please let me know if you have any comments.


- Paul

From: Kevin Hilman <khilman@ti.com>
Date: Fri, 27 Apr 2012 13:05:38 -0700
Subject: [PATCH 4/6] ARM: OMAP2+: hwmod: use init-time function pointer for
 wait_target_ready

Rather than using cpu_is* checking at runtime, initialize an SoC specific
function pointer for wait_target_ready().

While here, downgrade the BUG() to a WARN_ON() so it gives a noisy
warning instead of causing a kernel panic.

Signed-off-by: Kevin Hilman <khilman@ti.com>
[paul@pwsan.com: convert to use soc_ops function pointers; add kerneldoc;
 move soc_ops functions to their own section in the code; integrated
 the _wait_target_ready() function with the OMAP2/OMAP4 variants;
 renamed the wait_module_ready field to wait_target_ready]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |  115 ++++++++++++++++++++++----------------
 1 file changed, 66 insertions(+), 49 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 2b84583..d1f784c 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -178,6 +178,7 @@
 struct omap_hwmod_soc_ops {
 	void (*enable_module)(struct omap_hwmod *oh);
 	int (*disable_module)(struct omap_hwmod *oh);
+	int (*wait_target_ready)(struct omap_hwmod *oh);
 };
 
 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
@@ -1362,53 +1363,6 @@ static int _init_clocks(struct omap_hwmod *oh, void *data)
 }
 
 /**
- * _wait_target_ready - wait for a module to leave slave idle
- * @oh: struct omap_hwmod *
- *
- * Wait for a module @oh to leave slave idle.  Returns 0 if the module
- * does not have an IDLEST bit or if the module successfully leaves
- * slave idle; otherwise, pass along the return value of the
- * appropriate *_cm*_wait_module_ready() function.
- */
-static int _wait_target_ready(struct omap_hwmod *oh)
-{
-	struct omap_hwmod_ocp_if *os;
-	int ret;
-
-	if (!oh)
-		return -EINVAL;
-
-	if (oh->flags & HWMOD_NO_IDLEST)
-		return 0;
-
-	os = _find_mpu_rt_port(oh);
-	if (!os)
-		return 0;
-
-	/* XXX check module SIDLEMODE */
-
-	/* XXX check clock enable states */
-
-	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-		ret = omap2_cm_wait_module_ready(oh->prcm.omap2.module_offs,
-						 oh->prcm.omap2.idlest_reg_id,
-						 oh->prcm.omap2.idlest_idle_bit);
-	} else if (cpu_is_omap44xx()) {
-		if (!oh->clkdm)
-			return -EINVAL;
-
-		ret = omap4_cminst_wait_module_ready(oh->clkdm->prcm_partition,
-						     oh->clkdm->cm_inst,
-						     oh->clkdm->clkdm_offs,
-						     oh->prcm.omap4.clkctrl_offs);
-	} else {
-		BUG();
-	};
-
-	return ret;
-}
-
-/**
  * _lookup_hardreset - fill register bit info for this hwmod/reset line
  * @oh: struct omap_hwmod *
  * @name: name of the reset line in the context of this hwmod
@@ -1826,7 +1780,8 @@ static int _enable(struct omap_hwmod *oh)
 	if (soc_ops.enable_module)
 		soc_ops.enable_module(oh);
 
-	r = _wait_target_ready(oh);
+	r = (soc_ops.wait_target_ready) ? soc_ops.wait_target_ready(oh) :
+		-EINVAL;
 	if (!r) {
 		/*
 		 * Set the clockdomain to HW_AUTO only if the target is ready,
@@ -2443,6 +2398,63 @@ static int __init _alloc_linkspace(struct omap_hwmod_ocp_if **ois)
 	return 0;
 }
 
+/* Static functions intended only for use in soc_ops field function pointers */
+
+/**
+ * _omap2_wait_target_ready - wait for a module to leave slave idle
+ * @oh: struct omap_hwmod *
+ *
+ * Wait for a module @oh to leave slave idle.  Returns 0 if the module
+ * does not have an IDLEST bit or if the module successfully leaves
+ * slave idle; otherwise, pass along the return value of the
+ * appropriate *_cm*_wait_module_ready() function.
+ */
+static int _omap2_wait_target_ready(struct omap_hwmod *oh)
+{
+	if (!oh)
+		return -EINVAL;
+
+	if (oh->flags & HWMOD_NO_IDLEST)
+		return 0;
+
+	if (!_find_mpu_rt_port(oh))
+		return 0;
+
+	/* XXX check module SIDLEMODE, hardreset status, enabled clocks */
+
+	return omap2_cm_wait_module_ready(oh->prcm.omap2.module_offs,
+					  oh->prcm.omap2.idlest_reg_id,
+					  oh->prcm.omap2.idlest_idle_bit);
+}
+
+/**
+ * _omap4_wait_target_ready - wait for a module to leave slave idle
+ * @oh: struct omap_hwmod *
+ *
+ * Wait for a module @oh to leave slave idle.  Returns 0 if the module
+ * does not have an IDLEST bit or if the module successfully leaves
+ * slave idle; otherwise, pass along the return value of the
+ * appropriate *_cm*_wait_module_ready() function.
+ */
+static int _omap4_wait_target_ready(struct omap_hwmod *oh)
+{
+	if (!oh || !oh->clkdm)
+		return -EINVAL;
+
+	if (oh->flags & HWMOD_NO_IDLEST)
+		return 0;
+
+	if (!_find_mpu_rt_port(oh))
+		return 0;
+
+	/* XXX check module SIDLEMODE, hardreset status */
+
+	return omap4_cminst_wait_module_ready(oh->clkdm->prcm_partition,
+					      oh->clkdm->cm_inst,
+					      oh->clkdm->clkdm_offs,
+					      oh->prcm.omap4.clkctrl_offs);
+}
+
 /* Public functions */
 
 u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs)
@@ -3429,9 +3441,14 @@ int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int pad_idx, int irq_idx)
  */
 void __init omap_hwmod_init(void)
 {
-	if (cpu_is_omap44xx()) {
+	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
+		soc_ops.wait_target_ready = _omap2_wait_target_ready;
+	} else if (cpu_is_omap44xx()) {
 		soc_ops.enable_module = _omap4_enable_module;
 		soc_ops.disable_module = _omap4_disable_module;
+		soc_ops.wait_target_ready = _omap4_wait_target_ready;
+	} else {
+		WARN(1, "omap_hwmod: unknown SoC type\n");
 	}
 
 	inited = true;
-- 
1.7.10


- Paul

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 4/6] ARM: OMAP2+: hwmod: use init-time function pointer for wait_target_ready
@ 2012-04-30 14:33     ` Paul Walmsley
  0 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:33 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Kevin,

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> Rather than using cpu_is* checking at runtime, initialize an SoC specific
> function pointer for wait_target_ready().
> 
> While here, downgrade the BUG() to a WARN_ON() so it gives a noisy
> warning instead of causing a kernel panic.
> 
> Signed-off-by: Kevin Hilman <khilman@ti.com>

I've added some kerneldoc for each of these functions.  I'm trying to 
ensure that kerneldoc is present for all of the functions and structures 
that are added to code that I have to deal with, so it would be really 
great to have kerneldoc added on future patches :-)

Also the function pointers added here have been moved to the soc_ops 
structure created by earlier patches, and the wait_module_disable code has 
been integrated with the calling function and renamed to 
*_wait_target_disable(), which is slightly more descriptive in this case.
Please let me know if you have any comments.


- Paul

From: Kevin Hilman <khilman@ti.com>
Date: Fri, 27 Apr 2012 13:05:38 -0700
Subject: [PATCH 4/6] ARM: OMAP2+: hwmod: use init-time function pointer for
 wait_target_ready

Rather than using cpu_is* checking at runtime, initialize an SoC specific
function pointer for wait_target_ready().

While here, downgrade the BUG() to a WARN_ON() so it gives a noisy
warning instead of causing a kernel panic.

Signed-off-by: Kevin Hilman <khilman@ti.com>
[paul at pwsan.com: convert to use soc_ops function pointers; add kerneldoc;
 move soc_ops functions to their own section in the code; integrated
 the _wait_target_ready() function with the OMAP2/OMAP4 variants;
 renamed the wait_module_ready field to wait_target_ready]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |  115 ++++++++++++++++++++++----------------
 1 file changed, 66 insertions(+), 49 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 2b84583..d1f784c 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -178,6 +178,7 @@
 struct omap_hwmod_soc_ops {
 	void (*enable_module)(struct omap_hwmod *oh);
 	int (*disable_module)(struct omap_hwmod *oh);
+	int (*wait_target_ready)(struct omap_hwmod *oh);
 };
 
 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
@@ -1362,53 +1363,6 @@ static int _init_clocks(struct omap_hwmod *oh, void *data)
 }
 
 /**
- * _wait_target_ready - wait for a module to leave slave idle
- * @oh: struct omap_hwmod *
- *
- * Wait for a module @oh to leave slave idle.  Returns 0 if the module
- * does not have an IDLEST bit or if the module successfully leaves
- * slave idle; otherwise, pass along the return value of the
- * appropriate *_cm*_wait_module_ready() function.
- */
-static int _wait_target_ready(struct omap_hwmod *oh)
-{
-	struct omap_hwmod_ocp_if *os;
-	int ret;
-
-	if (!oh)
-		return -EINVAL;
-
-	if (oh->flags & HWMOD_NO_IDLEST)
-		return 0;
-
-	os = _find_mpu_rt_port(oh);
-	if (!os)
-		return 0;
-
-	/* XXX check module SIDLEMODE */
-
-	/* XXX check clock enable states */
-
-	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-		ret = omap2_cm_wait_module_ready(oh->prcm.omap2.module_offs,
-						 oh->prcm.omap2.idlest_reg_id,
-						 oh->prcm.omap2.idlest_idle_bit);
-	} else if (cpu_is_omap44xx()) {
-		if (!oh->clkdm)
-			return -EINVAL;
-
-		ret = omap4_cminst_wait_module_ready(oh->clkdm->prcm_partition,
-						     oh->clkdm->cm_inst,
-						     oh->clkdm->clkdm_offs,
-						     oh->prcm.omap4.clkctrl_offs);
-	} else {
-		BUG();
-	};
-
-	return ret;
-}
-
-/**
  * _lookup_hardreset - fill register bit info for this hwmod/reset line
  * @oh: struct omap_hwmod *
  * @name: name of the reset line in the context of this hwmod
@@ -1826,7 +1780,8 @@ static int _enable(struct omap_hwmod *oh)
 	if (soc_ops.enable_module)
 		soc_ops.enable_module(oh);
 
-	r = _wait_target_ready(oh);
+	r = (soc_ops.wait_target_ready) ? soc_ops.wait_target_ready(oh) :
+		-EINVAL;
 	if (!r) {
 		/*
 		 * Set the clockdomain to HW_AUTO only if the target is ready,
@@ -2443,6 +2398,63 @@ static int __init _alloc_linkspace(struct omap_hwmod_ocp_if **ois)
 	return 0;
 }
 
+/* Static functions intended only for use in soc_ops field function pointers */
+
+/**
+ * _omap2_wait_target_ready - wait for a module to leave slave idle
+ * @oh: struct omap_hwmod *
+ *
+ * Wait for a module @oh to leave slave idle.  Returns 0 if the module
+ * does not have an IDLEST bit or if the module successfully leaves
+ * slave idle; otherwise, pass along the return value of the
+ * appropriate *_cm*_wait_module_ready() function.
+ */
+static int _omap2_wait_target_ready(struct omap_hwmod *oh)
+{
+	if (!oh)
+		return -EINVAL;
+
+	if (oh->flags & HWMOD_NO_IDLEST)
+		return 0;
+
+	if (!_find_mpu_rt_port(oh))
+		return 0;
+
+	/* XXX check module SIDLEMODE, hardreset status, enabled clocks */
+
+	return omap2_cm_wait_module_ready(oh->prcm.omap2.module_offs,
+					  oh->prcm.omap2.idlest_reg_id,
+					  oh->prcm.omap2.idlest_idle_bit);
+}
+
+/**
+ * _omap4_wait_target_ready - wait for a module to leave slave idle
+ * @oh: struct omap_hwmod *
+ *
+ * Wait for a module @oh to leave slave idle.  Returns 0 if the module
+ * does not have an IDLEST bit or if the module successfully leaves
+ * slave idle; otherwise, pass along the return value of the
+ * appropriate *_cm*_wait_module_ready() function.
+ */
+static int _omap4_wait_target_ready(struct omap_hwmod *oh)
+{
+	if (!oh || !oh->clkdm)
+		return -EINVAL;
+
+	if (oh->flags & HWMOD_NO_IDLEST)
+		return 0;
+
+	if (!_find_mpu_rt_port(oh))
+		return 0;
+
+	/* XXX check module SIDLEMODE, hardreset status */
+
+	return omap4_cminst_wait_module_ready(oh->clkdm->prcm_partition,
+					      oh->clkdm->cm_inst,
+					      oh->clkdm->clkdm_offs,
+					      oh->prcm.omap4.clkctrl_offs);
+}
+
 /* Public functions */
 
 u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs)
@@ -3429,9 +3441,14 @@ int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int pad_idx, int irq_idx)
  */
 void __init omap_hwmod_init(void)
 {
-	if (cpu_is_omap44xx()) {
+	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
+		soc_ops.wait_target_ready = _omap2_wait_target_ready;
+	} else if (cpu_is_omap44xx()) {
 		soc_ops.enable_module = _omap4_enable_module;
 		soc_ops.disable_module = _omap4_disable_module;
+		soc_ops.wait_target_ready = _omap4_wait_target_ready;
+	} else {
+		WARN(1, "omap_hwmod: unknown SoC type\n");
 	}
 
 	inited = true;
-- 
1.7.10


- Paul

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH 5/6] ARM: OMAP2+: hwmod: use init-time function pointer for hardreset
  2012-04-27 20:05   ` Kevin Hilman
@ 2012-04-30 14:34     ` Paul Walmsley
  -1 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:34 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, linux-arm-kernel

Hi Kevin,

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> Rather than using cpu_is* checking at runtime, initialize SoC specific
> function pointers for the various hard reset functions at init time.
> 
> Signed-off-by: Kevin Hilman <khilman@ti.com>

Lots of kerneldoc has been added, and the function pointers have been 
moved to the soc_ops structure; please let me know if you have any 
comments.


- Paul

From: Kevin Hilman <khilman@ti.com>
Date: Fri, 27 Apr 2012 13:05:39 -0700
Subject: [PATCH 5/6] ARM: OMAP2+: hwmod: use init-time function pointer for
 hardreset

Rather than using cpu_is* checking at runtime, initialize SoC specific
function pointers for the various hard reset functions at init time.

Signed-off-by: Kevin Hilman <khilman@ti.com>
[paul@pwsan.com: convert to use soc_ops function pointers; add kerneldoc]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |  216 +++++++++++++++++++++++++++++---------
 1 file changed, 169 insertions(+), 47 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index d1f784c..93cb96d 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -179,6 +179,12 @@ struct omap_hwmod_soc_ops {
 	void (*enable_module)(struct omap_hwmod *oh);
 	int (*disable_module)(struct omap_hwmod *oh);
 	int (*wait_target_ready)(struct omap_hwmod *oh);
+	int (*assert_hardreset)(struct omap_hwmod *oh,
+				struct omap_hwmod_rst_info *ohri);
+	int (*deassert_hardreset)(struct omap_hwmod *oh,
+				  struct omap_hwmod_rst_info *ohri);
+	int (*is_hardreset_asserted)(struct omap_hwmod *oh,
+				     struct omap_hwmod_rst_info *ohri);
 };
 
 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
@@ -1398,32 +1404,31 @@ static u8 _lookup_hardreset(struct omap_hwmod *oh, const char *name,
  * @oh: struct omap_hwmod *
  * @name: name of the reset line to lookup and assert
  *
- * Some IP like dsp, ipu or iva contain processor that require
- * an HW reset line to be assert / deassert in order to enable fully
- * the IP.
+ * Some IP like dsp, ipu or iva contain processor that require an HW
+ * reset line to be assert / deassert in order to enable fully the IP.
+ * Returns -EINVAL if @oh is null, -ENOSYS if we have no way of
+ * asserting the hardreset line on the currently-booted SoC, or passes
+ * along the return value from _lookup_hardreset() or the SoC's
+ * assert_hardreset code.
  */
 static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
 {
 	struct omap_hwmod_rst_info ohri;
-	u8 ret;
+	u8 ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
 
+	if (!soc_ops.assert_hardreset)
+		return -ENOSYS;
+
 	ret = _lookup_hardreset(oh, name, &ohri);
 	if (IS_ERR_VALUE(ret))
 		return ret;
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx())
-		return omap2_prm_assert_hardreset(oh->prcm.omap2.module_offs,
-						  ohri.rst_shift);
-	else if (cpu_is_omap44xx())
-		return omap4_prminst_assert_hardreset(ohri.rst_shift,
-				  oh->clkdm->pwrdm.ptr->prcm_partition,
-				  oh->clkdm->pwrdm.ptr->prcm_offs,
-				  oh->prcm.omap4.rstctrl_offs);
-	else
-		return -EINVAL;
+	ret = soc_ops.assert_hardreset(oh, &ohri);
+
+	return ret;
 }
 
 /**
@@ -1432,38 +1437,29 @@ static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
  * @oh: struct omap_hwmod *
  * @name: name of the reset line to look up and deassert
  *
- * Some IP like dsp, ipu or iva contain processor that require
- * an HW reset line to be assert / deassert in order to enable fully
- * the IP.
+ * Some IP like dsp, ipu or iva contain processor that require an HW
+ * reset line to be assert / deassert in order to enable fully the IP.
+ * Returns -EINVAL if @oh is null, -ENOSYS if we have no way of
+ * deasserting the hardreset line on the currently-booted SoC, or passes
+ * along the return value from _lookup_hardreset() or the SoC's
+ * deassert_hardreset code.
  */
 static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
 {
 	struct omap_hwmod_rst_info ohri;
-	int ret;
+	int ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
 
+	if (!soc_ops.deassert_hardreset)
+		return -ENOSYS;
+
 	ret = _lookup_hardreset(oh, name, &ohri);
 	if (IS_ERR_VALUE(ret))
 		return ret;
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-		ret = omap2_prm_deassert_hardreset(oh->prcm.omap2.module_offs,
-						   ohri.rst_shift,
-						   ohri.st_shift);
-	} else if (cpu_is_omap44xx()) {
-		if (ohri.st_shift)
-			pr_err("omap_hwmod: %s: %s: hwmod data error: OMAP4 does not support st_shift\n",
-			       oh->name, name);
-		ret = omap4_prminst_deassert_hardreset(ohri.rst_shift,
-				  oh->clkdm->pwrdm.ptr->prcm_partition,
-				  oh->clkdm->pwrdm.ptr->prcm_offs,
-				  oh->prcm.omap4.rstctrl_offs);
-	} else {
-		return -EINVAL;
-	}
-
+	ret = soc_ops.deassert_hardreset(oh, &ohri);
 	if (ret == -EBUSY)
 		pr_warning("omap_hwmod: %s: failed to hardreset\n", oh->name);
 
@@ -1476,31 +1472,28 @@ static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
  * @oh: struct omap_hwmod *
  * @name: name of the reset line to look up and read
  *
- * Return the state of the reset line.
+ * Return the state of the reset line.  Returns -EINVAL if @oh is
+ * null, -ENOSYS if we have no way of reading the hardreset line
+ * status on the currently-booted SoC, or passes along the return
+ * value from _lookup_hardreset() or the SoC's is_hardreset_asserted
+ * code.
  */
 static int _read_hardreset(struct omap_hwmod *oh, const char *name)
 {
 	struct omap_hwmod_rst_info ohri;
-	u8 ret;
+	u8 ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
 
+	if (!soc_ops.is_hardreset_asserted)
+		return -ENOSYS;
+
 	ret = _lookup_hardreset(oh, name, &ohri);
 	if (IS_ERR_VALUE(ret))
 		return ret;
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-		return omap2_prm_is_hardreset_asserted(oh->prcm.omap2.module_offs,
-						       ohri.st_shift);
-	} else if (cpu_is_omap44xx()) {
-		return omap4_prminst_is_hardreset_asserted(ohri.rst_shift,
-				  oh->clkdm->pwrdm.ptr->prcm_partition,
-				  oh->clkdm->pwrdm.ptr->prcm_offs,
-				  oh->prcm.omap4.rstctrl_offs);
-	} else {
-		return -EINVAL;
-	}
+	return soc_ops.is_hardreset_asserted(oh, &ohri);
 }
 
 /**
@@ -2455,6 +2448,129 @@ static int _omap4_wait_target_ready(struct omap_hwmod *oh)
 					      oh->prcm.omap4.clkctrl_offs);
 }
 
+/**
+ * _omap2_assert_hardreset - call OMAP2 PRM hardreset fn with hwmod args
+ * @oh: struct omap_hwmod * to assert hardreset
+ * @ohri: hardreset line data
+ *
+ * Call omap2_prm_assert_hardreset() with parameters extracted from
+ * the hwmod @oh and the hardreset line data @ohri.  Only intended for
+ * use as an soc_ops function pointer.  Passes along the return value
+ * from omap2_prm_assert_hardreset().  XXX This function is scheduled
+ * for removal when the PRM code is moved into drivers/.
+ */
+static int _omap2_assert_hardreset(struct omap_hwmod *oh,
+				   struct omap_hwmod_rst_info *ohri)
+{
+	return omap2_prm_assert_hardreset(oh->prcm.omap2.module_offs,
+					  ohri->rst_shift);
+}
+
+/**
+ * _omap2_deassert_hardreset - call OMAP2 PRM hardreset fn with hwmod args
+ * @oh: struct omap_hwmod * to deassert hardreset
+ * @ohri: hardreset line data
+ *
+ * Call omap2_prm_deassert_hardreset() with parameters extracted from
+ * the hwmod @oh and the hardreset line data @ohri.  Only intended for
+ * use as an soc_ops function pointer.  Passes along the return value
+ * from omap2_prm_deassert_hardreset().  XXX This function is
+ * scheduled for removal when the PRM code is moved into drivers/.
+ */
+static int _omap2_deassert_hardreset(struct omap_hwmod *oh,
+				     struct omap_hwmod_rst_info *ohri)
+{
+	return omap2_prm_deassert_hardreset(oh->prcm.omap2.module_offs,
+					    ohri->rst_shift,
+					    ohri->st_shift);
+}
+
+/**
+ * _omap2_is_hardreset_asserted - call OMAP2 PRM hardreset fn with hwmod args
+ * @oh: struct omap_hwmod * to test hardreset
+ * @ohri: hardreset line data
+ *
+ * Call omap2_prm_is_hardreset_asserted() with parameters extracted
+ * from the hwmod @oh and the hardreset line data @ohri.  Only
+ * intended for use as an soc_ops function pointer.  Passes along the
+ * return value from omap2_prm_is_hardreset_asserted().  XXX This
+ * function is scheduled for removal when the PRM code is moved into
+ * drivers/.
+ */
+static int _omap2_is_hardreset_asserted(struct omap_hwmod *oh,
+					struct omap_hwmod_rst_info *ohri)
+{
+	return omap2_prm_is_hardreset_asserted(oh->prcm.omap2.module_offs,
+					       ohri->st_shift);
+}
+
+/**
+ * _omap4_assert_hardreset - call OMAP4 PRM hardreset fn with hwmod args
+ * @oh: struct omap_hwmod * to assert hardreset
+ * @ohri: hardreset line data
+ *
+ * Call omap4_prminst_assert_hardreset() with parameters extracted
+ * from the hwmod @oh and the hardreset line data @ohri.  Only
+ * intended for use as an soc_ops function pointer.  Passes along the
+ * return value from omap4_prminst_assert_hardreset().  XXX This
+ * function is scheduled for removal when the PRM code is moved into
+ * drivers/.
+ */
+static int _omap4_assert_hardreset(struct omap_hwmod *oh,
+				   struct omap_hwmod_rst_info *ohri)
+
+{
+	return omap4_prminst_assert_hardreset(ohri->rst_shift,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.rstctrl_offs);
+}
+
+/**
+ * _omap4_deassert_hardreset - call OMAP4 PRM hardreset fn with hwmod args
+ * @oh: struct omap_hwmod * to deassert hardreset
+ * @ohri: hardreset line data
+ *
+ * Call omap4_prminst_deassert_hardreset() with parameters extracted
+ * from the hwmod @oh and the hardreset line data @ohri.  Only
+ * intended for use as an soc_ops function pointer.  Passes along the
+ * return value from omap4_prminst_deassert_hardreset().  XXX This
+ * function is scheduled for removal when the PRM code is moved into
+ * drivers/.
+ */
+static int _omap4_deassert_hardreset(struct omap_hwmod *oh,
+				     struct omap_hwmod_rst_info *ohri)
+{
+	if (ohri->st_shift)
+		pr_err("omap_hwmod: %s: %s: hwmod data error: OMAP4 does not support st_shift\n",
+		       oh->name, ohri->name);
+	return omap4_prminst_deassert_hardreset(ohri->rst_shift,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.rstctrl_offs);
+}
+
+/**
+ * _omap4_is_hardreset_asserted - call OMAP4 PRM hardreset fn with hwmod args
+ * @oh: struct omap_hwmod * to test hardreset
+ * @ohri: hardreset line data
+ *
+ * Call omap4_prminst_is_hardreset_asserted() with parameters
+ * extracted from the hwmod @oh and the hardreset line data @ohri.
+ * Only intended for use as an soc_ops function pointer.  Passes along
+ * the return value from omap4_prminst_is_hardreset_asserted().  XXX
+ * This function is scheduled for removal when the PRM code is moved
+ * into drivers/.
+ */
+static int _omap4_is_hardreset_asserted(struct omap_hwmod *oh,
+					struct omap_hwmod_rst_info *ohri)
+{
+	return omap4_prminst_is_hardreset_asserted(ohri->rst_shift,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.rstctrl_offs);
+}
+
 /* Public functions */
 
 u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs)
@@ -3443,10 +3559,16 @@ void __init omap_hwmod_init(void)
 {
 	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
 		soc_ops.wait_target_ready = _omap2_wait_target_ready;
+		soc_ops.assert_hardreset = _omap2_assert_hardreset;
+		soc_ops.deassert_hardreset = _omap2_deassert_hardreset;
+		soc_ops.is_hardreset_asserted = _omap2_is_hardreset_asserted;
 	} else if (cpu_is_omap44xx()) {
 		soc_ops.enable_module = _omap4_enable_module;
 		soc_ops.disable_module = _omap4_disable_module;
 		soc_ops.wait_target_ready = _omap4_wait_target_ready;
+		soc_ops.assert_hardreset = _omap4_assert_hardreset;
+		soc_ops.deassert_hardreset = _omap4_deassert_hardreset;
+		soc_ops.is_hardreset_asserted = _omap4_is_hardreset_asserted;
 	} else {
 		WARN(1, "omap_hwmod: unknown SoC type\n");
 	}
-- 
1.7.10



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 5/6] ARM: OMAP2+: hwmod: use init-time function pointer for hardreset
@ 2012-04-30 14:34     ` Paul Walmsley
  0 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:34 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Kevin,

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> Rather than using cpu_is* checking at runtime, initialize SoC specific
> function pointers for the various hard reset functions at init time.
> 
> Signed-off-by: Kevin Hilman <khilman@ti.com>

Lots of kerneldoc has been added, and the function pointers have been 
moved to the soc_ops structure; please let me know if you have any 
comments.


- Paul

From: Kevin Hilman <khilman@ti.com>
Date: Fri, 27 Apr 2012 13:05:39 -0700
Subject: [PATCH 5/6] ARM: OMAP2+: hwmod: use init-time function pointer for
 hardreset

Rather than using cpu_is* checking at runtime, initialize SoC specific
function pointers for the various hard reset functions at init time.

Signed-off-by: Kevin Hilman <khilman@ti.com>
[paul at pwsan.com: convert to use soc_ops function pointers; add kerneldoc]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |  216 +++++++++++++++++++++++++++++---------
 1 file changed, 169 insertions(+), 47 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index d1f784c..93cb96d 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -179,6 +179,12 @@ struct omap_hwmod_soc_ops {
 	void (*enable_module)(struct omap_hwmod *oh);
 	int (*disable_module)(struct omap_hwmod *oh);
 	int (*wait_target_ready)(struct omap_hwmod *oh);
+	int (*assert_hardreset)(struct omap_hwmod *oh,
+				struct omap_hwmod_rst_info *ohri);
+	int (*deassert_hardreset)(struct omap_hwmod *oh,
+				  struct omap_hwmod_rst_info *ohri);
+	int (*is_hardreset_asserted)(struct omap_hwmod *oh,
+				     struct omap_hwmod_rst_info *ohri);
 };
 
 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
@@ -1398,32 +1404,31 @@ static u8 _lookup_hardreset(struct omap_hwmod *oh, const char *name,
  * @oh: struct omap_hwmod *
  * @name: name of the reset line to lookup and assert
  *
- * Some IP like dsp, ipu or iva contain processor that require
- * an HW reset line to be assert / deassert in order to enable fully
- * the IP.
+ * Some IP like dsp, ipu or iva contain processor that require an HW
+ * reset line to be assert / deassert in order to enable fully the IP.
+ * Returns -EINVAL if @oh is null, -ENOSYS if we have no way of
+ * asserting the hardreset line on the currently-booted SoC, or passes
+ * along the return value from _lookup_hardreset() or the SoC's
+ * assert_hardreset code.
  */
 static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
 {
 	struct omap_hwmod_rst_info ohri;
-	u8 ret;
+	u8 ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
 
+	if (!soc_ops.assert_hardreset)
+		return -ENOSYS;
+
 	ret = _lookup_hardreset(oh, name, &ohri);
 	if (IS_ERR_VALUE(ret))
 		return ret;
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx())
-		return omap2_prm_assert_hardreset(oh->prcm.omap2.module_offs,
-						  ohri.rst_shift);
-	else if (cpu_is_omap44xx())
-		return omap4_prminst_assert_hardreset(ohri.rst_shift,
-				  oh->clkdm->pwrdm.ptr->prcm_partition,
-				  oh->clkdm->pwrdm.ptr->prcm_offs,
-				  oh->prcm.omap4.rstctrl_offs);
-	else
-		return -EINVAL;
+	ret = soc_ops.assert_hardreset(oh, &ohri);
+
+	return ret;
 }
 
 /**
@@ -1432,38 +1437,29 @@ static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
  * @oh: struct omap_hwmod *
  * @name: name of the reset line to look up and deassert
  *
- * Some IP like dsp, ipu or iva contain processor that require
- * an HW reset line to be assert / deassert in order to enable fully
- * the IP.
+ * Some IP like dsp, ipu or iva contain processor that require an HW
+ * reset line to be assert / deassert in order to enable fully the IP.
+ * Returns -EINVAL if @oh is null, -ENOSYS if we have no way of
+ * deasserting the hardreset line on the currently-booted SoC, or passes
+ * along the return value from _lookup_hardreset() or the SoC's
+ * deassert_hardreset code.
  */
 static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
 {
 	struct omap_hwmod_rst_info ohri;
-	int ret;
+	int ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
 
+	if (!soc_ops.deassert_hardreset)
+		return -ENOSYS;
+
 	ret = _lookup_hardreset(oh, name, &ohri);
 	if (IS_ERR_VALUE(ret))
 		return ret;
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-		ret = omap2_prm_deassert_hardreset(oh->prcm.omap2.module_offs,
-						   ohri.rst_shift,
-						   ohri.st_shift);
-	} else if (cpu_is_omap44xx()) {
-		if (ohri.st_shift)
-			pr_err("omap_hwmod: %s: %s: hwmod data error: OMAP4 does not support st_shift\n",
-			       oh->name, name);
-		ret = omap4_prminst_deassert_hardreset(ohri.rst_shift,
-				  oh->clkdm->pwrdm.ptr->prcm_partition,
-				  oh->clkdm->pwrdm.ptr->prcm_offs,
-				  oh->prcm.omap4.rstctrl_offs);
-	} else {
-		return -EINVAL;
-	}
-
+	ret = soc_ops.deassert_hardreset(oh, &ohri);
 	if (ret == -EBUSY)
 		pr_warning("omap_hwmod: %s: failed to hardreset\n", oh->name);
 
@@ -1476,31 +1472,28 @@ static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
  * @oh: struct omap_hwmod *
  * @name: name of the reset line to look up and read
  *
- * Return the state of the reset line.
+ * Return the state of the reset line.  Returns -EINVAL if @oh is
+ * null, -ENOSYS if we have no way of reading the hardreset line
+ * status on the currently-booted SoC, or passes along the return
+ * value from _lookup_hardreset() or the SoC's is_hardreset_asserted
+ * code.
  */
 static int _read_hardreset(struct omap_hwmod *oh, const char *name)
 {
 	struct omap_hwmod_rst_info ohri;
-	u8 ret;
+	u8 ret = -EINVAL;
 
 	if (!oh)
 		return -EINVAL;
 
+	if (!soc_ops.is_hardreset_asserted)
+		return -ENOSYS;
+
 	ret = _lookup_hardreset(oh, name, &ohri);
 	if (IS_ERR_VALUE(ret))
 		return ret;
 
-	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-		return omap2_prm_is_hardreset_asserted(oh->prcm.omap2.module_offs,
-						       ohri.st_shift);
-	} else if (cpu_is_omap44xx()) {
-		return omap4_prminst_is_hardreset_asserted(ohri.rst_shift,
-				  oh->clkdm->pwrdm.ptr->prcm_partition,
-				  oh->clkdm->pwrdm.ptr->prcm_offs,
-				  oh->prcm.omap4.rstctrl_offs);
-	} else {
-		return -EINVAL;
-	}
+	return soc_ops.is_hardreset_asserted(oh, &ohri);
 }
 
 /**
@@ -2455,6 +2448,129 @@ static int _omap4_wait_target_ready(struct omap_hwmod *oh)
 					      oh->prcm.omap4.clkctrl_offs);
 }
 
+/**
+ * _omap2_assert_hardreset - call OMAP2 PRM hardreset fn with hwmod args
+ * @oh: struct omap_hwmod * to assert hardreset
+ * @ohri: hardreset line data
+ *
+ * Call omap2_prm_assert_hardreset() with parameters extracted from
+ * the hwmod @oh and the hardreset line data @ohri.  Only intended for
+ * use as an soc_ops function pointer.  Passes along the return value
+ * from omap2_prm_assert_hardreset().  XXX This function is scheduled
+ * for removal when the PRM code is moved into drivers/.
+ */
+static int _omap2_assert_hardreset(struct omap_hwmod *oh,
+				   struct omap_hwmod_rst_info *ohri)
+{
+	return omap2_prm_assert_hardreset(oh->prcm.omap2.module_offs,
+					  ohri->rst_shift);
+}
+
+/**
+ * _omap2_deassert_hardreset - call OMAP2 PRM hardreset fn with hwmod args
+ * @oh: struct omap_hwmod * to deassert hardreset
+ * @ohri: hardreset line data
+ *
+ * Call omap2_prm_deassert_hardreset() with parameters extracted from
+ * the hwmod @oh and the hardreset line data @ohri.  Only intended for
+ * use as an soc_ops function pointer.  Passes along the return value
+ * from omap2_prm_deassert_hardreset().  XXX This function is
+ * scheduled for removal when the PRM code is moved into drivers/.
+ */
+static int _omap2_deassert_hardreset(struct omap_hwmod *oh,
+				     struct omap_hwmod_rst_info *ohri)
+{
+	return omap2_prm_deassert_hardreset(oh->prcm.omap2.module_offs,
+					    ohri->rst_shift,
+					    ohri->st_shift);
+}
+
+/**
+ * _omap2_is_hardreset_asserted - call OMAP2 PRM hardreset fn with hwmod args
+ * @oh: struct omap_hwmod * to test hardreset
+ * @ohri: hardreset line data
+ *
+ * Call omap2_prm_is_hardreset_asserted() with parameters extracted
+ * from the hwmod @oh and the hardreset line data @ohri.  Only
+ * intended for use as an soc_ops function pointer.  Passes along the
+ * return value from omap2_prm_is_hardreset_asserted().  XXX This
+ * function is scheduled for removal when the PRM code is moved into
+ * drivers/.
+ */
+static int _omap2_is_hardreset_asserted(struct omap_hwmod *oh,
+					struct omap_hwmod_rst_info *ohri)
+{
+	return omap2_prm_is_hardreset_asserted(oh->prcm.omap2.module_offs,
+					       ohri->st_shift);
+}
+
+/**
+ * _omap4_assert_hardreset - call OMAP4 PRM hardreset fn with hwmod args
+ * @oh: struct omap_hwmod * to assert hardreset
+ * @ohri: hardreset line data
+ *
+ * Call omap4_prminst_assert_hardreset() with parameters extracted
+ * from the hwmod @oh and the hardreset line data @ohri.  Only
+ * intended for use as an soc_ops function pointer.  Passes along the
+ * return value from omap4_prminst_assert_hardreset().  XXX This
+ * function is scheduled for removal when the PRM code is moved into
+ * drivers/.
+ */
+static int _omap4_assert_hardreset(struct omap_hwmod *oh,
+				   struct omap_hwmod_rst_info *ohri)
+
+{
+	return omap4_prminst_assert_hardreset(ohri->rst_shift,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.rstctrl_offs);
+}
+
+/**
+ * _omap4_deassert_hardreset - call OMAP4 PRM hardreset fn with hwmod args
+ * @oh: struct omap_hwmod * to deassert hardreset
+ * @ohri: hardreset line data
+ *
+ * Call omap4_prminst_deassert_hardreset() with parameters extracted
+ * from the hwmod @oh and the hardreset line data @ohri.  Only
+ * intended for use as an soc_ops function pointer.  Passes along the
+ * return value from omap4_prminst_deassert_hardreset().  XXX This
+ * function is scheduled for removal when the PRM code is moved into
+ * drivers/.
+ */
+static int _omap4_deassert_hardreset(struct omap_hwmod *oh,
+				     struct omap_hwmod_rst_info *ohri)
+{
+	if (ohri->st_shift)
+		pr_err("omap_hwmod: %s: %s: hwmod data error: OMAP4 does not support st_shift\n",
+		       oh->name, ohri->name);
+	return omap4_prminst_deassert_hardreset(ohri->rst_shift,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.rstctrl_offs);
+}
+
+/**
+ * _omap4_is_hardreset_asserted - call OMAP4 PRM hardreset fn with hwmod args
+ * @oh: struct omap_hwmod * to test hardreset
+ * @ohri: hardreset line data
+ *
+ * Call omap4_prminst_is_hardreset_asserted() with parameters
+ * extracted from the hwmod @oh and the hardreset line data @ohri.
+ * Only intended for use as an soc_ops function pointer.  Passes along
+ * the return value from omap4_prminst_is_hardreset_asserted().  XXX
+ * This function is scheduled for removal when the PRM code is moved
+ * into drivers/.
+ */
+static int _omap4_is_hardreset_asserted(struct omap_hwmod *oh,
+					struct omap_hwmod_rst_info *ohri)
+{
+	return omap4_prminst_is_hardreset_asserted(ohri->rst_shift,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.rstctrl_offs);
+}
+
 /* Public functions */
 
 u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs)
@@ -3443,10 +3559,16 @@ void __init omap_hwmod_init(void)
 {
 	if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
 		soc_ops.wait_target_ready = _omap2_wait_target_ready;
+		soc_ops.assert_hardreset = _omap2_assert_hardreset;
+		soc_ops.deassert_hardreset = _omap2_deassert_hardreset;
+		soc_ops.is_hardreset_asserted = _omap2_is_hardreset_asserted;
 	} else if (cpu_is_omap44xx()) {
 		soc_ops.enable_module = _omap4_enable_module;
 		soc_ops.disable_module = _omap4_disable_module;
 		soc_ops.wait_target_ready = _omap4_wait_target_ready;
+		soc_ops.assert_hardreset = _omap4_assert_hardreset;
+		soc_ops.deassert_hardreset = _omap4_deassert_hardreset;
+		soc_ops.is_hardreset_asserted = _omap4_is_hardreset_asserted;
 	} else {
 		WARN(1, "omap_hwmod: unknown SoC type\n");
 	}
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH 6/6] ARM: OMAP2+: hwmod: use init-time function pointer for _init_clkdm
  2012-04-27 20:05   ` Kevin Hilman
@ 2012-04-30 14:35     ` Paul Walmsley
  -1 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:35 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, linux-arm-kernel

Hi Kevin,

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> Rather than use runtime cpu_is* checking inside _init_clkdm, initialize
> SoC specific function pointer at init time.
> 
> Note that initializing the function pointer oh->init_clkdm pointer
> must be done before _init_clocks() is called because it is used there.
> 
> Signed-off-by: Kevin Hilman <khilman@ti.com>

Converted this patch to use the soc_ops function pointers and tweaked the 
commit message - please let me know if you have any comments.


- Paul

From: Kevin Hilman <khilman@ti.com>
Date: Fri, 27 Apr 2012 13:05:40 -0700
Subject: [PATCH 6/6] ARM: OMAP2+: hwmod: use init-time function pointer for
 _init_clkdm

Rather than use runtime cpu_is* checking inside _init_clkdm, initialize
SoC specific function pointer at init time.

Signed-off-by: Kevin Hilman <khilman@ti.com>
[paul@pwsan.com: convert to use soc_ops function pointers; remove second para
 from commit message since soc_ops function pointers are now set during hwmod
 layer init]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 93cb96d..acc616c 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -185,6 +185,7 @@ struct omap_hwmod_soc_ops {
 				  struct omap_hwmod_rst_info *ohri);
 	int (*is_hardreset_asserted)(struct omap_hwmod *oh,
 				     struct omap_hwmod_rst_info *ohri);
+	int (*init_clkdm)(struct omap_hwmod *oh);
 };
 
 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
@@ -1315,9 +1316,6 @@ static struct omap_hwmod *_lookup(const char *name)
  */
 static int _init_clkdm(struct omap_hwmod *oh)
 {
-	if (cpu_is_omap24xx() || cpu_is_omap34xx())
-		return 0;
-
 	if (!oh->clkdm_name) {
 		pr_warning("omap_hwmod: %s: no clkdm_name\n", oh->name);
 		return -EINVAL;
@@ -1358,7 +1356,8 @@ static int _init_clocks(struct omap_hwmod *oh, void *data)
 	ret |= _init_main_clk(oh);
 	ret |= _init_interface_clks(oh);
 	ret |= _init_opt_clks(oh);
-	ret |= _init_clkdm(oh);
+	if (soc_ops.init_clkdm)
+		ret |= soc_ops.init_clkdm(oh);
 
 	if (!ret)
 		oh->_state = _HWMOD_STATE_CLKS_INITED;
@@ -3569,6 +3568,7 @@ void __init omap_hwmod_init(void)
 		soc_ops.assert_hardreset = _omap4_assert_hardreset;
 		soc_ops.deassert_hardreset = _omap4_deassert_hardreset;
 		soc_ops.is_hardreset_asserted = _omap4_is_hardreset_asserted;
+		soc_ops.init_clkdm = _init_clkdm;
 	} else {
 		WARN(1, "omap_hwmod: unknown SoC type\n");
 	}
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 6/6] ARM: OMAP2+: hwmod: use init-time function pointer for _init_clkdm
@ 2012-04-30 14:35     ` Paul Walmsley
  0 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:35 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Kevin,

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> Rather than use runtime cpu_is* checking inside _init_clkdm, initialize
> SoC specific function pointer at init time.
> 
> Note that initializing the function pointer oh->init_clkdm pointer
> must be done before _init_clocks() is called because it is used there.
> 
> Signed-off-by: Kevin Hilman <khilman@ti.com>

Converted this patch to use the soc_ops function pointers and tweaked the 
commit message - please let me know if you have any comments.


- Paul

From: Kevin Hilman <khilman@ti.com>
Date: Fri, 27 Apr 2012 13:05:40 -0700
Subject: [PATCH 6/6] ARM: OMAP2+: hwmod: use init-time function pointer for
 _init_clkdm

Rather than use runtime cpu_is* checking inside _init_clkdm, initialize
SoC specific function pointer at init time.

Signed-off-by: Kevin Hilman <khilman@ti.com>
[paul at pwsan.com: convert to use soc_ops function pointers; remove second para
 from commit message since soc_ops function pointers are now set during hwmod
 layer init]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 93cb96d..acc616c 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -185,6 +185,7 @@ struct omap_hwmod_soc_ops {
 				  struct omap_hwmod_rst_info *ohri);
 	int (*is_hardreset_asserted)(struct omap_hwmod *oh,
 				     struct omap_hwmod_rst_info *ohri);
+	int (*init_clkdm)(struct omap_hwmod *oh);
 };
 
 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
@@ -1315,9 +1316,6 @@ static struct omap_hwmod *_lookup(const char *name)
  */
 static int _init_clkdm(struct omap_hwmod *oh)
 {
-	if (cpu_is_omap24xx() || cpu_is_omap34xx())
-		return 0;
-
 	if (!oh->clkdm_name) {
 		pr_warning("omap_hwmod: %s: no clkdm_name\n", oh->name);
 		return -EINVAL;
@@ -1358,7 +1356,8 @@ static int _init_clocks(struct omap_hwmod *oh, void *data)
 	ret |= _init_main_clk(oh);
 	ret |= _init_interface_clks(oh);
 	ret |= _init_opt_clks(oh);
-	ret |= _init_clkdm(oh);
+	if (soc_ops.init_clkdm)
+		ret |= soc_ops.init_clkdm(oh);
 
 	if (!ret)
 		oh->_state = _HWMOD_STATE_CLKS_INITED;
@@ -3569,6 +3568,7 @@ void __init omap_hwmod_init(void)
 		soc_ops.assert_hardreset = _omap4_assert_hardreset;
 		soc_ops.deassert_hardreset = _omap4_deassert_hardreset;
 		soc_ops.is_hardreset_asserted = _omap4_is_hardreset_asserted;
+		soc_ops.init_clkdm = _init_clkdm;
 	} else {
 		WARN(1, "omap_hwmod: unknown SoC type\n");
 	}
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking
  2012-04-27 20:05 ` Kevin Hilman
@ 2012-04-30 14:41   ` Paul Walmsley
  -1 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:41 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, linux-arm-kernel

Hi Kevin,

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> This series attempts to remove all the runtime cpu_is* checking in
> omap_hwmod.c in favor of using function pointers initialized at init
> time.
> 
> This series was motivated by the addition of support for the AM335x
> series which was done by adding several more cpu_is* checks, and
> provided the proverbial straw that broke the camel's back.  
> 
> In addition to the cleanup, this provides a much cleaner way of adding
> additional SoC support since it no longer requires adding additional
> runtime cpu_is* checks.
> 
> Boot tested on OMAP3530/Overo and OMAP4430/Panda.

Thanks Kevin, this series should bridge the gap nicely between the current 
code, and the point in time that we're able to move these functions into 
PRM/CM device driver code.  And allow us to avoid adding more cpu_is_*() 
when we merge Vaibhav's hwmod changes.

As you've probably seen, the patches have been updated here.  The function 
pointers have been made file-static rather than per-hwmod; this should 
conserve some memory and cache.  Since they don't change on a per-hwmod 
basis, this should be safe.  Also added quite a bit of kerneldoc -- 
basically I have an internal rule here now to ensure this exists on all 
functions and structures that are added, so it would be great to have this 
on future code :-)

The updated series is at git://git.pwsan.com/linux-2.6 in 
the "hwmod_soc_conditional_cleanup_3.5" branch.  Please let me know if 
you have any comments.  It's only compile-tested here so far.  I'll be 
rebasing my local copy of Vaibhav's series on it and will plan to send it 
upstream for 3.5.


- Paul

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking
@ 2012-04-30 14:41   ` Paul Walmsley
  0 siblings, 0 replies; 40+ messages in thread
From: Paul Walmsley @ 2012-04-30 14:41 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Kevin,

On Fri, 27 Apr 2012, Kevin Hilman wrote:

> This series attempts to remove all the runtime cpu_is* checking in
> omap_hwmod.c in favor of using function pointers initialized at init
> time.
> 
> This series was motivated by the addition of support for the AM335x
> series which was done by adding several more cpu_is* checks, and
> provided the proverbial straw that broke the camel's back.  
> 
> In addition to the cleanup, this provides a much cleaner way of adding
> additional SoC support since it no longer requires adding additional
> runtime cpu_is* checks.
> 
> Boot tested on OMAP3530/Overo and OMAP4430/Panda.

Thanks Kevin, this series should bridge the gap nicely between the current 
code, and the point in time that we're able to move these functions into 
PRM/CM device driver code.  And allow us to avoid adding more cpu_is_*() 
when we merge Vaibhav's hwmod changes.

As you've probably seen, the patches have been updated here.  The function 
pointers have been made file-static rather than per-hwmod; this should 
conserve some memory and cache.  Since they don't change on a per-hwmod 
basis, this should be safe.  Also added quite a bit of kerneldoc -- 
basically I have an internal rule here now to ensure this exists on all 
functions and structures that are added, so it would be great to have this 
on future code :-)

The updated series is at git://git.pwsan.com/linux-2.6 in 
the "hwmod_soc_conditional_cleanup_3.5" branch.  Please let me know if 
you have any comments.  It's only compile-tested here so far.  I'll be 
rebasing my local copy of Vaibhav's series on it and will plan to send it 
upstream for 3.5.


- Paul

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking
  2012-04-30 12:59   ` Santosh Shilimkar
@ 2012-04-30 16:05     ` Tony Lindgren
  -1 siblings, 0 replies; 40+ messages in thread
From: Tony Lindgren @ 2012-04-30 16:05 UTC (permalink / raw)
  To: Santosh Shilimkar
  Cc: Kevin Hilman, Paul Walmsley, linux-omap, linux-arm-kernel

* Santosh Shilimkar <santosh.shilimkar@ti.com> [120430 06:03]:
> On Saturday 28 April 2012 01:35 AM, Kevin Hilman wrote:
> > This series attempts to remove all the runtime cpu_is* checking in
> > omap_hwmod.c in favor of using function pointers initialized at init
> > time.
> > 
> > This series was motivated by the addition of support for the AM335x
> > series which was done by adding several more cpu_is* checks, and
> > provided the proverbial straw that broke the camel's back.  
> > 
> > In addition to the cleanup, this provides a much cleaner way of adding
> > additional SoC support since it no longer requires adding additional
> > runtime cpu_is* checks.
> > 
> > Boot tested on OMAP3530/Overo and OMAP4430/Panda.
> > 
> I was looking at some of these while trying to OMAP5
> support. Indeed the cpu_is_* is becoming increasingly
> no maintanable and ugly. Thanks for the series.

Also we need to start considering what happens if non-omap code
calls cpu_is_omapxxx for common zImage kernels.. So it's best to
make sure they only happen in omap specific calls during init time.

Regards,

Tony

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking
@ 2012-04-30 16:05     ` Tony Lindgren
  0 siblings, 0 replies; 40+ messages in thread
From: Tony Lindgren @ 2012-04-30 16:05 UTC (permalink / raw)
  To: linux-arm-kernel

* Santosh Shilimkar <santosh.shilimkar@ti.com> [120430 06:03]:
> On Saturday 28 April 2012 01:35 AM, Kevin Hilman wrote:
> > This series attempts to remove all the runtime cpu_is* checking in
> > omap_hwmod.c in favor of using function pointers initialized at init
> > time.
> > 
> > This series was motivated by the addition of support for the AM335x
> > series which was done by adding several more cpu_is* checks, and
> > provided the proverbial straw that broke the camel's back.  
> > 
> > In addition to the cleanup, this provides a much cleaner way of adding
> > additional SoC support since it no longer requires adding additional
> > runtime cpu_is* checks.
> > 
> > Boot tested on OMAP3530/Overo and OMAP4430/Panda.
> > 
> I was looking at some of these while trying to OMAP5
> support. Indeed the cpu_is_* is becoming increasingly
> no maintanable and ugly. Thanks for the series.

Also we need to start considering what happens if non-omap code
calls cpu_is_omapxxx for common zImage kernels.. So it's best to
make sure they only happen in omap specific calls during init time.

Regards,

Tony

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 1/6] ARM: OMAP4: hwmod: rename _enable_module to _omap4_enable_module()
  2012-04-30 14:22     ` Paul Walmsley
@ 2012-04-30 17:15       ` Kevin Hilman
  -1 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-30 17:15 UTC (permalink / raw)
  To: Paul Walmsley; +Cc: linux-omap, linux-arm-kernel

Paul Walmsley <paul@pwsan.com> writes:

> Hi Kevin,
>
> On Fri, 27 Apr 2012, Kevin Hilman wrote:
>
>> _enable_module is specific to OMAP4-class SoCs, so rename it to
>> be consistend with the corresponding _omap4_disable_module.
>> 
>> Signed-off-by: Kevin Hilman <khilman@ti.com>
>
> I tweaked the commit message here a little bit - please let me know if you 
> have any comments.

Yes, that's better.   I wrote OMAP4-class SoCs, I meant OMAP4-class
PRCM, so the updated changelog looks good.  Thanks.

Also, the rest of your changes to the series look good to me.

Thanks,

Kevin

> From: Kevin Hilman <khilman@ti.com>
> Date: Fri, 27 Apr 2012 22:25:59 -0600
> Subject: [PATCH 1/6] ARM: OMAP4: hwmod: rename _enable_module to
>  _omap4_enable_module()
>
> _enable_module is specific to SoCs with PRCM interfaces similar to
> that of the OMAP4, so rename it to be consistent with the
> corresponding _omap4_disable_module.
>
> Signed-off-by: Kevin Hilman <khilman@ti.com>
> [paul@pwsan.com: tweaked commit message]
> Signed-off-by: Paul Walmsley <paul@pwsan.com>
> ---
>  arch/arm/mach-omap2/omap_hwmod.c |   10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index bf86f7e..939032a 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -771,13 +771,13 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
>  }
>  
>  /**
> - * _enable_module - enable CLKCTRL modulemode on OMAP4
> + * _omap4_enable_module - enable CLKCTRL modulemode on OMAP4
>   * @oh: struct omap_hwmod *
>   *
>   * Enables the PRCM module mode related to the hwmod @oh.
>   * No return value.
>   */
> -static void _enable_module(struct omap_hwmod *oh)
> +static void _omap4_enable_module(struct omap_hwmod *oh)
>  {
>  	/* The module mode does not exist prior OMAP4 */
>  	if (cpu_is_omap24xx() || cpu_is_omap34xx())
> @@ -786,8 +786,8 @@ static void _enable_module(struct omap_hwmod *oh)
>  	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
>  		return;
>  
> -	pr_debug("omap_hwmod: %s: _enable_module: %d\n",
> -		 oh->name, oh->prcm.omap4.modulemode);
> +	pr_debug("omap_hwmod: %s: %s: %d\n",
> +		 oh->name, __func__, oh->prcm.omap4.modulemode);
>  
>  	omap4_cminst_module_enable(oh->prcm.omap4.modulemode,
>  				   oh->clkdm->prcm_partition,
> @@ -1814,7 +1814,7 @@ static int _enable(struct omap_hwmod *oh)
>  	}
>  
>  	_enable_clocks(oh);
> -	_enable_module(oh);
> +	_omap4_enable_module(oh);
>  
>  	r = _wait_target_ready(oh);
>  	if (!r) {

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 1/6] ARM: OMAP4: hwmod: rename _enable_module to _omap4_enable_module()
@ 2012-04-30 17:15       ` Kevin Hilman
  0 siblings, 0 replies; 40+ messages in thread
From: Kevin Hilman @ 2012-04-30 17:15 UTC (permalink / raw)
  To: linux-arm-kernel

Paul Walmsley <paul@pwsan.com> writes:

> Hi Kevin,
>
> On Fri, 27 Apr 2012, Kevin Hilman wrote:
>
>> _enable_module is specific to OMAP4-class SoCs, so rename it to
>> be consistend with the corresponding _omap4_disable_module.
>> 
>> Signed-off-by: Kevin Hilman <khilman@ti.com>
>
> I tweaked the commit message here a little bit - please let me know if you 
> have any comments.

Yes, that's better.   I wrote OMAP4-class SoCs, I meant OMAP4-class
PRCM, so the updated changelog looks good.  Thanks.

Also, the rest of your changes to the series look good to me.

Thanks,

Kevin

> From: Kevin Hilman <khilman@ti.com>
> Date: Fri, 27 Apr 2012 22:25:59 -0600
> Subject: [PATCH 1/6] ARM: OMAP4: hwmod: rename _enable_module to
>  _omap4_enable_module()
>
> _enable_module is specific to SoCs with PRCM interfaces similar to
> that of the OMAP4, so rename it to be consistent with the
> corresponding _omap4_disable_module.
>
> Signed-off-by: Kevin Hilman <khilman@ti.com>
> [paul at pwsan.com: tweaked commit message]
> Signed-off-by: Paul Walmsley <paul@pwsan.com>
> ---
>  arch/arm/mach-omap2/omap_hwmod.c |   10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index bf86f7e..939032a 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -771,13 +771,13 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
>  }
>  
>  /**
> - * _enable_module - enable CLKCTRL modulemode on OMAP4
> + * _omap4_enable_module - enable CLKCTRL modulemode on OMAP4
>   * @oh: struct omap_hwmod *
>   *
>   * Enables the PRCM module mode related to the hwmod @oh.
>   * No return value.
>   */
> -static void _enable_module(struct omap_hwmod *oh)
> +static void _omap4_enable_module(struct omap_hwmod *oh)
>  {
>  	/* The module mode does not exist prior OMAP4 */
>  	if (cpu_is_omap24xx() || cpu_is_omap34xx())
> @@ -786,8 +786,8 @@ static void _enable_module(struct omap_hwmod *oh)
>  	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
>  		return;
>  
> -	pr_debug("omap_hwmod: %s: _enable_module: %d\n",
> -		 oh->name, oh->prcm.omap4.modulemode);
> +	pr_debug("omap_hwmod: %s: %s: %d\n",
> +		 oh->name, __func__, oh->prcm.omap4.modulemode);
>  
>  	omap4_cminst_module_enable(oh->prcm.omap4.modulemode,
>  				   oh->clkdm->prcm_partition,
> @@ -1814,7 +1814,7 @@ static int _enable(struct omap_hwmod *oh)
>  	}
>  
>  	_enable_clocks(oh);
> -	_enable_module(oh);
> +	_omap4_enable_module(oh);
>  
>  	r = _wait_target_ready(oh);
>  	if (!r) {

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking
  2012-04-30 14:41   ` Paul Walmsley
@ 2012-06-14 10:01     ` a0393909
  -1 siblings, 0 replies; 40+ messages in thread
From: a0393909 @ 2012-06-14 10:01 UTC (permalink / raw)
  To: Paul Walmsley, Tony; +Cc: Kevin Hilman, linux-omap, linux-arm-kernel

Paul,

On 04/30/2012 08:11 PM, Paul Walmsley wrote:
> Hi Kevin,
>
> On Fri, 27 Apr 2012, Kevin Hilman wrote:
>
>> This series attempts to remove all the runtime cpu_is* checking in
>> omap_hwmod.c in favor of using function pointers initialized at init
>> time.
>>
>> This series was motivated by the addition of support for the AM335x
>> series which was done by adding several more cpu_is* checks, and
>> provided the proverbial straw that broke the camel's back.
>>
>> In addition to the cleanup, this provides a much cleaner way of adding
>> additional SoC support since it no longer requires adding additional
>> runtime cpu_is* checks.
>>
>> Boot tested on OMAP3530/Overo and OMAP4430/Panda.
>
> Thanks Kevin, this series should bridge the gap nicely between the current
> code, and the point in time that we're able to move these functions into
> PRM/CM device driver code.  And allow us to avoid adding more cpu_is_*()
> when we merge Vaibhav's hwmod changes.
>
> As you've probably seen, the patches have been updated here.  The function
> pointers have been made file-static rather than per-hwmod; this should
> conserve some memory and cache.  Since they don't change on a per-hwmod
> basis, this should be safe.  Also added quite a bit of kerneldoc --
> basically I have an internal rule here now to ensure this exists on all
> functions and structures that are added, so it would be great to have this
> on future code :-)
>
> The updated series is at git://git.pwsan.com/linux-2.6 in
> the "hwmod_soc_conditional_cleanup_3.5" branch.  Please let me know if
> you have any comments.  It's only compile-tested here so far.  I'll be
> rebasing my local copy of Vaibhav's series on it and will plan to send it
> upstream for 3.5.
>
I guess this series missed 3.5 merge window. I was re-basing the OMAP5
minimal support against the 3.5-rc2 and one of the dependency for that
series is $subject series.

Tony,
How do we get the dependent series merged early enough so that OMAP5
support can be merged in linux-omap master to avoid any late build
breaks.

Regards
santosh




^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking
@ 2012-06-14 10:01     ` a0393909
  0 siblings, 0 replies; 40+ messages in thread
From: a0393909 @ 2012-06-14 10:01 UTC (permalink / raw)
  To: linux-arm-kernel

Paul,

On 04/30/2012 08:11 PM, Paul Walmsley wrote:
> Hi Kevin,
>
> On Fri, 27 Apr 2012, Kevin Hilman wrote:
>
>> This series attempts to remove all the runtime cpu_is* checking in
>> omap_hwmod.c in favor of using function pointers initialized at init
>> time.
>>
>> This series was motivated by the addition of support for the AM335x
>> series which was done by adding several more cpu_is* checks, and
>> provided the proverbial straw that broke the camel's back.
>>
>> In addition to the cleanup, this provides a much cleaner way of adding
>> additional SoC support since it no longer requires adding additional
>> runtime cpu_is* checks.
>>
>> Boot tested on OMAP3530/Overo and OMAP4430/Panda.
>
> Thanks Kevin, this series should bridge the gap nicely between the current
> code, and the point in time that we're able to move these functions into
> PRM/CM device driver code.  And allow us to avoid adding more cpu_is_*()
> when we merge Vaibhav's hwmod changes.
>
> As you've probably seen, the patches have been updated here.  The function
> pointers have been made file-static rather than per-hwmod; this should
> conserve some memory and cache.  Since they don't change on a per-hwmod
> basis, this should be safe.  Also added quite a bit of kerneldoc --
> basically I have an internal rule here now to ensure this exists on all
> functions and structures that are added, so it would be great to have this
> on future code :-)
>
> The updated series is at git://git.pwsan.com/linux-2.6 in
> the "hwmod_soc_conditional_cleanup_3.5" branch.  Please let me know if
> you have any comments.  It's only compile-tested here so far.  I'll be
> rebasing my local copy of Vaibhav's series on it and will plan to send it
> upstream for 3.5.
>
I guess this series missed 3.5 merge window. I was re-basing the OMAP5
minimal support against the 3.5-rc2 and one of the dependency for that
series is $subject series.

Tony,
How do we get the dependent series merged early enough so that OMAP5
support can be merged in linux-omap master to avoid any late build
breaks.

Regards
santosh

^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2012-06-14 10:02 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-27 20:05 [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking Kevin Hilman
2012-04-27 20:05 ` Kevin Hilman
2012-04-27 20:05 ` [PATCH 1/6] ARM: OMAP4: hwmod: rename _enable_module to _omap4_enable_module() Kevin Hilman
2012-04-27 20:05   ` Kevin Hilman
2012-04-29 10:11   ` Hiremath, Vaibhav
2012-04-29 10:11     ` Hiremath, Vaibhav
2012-04-30 14:22   ` Paul Walmsley
2012-04-30 14:22     ` Paul Walmsley
2012-04-30 17:15     ` Kevin Hilman
2012-04-30 17:15       ` Kevin Hilman
2012-04-27 20:05 ` [PATCH 2/6] ARM: OMAP2+: hwmod: use init-time function ptrs for enable/disable module Kevin Hilman
2012-04-27 20:05   ` Kevin Hilman
2012-04-30 14:28   ` Paul Walmsley
2012-04-30 14:28     ` Paul Walmsley
2012-04-27 20:05 ` [PATCH 3/6] ARM: OMAP4: hwmod: drop extra cpu_is check from _wait_target_disable() Kevin Hilman
2012-04-27 20:05   ` Kevin Hilman
2012-04-30 14:29   ` Paul Walmsley
2012-04-30 14:29     ` Paul Walmsley
2012-04-27 20:05 ` [PATCH 4/6] ARM: OMAP2+: hwmod: use init-time function pointer for wait_target_ready Kevin Hilman
2012-04-27 20:05   ` Kevin Hilman
2012-04-30 14:33   ` Paul Walmsley
2012-04-30 14:33     ` Paul Walmsley
2012-04-27 20:05 ` [PATCH 5/6] ARM: OMAP2+: hwmod: use init-time function pointer for hardreset Kevin Hilman
2012-04-27 20:05   ` Kevin Hilman
2012-04-30 14:34   ` Paul Walmsley
2012-04-30 14:34     ` Paul Walmsley
2012-04-27 20:05 ` [PATCH 6/6] ARM: OMAP2+: hwmod: use init-time function pointer for _init_clkdm Kevin Hilman
2012-04-27 20:05   ` Kevin Hilman
2012-04-30 14:35   ` Paul Walmsley
2012-04-30 14:35     ` Paul Walmsley
2012-04-29 10:29 ` [PATCH 0/6] ARM: OMAP: hwmod: remove runtime cpu_is checking Hiremath, Vaibhav
2012-04-29 10:29   ` Hiremath, Vaibhav
2012-04-30 12:59 ` Santosh Shilimkar
2012-04-30 12:59   ` Santosh Shilimkar
2012-04-30 16:05   ` Tony Lindgren
2012-04-30 16:05     ` Tony Lindgren
2012-04-30 14:41 ` Paul Walmsley
2012-04-30 14:41   ` Paul Walmsley
2012-06-14 10:01   ` a0393909
2012-06-14 10:01     ` a0393909

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.