linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] omap2+: mux: Initialise the static pads.
@ 2011-03-01 18:16 sricharan
  2011-03-04  2:28 ` Tony Lindgren
  0 siblings, 1 reply; 5+ messages in thread
From: sricharan @ 2011-03-01 18:16 UTC (permalink / raw)
  To: linux-omap; +Cc: tony, b-cousson, paul, santosh.shilimkar

commit 7d5b199a seperates the pads as dynamic and
static and avoids unessecary iteration. But the static
pads are not getting initialised after this.

Adding the changes for initialisation of static pads.

Signed-off-by: sricharan <r.sricharan@ti.com>
---
Tested this on 4430sdp for both static and dynamic pads
on top of linux-omap-2.6 master branch

 arch/arm/mach-omap2/mux.c        |   42 ++++++++++++++-----------------------
 arch/arm/mach-omap2/omap_hwmod.c |    5 +--
 2 files changed, 18 insertions(+), 29 deletions(-)

diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index b2d097a..dd9ee58 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -352,15 +352,12 @@ err1:
 void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
 {
 	int i;
-
 	/* Runtime idling of dynamic pads */
 	if (state == _HWMOD_STATE_IDLE && hmux->enabled) {
 		for (i = 0; i < hmux->nr_pads_dynamic; i++) {
-			struct omap_device_pad *pad = &hmux->pads[i];
+			struct omap_device_pad *pad = hmux->pads_dynamic[i];
 			int val = -EINVAL;
 
-			pad->flags &= ~OMAP_DEVICE_PAD_ENABLED;
-			pad->flags |= OMAP_DEVICE_PAD_IDLE;
 			val = pad->idle;
 			omap_mux_write(pad->partition, val,
 					pad->mux->reg_offset);
@@ -370,28 +367,25 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
 	}
 
 	/* Runtime enabling of dynamic pads */
-	if ((state == _HWMOD_STATE_ENABLED) && hmux->pads_dynamic) {
-		int idled = 0;
-
+	if ((state == _HWMOD_STATE_ENABLED) && hmux->pads_dynamic
+					&& hmux->enabled) {
 		for (i = 0; i < hmux->nr_pads_dynamic; i++) {
-			struct omap_device_pad *pad = &hmux->pads[i];
+			struct omap_device_pad *pad = hmux->pads_dynamic[i];
 			int val = -EINVAL;
 
-			if (!(pad->flags & OMAP_DEVICE_PAD_IDLE))
-				continue;
-
-			pad->flags &= ~OMAP_DEVICE_PAD_IDLE;
-			pad->flags |= OMAP_DEVICE_PAD_ENABLED;
 			val = pad->enable;
 			omap_mux_write(pad->partition, val,
 					pad->mux->reg_offset);
-			idled++;
 		}
 
-		if (idled)
-			return;
+		return;
 	}
 
+	/* When there are only static pads which are initialised, return */
+	if ((state == _HWMOD_STATE_ENABLED) && (!(hmux->pads_dynamic))
+						&& (hmux->enabled))
+		return;
+
 	/* Enabling, disabling or idling of all pads */
 	for (i = 0; i < hmux->nr_pads; i++) {
 		struct omap_device_pad *pad = &hmux->pads[i];
@@ -408,16 +402,7 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
 			pr_debug("%s: Enabling %s %x\n", __func__,
 					pad->name, val);
 			break;
-		case _HWMOD_STATE_IDLE:
-			if (!(flags & OMAP_DEVICE_PAD_REMUX))
-				break;
-			flags &= ~OMAP_DEVICE_PAD_ENABLED;
-			val = pad->idle;
-			pr_debug("%s: Idling %s %x\n", __func__,
-					pad->name, val);
-			break;
 		case _HWMOD_STATE_DISABLED:
-		default:
 			/* Use safe mode unless OMAP_DEVICE_PAD_REMUX */
 			if (flags & OMAP_DEVICE_PAD_REMUX)
 				val = pad->off;
@@ -426,7 +411,12 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
 			flags &= ~OMAP_DEVICE_PAD_ENABLED;
 			pr_debug("%s: Disabling %s %x\n", __func__,
 					pad->name, val);
-		};
+
+			break;
+		default:
+			/* Nothing to be done */
+			break;
+		}
 
 		if (val >= 0) {
 			omap_mux_write(pad->partition, val,
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index a86ed82..56f3c78 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1230,9 +1230,8 @@ static int _enable(struct omap_hwmod *oh)
 		_deassert_hardreset(oh, oh->rst_lines[0].name);
 
 	/* Mux pins for device runtime if populated */
-	if (oh->mux && ((oh->_state == _HWMOD_STATE_DISABLED) ||
-		((oh->_state == _HWMOD_STATE_IDLE) && oh->mux->pads_dynamic)))
-			omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
+	if (oh->mux)
+		omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
 
 	_add_initiator_dep(oh, mpu_oh);
 	_enable_clocks(oh);
-- 
1.7.0.4


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

* Re: [PATCH] omap2+: mux: Initialise the static pads.
  2011-03-01 18:16 [PATCH] omap2+: mux: Initialise the static pads sricharan
@ 2011-03-04  2:28 ` Tony Lindgren
       [not found]   ` <44e29d555f2b399b7067d827603897cc@mail.gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Tony Lindgren @ 2011-03-04  2:28 UTC (permalink / raw)
  To: sricharan; +Cc: linux-omap, b-cousson, paul, santosh.shilimkar

Hi,

Sorry for the delay on replying to this one, some comments below.

* sricharan <r.sricharan@ti.com> [110301 10:13]:
> --- a/arch/arm/mach-omap2/mux.c
> +++ b/arch/arm/mach-omap2/mux.c
> @@ -352,15 +352,12 @@ err1:
>  void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
>  {
>  	int i;
> -
>  	/* Runtime idling of dynamic pads */
>  	if (state == _HWMOD_STATE_IDLE && hmux->enabled) {
>  		for (i = 0; i < hmux->nr_pads_dynamic; i++) {
> -			struct omap_device_pad *pad = &hmux->pads[i];
> +			struct omap_device_pad *pad = hmux->pads_dynamic[i];
>  			int val = -EINVAL;

Heh good catch :) I guess I got lucky that I had both be the same in my
test case..
  
> -			pad->flags &= ~OMAP_DEVICE_PAD_ENABLED;
> -			pad->flags |= OMAP_DEVICE_PAD_IDLE;
>  			val = pad->idle;
>  			omap_mux_write(pad->partition, val,
>  					pad->mux->reg_offset);

Hmm I guess OMAP_DEVICE_PAD_ENABLED state tracking we can leave out.
But the OMAP_DEVICE_PAD_IDLE state tracking we need to keep as otherwise
omap_hwmod_mux function won't know if we need to enable all pads initially,
or just the runtime idled pads.

> @@ -370,28 +367,25 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
>  	}
>  
>  	/* Runtime enabling of dynamic pads */
> -	if ((state == _HWMOD_STATE_ENABLED) && hmux->pads_dynamic) {
> -		int idled = 0;
> -
> +	if ((state == _HWMOD_STATE_ENABLED) && hmux->pads_dynamic
> +					&& hmux->enabled) {
>  		for (i = 0; i < hmux->nr_pads_dynamic; i++) {
> -			struct omap_device_pad *pad = &hmux->pads[i];
> +			struct omap_device_pad *pad = hmux->pads_dynamic[i];
>  			int val = -EINVAL;
>  
> -			if (!(pad->flags & OMAP_DEVICE_PAD_IDLE))
> -				continue;
> -
> -			pad->flags &= ~OMAP_DEVICE_PAD_IDLE;
> -			pad->flags |= OMAP_DEVICE_PAD_ENABLED;
>  			val = pad->enable;
>  			omap_mux_write(pad->partition, val,
>  					pad->mux->reg_offset);
> -			idled++;
>  		}
>  
> -		if (idled)
> -			return;
> +		return;
>  	}

The same goes also for the idled flag, that's used to figure out that
we don't need to mux all the pins as we may have both dynamic and static
pins.
  
> +	/* When there are only static pads which are initialised, return */
> +	if ((state == _HWMOD_STATE_ENABLED) && (!(hmux->pads_dynamic))
> +						&& (hmux->enabled))
> +		return;
> +

It seems this would fail for the case where there are both static
and dynamic pins.

>  	/* Enabling, disabling or idling of all pads */
>  	for (i = 0; i < hmux->nr_pads; i++) {
>  		struct omap_device_pad *pad = &hmux->pads[i];
> @@ -408,16 +402,7 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
>  			pr_debug("%s: Enabling %s %x\n", __func__,
>  					pad->name, val);
>  			break;
> -		case _HWMOD_STATE_IDLE:
> -			if (!(flags & OMAP_DEVICE_PAD_REMUX))
> -				break;
> -			flags &= ~OMAP_DEVICE_PAD_ENABLED;
> -			val = pad->idle;
> -			pr_debug("%s: Idling %s %x\n", __func__,
> -					pad->name, val);
> -			break;
>  		case _HWMOD_STATE_DISABLED:
> -		default:
>  			/* Use safe mode unless OMAP_DEVICE_PAD_REMUX */
>  			if (flags & OMAP_DEVICE_PAD_REMUX)
>  				val = pad->off;

OK _HWMOD_STATE_IDLE can be left out. But the default handling we should keep.

> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -1230,9 +1230,8 @@ static int _enable(struct omap_hwmod *oh)
>  		_deassert_hardreset(oh, oh->rst_lines[0].name);
>  
>  	/* Mux pins for device runtime if populated */
> -	if (oh->mux && ((oh->_state == _HWMOD_STATE_DISABLED) ||
> -		((oh->_state == _HWMOD_STATE_IDLE) && oh->mux->pads_dynamic)))
> -			omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
> +	if (oh->mux)
> +		omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
>  

Here we want to avoid calling the omap_hwmod_mux function unless we
have dynamic pins.

Anyways, updated fix below. Also folded it into the original patch
in devel-mmc branch, can you please give it a try with your test
cases?

Regards,

Tony

omap: mux: Fix muxing for dynamic pads and static pads

Fix muxing for dynamic pads and static pads. Based on an
earlier patch by sricharan <r.sricharan@ti.com>.
 
Signed-off-by: Tony Lindgren <tony@atomide.com>

--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -356,10 +356,9 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
 	/* Runtime idling of dynamic pads */
 	if (state == _HWMOD_STATE_IDLE && hmux->enabled) {
 		for (i = 0; i < hmux->nr_pads_dynamic; i++) {
-			struct omap_device_pad *pad = &hmux->pads[i];
+			struct omap_device_pad *pad = hmux->pads_dynamic[i];
 			int val = -EINVAL;
 
-			pad->flags &= ~OMAP_DEVICE_PAD_ENABLED;
 			pad->flags |= OMAP_DEVICE_PAD_IDLE;
 			val = pad->idle;
 			omap_mux_write(pad->partition, val,
@@ -374,14 +373,13 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
 		int idled = 0;
 
 		for (i = 0; i < hmux->nr_pads_dynamic; i++) {
-			struct omap_device_pad *pad = &hmux->pads[i];
+			struct omap_device_pad *pad = hmux->pads_dynamic[i];
 			int val = -EINVAL;
 
 			if (!(pad->flags & OMAP_DEVICE_PAD_IDLE))
 				continue;
 
 			pad->flags &= ~OMAP_DEVICE_PAD_IDLE;
-			pad->flags |= OMAP_DEVICE_PAD_ENABLED;
 			val = pad->enable;
 			omap_mux_write(pad->partition, val,
 					pad->mux->reg_offset);
@@ -392,7 +390,7 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
 			return;
 	}
 
-	/* Enabling, disabling or idling of all pads */
+	/* Enabling or disabling of all pads */
 	for (i = 0; i < hmux->nr_pads; i++) {
 		struct omap_device_pad *pad = &hmux->pads[i];
 		int flags, val = -EINVAL;
@@ -401,21 +399,10 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
 
 		switch (state) {
 		case _HWMOD_STATE_ENABLED:
-			if (flags & OMAP_DEVICE_PAD_ENABLED)
-				break;
-			flags |= OMAP_DEVICE_PAD_ENABLED;
 			val = pad->enable;
 			pr_debug("%s: Enabling %s %x\n", __func__,
 					pad->name, val);
 			break;
-		case _HWMOD_STATE_IDLE:
-			if (!(flags & OMAP_DEVICE_PAD_REMUX))
-				break;
-			flags &= ~OMAP_DEVICE_PAD_ENABLED;
-			val = pad->idle;
-			pr_debug("%s: Idling %s %x\n", __func__,
-					pad->name, val);
-			break;
 		case _HWMOD_STATE_DISABLED:
 		default:
 			/* Use safe mode unless OMAP_DEVICE_PAD_REMUX */
@@ -423,7 +410,6 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
 				val = pad->off;
 			else
 				val = OMAP_MUX_MODE7;
-			flags &= ~OMAP_DEVICE_PAD_ENABLED;
 			pr_debug("%s: Disabling %s %x\n", __func__,
 					pad->name, val);
 		};
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
index 8f6e326..1d5bf42 100644
--- a/arch/arm/mach-omap2/mux.h
+++ b/arch/arm/mach-omap2/mux.h
@@ -160,7 +160,6 @@ struct omap_board_mux {
 };
 
 #define OMAP_DEVICE_PAD_IDLE		BIT(7)	/* Not needed for board-*.c */
-#define OMAP_DEVICE_PAD_ENABLED		BIT(6)	/* Not needed for board-*.c */
 #define OMAP_DEVICE_PAD_REMUX		BIT(1)	/* Dynamically remux a pad,
 						   needs enable, idle and off
 						   values */
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 028efda..e07b9ab 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1225,9 +1225,10 @@ static int _enable(struct omap_hwmod *oh)
 		_deassert_hardreset(oh, oh->rst_lines[0].name);
 
 	/* Mux pins for device runtime if populated */
-	if (oh->mux && ((oh->_state == _HWMOD_STATE_DISABLED) ||
-		((oh->_state == _HWMOD_STATE_IDLE) && oh->mux->pads_dynamic)))
-			omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
+	if (oh->mux && (!oh->mux->enabled ||
+			((oh->_state == _HWMOD_STATE_IDLE) &&
+			 oh->mux->pads_dynamic)))
+		omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
 
 	_add_initiator_dep(oh, mpu_oh);
 	_enable_clocks(oh);

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

* Re: [PATCH] omap2+: mux: Initialise the static pads.
       [not found]   ` <44e29d555f2b399b7067d827603897cc@mail.gmail.com>
