All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH pm_wip/voltdm_nm] ARM: OMAP: Explicitly mask VPVOLTAGE field
@ 2011-05-27  3:03 Todd Poynor
  2011-05-27 23:35 ` Kevin Hilman
  0 siblings, 1 reply; 2+ messages in thread
From: Todd Poynor @ 2011-05-27  3:03 UTC (permalink / raw)
  To: Kevin Hilman, linux-omap

Reading the VPVOLTAGE field of PRM_VP_*_VOLTAGE registers currently
relies on a u32 -> u8 conversion to mask off the FORCEUPDATEWAIT field
in the upper bits.  Make this explicit using the mask and shift symbols
already defined, added as new fields in struct omap_vp_common.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
---
 arch/arm/mach-omap2/vp.c          |    3 ++-
 arch/arm/mach-omap2/vp.h          |    4 ++++
 arch/arm/mach-omap2/vp3xxx_data.c |    3 +++
 arch/arm/mach-omap2/vp44xx_data.c |    2 ++
 4 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index e7d38f6..c3b7fde 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -227,7 +227,8 @@ unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm)
 		return 0;
 	}
 
-	curr_vsel = voltdm->read(vp->voltage);
+	curr_vsel = (voltdm->read(vp->voltage) & vp->common->vpvoltage_mask)
+		>> vp->common->vpvoltage_shift;
 
 	if (!voltdm->pmic || !voltdm->pmic->vsel_to_uv) {
 		pr_warning("%s: PMIC function to convert vsel to voltage"
diff --git a/arch/arm/mach-omap2/vp.h b/arch/arm/mach-omap2/vp.h
index 0d63267..cb62a7b 100644
--- a/arch/arm/mach-omap2/vp.h
+++ b/arch/arm/mach-omap2/vp.h
@@ -63,6 +63,8 @@ struct omap_vp_ops {
  * @vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg
  * @vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg
  * @vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg
+ * @vpvoltage_mask: VPVOLTAGE field mask in PRM_VP*_VOLTAGE reg
+ * @vpvoltage_shift: VPVOLTAGE field shift in PRM_VP*_VOLTAGE reg
  */
 struct omap_vp_common {
 	u32 vpconfig_erroroffset_mask;
@@ -79,6 +81,8 @@ struct omap_vp_common {
 	u8 vlimitto_vddmin_shift;
 	u8 vlimitto_vddmax_shift;
 	u8 vlimitto_timeout_shift;
+	u8 vpvoltage_mask;
+	u8 vpvoltage_shift;
 
 	const struct omap_vp_ops *ops;
 };
diff --git a/arch/arm/mach-omap2/vp3xxx_data.c b/arch/arm/mach-omap2/vp3xxx_data.c
index d429c44..0b149e0 100644
--- a/arch/arm/mach-omap2/vp3xxx_data.c
+++ b/arch/arm/mach-omap2/vp3xxx_data.c
@@ -51,6 +51,9 @@ static const struct omap_vp_common omap3_vp_common = {
 	.vlimitto_vddmin_shift = OMAP3430_VDDMIN_SHIFT,
 	.vlimitto_vddmax_shift = OMAP3430_VDDMAX_SHIFT,
 	.vlimitto_timeout_shift = OMAP3430_TIMEOUT_SHIFT,
+	.vpvoltage_mask = OMAP3430_VPVOLTAGE_MASK,
+	.vpvoltage_shift = OMAP3430_VPVOLTAGE_SHIFT,
+
 	.ops = &omap3_vp_ops,
 };
 
diff --git a/arch/arm/mach-omap2/vp44xx_data.c b/arch/arm/mach-omap2/vp44xx_data.c
index 0daf2a4..174d6f7 100644
--- a/arch/arm/mach-omap2/vp44xx_data.c
+++ b/arch/arm/mach-omap2/vp44xx_data.c
@@ -51,6 +51,8 @@ static const struct omap_vp_common omap4_vp_common = {
 	.vlimitto_vddmin_shift = OMAP4430_VDDMIN_SHIFT,
 	.vlimitto_vddmax_shift = OMAP4430_VDDMAX_SHIFT,
 	.vlimitto_timeout_shift = OMAP4430_TIMEOUT_SHIFT,
+	.vpvoltage_mask = OMAP4430_VPVOLTAGE_MASK,
+	.vpvoltage_shift = OMAP4430_VPVOLTAGE_SHIFT,
 	.ops = &omap4_vp_ops,
 };
 
-- 
1.7.3.1


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

* Re: [PATCH pm_wip/voltdm_nm] ARM: OMAP: Explicitly mask VPVOLTAGE field
  2011-05-27  3:03 [PATCH pm_wip/voltdm_nm] ARM: OMAP: Explicitly mask VPVOLTAGE field Todd Poynor
@ 2011-05-27 23:35 ` Kevin Hilman
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Hilman @ 2011-05-27 23:35 UTC (permalink / raw)
  To: Todd Poynor; +Cc: linux-omap

Hi Todd,

Todd Poynor <toddpoynor@google.com> writes:

