diff mbox

[04/15] ARM: OMAP2+: hwmod: Update the reset API for AM33XX

Message ID 1351859566-24818-5-git-send-email-vaibhav.bedia@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vaibhav Bedia Nov. 2, 2012, 12:32 p.m. UTC
WKUP-M3 has a reset status bit (RM_WKUP_STST.WKUP_M3_LRST)
Update the hardreset API to take care of the same to ensure
that the reset line properly deasserted.

Signed-off-by: Vaibhav Bedia <vaibhav.bedia@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |    5 +----
 arch/arm/mach-omap2/prm33xx.c    |   15 +++++++--------
 arch/arm/mach-omap2/prm33xx.h    |    2 +-
 3 files changed, 9 insertions(+), 13 deletions(-)

Comments

Vaibhav Hiremath Nov. 5, 2012, 6:58 a.m. UTC | #1
On 11/2/2012 6:02 PM, Vaibhav Bedia wrote:
> WKUP-M3 has a reset status bit (RM_WKUP_STST.WKUP_M3_LRST)
> Update the hardreset API to take care of the same to ensure
> that the reset line properly deasserted.
> 

Thanks for the patch, comments below -

> Signed-off-by: Vaibhav Bedia <vaibhav.bedia@ti.com>
> ---
>  arch/arm/mach-omap2/omap_hwmod.c |    5 +----
>  arch/arm/mach-omap2/prm33xx.c    |   15 +++++++--------
>  arch/arm/mach-omap2/prm33xx.h    |    2 +-
>  3 files changed, 9 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index 37eeb45..a1d5835 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -2944,11 +2944,8 @@ static int _am33xx_assert_hardreset(struct omap_hwmod *oh,
>  static int _am33xx_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 am33xx_prm_deassert_hardreset(ohri->rst_shift,
> +				ohri->st_shift,
>  				oh->clkdm->pwrdm.ptr->prcm_offs,
>  				oh->prcm.omap4.rstctrl_offs,
>  				oh->prcm.omap4.rstst_offs);
> diff --git a/arch/arm/mach-omap2/prm33xx.c b/arch/arm/mach-omap2/prm33xx.c
> index 53ec9cb..0f29cb9 100644
> --- a/arch/arm/mach-omap2/prm33xx.c
> +++ b/arch/arm/mach-omap2/prm33xx.c
> @@ -112,23 +112,22 @@ int am33xx_prm_assert_hardreset(u8 shift, s16 inst, u16 rstctrl_offs)
>   * -EINVAL upon an argument error, -EEXIST if the submodule was already out
>   * of reset, or -EBUSY if the submodule did not exit reset promptly.
>   */
> -int am33xx_prm_deassert_hardreset(u8 shift, s16 inst,
> +int am33xx_prm_deassert_hardreset(u8 shift, u8 st_shift, s16 inst,
>  		u16 rstctrl_offs, u16 rstst_offs)
>  {
>  	int c;
> -	u32 mask = 1 << shift;
> -
> -	/* Check the current status to avoid  de-asserting the line twice */
> -	if (am33xx_prm_is_hardreset_asserted(shift, inst, rstctrl_offs) == 0)
> -		return -EEXIST;

Any specific reason why you have removed this check?

Thanks,
Vaibhav

> +	u32 mask = 1 << st_shift;
>  
>  	/* Clear the reset status by writing 1 to the status bit */
>  	am33xx_prm_rmw_reg_bits(0xffffffff, mask, inst, rstst_offs);
> +
>  	/* de-assert the reset control line */
> +	mask = 1 << shift;
> +
>  	am33xx_prm_rmw_reg_bits(mask, 0, inst, rstctrl_offs);
> -	/* wait the status to be set */
>  
> -	omap_test_timeout(am33xx_prm_is_hardreset_asserted(shift, inst,
> +	/* wait the status to be set */
> +	omap_test_timeout(am33xx_prm_is_hardreset_asserted(st_shift, inst,
>  							   rstst_offs),
>  			  MAX_MODULE_HARDRESET_WAIT, c);
>  
> diff --git a/arch/arm/mach-omap2/prm33xx.h b/arch/arm/mach-omap2/prm33xx.h
> index 3f25c56..181fdab 100644
> --- a/arch/arm/mach-omap2/prm33xx.h
> +++ b/arch/arm/mach-omap2/prm33xx.h
> @@ -124,6 +124,6 @@ extern void am33xx_prm_global_warm_sw_reset(void);
>  extern int am33xx_prm_is_hardreset_asserted(u8 shift, s16 inst,
>  		u16 rstctrl_offs);
>  extern int am33xx_prm_assert_hardreset(u8 shift, s16 inst, u16 rstctrl_offs);
> -extern int am33xx_prm_deassert_hardreset(u8 shift, s16 inst,
> +extern int am33xx_prm_deassert_hardreset(u8 shift, u8 st_shift, s16 inst,
>  		u16 rstctrl_offs, u16 rstst_offs);
>  #endif
> 
--
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
Vaibhav Bedia Nov. 5, 2012, 5:57 p.m. UTC | #2
On Mon, Nov 05, 2012 at 12:28:36, Hiremath, Vaibhav wrote:
[...]
> > -	u32 mask = 1 << shift;
> > -
> > -	/* Check the current status to avoid  de-asserting the line twice */
> > -	if (am33xx_prm_is_hardreset_asserted(shift, inst, rstctrl_offs) == 0)
> > -		return -EEXIST;
> 
> Any specific reason why you have removed this check?

During bootup the hardreset line is asserted, so wouldn't that check lead
to the function always returning without doing anything?

Regards,
Vaibhav
--
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
Vaibhav Hiremath Nov. 6, 2012, 6:06 a.m. UTC | #3
On Mon, Nov 05, 2012 at 23:27:52, Bedia, Vaibhav wrote:
> On Mon, Nov 05, 2012 at 12:28:36, Hiremath, Vaibhav wrote:
> [...]
> > > -	u32 mask = 1 << shift;
> > > -
> > > -	/* Check the current status to avoid  de-asserting the line twice */
> > > -	if (am33xx_prm_is_hardreset_asserted(shift, inst, rstctrl_offs) == 0)
> > > -		return -EEXIST;
> > 
> > Any specific reason why you have removed this check?
> 
> During bootup the hardreset line is asserted, so wouldn't that check lead
> to the function always returning without doing anything?
> 

The check is,

/* Check the current status to avoid  de-asserting the line twice */
if (am33xx_prm_is_hardreset_asserted(shift, inst, rstctrl_offs) == 0)
	return -EEXIST;


The code is checking whether the line is already de-asserted (== 0), so I am 
not sure how this will change if hardreset line is asserted during bootup.

Thanks,
Vaibhav

--
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
Vaibhav Bedia Nov. 6, 2012, 7:19 a.m. UTC | #4
On Tue, Nov 06, 2012 at 11:36:20, Hiremath, Vaibhav wrote:
[...]

> 
> The code is checking whether the line is already de-asserted (== 0), so I am 
> not sure how this will change if hardreset line is asserted during bootup.

You are right. I just checked the behavior since I recall seeing something odd
earlier. Looks like this is needed to avoid issues with subsequent hardreset
deassertions so I'll put it back in.

Regards.
Vaibhav
--
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
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 37eeb45..a1d5835 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2944,11 +2944,8 @@  static int _am33xx_assert_hardreset(struct omap_hwmod *oh,
 static int _am33xx_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 am33xx_prm_deassert_hardreset(ohri->rst_shift,
+				ohri->st_shift,
 				oh->clkdm->pwrdm.ptr->prcm_offs,
 				oh->prcm.omap4.rstctrl_offs,
 				oh->prcm.omap4.rstst_offs);
diff --git a/arch/arm/mach-omap2/prm33xx.c b/arch/arm/mach-omap2/prm33xx.c
index 53ec9cb..0f29cb9 100644
--- a/arch/arm/mach-omap2/prm33xx.c
+++ b/arch/arm/mach-omap2/prm33xx.c
@@ -112,23 +112,22 @@  int am33xx_prm_assert_hardreset(u8 shift, s16 inst, u16 rstctrl_offs)
  * -EINVAL upon an argument error, -EEXIST if the submodule was already out
  * of reset, or -EBUSY if the submodule did not exit reset promptly.
  */
-int am33xx_prm_deassert_hardreset(u8 shift, s16 inst,
+int am33xx_prm_deassert_hardreset(u8 shift, u8 st_shift, s16 inst,
 		u16 rstctrl_offs, u16 rstst_offs)
 {
 	int c;
-	u32 mask = 1 << shift;
-
-	/* Check the current status to avoid  de-asserting the line twice */
-	if (am33xx_prm_is_hardreset_asserted(shift, inst, rstctrl_offs) == 0)
-		return -EEXIST;
+	u32 mask = 1 << st_shift;
 
 	/* Clear the reset status by writing 1 to the status bit */
 	am33xx_prm_rmw_reg_bits(0xffffffff, mask, inst, rstst_offs);
+
 	/* de-assert the reset control line */
+	mask = 1 << shift;
+
 	am33xx_prm_rmw_reg_bits(mask, 0, inst, rstctrl_offs);
-	/* wait the status to be set */
 
-	omap_test_timeout(am33xx_prm_is_hardreset_asserted(shift, inst,
+	/* wait the status to be set */
+	omap_test_timeout(am33xx_prm_is_hardreset_asserted(st_shift, inst,
 							   rstst_offs),
 			  MAX_MODULE_HARDRESET_WAIT, c);
 
diff --git a/arch/arm/mach-omap2/prm33xx.h b/arch/arm/mach-omap2/prm33xx.h
index 3f25c56..181fdab 100644
--- a/arch/arm/mach-omap2/prm33xx.h
+++ b/arch/arm/mach-omap2/prm33xx.h
@@ -124,6 +124,6 @@  extern void am33xx_prm_global_warm_sw_reset(void);
 extern int am33xx_prm_is_hardreset_asserted(u8 shift, s16 inst,
 		u16 rstctrl_offs);
 extern int am33xx_prm_assert_hardreset(u8 shift, s16 inst, u16 rstctrl_offs);
-extern int am33xx_prm_deassert_hardreset(u8 shift, s16 inst,
+extern int am33xx_prm_deassert_hardreset(u8 shift, u8 st_shift, s16 inst,
 		u16 rstctrl_offs, u16 rstst_offs);
 #endif