@ 2011-03-04 16:28     ` Tony Lindgren
       [not found]       ` <4ad439dff008aeca2a058207ef744650@mail.gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Tony Lindgren @ 2011-03-04 16:28 UTC (permalink / raw)
  To: Sricharan R; +Cc: linux-omap, Benoit Cousson, paul, Santosh Shilimkar

* Sricharan R <r.sricharan@ti.com> [110304 04:22]:
> 
> I have tested this on the devel-mux(I did not see a devel-mmc branch)

Sorry that was a typo, I meant devel-mux not devel-mmc..
 
> Ok. This works fine for all scenarios.

OK thanks for testing.
 
> A small cleanup change which helps.
...

> I was not able to see the your above patch in the tree and
> I saw only the older patch.

Hmm it's there as commit 93c5f165e10c21a3813a687204388a34072b2a62
in devel-mux branch. Can you please update your patch against
that commit so it's easier to see what your changes are?

BTW, the patch you posted got trashed by your email client
or server..

Regards,

Tony

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

* Re: [PATCH] omap2+: mux: Initialise the static pads.
       [not found]       ` <4ad439dff008aeca2a058207ef744650@mail.gmail.com>
@ 2011-03-04 17:43         ` Tony Lindgren
  2011-03-07  4:39           ` Sricharan R
  0 siblings, 1 reply; 5+ messages in thread
From: Tony Lindgren @ 2011-03-04 17:43 UTC (permalink / raw)
  To: Sricharan R; +Cc: linux-omap, Benoit Cousson, paul, Santosh Shilimkar

* Sricharan R <r.sricharan@ti.com> [110304 09:31]:
> Hi Tony,
> 
> >Hmm it's there as commit 93c5f165e10c21a3813a687204388a34072b2a62
> 
> >in devel-mux branch. Can you please update your patch against
> 
> >that commit so it's easier to see what your changes are?
> 
> >
> 
> >BTW, the patch you posted got trashed by your email client
> 
> >or server..
> 
> >
> 
> Here is the updated patch on top of your previous patch.

The patch formatting is still trashed, notice the double line
spacing..
 
> +++ b/arch/arm/mach-omap2/mux.c
> 
> @@ -359,7 +359,6 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8
> state)

..and the line wrapping of the patch lines.

> 
> +     if ((state == _HWMOD_STATE_ENABLED) && hmux->pads_dynamic
> 
> +                             && hmux->enabled) {

Yes I see that might allow removing the idle flag. Will give it
a try with my testcase once you get your mail issue sorted out
and can post a patch that applies.

Tony
 

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

* RE: [PATCH] omap2+: mux: Initialise the static pads.
  2011-03-04 17:43         ` Tony Lindgren