> Reading the VPVOLTAGE field of PRM_VP_*_VOLTAGE registers currently
> relies on a u32 -> u8 conversion to mask off the FORCEUPDATEWAIT field
> in the upper bits.  Make this explicit using the mask and shift symbols
> already defined, added as new fields in struct omap_vp_common.
>
> Signed-off-by: Todd Poynor <toddpoynor@google.com>

Thanks for the patch.  Indeed it's better to make this explict.

Minor nit: we don't need both the mask and the shift defined.  Just add
the mask, and the code can use __ffs(mask) to get the shift value.  This
is what I've done in the rest of the VC/VP code.

Also, can you make the subject prefix 'OMAP: VP: ...' 

Thanks,

Kevin

> ---
>  arch/arm/mach-omap2/vp.c          |    3 ++-
>  arch/arm/mach-omap2/vp.h          |    4 ++++
>  arch/arm/mach-omap2/vp3xxx_data.c |    3 +++
>  arch/arm/mach-omap2/vp44xx_data.c |    2 ++
>  4 files changed, 11 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
> index e7d38f6..c3b7fde 100644
> --- a/arch/arm/mach-omap2/vp.c
> +++ b/arch/arm/mach-omap2/vp.c
> @@ -227,7 +227,8 @@ unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm)
>  		return 0;
>  	}
>  
> -	curr_vsel = voltdm->read(vp->voltage);
> +	curr_vsel = (voltdm->read(vp->voltage) & vp->common->vpvoltage_mask)
> +		>> vp->common->vpvoltage_shift;
>  
>  	if (!voltdm->pmic || !voltdm->pmic->vsel_to_uv) {
>  		pr_warning("%s: PMIC function to convert vsel to voltage"
> diff --git a/arch/arm/mach-omap2/vp.h b/arch/arm/mach-omap2/vp.h
> index 0d63267..cb62a7b 100644
> --- a/arch/arm/mach-omap2/vp.h
> +++ b/arch/arm/mach-omap2/vp.h
> @@ -63,6 +63,8 @@ struct omap_vp_ops {
>   * @vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg
>   * @vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg
>   * @vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg
> + * @vpvoltage_mask: VPVOLTAGE field mask in PRM_VP*_VOLTAGE reg
> + * @vpvoltage_shift: VPVOLTAGE field shift in PRM_VP*_VOLTAGE reg
>   */
>  struct omap_vp_common {
>  	u32 vpconfig_erroroffset_mask;
> @@ -79,6 +81,8 @@ struct omap_vp_common {
>  	u8 vlimitto_vddmin_shift;
>  	u8 vlimitto_vddmax_shift;
>  	u8 vlimitto_timeout_shift;
> +	u8 vpvoltage_mask;
> +	u8 vpvoltage_shift;
>  
>  	const struct omap_vp_ops *ops;
>  };
> diff --git a/arch/arm/mach-omap2/vp3xxx_data.c b/arch/arm/mach-omap2/vp3xxx_data.c
> index d429c44..0b149e0 100644
> --- a/arch/arm/mach-omap2/vp3xxx_data.c
> +++ b/arch/arm/mach-omap2/vp3xxx_data.c
> @@ -51,6 +51,9 @@ static const struct omap_vp_common omap3_vp_common = {
>  	.vlimitto_vddmin_shift = OMAP3430_VDDMIN_SHIFT,
>  	.vlimitto_vddmax_shift = OMAP3430_VDDMAX_SHIFT,
>  	.vlimitto_timeout_shift = OMAP3430_TIMEOUT_SHIFT,
> +	.vpvoltage_mask = OMAP3430_VPVOLTAGE_MASK,
> +	.vpvoltage_shift = OMAP3430_VPVOLTAGE_SHIFT,
> +
>  	.ops = &omap3_vp_ops,
>  };
>  
> diff --git a/arch/arm/mach-omap2/vp44xx_data.c b/arch/arm/mach-omap2/vp44xx_data.c
> index 0daf2a4..174d6f7 100644
> --- a/arch/arm/mach-omap2/vp44xx_data.c
> +++ b/arch/arm/mach-omap2/vp44xx_data.c
> @@ -51,6 +51,8 @@ static const struct omap_vp_common omap4_vp_common = {
>  	.vlimitto_vddmin_shift = OMAP4430_VDDMIN_SHIFT,
>  	.vlimitto_vddmax_shift = OMAP4430_VDDMAX_SHIFT,
>  	.vlimitto_timeout_shift = OMAP4430_TIMEOUT_SHIFT,
> +	.vpvoltage_mask = OMAP4430_VPVOLTAGE_MASK,
> +	.vpvoltage_shift = OMAP4430_VPVOLTAGE_SHIFT,
>  	.ops = &omap4_vp_ops,
>  };

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

end of thread, other threads:[~2011-05-27 23:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-27  3:03 [PATCH pm_wip/voltdm_nm] ARM: OMAP: Explicitly mask VPVOLTAGE field Todd Poynor
2011-05-27 23:35 ` Kevin Hilman

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.