@ 2011-03-07  4:39           ` Sricharan R
  0 siblings, 0 replies; 5+ messages in thread
From: Sricharan R @ 2011-03-07  4:39 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, Benoit Cousson, paul, Santosh Shilimkar

Hi Tony,
>-----Original Message-----
>From: Tony Lindgren [mailto:tony@atomide.com]
>Sent: Friday, March 04, 2011 11:13 PM
>To: Sricharan R
>Cc: linux-omap@vger.kernel.org; Benoit Cousson; paul@pswan.com; Santosh
>Shilimkar
>Subject: Re: [PATCH] omap2+: mux: Initialise the static pads.
>
>* Sricharan R <r.sricharan@ti.com> [110304 09:31]:
>> Hi Tony,
>>
>> >Hmm it's there as commit 93c5f165e10c21a3813a687204388a34072b2a62
>>
>> >in devel-mux branch. Can you please update your patch against
>>
>> >that commit so it's easier to see what your changes are?
>>
>> >
>>
>> >BTW, the patch you posted got trashed by your email client
>>
>> >or server..
>>
>> >
>>
>> Here is the updated patch on top of your previous patch.
>
>The patch formatting is still trashed, notice the double line
>spacing..
>

Very sorry about this.
Below is the link for the patch.
http://marc.info/?l=linux-omap&m=129947252016935&w=2

>> +++ b/arch/arm/mach-omap2/mux.c
>>
>> @@ -359,7 +359,6 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info
*hmux,
>u8
>> state)
>
>..and the line wrapping of the patch lines.
>
>>
>> +     if ((state == _HWMOD_STATE_ENABLED) && hmux->pads_dynamic
>>
>> +                             && hmux->enabled) {
>
>Yes I see that might allow removing the idle flag. Will give it
>a try with my testcase once you get your mail issue sorted out
>and can post a patch that applies.
>
Ok. I have checked this applies on top of the devel-mux branch.
>Tony
>

Thanks,
 Sricharan

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

end of thread, other threads:[~2011-03-07  4:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-01 18:16 [PATCH] omap2+: mux: Initialise the static pads sricharan
2011-03-04  2:28 ` Tony Lindgren
     [not found]   ` <44e29d555f2b399b7067d827603897cc@mail.gmail.com>
2011-03-04 16:28     ` Tony Lindgren
     [not found]       ` <4ad439dff008aeca2a058207ef744650@mail.gmail.com>
2011-03-04 17:43         ` Tony Lindgren
2011-03-07  4:39           ` Sricharan R

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).